/* ============================================================
   ChurchOne — Design System
   Conceito: "luz através do vitral" — uma nave escura (navegação)
   e uma nave clara onde o trabalho acontece (conteúdo), unidas por
   um acento de vitral facetado usado como assinatura visual.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,500;9..144,600;9..144,700&family=Manrope:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  /* Cor */
  --ink: #1C1730;
  --ink-soft: #241E3D;
  --ink-softer: #2E2650;
  --line-on-ink: rgba(247, 244, 236, 0.12);
  --gold: #C9A15A;
  --gold-soft: #E4C989;
  --sage: #7C9885;
  --sage-soft: #A9C1AF;
  --cream: #F7F4EC;
  --cream-dim: #EFEADD;
  --text-ink: #241E38;
  --text-muted: #6E668A;
  --danger: #C1666B;
  --danger-bg: #FBEBEC;

  /* Tipografia */
  --font-display: 'Fraunces', serif;
  --font-body: 'Manrope', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Layout */
  --sidebar-w: 260px;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow-card: 0 1px 2px rgba(28, 23, 48, 0.04), 0 8px 24px rgba(28, 23, 48, 0.06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--cream);
  color: var(--text-ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  margin: 0;
  color: var(--text-ink);
}

a { color: inherit; text-decoration: none; }

.mono { font-family: var(--font-mono); letter-spacing: 0.02em; }

/* ---------------------------------------------------------- */
/* Vitral — assinatura visual: barra facetada usada como divisor */
/* ---------------------------------------------------------- */
.vitral-divider {
  height: 5px;
  width: 100%;
  background: linear-gradient(
    100deg,
    var(--gold) 0%, var(--gold) 12%,
    var(--sage) 12%, var(--sage) 27%,
    var(--gold-soft) 27%, var(--gold-soft) 40%,
    var(--ink-softer) 40%, var(--ink-softer) 55%,
    var(--sage-soft) 55%, var(--sage-soft) 68%,
    var(--gold) 68%, var(--gold) 82%,
    var(--sage) 82%, var(--sage) 100%
  );
  border-radius: 999px;
}

.vitral-avatar {
  background: linear-gradient(135deg, var(--gold) 0%, var(--sage) 55%, var(--ink-softer) 100%);
}

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

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--ink);
  color: var(--cream);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; bottom: 0; left: 0;
}

.sidebar-brand {
  padding: 28px 24px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-brand .mark {
  width: 34px; height: 34px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--gold) 0%, var(--sage) 100%);
  flex-shrink: 0;
}

.sidebar-brand .name {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 600;
  color: var(--cream);
}

.sidebar-brand .name small {
  display: block;
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 500;
  color: var(--gold-soft);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-top: 1px;
}

.sidebar-nav {
  flex: 1;
  padding: 8px 14px;
  overflow-y: auto;
}

.sidebar-section-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(247,244,236,0.4);
  padding: 16px 10px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  color: rgba(247,244,236,0.72);
  margin-bottom: 2px;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-item:hover {
  background: var(--ink-soft);
  color: var(--cream);
}

.nav-item.active {
  background: var(--ink-softer);
  color: var(--cream);
  box-shadow: inset 3px 0 0 var(--gold);
}

.nav-item .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor;
  opacity: 0.5;
  flex-shrink: 0;
}

.nav-item.disabled {
  opacity: 0.35;
  cursor: default;
}

.sidebar-footer {
  padding: 16px 20px 22px;
  border-top: 1px solid var(--line-on-ink);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-chip .avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--ink);
  font-size: 13px;
}

.user-chip .info { flex: 1; min-width: 0; }
.user-chip .info .name { font-size: 13px; font-weight: 600; color: var(--cream); }
.user-chip .info .role { font-size: 11.5px; color: rgba(247,244,236,0.55); }
.user-chip .logout {
  font-size: 11.5px;
  color: var(--gold-soft);
  font-weight: 600;
}

/* ---------------------------------------------------------- */
/* Área de conteúdo */
/* ---------------------------------------------------------- */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  padding: 32px 40px 60px;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 20px;
  margin-bottom: 18px;
}

.page-header .eyebrow {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--sage);
  margin-bottom: 6px;
}

.page-header h1 {
  font-size: 30px;
}

.page-header .subtitle {
  color: var(--text-muted);
  margin-top: 4px;
  font-size: 14px;
}

.page-header .actions { display: flex; gap: 10px; flex-shrink: 0; }

/* ---------------------------------------------------------- */
/* Componentes */
/* ---------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 700;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.1s ease, opacity 0.15s ease;
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--ink);
  color: var(--cream);
}
.btn-primary:hover { background: var(--ink-soft); }

.btn-gold {
  background: var(--gold);
  color: var(--ink);
}
.btn-gold:hover { background: var(--gold-soft); }

.btn-ghost {
  background: transparent;
  border-color: rgba(36,30,56,0.14);
  color: var(--text-ink);
}
.btn-ghost:hover { background: rgba(36,30,56,0.05); }

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

.btn-sm { padding: 7px 14px; font-size: 12.5px; }

.card {
  background: #fff;
  border: 1px solid rgba(36,30,56,0.06);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
}

.card-pad { padding: 22px 24px; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 20px 22px;
  border: 1px solid rgba(36,30,56,0.06);
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: hidden;
}

.stat-card .value {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 600;
}

.stat-card .label {
  font-size: 12.5px;
  color: var(--text-muted);
  font-weight: 600;
  margin-top: 2px;
}

.stat-card .accent-bar {
  position: absolute; top: 0; left: 0; right: 0; height: 4px;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 20px;
}

.section-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.list-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid rgba(36,30,56,0.06);
}
.list-row:last-child { border-bottom: none; }

.avatar-sm {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--ink);
  font-size: 13px;
  flex-shrink: 0;
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.tag-ativo { background: #E7F0E9; color: #4C7A5A; }
.tag-inativo { background: #F0EEEA; color: #857E6E; }
.tag-visitante { background: #EFE6F6; color: #7A54A6; }
.tag-transferido { background: #E6EEF6; color: #4A6FA0; }
.tag-desligado { background: var(--danger-bg); color: var(--danger); }
.tag-falecido { background: #EDEDED; color: #666; }

.tag-membro { background: #FCF2DF; color: #97722A; }
.tag-congregado { background: #E9F1EE; color: #4A7A66; }
.tag-obreiro { background: #EAE6F6; color: #5C4A9E; }

.tag-admin { background: #EAE6F6; color: #5C4A9E; }
.tag-pastor { background: #FCF2DF; color: #97722A; }
.tag-secretaria { background: #E6EEF6; color: #4A6FA0; }
.tag-lider { background: #E9F1EE; color: #4A7A66; }
.tag-tesouraria { background: #EFE6F6; color: #7A54A6; }

/* Financeiro */
.valor-entrada { color: #4C7A5A; font-weight: 700; }
.valor-saida { color: var(--danger); font-weight: 700; }

.fin-stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 22px;
}
@media (max-width: 900px) {
  .fin-stat-grid { grid-template-columns: repeat(2, 1fr); }
}

.fin-cat-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(36,30,56,0.06);
}
.fin-cat-row:last-child { border-bottom: none; }
.fin-cat-dot {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
}
.fin-cat-name { flex: 1; font-size: 13.5px; font-weight: 600; }
.fin-cat-bar-track {
  flex: 2; height: 6px; border-radius: 999px; background: rgba(36,30,56,0.06); overflow: hidden;
}
.fin-cat-bar-fill { height: 100%; border-radius: 999px; }
.fin-cat-total { width: 100px; text-align: right; font-family: var(--font-mono); font-size: 13px; }

.report-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding-bottom: 16px; margin-bottom: 16px; border-bottom: 2px solid var(--ink);
}
.report-totals {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 16px 0 22px;
}
.report-totals .box {
  padding: 14px; border-radius: var(--radius-sm); background: var(--cream-dim); text-align: center;
}
.report-totals .box .label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); margin-bottom: 4px; }
.report-totals .box .value { font-family: var(--font-mono); font-size: 20px; font-weight: 700; }

/* Formulários */
.form-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.field { display: flex; flex-direction: column; gap: 6px; }
.field.span-2 { grid-column: span 2; }
.field.span-3 { grid-column: span 3; }

.field label {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-ink);
}

.field .hint { font-size: 11.5px; color: var(--text-muted); font-weight: 500; }

input, select, textarea {
  font-family: var(--font-body);
  font-size: 14px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(36,30,56,0.15);
  background: #fff;
  color: var(--text-ink);
  width: 100%;
}

input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--gold);
  outline-offset: 1px;
  border-color: var(--gold);
}

textarea { resize: vertical; min-height: 80px; font-family: var(--font-body); }

.form-section {
  margin-bottom: 26px;
}

.form-section h3 {
  font-size: 14px;
  color: var(--sage);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 12px;
  font-weight: 700;
  font-family: var(--font-body);
}

.config-image-preview {
  width: 100%;
  max-width: 160px;
  height: 90px;
  border-radius: 10px;
  overflow: hidden;
  background: rgba(36,30,56,0.05);
  border: 1px solid rgba(36,30,56,0.08);
  display: flex;
  align-items: center;
  justify-content: center;
}
.config-image-preview img { width: 100%; height: 100%; object-fit: contain; }
.config-image-preview-wide { max-width: 280px; height: 110px; }
.config-image-preview-wide img { object-fit: cover; }

/* Tabela */
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 700;
  padding: 0 14px 10px;
  border-bottom: 1px solid rgba(36,30,56,0.08);
}
tbody td {
  padding: 13px 14px;
  border-bottom: 1px solid rgba(36,30,56,0.06);
  font-size: 13.5px;
}
tbody tr:hover { background: rgba(201,161,90,0.05); }
tbody tr:last-child td { border-bottom: none; }

.table-name { display: flex; align-items: center; gap: 10px; font-weight: 600; }

/* Filtros */
.filter-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.filter-bar input, .filter-bar select { width: auto; min-width: 160px; }
.filter-bar input[type="search"] { min-width: 240px; }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state h3 { font-size: 17px; margin-bottom: 6px; color: var(--text-ink); }
.empty-state p { font-size: 13.5px; margin-bottom: 18px; }

/* Flash messages */
.flash-stack {
  position: fixed;
  top: 20px; right: 20px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.flash {
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: var(--shadow-card);
  max-width: 340px;
}
.flash-sucesso { background: #2F4A38; color: #E7F0E9; }
.flash-erro { background: var(--danger); color: #fff; }

/* Login */
.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  background: var(--ink);
  background-image: radial-gradient(circle at 20% 20%, rgba(201,161,90,0.08), transparent 40%),
                     radial-gradient(circle at 80% 80%, rgba(124,152,133,0.08), transparent 40%);
  padding: 20px;
}

.login-bg-parallax {
  position: absolute;
  inset: -40px;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  transform: scale(1.12);
  z-index: 0;
  will-change: transform;
}

.login-bg-overlay {
  position: absolute;
  inset: 0;
  z-index: 1;
  background:
    radial-gradient(circle at 50% 40%, rgba(28,23,48,0.55), rgba(28,23,48,0.86) 75%),
    linear-gradient(180deg, rgba(28,23,48,0.65), rgba(28,23,48,0.8));
}

.login-card {
  background: var(--cream);
  border-radius: 20px;
  padding: 44px 40px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 30px 80px rgba(0,0,0,0.35);
  position: relative;
  z-index: 2;
}

.login-brand { text-align: center; margin-bottom: 8px; }
.login-brand .mark {
  width: 46px; height: 46px;
  border-radius: 12px;
  margin: 0 auto 14px;
  background: linear-gradient(135deg, var(--gold) 0%, var(--sage) 100%);
}
.login-brand .login-logo {
  width: 60px; height: 60px;
  border-radius: 14px;
  margin: 0 auto 14px;
  display: block;
  object-fit: contain;
  background: #fff;
  padding: 6px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.12);
}
.login-brand h1 { font-size: 22px; }
.login-brand p { color: var(--text-muted); font-size: 13px; margin-top: 4px; }

.login-form { margin-top: 28px; display: flex; flex-direction: column; gap: 14px; }
.login-form .btn { justify-content: center; margin-top: 6px; }

.login-hint {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid rgba(36,30,56,0.1);
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}

/* Detalhe do membro */
.profile-header {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 22px;
}
.profile-header .avatar-lg {
  width: 68px; height: 68px;
  border-radius: 18px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 600;
  color: var(--ink);
  flex-shrink: 0;
}
.profile-header .meta { display: flex; gap: 8px; align-items: center; margin-top: 6px; flex-wrap: wrap; }
.profile-header .code { font-size: 12.5px; color: var(--text-muted); }

.info-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px 24px;
}
.info-item .k { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); font-weight: 700; }
.info-item .v { font-size: 14px; margin-top: 3px; }

.timeline-item {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid rgba(36,30,56,0.06);
}
.timeline-item:last-child { border-bottom: none; }
.timeline-item .marker {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--gold);
  margin-top: 6px;
  flex-shrink: 0;
}
.timeline-item .desc { font-size: 13.5px; }
.timeline-item .when { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }

/* Responsivo */
@media (max-width: 980px) {
  .sidebar { display: none; }
  .main { margin-left: 0; padding: 20px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .field.span-2, .field.span-3 { grid-column: span 1; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ------------------------------------------------------------
   Agenda / Previsão de contas a pagar — componentes pequenos
   ------------------------------------------------------------ */
.tag-confirmado { background: #E7F0E9; color: #4C7A5A; }
.tag-cancelado { background: var(--danger-bg); color: var(--danger); }
.tag-concluido { background: #E6EEF6; color: #4A6FA0; }
.tag-planejado { background: #FCF2DF; color: #97722A; }
.tag-em_andamento { background: #EFE6F6; color: #7A54A6; }

.agenda-day-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  border-radius: 10px;
  background: var(--cream);
  border: 1px solid rgba(36,30,56,0.08);
  flex-shrink: 0;
}
.agenda-day-badge .dia { font-family: var(--font-mono); font-weight: 700; font-size: 15px; line-height: 1.1; }
.agenda-day-badge .mes { font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); }

.forecast-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid rgba(36,30,56,0.06);
}
.forecast-row:last-child { border-bottom: none; }
.forecast-row .valor { font-family: var(--font-mono); font-weight: 700; white-space: nowrap; }

/* ------------------------------------------------------------
   Impressão — usado nas telas de relatório (financeiro/relatorio,
   financeiro/previsao). O botão "Imprimir PDF" chama window.print();
   aqui escondemos tudo que não faz parte do conteúdo do relatório
   e deixamos o card ocupar a folha inteira.
   ------------------------------------------------------------ */
@media print {
  .sidebar, .page-header .actions, .filter-bar, .flash-stack, .hint,
  .no-print, .portal-topbar {
    display: none !important;
  }
  .main { margin-left: 0 !important; padding: 0 !important; }
  .app-shell { display: block !important; }
  body { background: #fff !important; }
  .card, .card-pad { box-shadow: none !important; border: none !important; }
  a[href]:after { content: "" !important; }
}
