/* ==========================================================================
   SQS CLOUD - DESIGN SYSTEM MODERNO & REFINADO
   ========================================================================== */

:root {
  /* Tema Escuro (Padrão) */
  --bg-main: #0b0f19;
  --bg-sidebar: #0f172a;
  --bg-card: rgba(30, 41, 59, 0.7);
  --bg-card-hover: rgba(30, 41, 59, 0.95);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-subtle: rgba(255, 255, 255, 0.04);
  
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --accent-primary: #6366f1;
  --accent-primary-hover: #4f46e5;
  --accent-glow: rgba(99, 102, 241, 0.25);
  
  --color-emerald: #10b981;
  --color-emerald-bg: rgba(16, 185, 129, 0.12);
  --color-amber: #f59e0b;
  --color-amber-bg: rgba(245, 158, 11, 0.12);
  --color-rose: #f43f5e;
  --color-rose-bg: rgba(244, 63, 94, 0.12);
  --color-indigo: #818cf8;
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -2px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -4px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 25px rgba(99, 102, 241, 0.15);
  
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Outfit', var(--font-sans);
}

body.light-theme {
  --bg-main: #f1f5f9;
  --bg-sidebar: #ffffff;
  --bg-card: rgba(255, 255, 255, 0.9);
  --bg-card-hover: #ffffff;
  --border-color: rgba(0, 0, 0, 0.08);
  --border-subtle: rgba(0, 0, 0, 0.04);
  
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08);
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-main);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

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

/* SIDEBAR */
.sidebar {
  width: 270px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 50;
  box-shadow: var(--shadow-md);
  transition: all 0.3s ease;
}

.brand-section {
  padding: 24px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border-color);
}

.brand-logo {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #6366f1, #3b82f6);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-glow);
  color: white;
}

.logo-icon {
  width: 24px;
  height: 24px;
}

.brand-text h2 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.brand-text h2 span {
  color: #818cf8;
}

.badge-version {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--color-emerald);
  letter-spacing: 0.5px;
}

.nav-menu {
  flex: 1;
  padding: 16px 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-group-title {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--text-muted);
  padding: 14px 12px 6px;
}

.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-item:hover {
  background-color: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  transform: translateX(3px);
}

.nav-item.active {
  background: linear-gradient(90deg, rgba(99, 102, 241, 0.15), rgba(99, 102, 241, 0.05));
  color: #a5b4fc;
  font-weight: 600;
  border-left: 3px solid var(--accent-primary);
}

.nav-item.nav-highlight {
  border: 1px dashed rgba(99, 102, 241, 0.4);
  background: rgba(99, 102, 241, 0.08);
  color: #c7d2fe;
}

.nav-item.nav-highlight:hover {
  background: rgba(99, 102, 241, 0.15);
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border-color);
}

.system-status-indicator {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.2);
  border-radius: var(--radius-md);
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: var(--color-emerald);
  box-shadow: 0 0 10px var(--color-emerald);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.8; }
}

.status-texts {
  display: flex;
  flex-direction: column;
}

.status-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-emerald);
}

.status-sub {
  font-size: 0.68rem;
  color: var(--text-muted);
}

/* MAIN WRAPPER */
.main-wrapper {
  flex: 1;
  margin-left: 270px;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* TOPBAR */
.topbar {
  height: 70px;
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 40;
}

.condo-selector-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
}

.selector-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
}

.select-condominio {
  background: var(--bg-sidebar);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  outline: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.select-condominio:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.theme-toggle-btn {
  background: var(--bg-sidebar);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  transition: all 0.2s;
}

.theme-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* CONTENT BODY */
.content-body {
  padding: 32px;
  flex: 1;
}

.view-section {
  display: none;
  animation: fadeIn 0.3s ease;
}

.view-section.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.view-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 28px;
  gap: 16px;
}

.view-title {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.view-subtitle {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-top: 4px;
}

/* BOTÕES */
.btn {
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
}

.btn-primary {
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: white;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #4f46e5, #4338ca);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.15);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.78rem;
}

.btn-block {
  width: 100%;
  justify-content: center;
}

.btn-large {
  padding: 14px 28px;
  font-size: 1rem;
}

.btn-link {
  background: none;
  border: none;
  color: #818cf8;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
}

.btn-link:hover {
  text-decoration: underline;
}

/* KPIS GRID */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}

.kpi-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 18px;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: rgba(255, 255, 255, 0.15);
}

.kpi-icon-box {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

.bg-indigo { background: rgba(99, 102, 241, 0.15); color: #818cf8; }
.bg-emerald { background: var(--color-emerald-bg); color: var(--color-emerald); }
.bg-rose { background: var(--color-rose-bg); color: var(--color-rose); }
.bg-amber { background: var(--color-amber-bg); color: var(--color-amber); }

.kpi-info {
  display: flex;
  flex-direction: column;
}

.kpi-label {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.kpi-value {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 700;
  margin: 2px 0;
  letter-spacing: -0.5px;
}

.kpi-trend {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.text-emerald { color: var(--color-emerald) !important; }
.text-rose { color: var(--color-rose) !important; }
.text-amber { color: var(--color-amber) !important; }
.text-muted { color: var(--text-muted) !important; }
.text-right { text-align: right; }

/* DASHBOARD GRID SECUNDÁRIO */
.dashboard-grid-secondary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.dashboard-panel {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.panel-header h3 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
}

.panel-tag {
  font-size: 0.75rem;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: rgba(99, 102, 241, 0.12);
  color: #a5b4fc;
  font-weight: 600;
}

.chart-container {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 10px 0;
}

/* TABELAS */
.table-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.table-filter-bar {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
}

.input-search {
  width: 100%;
  max-width: 400px;
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 8px 14px;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  outline: none;
}

.input-search:focus {
  border-color: var(--accent-primary);
}

.table-responsive {
  overflow-x: auto;
}

.data-table, .table-simple {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.data-table th, .table-simple th {
  padding: 14px 18px;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  background: rgba(0, 0, 0, 0.15);
  border-bottom: 1px solid var(--border-color);
}

.data-table td, .table-simple td {
  padding: 14px 18px;
  font-size: 0.88rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-secondary);
}

.data-table tr:hover, .table-simple tr:hover {
  background-color: rgba(255, 255, 255, 0.02);
}

/* BADGES DE STATUS */
.status-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
}

.status-pago {
  background: var(--color-emerald-bg);
  color: var(--color-emerald);
}

.status-pendente {
  background: var(--color-amber-bg);
  color: var(--color-amber);
}

.status-atrasado {
  background: var(--color-rose-bg);
  color: var(--color-rose);
}

.status-cancelado {
  background: rgba(244, 63, 94, 0.15);
  color: #fb7185;
  border: 1px solid rgba(244, 63, 94, 0.35);
}

.btn-filter-active {
  background: var(--color-primary) !important;
  color: #fff !important;
  border-color: var(--color-primary) !important;
}

.boleto-cancelado-banner {
  background: rgba(244, 63, 94, 0.12);
  border: 2px dashed #f43f5e;
  color: #f43f5e;
  padding: 10px 16px;
  border-radius: 6px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 14px;
  font-size: 0.92rem;
  letter-spacing: 0.5px;
}

/* CARDS DE CONDOMÍNIOS */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 24px;
}

.condo-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 16px;
  transition: all 0.2s ease;
}

.condo-card:hover {
  border-color: rgba(99, 102, 241, 0.3);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.condo-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.condo-card-title {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
}

.condo-code {
  font-size: 0.75rem;
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-weight: 600;
}

.condo-details {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.condo-saldos-box {
  background: rgba(0, 0, 0, 0.2);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
}

/* RATEIO FORM */
.rateio-split-container {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 28px;
}

.rateio-form-card, .rateio-info-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 28px;
}

.rateio-preview-box {
  background: rgba(0, 0, 0, 0.25);
  border-radius: var(--radius-md);
  padding: 18px;
  margin: 20px 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.preview-item {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
}

.preview-item.total {
  border-top: 1px dashed var(--border-color);
  padding-top: 10px;
  font-weight: 700;
}

.rateio-regras-lista {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 20px;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

/* BALANCETE DOCUMENTO */
.balancete-container {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 36px;
  box-shadow: var(--shadow-sm);
}

.balancete-header-doc {
  text-align: center;
  border-bottom: 2px solid var(--border-color);
  padding-bottom: 24px;
  margin-bottom: 28px;
}

.balancete-titulo-doc h2 {
  font-family: var(--font-display);
  font-size: 1.7rem;
}

.balancete-badge-comp {
  display: inline-block;
  margin-top: 12px;
  padding: 6px 16px;
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: var(--radius-full);
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.5px;
}

.balancete-resumo-saldos {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 32px;
}

.resumo-box {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: center;
}

.resumo-title {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
}

.resumo-val {
  display: block;
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
  margin-top: 4px;
}

.box-positivo .resumo-val { color: var(--color-emerald); }
.box-negativo .resumo-val { color: var(--color-rose); }
.box-destaque {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.15), rgba(99, 102, 241, 0.05));
  border-color: rgba(99, 102, 241, 0.4);
}
.box-destaque .resumo-val { color: #a5b4fc; }

.balancete-detalhes-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
}

.balancete-quadro {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
}

.quadro-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 16px;
}

.table-balancete {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.table-balancete th, .table-balancete td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-color);
}

/* INADIMPLENTES BAR */
.inadimplencia-kpi-bar {
  display: flex;
  gap: 24px;
  background: var(--bg-card);
  padding: 20px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  margin-bottom: 24px;
}

.inadimplencia-kpi {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.inadimplencia-kpi span {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 600;
}

.inadimplencia-kpi strong {
  font-size: 1.4rem;
  font-family: var(--font-display);
}

/* MIGRADOR SQS DOS */
.migrador-container {
  max-width: 900px;
}

.migrador-card-status {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 32px;
}

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

.disk-badge {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 1.1rem;
  font-weight: 600;
}

.disk-badge code {
  background: rgba(255, 255, 255, 0.1);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  color: #a5b4fc;
}

.badge-status-green {
  background: var(--color-emerald-bg);
  color: var(--color-emerald);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 700;
}

.migrador-stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin: 24px 0;
}

.migrador-stat-box {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
}

.stat-title {
  display: block;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.migrador-action-area {
  margin: 32px 0 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.migrador-note {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.migrador-log-box {
  background: #050811;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  padding: 16px;
}

.log-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}

#migradorLogContent {
  font-family: 'Consolas', monospace;
  font-size: 0.82rem;
  color: #a5b4fc;
  max-height: 200px;
  overflow-y: auto;
  white-space: pre-wrap;
}

/* MODAL & DIALOGS */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: all 0.2s ease;
}

.modal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-dialog {
  background: var(--bg-sidebar);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 580px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: modalScale 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-boleto-dialog {
  max-width: 760px;
}

@keyframes modalScale {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

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

.modal-title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.3rem;
  cursor: pointer;
}

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

.modal-body {
  padding: 24px;
  max-height: 75vh;
  overflow-y: auto;
}

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

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

.form-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-secondary);
}

.form-input {
  width: 100%;
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
}

.form-input:focus {
  border-color: var(--accent-primary);
}

.form-row {
  display: flex;
  gap: 16px;
}

.form-row .form-group {
  flex: 1;
}

/* LAYOUT OFICIAL DO BOLETO */
.boleto-layout {
  background: #ffffff;
  color: #000000;
  padding: 24px;
  border-radius: var(--radius-md);
  border: 1px solid #cccccc;
  font-family: Arial, sans-serif;
}

.boleto-header {
  display: flex;
  align-items: center;
  border-bottom: 2px solid #000000;
  padding-bottom: 8px;
  margin-bottom: 12px;
  gap: 14px;
}

.banco-nome-display {
  font-size: 1.2rem;
  font-weight: 900;
  color: #002e7a;
}

.banco-codigo-box {
  border-left: 2px solid #000000;
  padding-left: 14px;
  font-size: 1.25rem;
  font-weight: 800;
}

.linha-digitavel-box,
.barras-quadro,
#bolBarcodeArea {
  display: none !important;
}

.boleto-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 1px;
  background: #000000;
  border: 1px solid #000000;
  margin-bottom: 16px;
}

.bol-cell {
  background: #ffffff;
  padding: 6px 10px;
}

.col-2 { grid-column: span 2; }
.col-3 { grid-column: span 3; }
.col-4 { grid-column: span 4; }
.col-6 { grid-column: span 6; }
.col-8 { grid-column: span 8; }
.col-12 { grid-column: span 12; }

.bol-cell label {
  display: block;
  font-size: 0.65rem;
  text-transform: uppercase;
  color: #666666;
  margin-bottom: 2px;
}

.bol-cell .val {
  font-size: 0.88rem;
  font-weight: 600;
  color: #000000;
}

.bol-cell .val.highlight {
  font-size: 1rem;
  font-weight: 800;
  color: #b91c1c;
}

.bol-cell .val.highlight-green {
  font-size: 1.1rem;
  font-weight: 900;
  color: #047857;
}

.bol-cell .text-small {
  font-size: 0.75rem;
  line-height: 1.4;
}

.boleto-pagamento-duplo {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px dashed #999999;
}

.pix-quadro {
  width: 100%;
  max-width: 480px;
  background: #f8fafc;
  border: 1.5px solid #059669;
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  text-align: center;
}

.pix-quadro h4 {
  font-size: 0.8rem;
  color: #047857;
  margin-bottom: 8px;
}

.pix-qr-area {
  display: flex;
  justify-content: center;
  margin-bottom: 8px;
}

.input-pix {
  width: 100%;
  font-size: 0.7rem;
  padding: 4px;
  margin-bottom: 6px;
  border: 1px solid #cbd5e1;
}

.barras-quadro {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: #fafafa;
  padding: 16px;
  border: 1px solid #e5e5e5;
}

.barras-quadro h4 {
  font-size: 0.8rem;
  margin-bottom: 12px;
  color: #555;
}

.barcode-visual {
  height: 60px;
  width: 90%;
  background: repeating-linear-gradient(
    90deg,
    #000000,
    #000000 2px,
    #ffffff 2px,
    #ffffff 4px,
    #000000 4px,
    #000000 7px,
    #ffffff 7px,
    #ffffff 9px
  );
  margin-bottom: 6px;
}

.barcode-numeros {
  font-family: monospace;
  font-size: 0.8rem;
  letter-spacing: 1px;
}

/* TOAST NOTIFICAÇÃO */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: var(--bg-sidebar);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
  border-radius: var(--radius-md);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.88rem;
  animation: toastIn 0.3s ease;
  min-width: 280px;
}

@keyframes toastIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* SUBTABS DE NAVEGAÇÃO INTERNA */
.subtabs-nav-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 10px;
  flex-wrap: wrap;
}

.subtab-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.subtab-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--text-muted);
}

.subtab-btn.active {
  background: var(--accent-primary);
  color: #ffffff;
  border-color: var(--accent-primary);
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.25);
}

/* FILTER PILLS */
.filter-pills {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.pill-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.pill-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

.pill-btn.active {
  background: rgba(99, 102, 241, 0.2);
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  font-weight: 600;
}

/* BADGES ESPECÍFICOS PARA PLANO DE CONTAS & VERBAS */
.badge-receita {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.3);
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-despesa {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.3);
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-sintetica {
  background: rgba(168, 85, 247, 0.15);
  color: #c084fc;
  border: 1px solid rgba(168, 85, 247, 0.3);
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
}

.badge-analitica {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.3);
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
}

.badge-criterio {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.3);
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 500;
}

.row-sintetica {
  background: rgba(255, 255, 255, 0.02);
  font-weight: 600;
}

.row-sintetica-grupo {
  background: rgba(255, 255, 255, 0.05);
  font-weight: 700;
}

/* CANHOTO / RECIBO DO SACADO (MORADOR) */
.boleto-canhoto {
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  padding: 10px 14px;
  margin-bottom: 14px;
}

.linha-corte-picote {
  text-align: center;
  border-top: 1px dashed #94a3b8;
  margin-top: 10px;
  padding-top: 4px;
  color: #64748b;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.5px;
}

/* QUADRO DE COMUNICADO DO SÍNDICO / MENSAGEM */
.boleto-comunicado-box {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-left: 4px solid #f59e0b;
  padding: 8px 12px;
  border-radius: 4px;
  margin-bottom: 12px;
}

/* ABAS DO MODAL DE CONFIGURAÇÃO DO BOLETO */
.config-tabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 16px;
  overflow-x: auto;
}

.config-tab-btn {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  padding: 8px 12px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

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

.config-tab-btn.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

/* ==========================================================================
   REGRAS DE IMPRESSÃO GERAL (BOLETOS, BALANCETES, RELATÓRIOS E INADIMPLÊNCIA)
   ========================================================================== */
@page {
  size: A4 portrait;
  margin: 6mm 8mm;
}

@media print {
  /* 1. Oculta menus, navegações, botões e controles de interface */
  .sidebar,
  .app-header,
  .nav-menu,
  .header-actions,
  .table-filter-bar,
  .btn,
  .modal-close,
  .modal-header .btn,
  .modal-footer,
  .toast-container,
  #bannerAvisoFileProtocol {
    display: none !important;
  }

  html, body {
    background: #ffffff !important;
    color: #000000 !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    overflow: visible !important;
  }

  /* SE O MODAL DO BOLETO ESTIVER ABERTO (OU IMPRIMINDO BOLETO INDIVIDUAL):
     Oculta completamente a estrutura principal (.app-container) para não gerar página vazia ou quebra */
  body:has(#modalBoleto.open) .app-container,
  body.boleto-aberto-para-impressao .app-container,
  body.imprimindo-boleto-individual .app-container,
  body:has(#modalBoleto.open) .main-wrapper,
  body:has(#modalBoleto.open) .sidebar,
  body:has(#modalBoleto.open) .view-section,
  body:has(#modalBoleto.open) .toast-container,
  body.boleto-aberto-para-impressao .toast-container {
    display: none !important;
    height: 0 !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  /* MODAL DO BOLETO INDIVIDUAL: Formata para caber em exatamente 1 folha A4 */
  #modalBoleto.open {
    position: static !important;
    background: transparent !important;
    padding: 0 !important;
    margin: 0 !important;
    display: block !important;
    opacity: 1 !important;
    width: 100% !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    page-break-after: avoid !important;
    break-after: avoid !important;
  }

  #modalBoleto.open .modal-dialog {
    max-width: 100% !important;
    width: 100% !important;
    box-shadow: none !important;
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
    background: #ffffff !important;
    animation: none !important;
    transform: none !important;
    overflow: visible !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }

  #modalBoleto.open .modal-header,
  #modalBoleto.open .modal-footer {
    display: none !important;
  }

  #modalBoleto.open .modal-body {
    padding: 0 !important;
    margin: 0 !important;
    max-height: none !important;
    overflow: visible !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }

  #modalBoleto:not(.open),
  .modal-backdrop:not(.open) {
    display: none !important;
  }

  /* SEÇÕES DO SISTEMA (BALANCETE, RELATÓRIOS, INADIMPLÊNCIA, ETC.) */
  .view-section:not(.active) {
    display: none !important;
  }

  .view-section.active {
    display: block !important;
    width: 100% !important;
    padding: 0 !important;
  }

  .view-title {
    color: #000000 !important;
    font-size: 1.3rem !important;
  }

  .view-subtitle {
    color: #475569 !important;
    font-size: 0.82rem !important;
    margin-bottom: 10px !important;
  }

  /* CARDS, TABELAS E BALANCETES */
  .table-card, .balancete-container, .inadimplencia-kpi-bar {
    background: #ffffff !important;
    color: #000000 !important;
    border: 1px solid #cbd5e1 !important;
    box-shadow: none !important;
    border-radius: 4px !important;
    page-break-inside: avoid;
  }

  .inadimplencia-kpi-bar {
    display: flex !important;
    justify-content: space-around !important;
    padding: 8px !important;
    margin-bottom: 10px !important;
  }

  .inadimplencia-kpi span {
    color: #475569 !important;
  }

  .inadimplencia-kpi strong {
    color: #0f172a !important;
  }

  .data-table {
    width: 100% !important;
    border-collapse: collapse !important;
    color: #000000 !important;
  }

  .data-table th, .data-table td {
    color: #000000 !important;
    border: 1px solid #cbd5e1 !important;
    padding: 5px 7px !important;
    background: transparent !important;
  }

  .data-table th {
    background: #f1f5f9 !important;
    font-weight: 700 !important;
  }

  /* Oculta coluna de Ações em relatórios impressos */
  .data-table th:last-child,
  .data-table td:last-child {
    display: none !important;
  }

  /* =========================================================================
     FORMATAÇÃO COMPACTA DO BOLETO PARA ENCAIXE PERFEITO EM 1 FOLHA A4
     ========================================================================= */
  .boleto-canhoto {
    border: 1px solid #000000 !important;
    background: #ffffff !important;
    color: #000000 !important;
    padding: 4px 8px !important;
    margin-bottom: 6px !important;
    font-size: 0.7rem !important;
    page-break-inside: avoid !important;
  }

  .linha-corte-picote {
    margin-top: 3px !important;
    font-size: 0.65rem !important;
    color: #555555 !important;
  }

  .boleto-layout {
    border: 1.5px solid #000000 !important;
    padding: 8px 10px !important;
    margin: 0 !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
    background: #ffffff !important;
    box-sizing: border-box !important;
  }

  .boleto-header {
    border-bottom: 2px solid #000000 !important;
    padding-bottom: 3px !important;
    margin-bottom: 6px !important;
    gap: 8px !important;
  }

  .banco-nome-display {
    font-size: 1.05rem !important;
    font-weight: 900 !important;
    color: #000000 !important;
  }

  .banco-codigo-box {
    font-size: 1.05rem !important;
    padding-left: 8px !important;
    border-left: 2px solid #000000 !important;
    border-right: none !important;
  }

  .linha-digitavel-box,
  .barras-quadro,
  #bolBarcodeArea {
    display: none !important;
  }

  .boleto-comunicado-box {
    padding: 3px 6px !important;
    margin-bottom: 5px !important;
    font-size: 0.7rem !important;
    border: 1px solid #78350f !important;
  }

  .boleto-grid {
    display: grid !important;
    grid-template-columns: repeat(12, 1fr) !important;
    gap: 1px !important;
    background: #000000 !important;
    border: 1px solid #000000 !important;
    margin-bottom: 6px !important;
    page-break-inside: avoid !important;
  }

  .bol-cell {
    background: #ffffff !important;
    padding: 2.5px 6px !important;
  }

  .bol-cell label {
    font-size: 0.58rem !important;
    color: #333333 !important;
    margin-bottom: 1px !important;
  }

  .bol-cell .val {
    font-size: 0.75rem !important;
    color: #000000 !important;
    line-height: 1.2 !important;
  }

  .bol-cell .val.highlight {
    font-size: 0.85rem !important;
    color: #000000 !important;
    font-weight: 800 !important;
  }

  .bol-cell .val.highlight-green {
    font-size: 0.92rem !important;
    color: #000000 !important;
    font-weight: 900 !important;
  }

  .bol-cell .text-small {
    font-size: 0.67rem !important;
    line-height: 1.2 !important;
  }

  .bol-cell table {
    font-size: 0.65rem !important;
  }

  .bol-cell table th, .bol-cell table td {
    padding: 1px 3px !important;
  }

  .bol-rodape-contatos {
    margin-top: 4px !important;
    padding: 2px 4px !important;
    font-size: 0.66rem !important;
    border-top: 1px solid #cbd5e1 !important;
    color: #333333 !important;
  }

  .boleto-pagamento-duplo {
    display: flex !important;
    justify-content: center !important;
    margin-top: 6px !important;
    padding-top: 6px !important;
    border-top: 1px dashed #666666 !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }

  .pix-quadro {
    width: 100% !important;
    max-width: 380px !important;
    margin: 0 auto !important;
    background: #ffffff !important;
    border: 1.5px solid #000000 !important;
    padding: 6px 10px !important;
    text-align: center !important;
  }

  .pix-quadro h4 {
    font-size: 0.7rem !important;
    color: #000000 !important;
    margin-bottom: 2px !important;
  }

  #bolPixInfoChave {
    font-size: 0.64rem !important;
    margin-bottom: 2px !important;
    color: #000000 !important;
  }

  .pix-qr-area {
    margin-bottom: 0 !important;
  }

  #qrCodePixCanvas,
  #qrCodePixImg {
    width: 86px !important;
    height: 86px !important;
    display: block !important;
    margin: 0 auto !important;
  }

  /* No papel impresso, o campo e botão copia-e-cola são ocultados para economizar espaço */
  .pix-copia-cola-box {
    display: none !important;
  }

  .barras-quadro {
    background: #ffffff !important;
    border: 1px solid #999999 !important;
    padding: 6px 10px !important;
  }

  .barras-quadro h4 {
    font-size: 0.7rem !important;
    margin-bottom: 3px !important;
    color: #000000 !important;
  }

  .barcode-visual {
    height: 38px !important;
    margin-bottom: 3px !important;
  }

  .barcode-numeros {
    font-size: 0.72rem !important;
    letter-spacing: 0.8px !important;
    color: #000000 !important;
  }

  /* Lote de Boletos: quebra de página por folha */
  .quebra-folha-boleto {
    page-break-after: always !important;
    break-after: page !important;
  }
}
