#view-container:has(#view-financeiro.active) {
  overflow: hidden !important;
}

#view-financeiro {
  display: none;
}

#view-financeiro.active {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0 !important;
  max-height: 100% !important;
  overflow: hidden;
}

/* Layout principal: 2 colunas */
.fin-layout {
  display: grid;
  grid-template-columns: 450px 1fr;
  grid-template-rows: 1fr;
  gap: var(--space-5);
  flex: 1;
  min-height: 0;
  padding: var(--space-4) var(--space-6) var(--space-6);
}

/* ── Coluna de Clientes ──────────────────── */

.fin-client-column {
  display: flex;
  flex-direction: column;
  background: var(--bg-card-premium);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  overflow: hidden;
  min-height: 0;
  height: 100%;
}

.fin-column-header {
  padding: var(--space-5) var(--space-5) var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-card-premium);
}

.fin-base-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
}

.fin-base-title {
  font-family: var(--font-heading);
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--text-primary);
}

.fin-base-stats {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.fin-client-list {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.fin-client-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-4) var(--space-5);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-lg);
  cursor: pointer;
  text-align: left;
  color: var(--text-primary);
  transition: all var(--transition-fast);
}

.fin-client-item:hover {
  background: var(--bg-chip);
}

.fin-client-item.active {
  background: var(--bg-chip-active);
}

/* ── Avatar ─── */
.fin-client-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg-chip);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xs);
  font-weight: 700;
  font-family: var(--font-heading);
  letter-spacing: 0.5px;
  flex-shrink: 0;
}

.fin-client-avatar.is-monthly {
  background: var(--accent);
  color: #000;
}

.fin-client-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.fin-client-name {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fin-client-meta-text {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-family: var(--font-mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Right side (badge + valor) ─── */
.fin-client-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}

.fin-client-value {
  text-align: right;
  line-height: 1;
}

.fin-client-value-amount {
  font-size: var(--text-sm);
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-primary);
}

.fin-client-value-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-left: 2px;
}

/* Badge de mensalidade (verde) */
.fin-badge-monthly {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.25);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.2px;
}

/* Badge de demandas (neutro) */
.fin-badge-demand {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  background: var(--bg-chip);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 600;
}

/* ── Painel de Demandas ───────────────────── */

.fin-delivery-column {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
  height: 100%;
}

.fin-delivery-panel {
  flex: 1;
  background: var(--bg-card-premium);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Empty State */
.fin-empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  padding: var(--space-16);
  text-align: center;
  color: var(--text-muted);
}

.fin-empty-state svg {
  opacity: 0.3;
}

.fin-empty-state p {
  font-size: var(--text-sm);
  line-height: 1.6;
  max-width: 280px;
}

/* ── Insights section (topo do painel direito) ── */
.fin-insights-section {
  flex-shrink: 0;
  padding: var(--space-4) var(--space-5) 0;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-card-premium);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}

.fin-insights-row {
  display: flex;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.fin-insight-card {
  flex: 1;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4);
  border-radius: var(--radius-lg);
  border: 1px solid;
}

.fin-insight-paid {
  background: rgba(16, 185, 129, 0.06);
  border-color: rgba(16, 185, 129, 0.2);
}

.fin-insight-pending {
  background: rgba(234, 179, 8, 0.06);
  border-color: rgba(234, 179, 8, 0.2);
}

.fin-insight-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.fin-insight-paid .fin-insight-icon {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
}

.fin-insight-pending .fin-insight-icon {
  background: rgba(234, 179, 8, 0.15);
  color: #ca8a04;
}

.fin-insight-body {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.fin-insight-label {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.fin-insight-value {
  font-size: var(--text-xl);
  font-weight: 700;
  font-family: var(--font-mono);
  line-height: 1;
}

.fin-insight-paid .fin-insight-value {
  color: #10b981;
}

.fin-insight-pending .fin-insight-value {
  color: #ca8a04;
}

/* Controles de filtro dentro do insights-section */
.fin-panel-controls {
  display: flex;
  align-items: center;
  flex-direction: row;
  gap: var(--space-2);
  flex-shrink: 0;
  flex-wrap: wrap;
  padding-bottom: var(--space-3);
}

.fin-period-selects {
  display: contents; /* cada select fica diretamente no flex do controls */
}

.fin-select {
  height: 28px;
  padding: 0 var(--space-3);
  font-size: var(--text-xs);
  font-weight: 500;
  font-family: var(--font-ui);
  background: var(--bg-chip);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  cursor: pointer;
  transition: border-color var(--transition-fast), color var(--transition-fast);
  outline: none;
}

.fin-select:focus,
.fin-select:hover {
  border-color: var(--accent);
  color: var(--text-primary);
}

/* Separador visual entre selects e botões de status */
.fin-filter-separator {
  width: 1px;
  height: 18px;
  background: var(--border-subtle);
  flex-shrink: 0;
}

.fin-panel-title {
  font-family: var(--font-heading);
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
  line-height: 1.2;
}

.fin-panel-subtitle {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 2px;
  display: block;
}

/* Filter Buttons */
.fin-payment-filter {
  display: flex;
  gap: 2px;
  background: var(--bg-chip);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 3px;
  flex-shrink: 0;
}

.fin-filter-btn {
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-xs);
  font-weight: 600;
  font-family: var(--font-ui);
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.fin-filter-btn:hover {
  color: var(--text-primary);
}

.fin-filter-btn.active {
  background: var(--accent);
  color: #fff;
}

/* Groups Container — área rolável */
.fin-groups-container {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4) var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

/* Month Group */
.fin-month-group {
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  animation: fadeInUp 300ms ease both;
}

.fin-month-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  background: var(--bg-card-premium);
  border-bottom: 1px solid var(--border-subtle);
}

.fin-month-label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--text-primary);
  flex: 1;
  cursor: pointer;
  user-select: none;
}

.fin-month-label svg {
  color: var(--accent);
  flex-shrink: 0;
}

.fin-month-count {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-weight: 500;
  margin-left: var(--space-1);
}

/* Chevron para indicar collapse */
.fin-chevron {
  color: var(--text-muted) !important;
  transition: transform var(--transition-base);
  flex-shrink: 0;
}

.fin-month-group.is-collapsed .fin-chevron {
  transform: rotate(-90deg);
}

.fin-month-right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.fin-month-total {
  font-size: var(--text-sm);
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--accent);
}

/* Collapsible deliveries list */
.fin-deliveries-list {
  display: flex;
  flex-direction: column;
  transition: max-height 280ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Header do mês clicável */
.fin-month-toggle-header {
  cursor: pointer;
  transition: background var(--transition-fast);
}

.fin-month-toggle-header:hover {
  background: rgba(255, 255, 255, 0.03);
}

.fin-delivery-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  transition: background var(--transition-fast);
  cursor: pointer;
}

.fin-delivery-row:last-child {
  border-bottom: none;
}

.fin-delivery-row:hover {
  background: rgba(var(--accent-rgb, 124, 58, 237), 0.05);
}

.fin-delivery-row.is-paid {
  background: rgba(16, 185, 129, 0.04);
}

.fin-delivery-row.is-paid .fin-delivery-title {
  color: var(--text-muted);
}

.fin-delivery-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.fin-delivery-title {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color var(--transition-fast);
}

.fin-delivery-date {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* Linha abaixo do título: data + tags de produto */
.fin-delivery-meta-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.fin-product-tags {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.fin-product-tag {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  background: rgba(var(--accent-rgb, 124, 58, 237), 0.1);
  color: var(--accent);
  border: 1px solid rgba(var(--accent-rgb, 124, 58, 237), 0.2);
  border-radius: var(--radius-full);
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
}

.fin-delivery-right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-shrink: 0;
}

.fin-delivery-value {
  font-size: var(--text-sm);
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  min-width: 80px;
  text-align: right;
}

/* Monthly Notice */
.fin-monthly-notice {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-4);
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-style: italic;
}

.fin-monthly-notice svg {
  flex-shrink: 0;
  color: var(--accent);
}

/* ── Toggle Switch ────────────────────────── */

.fin-toggle {
  display: flex;
  align-items: center;
  cursor: pointer;
  flex-shrink: 0;
}

.fin-toggle-input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.fin-toggle-track {
  position: relative;
  width: 36px;
  height: 20px;
  background: var(--bg-chip);
  border: 1px solid var(--border-default);
  border-radius: 999px;
  transition: all var(--transition-fast);
  display: block;
}

.fin-toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: all var(--transition-base);
}

.fin-toggle-input:checked + .fin-toggle-track {
  background: rgba(16, 185, 129, 0.2);
  border-color: #10b981;
}

.fin-toggle-input:checked + .fin-toggle-track .fin-toggle-thumb {
  transform: translateX(16px);
  background: #10b981;
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.5);
}

.fin-toggle:hover .fin-toggle-track {
  border-color: var(--accent);
}

/* Month toggle slightly bigger */
.fin-toggle-month .fin-toggle-track {
  width: 40px;
  height: 22px;
}

.fin-toggle-month .fin-toggle-thumb {
  width: 16px;
  height: 16px;
}

.fin-toggle-month .fin-toggle-input:checked + .fin-toggle-track .fin-toggle-thumb {
  transform: translateX(18px);
}

/* ── Scrollbar estilizado ─────────────────── */

.fin-client-list::-webkit-scrollbar,
.fin-groups-container::-webkit-scrollbar {
  width: 4px;
}

.fin-client-list::-webkit-scrollbar-track,
.fin-groups-container::-webkit-scrollbar-track {
  background: transparent;
}

.fin-client-list::-webkit-scrollbar-thumb,
.fin-groups-container::-webkit-scrollbar-thumb {
  background: var(--border-default);
  border-radius: 4px;
}

/* Empty Month Notice */
.fin-empty-month-notice {
  padding: var(--space-4) var(--space-6);
  text-align: center;
  color: var(--text-muted);
  font-size: var(--text-xs);
  font-style: italic;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(0, 0, 0, 0.05);
}

.fin-empty-month-notice:last-child {
  border-bottom: none;
}


/* ── Responsivo ───────────────────────────── */

@media (max-width: 900px) {
  #view-financeiro {
    height: auto;
    overflow: visible;
  }

  .fin-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    flex: none;
    padding: 0 var(--space-4) var(--space-6);
  }

  .fin-client-column {
    max-height: 240px;
  }

  .fin-delivery-panel {
    min-height: 400px;
  }
}
