/* ============================================================
   SíndicoOne — Design System
   Conceito: mesma "nave escura / nave clara" da família ClassOne/
   ChurchOne (navegação escura, conteúdo claro), com paleta própria
   em navy + âmbar — a mesma linguagem visual já usada no gerador
   de licença de uso interno da equipe, pra manter consistência
   entre as ferramentas internas e os produtos que vendemos.
   ============================================================ */

@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: #132A3D;
  --ink-soft: #1C3A52;
  --ink-softer: #234A68;
  --line-on-ink: rgba(243, 245, 247, 0.12);
  --gold: #E0972D;
  --gold-soft: #EFB769;
  --sage: #4F84A0;
  --sage-soft: #86AEC2;
  --cream: #F3F5F7;
  --cream-dim: #E7EBEE;
  --text-ink: #16232E;
  --text-muted: #647485;
  --danger: #C9432F;
  --danger-bg: #FBEAE7;

  /* 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 */
/* ---------------------------------------------------------- */
.predio-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;
}

.predio-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 .sidebar-logo {
  width: 34px; height: 34px;
  border-radius: 9px;
  flex-shrink: 0;
  object-fit: contain;
  background: #fff;
  padding: 3px;
}

.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 .nav-icon {
  width: 20px;
  flex-shrink: 0;
  text-align: center;
  font-size: 15px;
  line-height: 1;
  opacity: 0.9;
}

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

.nav-badge {
  margin-left: auto;
  background: var(--gold);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  padding: 3px 6px;
  border-radius: 999px;
  min-width: 18px;
  text-align: center;
}

.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 .info .conta-link {
  display: inline-block;
  margin-top: 3px;
  font-size: 11px;
  color: var(--gold-soft);
  text-decoration: underline;
}
.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-pendente { background: #FBF0DD; color: #96701F; margin-left: 6px; }
.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; }

.identidade-preview {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}
.identidade-preview img {
  width: 56px; height: 56px;
  object-fit: contain;
  border-radius: 10px;
  background: #fff;
  border: 1px solid var(--cream-dim);
  padding: 4px;
}
.identidade-remover {
  font-size: 12.5px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
  cursor: pointer;
}
.identidade-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
}

/* Imagem de fundo opcional (identidade visual do escritório), aplicada
   como marca d'água discreta atrás do conteúdo das telas internas —
   ver body.tem-fundo, injetado pelo base.html quando escritorio.fundo_path
   está preenchido. */
body.tem-fundo {
  position: relative;
}
body.tem-fundo::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image: var(--app-bg-image);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  opacity: 0.05;
  z-index: 0;
  pointer-events: none;
}
body.tem-fundo .app-shell { position: relative; z-index: 1; }

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; }

/* ------------------------------------------------------------
   Obras — galeria de cards e comparação antes/depois
   ------------------------------------------------------------ */
.obras-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 16px;
}
.obra-card {
  display: block;
  border: 1px solid rgba(36,30,56,0.08);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #fff;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow-card);
  transition: transform 0.15s ease;
}
.obra-card:hover { transform: translateY(-2px); }
.obra-card-foto {
  width: 100%;
  aspect-ratio: 4 / 3;
  background: var(--cream-dim);
  overflow: hidden;
}
.obra-card-foto img { width: 100%; height: 100%; object-fit: cover; display: block; }
.obra-card-foto.sem-foto {
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); font-size: 12px; text-align: center; padding: 10px;
}
.obra-card-body { padding: 12px 14px; }
.obra-card-body h4 { margin: 0 0 4px; font-size: 14.5px; font-family: var(--font-display); }
.obra-card-body .meta { font-size: 12px; color: var(--text-muted); }

.antes-depois {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 14px;
}
.antes-depois-col .rotulo {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--text-muted); margin-bottom: 8px;
}
.antes-depois-fotos { display: flex; flex-direction: column; gap: 10px; }
.antes-depois-fotos img,
.antes-depois-fotos .sem-foto {
  width: 100%; border-radius: var(--radius-sm); object-fit: cover; display: block;
  border: 1px solid rgba(36,30,56,0.08);
}
.antes-depois-fotos .sem-foto {
  aspect-ratio: 4/3; display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); font-size: 12px; background: var(--cream-dim);
}
.foto-thumb-wrap { position: relative; display: inline-block; width: 100%; }
.foto-thumb-wrap .btn-remover-foto {
  position: absolute; top: 6px; right: 6px; width: 26px; height: 26px; border-radius: 50%;
  background: rgba(19,42,61,0.85); color: #fff; border: none; font-size: 14px; line-height: 1;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
}

@media (max-width: 600px) {
  .antes-depois { grid-template-columns: 1fr; }
  .obras-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ------------------------------------------------------------
   Responsivo — padrão para TODAS as telas, atual e futuras
   ------------------------------------------------------------
   Regra geral daqui pra frente: nenhuma tela nova deve depender de
   media query própria pra não vazar no celular. Os componentes de
   base (.page-header, .stat-grid, .info-grid, .form-grid, .card-pad,
   tabelas, .filter-bar etc.) já se adaptam sozinhos. Só crie um bloco
   responsivo específico se estiver inventando um componente de layout
   novo que não existe aqui embaixo. */

/* Safety net: nada deve conseguir empurrar a página inteira pro lado.
   Contêineres que realmente precisam de rolagem horizontal (ex.:
   .table-responsive) fazem isso dentro de si mesmos, não na página. */
html, body { max-width: 100%; overflow-x: hidden; }
img, svg { max-width: 100%; height: auto; }

/* Barra superior mobile: só existe visualmente abaixo do breakpoint
   de 980px, mas o markup já fica sempre no base.html (ver .portal-topbar
   no HTML). Contém o botão de abrir/fechar o menu lateral. */
.portal-topbar {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 58px;
  z-index: 210;
  background: var(--ink);
  color: var(--cream);
  align-items: center;
  gap: 12px;
  padding: 0 14px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.15);
}
.portal-topbar .name {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  color: var(--cream);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.menu-toggle {
  width: 38px; height: 38px;
  flex-shrink: 0;
  border-radius: 9px;
  border: 1px solid var(--line-on-ink);
  background: var(--ink-soft);
  color: var(--cream);
  font-size: 18px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.menu-toggle:active { background: var(--ink-softer); }

/* Fundo escurecido atrás do menu quando ele abre por cima do conteúdo */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(19,42,61,0.5);
  z-index: 190;
}
.sidebar-backdrop.show { display: block; }

/* Tabela com rolagem própria: em vez de estourar a largura da tela
   (o "vazamento" no celular), a tabela vira uma faixa que rola só ela,
   dentro do card. Todo <table> do sistema é envolvido automaticamente
   nisso pelo script no fim do base.html — não precisa lembrar de fazer
   isso manualmente em telas novas. */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.table-responsive table { min-width: 620px; }

@media (max-width: 980px) {
  .portal-topbar { display: flex; }
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    z-index: 220;
    width: min(var(--sidebar-w), 84vw);
    box-shadow: 0 0 0 rgba(0,0,0,0);
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 0 0 44px rgba(0,0,0,0.35);
  }
  .main { margin-left: 0; padding: 20px; padding-top: 78px; }
  .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; }
}

/* Breakpoint extra pra telas de celular estreitas (a maioria dos
   aparelhos reais: ~360–430px). Aqui é onde as coisas realmente
   vazavam: grades de 2+ colunas, cabeçalhos flex sem quebra, e
   padding generoso demais pra pouca largura disponível. */
@media (max-width: 600px) {
  .main { padding: 14px; padding-top: 72px; }
  .card-pad { padding: 16px; }

  .page-header, .profile-header, .report-header {
    flex-wrap: wrap;
    align-items: flex-start;
  }
  .page-header .actions { flex-wrap: wrap; width: 100%; }
  .page-header .actions .btn { flex: 1 1 auto; justify-content: center; }
  .page-header h1 { font-size: 23px; }

  .stat-grid, .fin-stat-grid, .info-grid, .report-totals,
  .condominio-picker-grid {
    grid-template-columns: 1fr;
  }

  .filter-bar input, .filter-bar select,
  .filter-bar input[type="search"] {
    width: 100%;
    min-width: 0;
  }

  .voto-tally, .voto-form { flex-wrap: wrap; }
  .voto-form select { width: 100%; min-width: 0; }

  .login-card { padding: 32px 22px; }
  .em-construcao { padding: 56px 16px; }
}

@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, .sidebar-backdrop {
    display: none !important;
  }
  .main { margin-left: 0 !important; padding: 0 !important; }
  .app-shell { display: block !important; }
  body { background: #fff !important; overflow-x: visible !important; }
  .card, .card-pad { box-shadow: none !important; border: none !important; }
  .table-responsive { overflow-x: visible !important; }
  .table-responsive table { min-width: 0 !important; }
  a[href]:after { content: "" !important; }
}

/* ------------------------------------------------------------
   SíndicoOne — Trocador de condomínio ativo (sidebar)
   ------------------------------------------------------------ */
.condominio-switch {
  margin: 0 14px 10px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line-on-ink);
}
.condominio-switch-link {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--ink-soft);
  transition: background 0.15s ease;
}
.condominio-switch-link:hover { background: var(--ink-softer); }
.condominio-switch-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(243,245,247,0.5);
}
.condominio-switch-nome {
  font-family: var(--font-display);
  font-size: 14.5px;
  font-weight: 600;
  color: var(--cream);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.condominio-switch-trocar {
  font-size: 11px;
  font-weight: 700;
  color: var(--gold-soft);
  margin-top: 2px;
}

/* Seleção de condomínio (grade de cards) */
.condominio-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}
.condominio-picker-card {
  display: block;
  padding: 18px 20px;
  border-radius: var(--radius);
  background: #fff;
  border: 1px solid rgba(36,30,56,0.06);
  box-shadow: var(--shadow-card);
  transition: transform 0.1s ease, border-color 0.15s ease;
}
.condominio-picker-card:hover { transform: translateY(-2px); border-color: var(--gold); }
.condominio-picker-card .nome { font-family: var(--font-display); font-size: 16.5px; font-weight: 600; }
.condominio-picker-card .endereco { font-size: 12.5px; color: var(--text-muted); margin-top: 4px; }

/* Página "em construção" dos módulos ainda não implementados */
.em-construcao {
  text-align: center;
  padding: 80px 20px;
}
.em-construcao .icone {
  width: 56px; height: 56px;
  margin: 0 auto 18px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--gold) 0%, var(--sage) 100%);
}
.em-construcao h2 { font-size: 20px; margin-bottom: 8px; }
.em-construcao p { color: var(--text-muted); font-size: 13.5px; max-width: 420px; margin: 0 auto; }

/* Status de condomínio */
.tag-suspenso { background: #FCF2DF; color: #97722A; }
.tag-encerrado { background: #F0EEEA; color: #857E6E; }

/* ------------------------------------------------------------
   SíndicoOne — Módulo Assembleias (Fase 1)
   Bloco só ADITIVO: nenhuma regra existente acima foi alterada.
   ------------------------------------------------------------ */
.quorum-summary {
  font-size: 13px;
  color: var(--text-muted);
  margin: 8px 0 10px;
}
.pauta-item {
  border: 1px solid rgba(36,30,56,0.08);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  margin-bottom: 14px;
}
.pauta-item:last-child { margin-bottom: 0; }
.pauta-item-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
}
.pauta-item-titulo { font-weight: 700; font-size: 14.5px; }
.pauta-item-desc { font-size: 12.5px; color: var(--text-muted); margin-top: 3px; }
.voto-tally {
  display: flex;
  gap: 18px;
  margin: 12px 0;
  font-size: 12.5px;
}
.voto-tally-row { display: flex; gap: 6px; align-items: baseline; color: var(--text-muted); }
.voto-tally-row strong { font-family: var(--font-mono); font-size: 14px; color: var(--text-ink); }
.voto-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}
.voto-form select { width: auto; min-width: 160px; }
.voto-lista { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }

/* ============================================================
   Comercial — CRM (quadro de prospecção de novos condomínios)
   ============================================================ */
.crm-board {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding-bottom: 8px;
  align-items: flex-start;
}
.crm-coluna {
  flex: 0 0 290px;
  width: 290px;
  background: var(--cream-dim);
  border-radius: var(--radius);
  padding: 12px;
  min-height: 160px;
}
.crm-coluna-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 4px 10px;
}
.crm-coluna-titulo { font-family: var(--font-display); font-weight: 600; font-size: 14.5px; }
.crm-coluna-count {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-muted);
  background: #fff;
  border-radius: 999px;
  padding: 2px 8px;
}
.crm-coluna-valor { font-size: 11.5px; color: var(--text-muted); padding: 0 4px 8px; }
.crm-card {
  background: #fff;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-card);
  padding: 12px 14px;
  margin-bottom: 10px;
}
.crm-card-titulo { font-weight: 700; font-size: 14px; margin-bottom: 2px; }
.crm-card-sub { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; }
.crm-card-meta { font-size: 11.5px; color: var(--text-muted); display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.crm-card-meta span { background: var(--cream-dim); border-radius: 999px; padding: 2px 8px; }
.crm-card-valor { font-family: var(--font-mono); font-weight: 700; color: var(--sage); font-size: 13.5px; margin-bottom: 6px; }
.crm-card-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.crm-card-actions details { position: relative; }
.crm-card-actions summary {
  list-style: none;
  cursor: pointer;
}
.crm-card-actions summary::-webkit-details-marker { display: none; }
.crm-card-actions details form,
.crm-card-actions details .crm-quickform {
  position: absolute;
  z-index: 20;
  top: calc(100% + 6px);
  left: 0;
  background: #fff;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-card);
  padding: 12px;
  display: grid;
  gap: 8px;
  min-width: 240px;
}
.crm-empty-coluna {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  padding: 18px 6px;
}
.crm-perdidos-toggle summary {
  cursor: pointer;
  font-size: 13px;
  color: var(--text-muted);
}
@media (max-width: 980px) {
  .crm-coluna { flex: 0 0 84vw; width: 84vw; }
}

/* ------------------------------------------------------------
   Chat interno
   ------------------------------------------------------------ */
.chat-lista-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  text-decoration: none;
  color: var(--text-ink);
  border-bottom: 1px solid var(--cream-dim);
  transition: background 0.15s ease;
}
.chat-lista-item:last-child { border-bottom: none; }
.chat-lista-item:hover { background: var(--cream); }
.chat-lista-item .avatar {
  width: 40px; height: 40px; flex-shrink: 0;
  border-radius: 50%;
  background: var(--sage-soft);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 15px;
}
.chat-lista-item .corpo { flex: 1; min-width: 0; }
.chat-lista-item .nome-conversa {
  font-weight: 700;
  font-size: 14.5px;
  margin-bottom: 2px;
}
.chat-lista-item .preview {
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-lista-item.tem-nao-lida .preview { color: var(--text-ink); font-weight: 600; }
.chat-lista-item .meta {
  flex-shrink: 0;
  text-align: right;
  font-size: 11.5px;
  color: var(--text-muted);
}
.chat-lista-item .nao-lidas-dot {
  display: inline-block;
  margin-top: 6px;
  background: var(--gold);
  color: var(--ink);
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 999px;
}

.chat-janela {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 220px);
  min-height: 420px;
}
.chat-mensagens {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.chat-bolha {
  max-width: 68%;
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.45;
  word-wrap: break-word;
  background: var(--cream);
  color: var(--text-ink);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}
.chat-bolha.minha {
  background: var(--ink-softer);
  color: var(--cream);
  align-self: flex-end;
  border-bottom-left-radius: 14px;
  border-bottom-right-radius: 4px;
}
.chat-bolha .remetente {
  font-size: 11px;
  font-weight: 700;
  opacity: 0.7;
  margin-bottom: 2px;
}
.chat-bolha .hora {
  font-size: 10px;
  opacity: 0.6;
  margin-top: 4px;
  text-align: right;
}
.chat-form-envio {
  display: flex;
  gap: 10px;
  padding: 14px 18px;
  border-top: 1px solid var(--cream-dim);
}
.chat-form-envio input[type="text"] {
  flex: 1;
}
.chat-participantes-chip {
  font-size: 12.5px;
  color: var(--text-muted);
  padding: 10px 18px;
  border-bottom: 1px solid var(--cream-dim);
}
.chat-selecao-usuarios {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 4px;
  max-height: 320px;
  overflow-y: auto;
  padding: 4px;
  border: 1px solid var(--cream-dim);
  border-radius: var(--radius-sm);
}
.chat-selecao-usuarios label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
}
.chat-selecao-usuarios label:hover { background: var(--cream); }
.chat-selecao-usuarios input[type="checkbox"] { width: auto; }
