/* ============================================================
   Koinonia — Sistema de Gestão de Igrejas
   Estilos principais
   ============================================================ */

:root {
  --primary: #4338ca;
  --primary-dark: #312890;
  --primary-light: #6366f1;
  --accent: #d4a843;
  --accent-light: #f0d9a0;
  --bg: #f4f5fa;
  --surface: #ffffff;
  --text: #1f2333;
  --text-muted: #6b7080;
  --border: #e7e8f1;
  --success: #1aa179;
  --success-bg: #e6f7f1;
  --danger: #d8485f;
  --danger-bg: #fcebee;
  --warning: #d99a2b;
  --warning-bg: #fdf3e2;
  --info: #2f7ed8;
  --info-bg: #e8f2fd;
  --sidebar-bg: #1c1b3a;
  --sidebar-bg-2: #16152e;
  --sidebar-text: #c7c6e0;
  --sidebar-text-active: #ffffff;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 2px 10px rgba(28, 27, 58, 0.06);
  --shadow-md: 0 6px 24px rgba(28, 27, 58, 0.10);
  --sidebar-w: 260px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: inherit; }
ul { list-style: none; margin: 0; padding: 0; }

h1, h2, h3, h4, h5 { font-family: 'Poppins', 'Inter', sans-serif; font-weight: 600; margin: 0 0 4px; color: var(--text); }

/* ===================== Layout ===================== */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, var(--sidebar-bg) 0%, var(--sidebar-bg-2) 100%);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  z-index: 1000;
  transition: transform .25s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 26px 24px 18px;
}

.sidebar-brand .logo-mark {
  width: 38px; height: 38px;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--accent), #b9883a);
  display: flex; align-items: center; justify-content: center;
  font-family: 'Poppins', sans-serif;
  font-weight: 700;
  color: #2a2105;
  font-size: 18px;
  flex-shrink: 0;
}

.sidebar-brand .brand-name {
  font-family: 'Poppins', sans-serif;
  font-weight: 600;
  font-size: 19px;
  color: #fff;
  line-height: 1.1;
}
.sidebar-brand .brand-sub {
  font-size: 11px;
  color: var(--sidebar-text);
  opacity: .7;
}

.sidebar-section-label {
  text-transform: uppercase;
  font-size: 10.5px;
  letter-spacing: .08em;
  color: rgba(255,255,255,.35);
  padding: 18px 24px 6px;
  font-weight: 600;
}

.sidebar-nav { flex: 1; overflow-y: auto; padding-bottom: 12px; }

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 24px;
  font-size: 14.5px;
  font-weight: 500;
  color: var(--sidebar-text);
  border-left: 3px solid transparent;
  transition: background .15s, color .15s;
}
.sidebar-nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar-nav a.active {
  background: rgba(255,255,255,.08);
  color: #fff;
  border-left-color: var(--accent);
}
.sidebar-nav a i { width: 19px; text-align: center; font-size: 16px; opacity: .9; }

.sidebar-foot {
  padding: 16px 24px 22px;
  border-top: 1px solid rgba(255,255,255,.08);
  font-size: 12.5px;
  color: rgba(255,255,255,.5);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 24px;
  border-top: 1px solid rgba(255,255,255,.08);
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-user .avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--primary-light);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 600; font-size: 14px; flex-shrink: 0;
}
.sidebar-user .u-name { color: #fff; font-size: 13.5px; font-weight: 600; line-height: 1.2; }
.sidebar-user .u-role { font-size: 11px; color: var(--accent-light); text-transform: uppercase; letter-spacing: .04em; }

.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 16px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar .page-title { font-size: 20px; font-weight: 600; }
.topbar .page-desc { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

.menu-toggle {
  display: none;
  background: none; border: none; font-size: 22px; color: var(--text);
  cursor: pointer;
}

.content { padding: 26px 28px 50px; flex: 1; }

/* ===================== Componentes ===================== */

.card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.card-body { padding: 22px; }

.card-header-x {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}
.card-header-x h3 { font-size: 16.5px; margin: 0; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 20px 22px;
  display: flex;
  align-items: center;
  gap: 16px;
  position: relative;
  overflow: hidden;
}
.stat-card .stat-icon {
  width: 50px; height: 50px;
  border-radius: 13px;
  display: flex; align-items: center; justify-content: center;
  font-size: 21px;
  flex-shrink: 0;
}
.stat-card .stat-value { font-size: 24px; font-weight: 700; font-family: 'Poppins', sans-serif; line-height: 1.1; }
.stat-card .stat-label { font-size: 12.5px; color: var(--text-muted); font-weight: 500; margin-top: 3px; }

.bg-violet { background: #ece9fe; color: var(--primary); }
.bg-gold { background: #faf1da; color: #a87e1f; }
.bg-green { background: var(--success-bg); color: var(--success); }
.bg-red { background: var(--danger-bg); color: var(--danger); }
.bg-blue { background: var(--info-bg); color: var(--info); }
.bg-orange { background: var(--warning-bg); color: var(--warning); }

.chart-grid {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 18px;
  margin-bottom: 24px;
}
@media (max-width: 980px) { .chart-grid { grid-template-columns: 1fr; } }

.chart-wrap { position: relative; height: 280px; }

/* Botões */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all .15s ease;
  white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-accent { background: var(--accent); color: #2a2105; }
.btn-accent:hover { background: #c19736; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { background: var(--bg); }
.btn-danger { background: var(--danger-bg); color: var(--danger); }
.btn-danger:hover { background: #f6d4da; }
.btn-success { background: var(--success-bg); color: var(--success); }
.btn-success:hover { background: #cdeee2; }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* Formulários */
.form-label { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 6px; display: block; }
.form-control, .form-select {
  width: 100%;
  padding: 10px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14.5px;
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  transition: border-color .15s;
}
.form-control:focus, .form-select:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(99,102,241,.12);
}
.form-group { margin-bottom: 16px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px,1fr)); gap: 16px; }
.form-text-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
textarea.form-control { resize: vertical; min-height: 80px; }

.input-radio-group { display: flex; gap: 10px; flex-wrap: wrap; }
.input-radio-card {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 18px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  display: flex; align-items: center; gap: 8px;
  transition: all .15s;
}
.input-radio-card input { accent-color: var(--primary); }
.input-radio-card.checked-dizimo { border-color: var(--success); background: var(--success-bg); color: var(--success); }
.input-radio-card.checked-oferta { border-color: var(--accent); background: #faf1da; color: #a87e1f; }

/* Tabelas */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 14px; }
table.table th {
  text-align: left;
  padding: 12px 16px;
  background: #fafafe;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .03em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.table td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.table tbody tr:hover { background: #fafaff; }
table.table tbody tr:last-child td { border-bottom: none; }

.avatar-sm {
  width: 38px; height: 38px; border-radius: 50%;
  object-fit: cover; background: var(--bg); border: 1px solid var(--border);
}
.avatar-placeholder {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--primary-light); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 13px;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.badge-green { background: var(--success-bg); color: var(--success); }
.badge-red { background: var(--danger-bg); color: var(--danger); }
.badge-gold { background: #faf1da; color: #a87e1f; }
.badge-blue { background: var(--info-bg); color: var(--info); }
.badge-gray { background: #eef0f5; color: var(--text-muted); }

/* Login */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at top left, #2b2563 0%, #16152e 55%, #100f24 100%);
  padding: 20px;
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border-radius: 20px;
  padding: 38px 34px;
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
.login-logo {
  display: flex; flex-direction: column; align-items: center; gap: 12px; margin-bottom: 26px;
}
.login-logo .logo-mark {
  width: 56px; height: 56px; border-radius: 16px;
  background: linear-gradient(135deg, var(--accent), #b9883a);
  display: flex; align-items: center; justify-content: center;
  font-family: 'Poppins', sans-serif; font-weight: 700; color: #2a2105; font-size: 26px;
}
.login-logo h1 { font-size: 21px; margin: 0; }
.login-logo p { font-size: 12.5px; color: var(--text-muted); margin: 0; }

.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 9px;
}
.alert-danger { background: var(--danger-bg); color: var(--danger); }
.alert-success { background: var(--success-bg); color: var(--success); }
.alert-info { background: var(--info-bg); color: var(--info); }
.alert-warning { background: var(--warning-bg); color: var(--warning); }

/* Empty state */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state i { font-size: 42px; opacity: .35; margin-bottom: 14px; display: block; }

/* Filtros */
.filter-bar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: flex-end;
  margin-bottom: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.filter-bar .form-group { margin-bottom: 0; min-width: 150px; flex: 1; }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tabs a {
  padding: 11px 18px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 2.5px solid transparent;
  margin-bottom: -1px;
}
.tabs a.active { color: var(--primary); border-color: var(--primary); }

/* Modal */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(15,15,30,.5);
  z-index: 2000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.show { display: flex; }
.modal-box {
  background: var(--surface);
  border-radius: var(--radius);
  width: 100%;
  max-width: 440px;
  padding: 26px;
  box-shadow: var(--shadow-md);
}

/* Photo upload */
.photo-upload {
  display: flex;
  align-items: center;
  gap: 18px;
}
.photo-preview {
  width: 84px; height: 84px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
  background: var(--bg);
}

.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.fw-bold { font-weight: 700; }
.mb-0 { margin-bottom: 0 !important; }
.d-flex { display: flex; }
.gap-2 { gap: 8px; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }

/* Responsivo */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.show { transform: translateX(0); }
  .main { margin-left: 0; }
  .menu-toggle { display: block; }
  .content { padding: 18px; }
  .topbar { padding: 14px 18px; }
}

.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 999;
}
.sidebar-backdrop.show { display: block; }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: #d6d7e6; border-radius: 10px; }
::-webkit-scrollbar-track { background: transparent; }

/* ===================== TEMA ESCURO ===================== */
[data-theme="dark"] {
  --primary: #6366f1;
  --primary-dark: #4338ca;
  --primary-light: #818cf8;
  --bg: #0d0d1a;
  --surface: #16162a;
  --text: #e5e6f0;
  --text-muted: #8b8da8;
  --border: #2a2a42;
  --success-bg: #0d2e24;
  --danger-bg: #2e0f15;
  --warning-bg: #2a1e07;
  --info-bg: #0a1e35;
  --shadow: 0 2px 10px rgba(0,0,0,0.35);
  --shadow-md: 0 6px 24px rgba(0,0,0,0.45);
}
[data-theme="dark"] .topbar {
  background: var(--surface);
  border-color: var(--border);
}
[data-theme="dark"] .card {
  background: var(--surface);
  border-color: var(--border);
}
[data-theme="dark"] .stat-card {
  background: var(--surface);
  border-color: var(--border);
}
[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select {
  background: #1e1e36;
  border-color: var(--border);
  color: var(--text);
}
[data-theme="dark"] table.table th {
  background: #1a1a30;
  border-color: var(--border);
}
[data-theme="dark"] table.table td { border-color: var(--border); }
[data-theme="dark"] table.table tbody tr:hover { background: #1e1e34; }
[data-theme="dark"] .filter-bar {
  background: var(--surface);
  border-color: var(--border);
}
[data-theme="dark"] .login-card { background: #1a1a30; }
[data-theme="dark"] .modal-box { background: #1e1e36; border: 1px solid var(--border); }
[data-theme="dark"] .bg-violet { background: #1e1b4b; }
[data-theme="dark"] .bg-green  { background: #0a2118; }
[data-theme="dark"] .bg-gold   { background: #2a1e06; }
[data-theme="dark"] .bg-red    { background: #2a0c12; }
[data-theme="dark"] .bg-blue   { background: #071b30; }
[data-theme="dark"] .badge-gray { background: #2a2a42; color: var(--text-muted); }
[data-theme="dark"] .tabs { border-color: var(--border); }
[data-theme="dark"] .tabs a { color: var(--text-muted); }
[data-theme="dark"] .btn-outline {
  border-color: var(--border);
  color: var(--text);
}
[data-theme="dark"] .btn-outline:hover { background: #1e1e36; }
[data-theme="dark"] .input-radio-card { border-color: var(--border); color: var(--text); }
[data-theme="dark"] .avatar-placeholder { background: var(--primary); }
[data-theme="dark"] .card-header-x { border-color: var(--border); }
[data-theme="dark"] .sidebar-foot { color: rgba(255,255,255,.35); }

/* ===================== Tema: botão toggle ===================== */
.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 17px;
  transition: all .15s;
}
.theme-toggle:hover { background: var(--bg); color: var(--text); }

/* ===================== Notificações (sino) ===================== */
.notif-btn {
  position: relative;
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 17px;
  transition: all .15s;
}
.notif-btn:hover { background: var(--bg); color: var(--text); }
.notif-badge {
  position: absolute;
  top: -5px; right: -5px;
  background: var(--danger);
  color: #fff;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  min-width: 17px; height: 17px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 3px;
}

/* ===================== Impersonation banner ===================== */
.impersonate-bar {
  background: linear-gradient(90deg, #b45309, #d97706);
  color: #fff;
  padding: 9px 28px;
  font-size: 13.5px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.impersonate-bar a {
  background: rgba(255,255,255,.2);
  border-radius: 6px;
  padding: 5px 12px;
  color: #fff;
  font-size: 12.5px;
}
.impersonate-bar a:hover { background: rgba(255,255,255,.35); }

/* ===================== Conta bloqueada ===================== */
.blocked-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 24px;
}
.blocked-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 500px;
  width: 100%;
  padding: 40px 36px;
  text-align: center;
  box-shadow: var(--shadow-md);
}
.blocked-icon {
  font-size: 56px;
  color: var(--danger);
  margin-bottom: 18px;
}

/* ===================== Fatura modal ===================== */
.invoice-preview {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 20px;
  margin-bottom: 16px;
  background: var(--bg);
  font-size: 14px;
}
.invoice-preview h4 { font-size: 16px; margin-bottom: 10px; }
.invoice-preview .inv-row {
  display: flex;
  justify-content: space-between;
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
}
.invoice-preview .inv-row:last-child { border-bottom: none; }
.inv-total { font-size: 20px; font-weight: 700; color: var(--primary); margin-top: 10px; }

/* ===================== Credencial / Documentos ===================== */
.credential-card {
  width: 340px;
  background: linear-gradient(135deg, #1c1b3a 0%, #312890 100%);
  border-radius: 18px;
  padding: 28px 22px 22px;
  color: #fff;
  position: relative;
  overflow: hidden;
  font-family: 'Poppins','Inter',sans-serif;
  box-shadow: 0 8px 32px rgba(67,56,202,.35);
}
.credential-card::before {
  content: '';
  position: absolute;
  top: -40px; right: -40px;
  width: 140px; height: 140px;
  border-radius: 50%;
  background: rgba(255,255,255,.06);
}
.credential-card::after {
  content: '';
  position: absolute;
  bottom: -30px; left: -30px;
  width: 100px; height: 100px;
  border-radius: 50%;
  background: rgba(212,168,67,.08);
}
.cred-logo { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; opacity: .7; margin-bottom: 16px; }
.cred-photo {
  width: 80px; height: 80px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid #d4a843;
  margin-bottom: 12px;
}
.cred-photo-placeholder {
  width: 80px; height: 80px;
  border-radius: 50%;
  background: rgba(255,255,255,.15);
  display: flex; align-items: center; justify-content: center;
  font-size: 30px; font-weight: 700;
  margin-bottom: 12px;
  border: 3px solid #d4a843;
}
.cred-name { font-size: 18px; font-weight: 700; margin-bottom: 4px; }
.cred-role { font-size: 12.5px; opacity: .75; margin-bottom: 2px; }
.cred-church { font-size: 11.5px; color: #d4a843; margin-bottom: 14px; }
.cred-id { font-size: 10px; opacity: .5; letter-spacing: .06em; margin-top: 8px; }
.cred-footer {
  border-top: 1px solid rgba(255,255,255,.12);
  margin-top: 14px;
  padding-top: 10px;
  font-size: 10px;
  opacity: .55;
}
.cred-qr { background: #fff; border-radius: 8px; padding: 4px; display: inline-block; margin-top: 4px; }

/* Documentos / Certificados */
.doc-page {
  max-width: 720px;
  margin: 0 auto;
  background: #fff;
  color: #1f2333;
  padding: 60px;
  font-family: 'Times New Roman', Times, serif;
  line-height: 1.8;
}
.doc-header { text-align: center; margin-bottom: 30px; }
.doc-header h2 { font-size: 22px; text-transform: uppercase; letter-spacing: .06em; }
.doc-header .doc-church { font-size: 15px; color: #555; margin-top: 6px; }
.doc-divider { border: none; border-top: 2px solid #1c1b3a; margin: 20px 0; }
.doc-title { text-align: center; font-size: 18px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; margin: 30px 0 20px; }
.doc-body { font-size: 14px; text-align: justify; }
.doc-body p { margin: 14px 0; }
.doc-signature { margin-top: 60px; text-align: center; }
.doc-signature .sig-line { border-top: 1px solid #333; width: 260px; margin: 0 auto 8px; }
.doc-footer { text-align: center; font-size: 11px; color: #888; margin-top: 40px; border-top: 1px solid #eee; padding-top: 12px; }

/* Pendente badge */
.badge-orange { background: var(--warning-bg); color: var(--warning); }

/* Public registration page */
.public-wrap {
  min-height: 100vh;
  background: radial-gradient(circle at top left, #2b2563 0%, #16152e 55%, #100f24 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.public-card {
  background: var(--surface);
  border-radius: 20px;
  padding: 36px;
  max-width: 680px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
}

@media print {
  body { background: #fff !important; }
  .no-print, .topbar, .sidebar, .app-shell > .main > .topbar,
  .sidebar-backdrop, .btn-print-hide { display: none !important; }
  .main { margin-left: 0 !important; }
  .content { padding: 0 !important; }
  .doc-page { box-shadow: none !important; max-width: 100% !important; padding: 20px !important; }
  .credential-card { box-shadow: none !important; }
}

/* ── Stat card: fonte responsiva pra não ultrapassar o card ── */
.stat-card .stat-value {
  font-size: clamp(16px, 2.2vw, 22px) !important;
  word-break: break-all;
  overflow-wrap: break-word;
}
.stats-grid {
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}

/* ── Documento em modal ── */
.doc-modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.65);
  z-index: 9999;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
  backdrop-filter: blur(4px);
}
.doc-modal-overlay.show { display: flex; }
.doc-modal-inner {
  background: var(--surface);
  border-radius: 16px;
  width: 100%;
  max-width: 760px;
  margin: auto;
  box-shadow: 0 24px 80px rgba(0,0,0,.3);
  overflow: hidden;
}
.doc-modal-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.doc-modal-bar h3 { margin: 0; font-size: 15px; }
.doc-modal-content {
  padding: 0;
  max-height: calc(100vh - 160px);
  overflow-y: auto;
}
.doc-modal-content iframe {
  width: 100%; min-height: 500px; border: none; display: block;
}

/* ── Credencial melhorada ── */
.cred-card-v2 {
  width: 340px; height: 213px; /* proporção cartão bancário */
  border-radius: 16px;
  position: relative;
  overflow: hidden;
  font-family: 'Poppins', 'Inter', sans-serif;
  box-shadow: 0 8px 32px rgba(0,0,0,.25);
  display: flex;
  flex-direction: column;
}
.cred-card-v2 .cred-bar {
  padding: 10px 16px 8px;
  display: flex; align-items: center; justify-content: space-between;
}
.cred-card-v2 .cred-bar .cred-church-name {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; opacity: .9;
}
.cred-card-v2 .cred-bar .cred-type {
  font-size: 9px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; opacity: .7;
}
.cred-card-v2 .cred-body {
  flex: 1;
  display: flex; gap: 0;
}
.cred-card-v2 .cred-photo-col {
  width: 88px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 0 12px 12px;
}
.cred-card-v2 .cred-photo-col img,
.cred-card-v2 .cred-photo-col .cred-initials {
  width: 72px; height: 88px;
  border-radius: 8px;
  object-fit: cover;
  border: 2px solid rgba(255,255,255,.4);
}
.cred-card-v2 .cred-photo-col .cred-initials {
  background: rgba(255,255,255,.2);
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; font-weight: 700; color: #fff;
}
.cred-card-v2 .cred-info {
  flex: 1; padding: 4px 14px 12px 4px;
  display: flex; flex-direction: column; justify-content: center;
}
.cred-card-v2 .cred-cargo {
  font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .12em;
  opacity: .75; margin-bottom: 4px;
}
.cred-card-v2 .cred-nome {
  font-size: 14px; font-weight: 700; line-height: 1.3; margin-bottom: 6px;
  word-break: break-word;
}
.cred-card-v2 .cred-constr {
  font-size: 9.5px; opacity: .7; line-height: 1.5;
}
.cred-card-v2 .cred-qr-mini {
  width: 44px; height: 44px;
  background: rgba(255,255,255,.9);
  border-radius: 6px; padding: 2px;
  margin-top: 4px;
}
.cred-card-v2 .cred-foot {
  padding: 7px 14px;
  display: flex; align-items: center; justify-content: space-between;
  border-top: 1px solid rgba(255,255,255,.12);
  font-size: 9px; opacity: .65;
}

/* Cores por cargo */
.cred-pastor     { background: linear-gradient(135deg, #1e3a5f 0%, #1e5799 100%); color: #fff; }
.cred-diacono    { background: linear-gradient(135deg, #145a32 0%, #1e8449 100%); color: #fff; }
.cred-presbitero { background: linear-gradient(135deg, #4a235a 0%, #7d3c98 100%); color: #fff; }
.cred-evangelista{ background: linear-gradient(135deg, #7d3c00 0%, #d68910 100%); color: #fff; }
.cred-lider      { background: linear-gradient(135deg, #1a535c 0%, #1abc9c 100%); color: #fff; }
.cred-membro     { background: linear-gradient(135deg, #1c1b3a 0%, #4338ca 100%); color: #fff; }
.cred-outro      { background: linear-gradient(135deg, #424242 0%, #757575 100%); color: #fff; }

/* Verso da credencial */
.cred-verso {
  width: 340px; height: 213px;
  border-radius: 16px;
  background: #f8f8fc;
  border: 1px solid #e0e0e8;
  padding: 16px;
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  color: #2a2a3a;
  position: relative;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0,0,0,.15);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}
.cred-verso::before {
  content: '';
  position: absolute; right: -20px; top: -20px;
  width: 120px; height: 120px;
  border-radius: 50%;
  background: rgba(67,56,202,.06);
}
.cred-verso-col { display: flex; flex-direction: column; gap: 6px; padding: 4px 8px 0 0; }
.cred-verso-col:last-child { border-left: 1px solid #e0e0e8; padding: 4px 0 0 12px; }
.cred-verso .vrow { line-height: 1.4; }
.cred-verso .vrow b { display: block; font-size: 9px; text-transform: uppercase; letter-spacing: .06em; color: #6b7280; }
.cred-verso .vrow span { font-weight: 600; font-size: 11.5px; color: #1f2333; }
.cred-verso-obs {
  position: absolute; bottom: 10px; left: 16px; right: 16px;
  font-size: 8.5px; color: #9ca3af; line-height: 1.4;
  border-top: 1px solid #e0e0e8; padding-top: 6px;
  font-style: italic;
}

/* Certificado background */
.doc-page.cert-batismo {
  background-image: url("data:image/svg+xml,%3Csvg width='400' height='400' viewBox='0 0 400 400' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none'%3E%3Ccircle cx='200' cy='200' r='190' stroke='%234338ca' stroke-width='.4' opacity='.15'/%3E%3Ccircle cx='200' cy='200' r='160' stroke='%234338ca' stroke-width='.3' opacity='.1'/%3E%3Ccircle cx='200' cy='200' r='120' stroke='%234338ca' stroke-width='.2' opacity='.08'/%3E%3C/g%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center center;
  background-size: 420px;
}
.cert-border {
  border: 2.5px solid #4338ca;
  padding: 6px;
  border-radius: 4px;
  margin-bottom: 24px;
}
.cert-border-inner {
  border: 1px solid rgba(67,56,202,.35);
  padding: 40px 44px;
}
