/* BFT Gestao de Inadimplencia — extraido de bft_inadimplencia_v14.html */
/* BFT - Gestão de Inadimplência - Professional Dashboard Styles */

:root {
  /* Status Colors */
  --status-pago: #22c55e;
  --status-pago-luz: #bbf7d0;
  --status-pago-atraso: #eab308;
  --status-pago-atraso-luz: #fef08a;
  --status-aberto-vencer: #f59e0b;
  --status-aberto-vencer-luz: #fde68a;
  --status-inadimplente: #ef4444;
  --status-inadimplente-luz: #fecaca;
  --status-rma: #f97316;
  --status-rma-luz: #fed7aa;
  --status-baixado: #6b7280;
  --status-baixado-luz: #e5e7eb;
  --status-analise: #8b5cf6;
  --status-analise-luz: #ddd6fe;
  --status-divergencia: #dc2626;
  --status-divergencia-luz: #fecaca;

  /* Brand Colors */
  --primary: #1e40af;
  --primary-hover: #1e3a8a;
  --secondary: #64748b;
  --accent: #3b82f6;
  --accent-light: #dbeafe;

  /* Neutral */
  --bg-dark: #0f172a;
  --bg-sidebar: #1e293b;
  --bg-card: #ffffff;
  --bg-body: #f1f5f9;
  --border: #e2e8f0;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

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

html, body {
  height: 100%;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-body);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
}

#app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* Layout Principal */
.layout {
  display: flex;
  width: 100%;
  height: 100%;
}

/* Sidebar */
/* CORREÇÃO DO BUG: a largura base é a do menu EXPANDIDO (260px). Antes a base
   era 72px e, ao expandir (remover .collapsed), os nomes dos menus eram
   exibidos dentro de um trilho de 72px — quebrando o layout. Agora o modo
   recolhido é que reduz a largura para 72px. */
.sidebar {
  width: 260px;
  background: var(--bg-sidebar);
  color: white;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  border-right: 1px solid rgba(255,255,255,0.1);
  transition: width 0.2s ease;
  position: relative;
  z-index: 50;
}

/* Modo recolhido (padrão): mostra apenas ícones */
.sidebar.collapsed {
  width: 72px;
}

/* Evita que textos "vazem" durante a transição de largura */
.sidebar-nav,
.sidebar-header,
.sidebar-footer {
  overflow-x: hidden;
}

.nav-item span,
.sidebar-logo-text,
.sidebar-logo-sub {
  white-space: nowrap;
}

/* Modo recolhido (padrão): mostra apenas ícones */
.sidebar.collapsed .sidebar-logo-text,
.sidebar.collapsed .sidebar-logo-sub,
.sidebar.collapsed .nav-item span,
.sidebar.collapsed .nav-section-title,
.sidebar.collapsed .nav-badge,
.sidebar.collapsed .sidebar-footer-info {
  display: none;
}

.sidebar.collapsed .sidebar-header {
  padding: 16px 0;
  display: flex;
  justify-content: center;
}

.sidebar.collapsed .sidebar-logo {
  justify-content: center;
  gap: 0;
}

.sidebar.collapsed .nav-item {
  justify-content: center;
  padding: 12px 0;
}

.sidebar.collapsed .sidebar-footer {
  display: flex;
  justify-content: center;
  padding: 12px 0;
}

/* Tooltip com o nome do menu ao passar o mouse (somente no modo recolhido) */
.sidebar.collapsed .nav-item {
  position: relative;
}

.sidebar.collapsed .nav-item::after,
.sidebar.collapsed .sidebar-toggle::after {
  content: attr(data-label);
  position: absolute;
  left: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%) translateX(-6px);
  background: #0f172a;
  color: white;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease, transform 0.15s ease;
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
  z-index: 100;
}

.sidebar.collapsed .nav-item::before,
.sidebar.collapsed .sidebar-toggle::before {
  content: '';
  position: absolute;
  left: calc(100% + 4px);
  top: 50%;
  transform: translateY(-50%);
  border: 6px solid transparent;
  border-right-color: #0f172a;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease;
  z-index: 100;
}

.sidebar.collapsed .nav-item:hover::after,
.sidebar.collapsed .sidebar-toggle:hover::after {
  opacity: 1;
  visibility: visible;
  transform: translateY(-50%) translateX(0);
}

.sidebar.collapsed .nav-item:hover::before,
.sidebar.collapsed .sidebar-toggle:hover::before {
  opacity: 1;
  visibility: visible;
}

/* Botão de recolher/expandir o menu — fica DENTRO do menu, logo acima do
   rodapé, para nunca sobrepor o conteúdo principal */
.sidebar-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 4px 12px 8px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  color: rgba(255,255,255,0.6);
  font-size: 12px;
  font-weight: 500;
  background: rgba(255,255,255,0.04);
  transition: background 0.15s ease, color 0.15s ease;
  position: relative;
}

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

.sidebar-toggle .toggle-icon {
  font-size: 15px;
  line-height: 1;
  flex-shrink: 0;
  width: 18px;
  text-align: center;
}

.sidebar.collapsed .sidebar-toggle {
  justify-content: center;
  margin: 4px 8px 8px;
  padding: 10px 0;
}

.sidebar.collapsed .sidebar-toggle span:not(.toggle-icon) {
  display: none;
}

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

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

.sidebar-logo-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
}

.sidebar-logo-text {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.025em;
}

.sidebar-logo-sub {
  font-size: 10px;
  opacity: 0.7;
  display: block;
  margin-top: 2px;
}

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

.nav-section {
  margin-bottom: 20px;
}

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

.sidebar.collapsed .nav-section:first-child {
  border-top: none;
  padding-top: 0;
}

.nav-section-title {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: rgba(255,255,255,0.5);
  padding: 0 8px;
  margin-bottom: 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
  color: rgba(255,255,255,0.7);
  font-size: 13px;
  font-weight: 500;
}

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

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

.nav-item i[data-lucide] {
  width: 18px;
  height: 18px;
  opacity: 0.8;
}

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

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255,255,255,0.1);
}

.sidebar-footer-info {
  font-size: 11px;
  color: rgba(255,255,255,0.5);
}

/* Main Content */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Header */
.header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  flex-shrink: 0;
}

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

.header-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-filters {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  justify-content: flex-end;
}

/* Content Area */
.content {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
}

/* Cards */
.card {
  background: var(--bg-card);
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

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

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

.card-body {
  padding: 20px;
}

.card-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg-body);
  border-radius: 0 0 12px 12px;
}

/* KPI Cards */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

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

.kpi-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.kpi-card.highlight {
  border-color: var(--accent);
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.05), transparent);
}

.kpi-card.danger {
  border-color: var(--status-inadimplente);
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.05), transparent);
}

.kpi-card.warning {
  border-color: var(--status-rma);
  background: linear-gradient(135deg, rgba(249, 115, 22, 0.05), transparent);
}

.kpi-card.success {
  border-color: var(--status-pago);
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.05), transparent);
}

.kpi-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.kpi-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.kpi-value.danger { color: var(--status-inadimplente); }
.kpi-value.warning { color: var(--status-rma); }
.kpi-value.success { color: var(--status-pago); }

.kpi-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.kpi-sub span {
  font-weight: 600;
}

/* Status Badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  gap: 4px;
}

.status-badge.pago { background: var(--status-pago-luz); color: #166534; }
.status-badge.pago_atraso { background: var(--status-pago-atraso-luz); color: #854d0e; }
.status-badge.aberto_vencer { background: var(--status-aberto-vencer-luz); color: #92400e; }
.status-badge.aberto_vencido { background: var(--status-aberto-vencer-luz); color: #92400e; }
.status-badge.inadimplente_real { background: var(--status-inadimplente-luz); color: #991b1b; }
.status-badge.rma_devolucao { background: var(--status-rma-luz); color: #9a3412; }
.status-badge.baixado { background: var(--status-baixado-luz); color: #374151; }
.status-badge.analise { background: var(--status-analise-luz); color: #5b21b6; }
.status-badge.divergencia { background: var(--status-divergencia-luz); color: #991b1b; }
.status-badge.sem_rma { background: #f3f4f6; color: #374151; }
.status-badge.rma_confirmado { background: var(--status-rma-luz); color: #9a3412; }
.status-badge.rma_probavel { background: var(--status-pago-atraso-luz); color: #854d0e; }
.status-badge.revisar { background: var(--status-analise-luz); color: #5b21b6; }

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

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

th {
  text-align: left;
  padding: 12px 16px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  background: var(--bg-body);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  vertical-align: middle;
}

tr:hover td {
  background: var(--bg-body);
}

tr:last-child td {
  border-bottom: none;
}

/* Forms */
.form-group {
  margin-bottom: 16px;
}

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

.form-input, .form-select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-primary);
  background: var(--bg-card);
  transition: all 0.15s ease;
}

.form-input:focus, .form-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.form-input::placeholder {
  color: var(--text-muted);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  border: none;
}

.btn i[data-lucide] {
  width: 16px;
  height: 16px;
}

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

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

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

.btn-secondary:hover {
  background: var(--border);
}

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

.btn-danger:hover {
  background: #dc2626;
}

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

.btn-lg {
  padding: 14px 24px;
  font-size: 15px;
}

/* Buttons Grid */
.btn-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

/* Grid Layouts */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
}

.rankings-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
}

@media (max-width: 900px) {
  .rankings-grid {
    grid-template-columns: 1fr;
  }
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

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

/* Tabs */
.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--bg-body);
  border-radius: 8px;
  margin-bottom: 24px;
}

.tab {
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  color: var(--text-secondary);
  border: none;
  background: transparent;
}

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

.tab.active {
  background: var(--bg-card);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

/* Charts Container */
.chart-container {
  height: 300px;
  position: relative;
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
}

.chart-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

@media (max-width: 1200px) {
  .chart-grid-3 {
    grid-template-columns: repeat(2, 1fr);
  }
}

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

/* File Upload */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 48px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s ease;
  background: var(--bg-body);
}

.upload-zone:hover {
  border-color: var(--accent);
  background: var(--accent-light);
}

.upload-zone.dragover {
  border-color: var(--accent);
  background: var(--accent-light);
}

.upload-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  color: var(--text-muted);
}

.upload-text {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.upload-subtext {
  font-size: 13px;
  color: var(--text-secondary);
}

/* Sheet Selector */
.sheet-selector {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.sheet-item {
  background: var(--bg-body);
  border-radius: 8px;
  padding: 16px;
}

.sheet-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.sheet-item-name {
  font-weight: 600;
  color: var(--text-primary);
}

.sheet-item-count {
  font-size: 12px;
  color: var(--text-secondary);
  background: var(--bg-card);
  padding: 2px 8px;
  border-radius: 4px;
}

/* Data Preview */
.data-preview {
  background: var(--bg-body);
  border-radius: 8px;
  overflow: hidden;
  margin-top: 16px;
}

.preview-header {
  padding: 12px 16px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.preview-title {
  font-weight: 600;
  font-size: 13px;
}

.preview-content {
  max-height: 200px;
  overflow: auto;
}

/* Filters */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 16px 20px;
  background: var(--bg-body);
  border-radius: 8px;
  margin-bottom: 24px;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.filter-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.filter-select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  background: var(--bg-card);
  min-width: 140px;
}

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

/* Empty State */
.empty-state {
  text-align: center;
  padding: 64px 24px;
}

.empty-icon {
  width: 80px;
  height: 80px;
  margin: 0 auto 24px;
  color: var(--text-muted);
}

.empty-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.empty-text {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

/* Loading State */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
}

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

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

/* Alert/Validation */
.validation-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.validation-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg-body);
  border-radius: 8px;
  border-left: 4px solid;
}

.validation-item.error {
  border-left-color: var(--status-inadimplente);
}

.validation-item.warning {
  border-left-color: var(--status-pago-atraso);
}

.validation-item.info {
  border-left-color: var(--accent);
}

.validation-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.validation-text {
  flex: 1;
  font-size: 13px;
}

.validation-count {
  font-weight: 600;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 4px;
}

/* Search */
.search-box {
  position: relative;
}

.search-input {
  padding-left: 40px;
  width: 300px;
}

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

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

.pagination-info {
  font-size: 12px;
  color: var(--text-secondary);
}

.pagination-controls {
  display: flex;
  gap: 8px;
}

.page-btn {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-card);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
}

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

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

/* Tooltip */
.tooltip {
  position: relative;
}

.tooltip::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 10px;
  background: var(--bg-dark);
  color: white;
  font-size: 11px;
  border-radius: 4px;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: all 0.15s ease;
}

.tooltip:hover::after {
  opacity: 1;
  visibility: visible;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 24px;
}

.modal {
  background: var(--bg-card);
  border-radius: 16px;
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
}

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

.modal-title {
  font-size: 16px;
  font-weight: 600;
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  background: var(--bg-body);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.modal-body {
  padding: 24px;
  overflow-y: auto;
}

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

/* Aging Table */
.aging-bar {
  display: flex;
  height: 24px;
  border-radius: 4px;
  overflow: hidden;
  background: var(--bg-body);
}

.aging-segment {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 600;
  color: white;
  min-width: 30px;
}

.aging-segment.vencer { background: var(--status-pago); }
.aging-segment.d30 { background: #86efac; }
.aging-segment.d60 { background: var(--status-pago-atraso); }
.aging-segment.d90 { background: #fb923c; }
.aging-segment.d120 { background: #f97316; }
.aging-segment.d180 { background: #ea580c; }
.aging-segment.d365 { background: var(--status-inadimplente); }
.aging-segment.plus { background: #991b1b; }

/* Progress Bar */
.progress-bar {
  height: 8px;
  background: var(--bg-body);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s ease;
}

.progress-fill.pago { background: var(--status-pago); }
.progress-fill.atraso { background: var(--status-pago-atraso); }
.progress-fill.aberto { background: var(--status-aberto-vencer); }
.progress-fill.inadimplente { background: var(--status-inadimplente); }

/* Flex utilities */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }
.gap-6 { gap: 24px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.text-muted { color: var(--text-secondary); }
.text-right { text-align: right; }
.danger { color: var(--status-inadimplente); }
.warning { color: var(--status-rma); }
.company-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

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

@media (max-width: 768px) {
  .sidebar { display: none; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .header-filters { flex-wrap: wrap; }
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-body);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Print */
@media print {
  .sidebar, .header, .filter-bar { display: none; }
  .content { padding: 0; }
  .card { box-shadow: none; border: 1px solid #ddd; }
}

/* Company Tabs */
.company-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
}

.company-tab {
  padding: 12px 24px;
  border-radius: 8px;
  border: 2px solid var(--border);
  background: var(--bg-card);
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}

.company-tab:hover {
  border-color: var(--accent);
}

.company-tab.active {
  border-color: var(--primary);
  background: var(--accent-light);
}

.company-tab-icon {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: white;
}

.company-tab-icon.bfdi { background: var(--primary); }
.company-tab-icon.bb { background: var(--status-pago); }

.company-tab-name {
  font-weight: 600;
  font-size: 14px;
}

.company-tab-count {
  font-size: 11px;
  color: var(--text-secondary);
}

/* Stats Row */
.stats-row {
  display: flex;
  gap: 24px;
  padding: 16px 20px;
  background: var(--bg-body);
  border-radius: 8px;
}

.stat-item {
  flex: 1;
  text-align: center;
}

.stat-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}

.stat-label {
  font-size: 11px;
  color: var(--text-secondary);
  text-transform: uppercase;
  margin-top: 2px;
}

/* Import Status */
.import-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: var(--status-pago-luz);
  border-radius: 8px;
  border: 1px solid var(--status-pago);
  margin-bottom: 24px;
}

.import-status-icon {
  width: 20px;
  height: 20px;
  color: var(--status-pago);
}

.import-status-text {
  font-weight: 600;
  font-size: 13px;
  color: #166534;
}

/* Last Update Info */
.last-update {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  background: var(--bg-body);
  border-radius: 8px;
  font-size: 12px;
  color: var(--text-secondary);
}

.last-update-icon {
  width: 16px;
  height: 16px;
  color: var(--text-muted);
}

.last-update strong {
  color: var(--text-primary);
}

/* Action Bar */
.action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.action-bar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.action-bar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Tag/Label */
.tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
}

.tag.primary { background: var(--accent-light); color: var(--primary); }
.tag.success { background: var(--status-pago-luz); color: #166534; }
.tag.warning { background: var(--status-pago-atraso-luz); color: #854d0e; }
.tag.danger { background: var(--status-inadimplente-luz); color: #991b1b; }
.tag.info { background: #e0e7ff; color: #3730a3; }

/* Data Table - Larger spacing for readability */
.data-table th {
  padding: 14px 16px;
  font-size: 11px;
}

.data-table td {
  padding: 14px 16px;
  font-size: 13px;
}

.data-table tr {
  transition: background 0.1s ease;
}

/* Number formatting */
.number { font-variant-numeric: tabular-nums; }
.currency { font-weight: 600; }
.currency.positive { color: var(--status-pago); }
.currency.negative { color: var(--status-inadimplente); }
.percentage { font-weight: 600; }

/* Aging cells */
.aging-cell {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.aging-bar-mini {
  height: 6px;
  background: var(--bg-body);
  border-radius: 3px;
  overflow: hidden;
  display: flex;
}

.aging-bar-mini span {
  height: 100%;
}

.aging-label {
  font-size: 11px;
  color: var(--text-secondary);
}

/* Customer card in analysis */
.customer-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
}

.customer-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.customer-name {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}

.customer-code {
  font-size: 13px;
  color: var(--text-secondary);
}

.customer-stats {
  display: flex;
  gap: 16px;
}

.customer-stat {
  text-align: center;
  padding: 12px 16px;
  background: var(--bg-body);
  border-radius: 8px;
}

.customer-stat-value {
  font-size: 18px;
  font-weight: 700;
}

.customer-stat-label {
  font-size: 10px;
  color: var(--text-secondary);
  text-transform: uppercase;
}

/* Perfil Matrix Table */
.perfil-matrix-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  white-space: nowrap;
}

.perfil-matrix-table th {
  padding: 10px 8px;
  text-align: center;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  background: #f8fafc;
  border-bottom: 2px solid #e5e7eb;
  color: #475569;
}

.perfil-matrix-table th:first-child {
  text-align: left;
  padding-left: 12px;
}

.perfil-matrix-table td {
  padding: 8px 6px;
  text-align: right;
  border-bottom: 1px solid #f3f4f6;
  vertical-align: middle;
}

.perfil-matrix-table td:first-child {
  text-align: left;
  padding-left: 12px;
  font-weight: 500;
  color: #374151;
}

.perfil-matrix-table tbody tr:hover td {
  background: #f9fafb;
}

.perfil-matrix-table .month-cell {
  text-align: right;
}

.perfil-matrix-table .month-cell .value {
  font-weight: 500;
  color: #1f2937;
}

.perfil-matrix-table .month-cell .pct {
  font-size: 10px;
  color: #6b7280;
  margin-top: 2px;
}

.perfil-matrix-table .total-row td {
  border-top: 2px solid #d1d5db;
  border-bottom: none;
  font-weight: 700;
  background: #f1f5f9;
}

.perfil-matrix-table .saldo-row td {
  background: #fef2f2;
  border-top: 1px solid #fecaca;
}

/* Import Section */
.import-screen {
  max-width: 900px;
  margin: 0 auto;
}

.import-section {
  background: var(--bg-card);
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 24px;
  margin-bottom: 24px;
}

.import-section-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.import-section-desc {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

.import-divider {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 24px 0;
  color: var(--text-muted);
  font-size: 13px;
}

.import-divider::before,
.import-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.import-divider span {
  padding: 0 8px;
}

/* Sheet URL Info */
.sheet-url-info {
  margin-top: 8px;
  padding: 8px 12px;
  background: #f3f4f6;
  border-radius: 6px;
  font-size: 11px;
  color: var(--text-secondary);
}

/* File Upload Area */
.file-upload-area {
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 32px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s ease;
  background: var(--bg-card);
}

.file-upload-area:hover {
  border-color: var(--accent);
  background: var(--accent-light);
}

.file-upload-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.file-upload-area .upload-icon {
  width: 48px;
  height: 48px;
  color: var(--text-muted);
}

.file-upload-area .upload-text {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.file-upload-area .upload-subtext {
  font-size: 12px;
  color: var(--text-secondary);
}

.file-info {
  margin-top: 16px;
  padding: 12px 16px;
  background: var(--accent-light);
  border-radius: 8px;
  font-size: 13px;
}

.file-info strong {
  color: var(--primary);
}

/* Sheet Selector */
.sheet-selector {
  margin-top: 20px;
}

.sheet-selector .sheet-item {
  margin-bottom: 12px;
}

.mt-4 {
  margin-top: 16px;
}
