﻿/* ========================================
   ConciliaÃ§Ã£o BancÃ¡ria - Design System
   ======================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* --- CSS Custom Properties --- */
:root {
  /* Colors - Dark Theme */
  --bg-primary: #0a0e1a;
  --bg-secondary: #111827;
  --bg-card: rgba(17, 24, 39, 0.7);
  --bg-glass: rgba(255, 255, 255, 0.03);
  --bg-glass-hover: rgba(255, 255, 255, 0.06);
  --bg-input: rgba(255, 255, 255, 0.05);

  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-medium: rgba(255, 255, 255, 0.1);
  --border-accent: rgba(99, 102, 241, 0.3);

  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-inverse: #0f172a;

  /* Brand Colors */
  --fpp-red: #CC0000;
  --fpp-blue: #003399;

  /* Accent Colors */
  --accent-primary: var(--fpp-red);
  --accent-primary-hover: #a30000;
  --accent-glow: rgba(204, 0, 0, 0.15);

  /* Semantic Colors */
  --color-success: #10b981;
  --color-success-bg: rgba(16, 185, 129, 0.1);
  --color-success-border: rgba(16, 185, 129, 0.25);

  --color-danger: #ef4444;
  --color-danger-bg: rgba(239, 68, 68, 0.1);
  --color-danger-border: rgba(239, 68, 68, 0.25);

  --color-warning: #f59e0b;
  --color-warning-bg: rgba(245, 158, 11, 0.1);
  --color-warning-border: rgba(245, 158, 11, 0.25);

  --color-info: #3b82f6;
  --color-info-bg: rgba(59, 130, 246, 0.1);
  --color-info-border: rgba(59, 130, 246, 0.25);

  /* Gradients */
  --gradient-accent: linear-gradient(135deg, #6366f1, #8b5cf6, #a855f7);
  --gradient-success: linear-gradient(135deg, #10b981, #34d399);
  --gradient-danger: linear-gradient(135deg, #ef4444, #f87171);
  --gradient-warning: linear-gradient(135deg, #f59e0b, #fbbf24);
  --gradient-hero: linear-gradient(135deg, rgba(99, 102, 241, 0.12), rgba(168, 85, 247, 0.08), rgba(236, 72, 153, 0.06));

  /* Typography */
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;

  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  --space-3xl: 4rem;

  /* Radius */
  --radius-sm: 0.375rem;
  --radius-md: 0.625rem;
  --radius-lg: 1rem;
  --radius-xl: 1.25rem;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -2px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -4px rgba(0, 0, 0, 0.3);
  --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.15);

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Light Theme --- */
[data-theme="light"] {
  --bg-primary: #f0f4f8;
  --bg-secondary: #e2e8f0;
  --bg-card: rgba(255, 255, 255, 0.85);
  --bg-glass: rgba(0, 0, 0, 0.03);
  --bg-glass-hover: rgba(0, 0, 0, 0.06);
  --bg-input: rgba(0, 0, 0, 0.04);

  --border-subtle: rgba(0, 0, 0, 0.07);
  --border-medium: rgba(0, 0, 0, 0.12);
  --border-accent: rgba(99, 102, 241, 0.3);

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --text-inverse: #f1f5f9;

  --accent-glow: rgba(204, 0, 0, 0.1);
  --border-accent: rgba(204, 0, 0, 0.3);

  --color-success-bg: rgba(16, 185, 129, 0.08);
  --color-danger-bg: rgba(239, 68, 68, 0.08);
  --color-warning-bg: rgba(245, 158, 11, 0.08);

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.12);
  --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.1);

  --gradient-hero: linear-gradient(135deg, rgba(99, 102, 241, 0.05), rgba(168, 85, 247, 0.03), rgba(236, 72, 153, 0.03));
}

/* --- Reset & Base --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--gradient-hero);
  pointer-events: none;
  z-index: 0;
}

/* --- Layout --- */
.app-container {
  position: relative;
  z-index: 1;
  max-width: 1400px;
  margin: 0 auto;
  padding: var(--space-lg) var(--space-xl);
  min-height: 100vh;
}

/* --- Header --- */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-3xl);
  padding: var(--space-2xl) 0 var(--space-lg);
  position: relative;
}

.header-brand {
  flex: 1;
  text-align: center;
  margin-left: 140px; /* compensate for toggle button width */
}

.app-logo {
  font-size: 2.5rem;
  font-weight: 800;
  background: var(--gradient-accent);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.03em;
  margin-bottom: var(--space-sm);
}

.app-subtitle {
  color: var(--text-secondary);
  font-size: 1.05rem;
  font-weight: 400;
  letter-spacing: 0.01em;
}

/* --- Theme Toggle Button --- */
.theme-toggle-btn {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 0.5rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-full);
  color: var(--text-secondary);
  font-family: var(--font-family);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-base);
  white-space: nowrap;
  flex-shrink: 0;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: var(--shadow-sm);
}

.theme-toggle-btn:hover {
  background: var(--bg-glass-hover);
  border-color: var(--accent-primary);
  color: var(--text-primary);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.theme-icon-dark,
.theme-icon-light {
  font-size: 1rem;
  line-height: 1;
}

/* When light theme is active: show sun, hide moon */
[data-theme="light"] .theme-icon-dark { display: none; }
[data-theme="light"] .theme-icon-light { display: inline; }
.theme-toggle-label { font-size: 0.8rem; }

/* Default (dark): show moon, hide sun */
:not([data-theme="light"]) .theme-icon-dark { display: inline; }
:not([data-theme="light"]) .theme-icon-light { display: none; }

/* Light theme general adjustments */
[data-theme="light"] body::before {
  opacity: 0.4;
}

[data-theme="light"] .card,
[data-theme="light"] .modal-card {
  box-shadow: 0 2px 16px rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .data-table th {
  background: #eef2ff; /* Cor sÃ³lida em vez de rgba translÃºcido para o sticky header */
}

[data-theme="light"] .data-table tr:hover {
  background: rgba(99, 102, 241, 0.04);
}

[data-theme="light"] .row-success { background: rgba(0, 200, 83, 0.05); }
[data-theme="light"] .row-dda { background: rgba(108, 92, 231, 0.05); }
[data-theme="light"] .row-erp { background: rgba(255, 160, 0, 0.05); }
[data-theme="light"] .row-manual { background: rgba(0, 210, 255, 0.05); }
[data-theme="light"] .row-desconsiderar { background-color: rgba(200, 30, 30, 0.07) !important; }
[data-theme="light"] .row-desconsiderar td { color: #7f1d1d !important; }

/* --- Wizard Steps Indicator --- */
.wizard-steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin-bottom: var(--space-3xl);
  padding: 0 var(--space-xl);
}

.wizard-step {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-lg);
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: all var(--transition-base);
  position: relative;
  cursor: default;
}

.wizard-step .step-number {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  font-size: 0.75rem;
  font-weight: 700;
  transition: all var(--transition-base);
}

.wizard-step.active {
  color: var(--text-primary);
}

.wizard-step.active .step-number {
  background: var(--gradient-accent);
  border-color: transparent;
  color: white;
  box-shadow: var(--shadow-glow);
}

.wizard-step.completed {
  color: var(--color-success);
}

.wizard-step.completed .step-number {
  background: var(--color-success);
  border-color: transparent;
  color: white;
}

.wizard-connector {
  width: 40px;
  height: 2px;
  background: var(--border-subtle);
  transition: background var(--transition-base);
}

.wizard-connector.active {
  background: var(--gradient-accent);
}

/* --- Glass Card --- */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: var(--space-2xl);
  transition: all var(--transition-base);
}

.card:hover {
  border-color: var(--border-medium);
}

.card-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: var(--space-xs);
  letter-spacing: -0.02em;
}

.card-description {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: var(--space-xl);
}

/* --- Step Panels --- */
.step-panel {
  display: none;
  animation: fadeSlideIn 0.4s ease-out;
}

.step-panel.active {
  display: block;
}

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

/* --- Drop Zone --- */
.upload-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-xl);
}

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

.drop-zone-wrapper {
  min-width: 0;
  width: 100%;
}

.drop-zone {
  border: 2px dashed var(--border-medium);
  border-radius: var(--radius-lg);
  padding: var(--space-2xl) var(--space-xl);
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-base);
  position: relative;
  overflow: hidden;
}

.drop-zone::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--accent-glow);
  opacity: 0;
  transition: opacity var(--transition-base);
}

.drop-zone:hover,
.drop-zone.dragover {
  border-color: var(--accent-primary);
  background: var(--bg-glass-hover);
}

.drop-zone:hover::before,
.drop-zone.dragover::before {
  opacity: 1;
}

.drop-zone.has-file {
  border-color: var(--color-success-border);
  border-style: solid;
  background: var(--color-success-bg);
}

.drop-zone-icon {
  font-size: 2.5rem;
  margin-bottom: var(--space-md);
  opacity: 0.6;
}

.drop-zone-label {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: var(--space-xs);
  color: var(--text-primary);
}

.drop-zone-sublabel {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.drop-zone-filename {
  display: none;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--color-success);
  margin-top: var(--space-sm);
  word-break: break-all;
}

.drop-zone.has-file .drop-zone-filename {
  display: block;
}

.drop-zone-fileinfo {
  display: none;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: var(--space-xs);
}

.drop-zone.has-file .drop-zone-fileinfo {
  display: block;
}

.drop-zone input[type="file"] {
  display: none;
}

/* --- Preview Table (Step 1) --- */
.preview-section {
  margin-top: var(--space-xl);
  display: none;
}

.preview-section.visible {
  display: block;
}

.preview-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-sm);
}

.preview-table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  max-height: 200px;
}

.preview-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.75rem;
}

.preview-table th {
  background: var(--bg-secondary);
  color: var(--text-secondary);
  padding: var(--space-sm) var(--space-md);
  text-align: left;
  font-weight: 600;
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}

.preview-table td {
  padding: var(--space-sm) var(--space-md);
  border-top: 1px solid var(--border-subtle);
  white-space: nowrap;
  color: var(--text-secondary);
}

/* --- Column Mapping (Step 2) --- */
.mapping-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2xl);
}

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

.mapping-section {
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
}

.mapping-section-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: var(--space-lg);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.mapping-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-md);
  gap: var(--space-md);
}

.mapping-label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  min-width: 120px;
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.mapping-label .required {
  color: var(--color-danger);
  font-weight: 700;
}

.mapping-select {
  flex: 1;
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  padding: var(--space-sm) var(--space-md);
  font-family: var(--font-family);
  font-size: 0.85rem;
  cursor: pointer;
  transition: border-color var(--transition-fast);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpolyline points='6,9 12,15 18,9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

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

.mapping-select option {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
}

/* --- Processing (Step 3) --- */
.processing-container {
  text-align: center;
  padding: var(--space-3xl) 0;
}

.processing-spinner {
  width: 64px;
  height: 64px;
  border: 3px solid var(--border-subtle);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto var(--space-xl);
}

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

.processing-title {
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: var(--space-sm);
}

.processing-detail {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.progress-bar-wrapper {
  margin-top: var(--space-xl);
  background: var(--bg-glass);
  border-radius: var(--radius-full);
  height: 8px;
  overflow: hidden;
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
}

.progress-bar {
  height: 100%;
  background: var(--gradient-accent);
  border-radius: var(--radius-full);
  width: 0%;
  transition: width 0.3s ease;
}

/* --- Results (Step 4) --- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: var(--space-md);
  margin-bottom: var(--space-2xl);
}

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

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

.stat-card {
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  text-align: center;
  transition: all var(--transition-base);
}

.stat-card:hover {
  border-color: var(--border-medium);
  transform: translateY(-2px);
}

.stat-value {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: var(--space-xs);
}

.stat-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-card.success .stat-value { color: var(--color-success); }
.stat-card.danger .stat-value { color: var(--color-danger); }
.stat-card.warning .stat-value { color: var(--color-warning); }
.stat-card.info .stat-value { color: var(--color-info); }
.stat-card.neutral .stat-value { color: var(--text-primary); }

/* --- Tabs --- */
.tabs {
  display: flex;
  gap: var(--space-xs);
  margin-bottom: var(--space-lg);
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 0;
}

.tab-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-family);
  font-size: 0.85rem;
  font-weight: 500;
  padding: var(--space-sm) var(--space-lg);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

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

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

.tab-badge {
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  padding: 1px 8px;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-primary);
}

.tab-btn.active .tab-badge {
  background: var(--accent-primary);
  border-color: var(--accent-primary-hover);
  color: #ffffff;
}

/* Badge especial da aba Avisos */
.tab-badge.avisos-badge {
  background: #6b7280;
  color: #ffffff;
}
.tab-badge.avisos-badge.has-pending {
  background: #f59e0b;
  color: #ffffff;
}
.tab-btn.active .tab-badge.avisos-badge {
  background: var(--accent-primary);
  border-color: var(--accent-primary-hover);
  color: #ffffff;
}

/* Badge variants */
.tab-badge.matched { background: rgba(0, 200, 83, 0.2); color: #00c853; border-color: rgba(0, 200, 83, 0.3); }
.tab-badge.unmatched-dda { background: rgba(108, 92, 231, 0.2); color: #a29bfe; border-color: rgba(108, 92, 231, 0.3); }
.tab-badge.unmatched-erp { background: rgba(255, 160, 0, 0.2); color: #ffca28; border-color: rgba(255, 160, 0, 0.3); }
.tab-badge.manual { background: rgba(0, 210, 255, 0.2); color: #00d2ff; border-color: rgba(0, 210, 255, 0.3); }

.tab-btn.active .tab-badge.matched { background: #00c853; color: white; }
.tab-btn.active .tab-badge.unmatched-dda { background: #6c5ce7; color: white; }
.tab-btn.active .tab-badge.unmatched-erp { background: #ffa000; color: white; }
.tab-btn.active .tab-badge.manual { background: #00d2ff; color: white; }

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

/* --- Data Table --- */
.table-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
  flex-wrap: wrap;
}

.search-input {
  background: var(--bg-input);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  padding: var(--space-sm) var(--space-md);
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 0.85rem;
  min-width: 260px;
  transition: border-color var(--transition-fast);
}

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

.search-input:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.data-table th {
  background: var(--bg-secondary);
  color: var(--text-secondary);
  padding: var(--space-sm) var(--space-md);
  text-align: left;
  font-weight: 600;
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
  cursor: pointer;
  user-select: none;
  transition: color var(--transition-fast);
}

.data-table th:hover {
  color: var(--text-primary);
}

/* --- Sortable Column Headers --- */
.data-table th.th-sortable {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.data-table th.th-sortable:hover {
  color: var(--accent-primary-hover);
  background: rgba(99, 102, 241, 0.06);
}

.data-table th.th-sorted {
  color: var(--accent-primary-hover);
}

.data-table th.th-hash {
  width: 42px;
  cursor: default;
}

.sort-icon {
  display: inline-block;
  font-size: 0.7rem;
  margin-left: 4px;
  vertical-align: middle;
  opacity: 0.5;
  transition: opacity var(--transition-fast), color var(--transition-fast);
}

.data-table th.th-sortable:hover .sort-icon,
.data-table th.th-sorted .sort-icon {
  opacity: 1;
}

.sort-icon.sort-asc  { color: #00c853; opacity: 1; }
.sort-icon.sort-desc { color: var(--accent-primary-hover); opacity: 1; }
.sort-icon.sort-idle { color: var(--text-muted); }

.sort-rank {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  background: var(--accent-primary);
  color: #fff;
  border-radius: 50%;
  font-size: 0.6rem;
  font-weight: 700;
  margin-left: 3px;
  vertical-align: middle;
}

.data-table td {
  padding: var(--space-sm) var(--space-md);
  border-top: 1px solid var(--border-subtle);
  white-space: nowrap;
}

.data-table tbody tr {
  transition: background var(--transition-fast);
}

.data-table tbody tr:hover {
  background: var(--bg-glass-hover);
}

.data-table .value-cell {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.8rem;
}

/* Semantic row highlights */
.data-table tr.row-success td:first-child {
  border-left: 3px solid var(--color-success);
}

.data-table tr.row-danger td:first-child {
  border-left: 3px solid var(--color-danger);
}

.data-table tr.row-warning td:first-child {
  border-left: 3px solid var(--color-warning);
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-xl);
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-family);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--gradient-accent);
  color: white;
  box-shadow: var(--shadow-md);
}

.btn-primary:hover:not(:disabled) {
  box-shadow: var(--shadow-glow), var(--shadow-lg);
  transform: translateY(-1px);
}

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

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-glass-hover);
  border-color: var(--border-accent);
}

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

.btn-success:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 0 20px rgba(16, 185, 129, 0.2);
}

.btn-group {
  display: flex;
  gap: var(--space-md);
  justify-content: flex-end;
  margin-top: var(--space-xl);
}

/* --- Navigation Buttons --- */
.nav-buttons {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: var(--space-2xl);
  padding-top: var(--space-xl);
  border-top: 1px solid var(--border-subtle);
}

/* --- Utility --- */
.text-success { color: var(--color-success); }
.text-danger { color: var(--color-danger); }
.text-warning { color: var(--color-warning); }
.text-muted { color: var(--text-muted); }

.hidden { display: none !important; }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-success {
  background: var(--color-success-bg);
  color: var(--color-success);
  border: 1px solid var(--color-success-border);
}

.badge-danger {
  background: var(--color-danger-bg);
  color: var(--color-danger);
  border: 1px solid var(--color-danger-border);
}

.badge-warning {
  background: var(--color-warning-bg);
  color: var(--color-warning);
  border: 1px solid var(--color-warning-border);
}

/* --- Toast Notification --- */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: var(--space-md) var(--space-xl);
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 500;
  color: white;
  z-index: 9999;
  transform: translateY(100px);
  opacity: 0;
  transition: all var(--transition-base);
  box-shadow: var(--shadow-lg);
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.toast.success { background: var(--color-success); }
.toast.error { background: var(--color-danger); }
.toast.warning { background: var(--color-warning); }

/* --- Empty State --- */
.empty-state {
  text-align: center;
  padding: var(--space-3xl) var(--space-xl);
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: var(--space-md);
  opacity: 0.5;
}

.empty-state-text {
  font-size: 0.95rem;
}

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

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-medium);
  border-radius: var(--radius-full);
}

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

/* --- Responsive --- */
@media (max-width: 640px) {
  .app-container {
    padding: var(--space-md);
  }

  .app-logo {
    font-size: 1.75rem;
  }

  .wizard-step .step-label {
    display: none;
  }

  .card {
    padding: var(--space-lg);
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }

  .tabs {
    overflow-x: auto;
  }

  .btn-group {
    flex-direction: column;
  }
}

/* --- Modal Manual Match --- */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(5px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-base);
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  width: 90%;
  max-width: 1000px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  transform: translateY(20px) scale(0.95);
  transition: transform var(--transition-base);
  padding: var(--space-xl);
}

.modal-overlay.active .modal-content {
  transform: translateY(0) scale(1);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: var(--space-sm);
}

.btn-icon {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
  transition: color var(--transition-fast);
}

.btn-icon:hover {
  color: var(--color-danger);
}

.manual-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-lg);
  margin-top: var(--space-md);
  margin-bottom: var(--space-xl);
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

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

.manual-col {
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.manual-col-title {
  font-size: 0.9rem;
  font-weight: 600;
  padding: var(--space-md);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

.manual-col-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) var(--space-md) 0;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-subtle);
}

.manual-col-header .manual-col-title {
  padding: var(--space-sm) 0;
  background: transparent;
  border: none;
}

/* Sortable header row inside each modal column */
.manual-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.35rem var(--space-md);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-subtle);
}

.manual-list-th {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: color var(--transition-fast);
}

.manual-list-th:hover {
  color: var(--accent-primary-hover);
}

.manual-list-th.th-right {
  justify-content: flex-end;
}

.manual-list {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-sm);
}

.match-item {
  background: var(--bg-input);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: var(--space-sm) var(--space-md);
  margin-bottom: var(--space-xs);
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.match-item:hover {
  background: var(--bg-glass-hover);
  border-color: var(--border-medium);
}

.match-item.selected {
  background: var(--accent-glow);
  border-color: var(--accent-primary);
  box-shadow: inset 0 0 0 1px var(--accent-primary);
}

.match-item-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  justify-content: space-between;
}

.match-item-value {
  color: var(--accent-primary-hover);
  font-family: var(--font-mono);
}

.match-item-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.manual-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-lg);
  padding-top: var(--space-lg);
  border-top: 1px solid var(--border-subtle);
}

.manual-reason {
  flex: 1;
  min-width: 300px;
}

.manual-reason label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: var(--space-xs);
}

.reason-inputs {
  display: flex;
  gap: var(--space-sm);
}

.reason-inputs .mapping-select {
  flex: 0 0 200px;
}

.reason-inputs .search-input {
  flex: 1;
}

.manual-buttons {
  display: flex;
  gap: var(--space-sm);
}

.row-success { border-left: 3px solid #00c853; background: rgba(0, 200, 83, 0.03); }
.row-dda { border-left: 3px solid #6c5ce7; background: rgba(108, 92, 231, 0.03); }
.row-erp { border-left: 3px solid #ffa000; background: rgba(255, 160, 0, 0.03); }
.row-manual { border-left: 3px solid #00d2ff; background: rgba(0, 210, 255, 0.03); }
.row-danger { border-left: 3px solid #ff3d3d; background: rgba(255, 61, 61, 0.03); }
.row-warning { border-left: 3px solid #ff9100; background: rgba(255, 145, 0, 0.03); }

.row-desconsiderar {
  background-color: rgba(255, 60, 60, 0.08) !important;
  border-left: 3px solid #ff4c4c;
}
/* No modo escuro, o texto precisa de ajuda para contrastar com o fundo avermelhado */
:not([data-theme="light"]) .row-desconsiderar td {
  color: rgba(255, 220, 220, 0.95);
}

/* --- Modal: Multi-Select Helpers --- */
.manual-col-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.sel-summary {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  min-height: 1.2rem;
}

.sel-count {
  background: var(--accent-primary);
  color: #fff;
  border-radius: var(--radius-full);
  padding: 1px 7px;
  font-weight: 600;
  font-size: 0.7rem;
}

.sel-total {
  color: var(--accent-primary-hover);
  font-weight: 700;
  font-family: var(--font-mono);
  font-size: 0.75rem;
}

/* --- DiferenÃ§a com sinal na aba Ajustes Manuais --- */
.diff-negative {
  color: #f87171 !important;
  font-weight: 700;
}
[data-theme="light"] .diff-negative {
  color: #b91c1c !important;
}

.diff-positive {
  color: #34d399 !important;
  font-weight: 700;
}
[data-theme="light"] .diff-positive {
  color: #065f46 !important;
}

/* --- Coluna de aÃ§Ã£o (Editar) --- */
.th-action {
  width: 44px;
  min-width: 44px;
  padding: 0 !important;
}

.action-cell {
  text-align: center;
  padding: 0 !important;
}

.btn-edit-manual {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast), transform var(--transition-fast);
  line-height: 1;
  opacity: 0.55;
}

.btn-edit-manual:hover {
  background: var(--bg-glass-hover);
  opacity: 1;
  transform: scale(1.15);
}

/* ========================================
   FINEXY DASHBOARD LAYOUT
   ======================================== */

.finexy-layout {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background-color: var(--bg-primary);
}

.finexy-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 72px;
  background-color: var(--bg-card);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0 var(--space-xl);
  flex-shrink: 0;
  z-index: 20;
}

.header-brand-finexy {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.header-logo-img {
  height: 40px;
  object-fit: contain;
}

.header-nav-sectors {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  background: var(--bg-glass);
  padding: 4px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle);
}

.sector-link {
  text-decoration: none;
  color: var(--text-secondary);
  font-weight: 600;
  padding: var(--space-sm) var(--space-xl);
  border-radius: var(--radius-full);
  transition: all var(--transition-fast);
  font-size: 0.95rem;
}

.sector-link:hover:not(.disabled) {
  color: var(--text-primary);
}

.sector-link.active {
  background: var(--text-primary);
  color: var(--bg-primary);
}

.sector-link.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.user-profile {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  cursor: pointer;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--fpp-blue);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 0.85rem;
}

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

.user-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-primary);
}

.finexy-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.finexy-sidebar {
  width: 260px;
  background-color: #0b1120; /* Azul escuro profundo premium da marca */
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 10;
  transition: width var(--transition-base);
  height: 100%;
}

.sidebar-brand-section {
  display: flex;
  align-items: center;
  padding: 1.5rem;
  gap: 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background-color: rgba(255, 255, 255, 0.02);
}

.sidebar-logo-img {
  height: 32px;
  width: auto;
  object-fit: contain;
}

.sidebar-brand-text {
  font-family: var(--font-family);
  font-size: 1.1rem;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: 0.05em;
}

.sidebar-content-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.sidebar-nav-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.sidebar-group-title {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.35);
  margin-bottom: 0.5rem;
  font-weight: 700;
  padding-left: 0.75rem;
}

.tool-link {
  display: flex;
  align-items: center;
  padding: 0.65rem 0.88rem;
  border-radius: var(--radius-md);
  color: #94a3b8;
  text-decoration: none;
  transition: all var(--transition-fast);
  gap: 0.75rem;
  font-weight: 500;
  font-size: 0.92rem;
  background: transparent;
  width: 100%;
}

.tool-icon {
  font-size: 1.15rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.tool-text {
  flex: 1;
}

.tool-arrow {
  font-size: 0.8rem;
  opacity: 0.4;
  transition: transform var(--transition-fast), opacity var(--transition-fast);
}

.tool-link:hover:not(.disabled) {
  background-color: rgba(255, 255, 255, 0.05);
  color: #ffffff;
}

.tool-link:hover:not(.disabled) .tool-arrow {
  opacity: 0.8;
  transform: translate(2px, -2px);
}

.tool-link.active {
  background-color: var(--fpp-red) !important;
  color: #ffffff !important;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(204, 0, 0, 0.2);
}

.tool-link.active .tool-arrow {
  opacity: 1;
  color: #ffffff;
}

.tool-link.disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.sidebar-footer {
  padding: 1rem 0.75rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  background-color: rgba(255, 255, 255, 0.01);
}

.footer-link {
  display: flex;
  align-items: center;
  padding: 0.6rem 0.88rem;
  border-radius: var(--radius-md);
  color: #64748b;
  text-decoration: none;
  transition: all var(--transition-fast);
  gap: 0.75rem;
  font-size: 0.88rem;
  font-weight: 500;
}

.footer-link:hover {
  background-color: rgba(255, 255, 255, 0.04);
  color: #cbd5e1;
}

.theme-toggle-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.88rem;
  margin-top: 0.25rem;
}

.finexy-theme-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #cbd5e1;
  transition: all var(--transition-fast);
}

.finexy-theme-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.finexy-content {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-lg) var(--space-xl);
  background-color: var(--bg-primary);
}

/* Home Cards */
.home-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: var(--space-xl);
  max-width: 1000px;
}

.module-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: var(--space-xl);
  position: relative;
  transition: all var(--transition-base);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.module-card:hover:not(.disabled) {
  border-color: var(--border-medium);
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
}

.module-card.disabled {
  opacity: 0.7;
  pointer-events: none;
  filter: grayscale(1);
}

.card-badge {
  position: absolute;
  top: var(--space-md);
  right: var(--space-md);
  background: var(--color-warning-bg);
  color: var(--color-warning);
  border: 1px solid var(--color-warning-border);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
}

.card-icon {
  font-size: 2.5rem;
  margin-bottom: var(--space-sm);
  background: var(--accent-glow);
  width: 60px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-lg);
  color: var(--accent-primary);
}

.module-card .card-title {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: var(--space-xs);
  color: var(--text-primary);
}

.module-card .card-desc {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: var(--space-lg);
  flex: 1;
}

.btn-access {
  width: 100%;
}

@media (max-width: 768px) {
  .finexy-header {
    flex-wrap: wrap;
    height: auto;
    padding: var(--space-md);
    gap: var(--space-md);
  }
  .header-nav-sectors {
    order: 3;
    width: 100%;
    justify-content: center;
  }
  .finexy-body {
    flex-direction: column;
  }
    .finexy-sidebar {
    width: 100% !important;
    height: auto !important;
    flex-direction: row !important;
    padding: 0.5rem 1rem !important;
    border-right: none !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
  }
  .sidebar-brand-section, .sidebar-group-title, .tool-text, .tool-arrow, .sidebar-footer {
    display: none !important;
  }
  .sidebar-content-scroll {
    flex-direction: row !important;
    gap: 0.5rem !important;
    width: 100% !important;
    padding: 0 !important;
    justify-content: space-around !important;
    overflow-y: visible !important;
  }
  .sidebar-nav-group {
    display: flex !important;
    flex-direction: row !important;
    gap: 0.5rem !important;
  }
  .tool-link {
    width: 44px !important;
    height: 44px !important;
    border-radius: 50% !important;
    justify-content: center !important;
    padding: 0 !important;
    margin: 0 !important;
  }
  .tool-icon {
    font-size: 1.2rem !important;
    margin: 0 !important;
  }
  .finexy-content {
    padding: var(--space-lg);
  }
}

/* ========================================
   FLUXO DE CAIXA (CASHFLOW)
   ======================================== */

.loader-spinner {
  border: 4px solid var(--border-subtle);
  border-top: 4px solid var(--accent-primary);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
  margin: 0 auto;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.cf-panel {
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  margin-bottom: var(--space-xl);
  border: 1px solid transparent;
}

.cf-panel-success {
  background-color: var(--color-success-bg);
  border-color: var(--color-success-border);
  color: var(--color-success);
}

.cf-panel-warning {
  background-color: var(--color-warning-bg);
  border-color: var(--color-warning-border);
  color: var(--color-warning);
}

.cf-panel-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: var(--space-md);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.cf-combination-list {
  list-style: none;
  margin: 0 0 var(--space-md) 0;
  padding: 0;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  overflow: hidden;
}

.cf-combination-item {
  display: flex;
  justify-content: space-between;
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.9rem;
}

.cf-combination-item:last-child {
  border-bottom: none;
}

.cf-item-duplicate {
  background-color: var(--accent-glow);
  border-left: 4px solid var(--fpp-red);
  padding-left: calc(var(--space-md) - 4px);
}

.cf-item-checked {
  background-color: var(--color-success-bg) !important;
  border-left: 4px solid var(--color-success);
  padding-left: calc(var(--space-md) - 4px);
}

.cf-item-checkbox {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--color-success);
}

.cf-total-row {
  display: flex;
  justify-content: space-between;
  font-weight: 700;
  font-size: 1.1rem;
  padding-top: var(--space-md);
  border-top: 2px dashed currentColor;
  margin-top: var(--space-md);
}

.cf-closest-match {
  margin-bottom: var(--space-lg);
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--border-subtle);
}

.cf-closest-match:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.cf-diff-badge {
  font-size: 0.85rem;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-weight: 600;
  margin-left: var(--space-sm);
}

.cf-diff-over {
  background-color: var(--color-danger-bg);
  color: var(--color-danger);
}

.cf-diff-under {
  background-color: var(--color-info-bg);
  color: var(--color-info);
}

.cf-diff-approx {
  background-color: var(--color-success-bg);
  color: var(--color-success);
}

/* --- CONCILIAÃ‡ÃƒO BANCÃRIA --- */

.bankrec-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 2rem;
  align-items: start;
}

.bankrec-accounts-panel {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 1rem;
  max-height: calc(100vh - 150px);
  overflow-y: auto;
}

.bankrec-account-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 0.75rem;
  margin-bottom: 0.75rem;
  border-radius: var(--radius-md);
  border: 1px solid #cbd5e1; /* Hardcoded solid border for clear silhouette */
  cursor: pointer;
  transition: all 0.2s ease;
  background: #ffffff; /* Solid white background for clear shape */
  position: relative;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.bankrec-account-item:hover {
  border-color: #94a3b8;
  background: #f8fafc;
  transform: translateY(-1px);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.bankrec-account-item:active {
  transform: translateY(0);
}

.bankrec-account-item.active {
  border-color: var(--color-info); /* Blue border for active selection */
  background: #eff6ff; /* Light blue background */
  box-shadow: 0 0 0 1px var(--color-info), 0 4px 6px -1px rgba(0,0,0,0.1);
}

/* Radio button style for selection */
.acc-selector {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 0.25rem;
}

.radio-circle {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid #94a3b8;
  position: relative;
  transition: all 0.2s ease;
  background: #ffffff;
}

.bankrec-account-item.active .radio-circle {
  border-color: var(--color-info);
}

.bankrec-account-item.active .radio-circle::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--color-info);
}

.bankrec-account-item .acc-icon {
  font-size: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.bankrec-account-item.active .acc-icon {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
}

.bankrec-account-item .acc-info {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.bankrec-account-item .acc-name {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.bankrec-account-item .acc-details {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

.bankrec-account-item.status-empty .acc-icon { opacity: 0.5; filter: grayscale(1); }
.bankrec-account-item.status-pending { border-left: 4px solid var(--color-warning); }
.bankrec-account-item.status-error { border-left: 4px solid var(--color-danger); }
.bankrec-account-item.status-confirmed { border-left: 4px solid var(--color-success); }

#bankrec-summary-panel .summary-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-subtle);
}

.summary-row {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 0;
  font-size: 1rem;
  border-bottom: 1px solid var(--border-subtle);
}

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

.summary-row .value {
  font-weight: 600;
  font-family: var(--font-mono);
}

.summary-row.total-row {
  font-weight: 700;
  font-size: 1.2rem;
  border-top: 2px solid var(--border-strong);
  margin-top: 0.5rem;
  padding-top: 1rem;
}

.conf-row {
  font-weight: 700;
  font-size: 1.1rem;
  margin-top: 0.5rem;
  padding: 0.5rem;
  border-radius: var(--radius-md);
}

.conf-ok {
  background: var(--color-success-bg);
  color: var(--color-success);
}

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

.edit-balance {
  cursor: pointer;
  color: var(--primary-color);
}
.edit-balance:hover {
  text-decoration: underline;
}

.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-muted);
}

.empty-state .empty-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

/* Category Group Styles */
.category-group-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-surface);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  margin-bottom: 0.5rem;
  border-left: 4px solid var(--accent-primary);
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.tx-row.pending-change td {
  background-color: var(--color-warning-bg) !important;
  transition: background-color 0.3s ease;
}
.tx-row.pending-change select {
  border-color: var(--color-warning);
  background-color: #fff;
}

/* BotÃ£o Voltar ao Topo */
.btn-back-to-top {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 45px;
  height: 45px;
  border-radius: 50%;
  background-color: var(--accent-primary);
  color: #ffffff;
  border: none;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px);
  transition: all 0.3s ease;
  z-index: 9999;
}

.btn-back-to-top.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.btn-back-to-top:hover {
  background-color: var(--accent-hover);
  transform: translateY(-3px);
  box-shadow: 0 6px 16px rgba(0,0,0,0.3);
}

/* --- Agrupamento HierÃ¡rquico (RH) --- */
.group-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0.75rem;
  font-size: 0.85rem;
  border-radius: var(--radius-full);
  cursor: grab;
  transition: all var(--transition-fast);
  background: var(--bg-card);
  border: 1px solid var(--border-medium);
  color: var(--text-primary);
  user-select: none;
}

.group-pill:hover {
  background: var(--bg-hover);
  border-color: var(--accent-primary);
}

.group-pill:active {
  cursor: grabbing;
}

.group-pill .remove-pill {
  cursor: pointer;
  color: var(--color-danger);
  font-weight: bold;
  font-size: 1rem;
  line-height: 1;
  padding: 0 0.2rem;
  margin-left: 0.25rem;
  border-radius: 50%;
  transition: background 0.15s, color 0.15s;
}

.group-pill .remove-pill:hover {
  color: red;
  background: rgba(0,0,0,0.1);
}

/* Ã— nas pills coloridas do agrupamento ativo â€” sempre branco e bem visÃ­vel */
.group-pill.level-0 .remove-pill,
.group-pill.level-1 .remove-pill,
.group-pill.level-2 .remove-pill,
.group-pill.level-3 .remove-pill {
  color: rgba(255, 255, 255, 0.9);
  font-size: 1.1rem;
  font-weight: 900;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

/* Hierarquia Visual dos Grupos */
.rh-group-block.level-0 {
  --lvl-main: #d9534f;
  --lvl-bg: #fcf1f1;
  --lvl-border: #eebdbb;
  --lvl-badge-bg: #fadcd9;
}

.rh-group-block.level-1, .group-pill.level-1 {
  --lvl-main: #337ab7;
  --lvl-bg: #eaf2fd;
  --lvl-border: #b8d1fb;
  --lvl-badge-bg: #d9e6fa;
}

.rh-group-block.level-2, .group-pill.level-2 {
  --lvl-main: #5cb85c;
  --lvl-bg: #eef7f0;
  --lvl-border: #c0e6ca;
  --lvl-badge-bg: #dff0d8;
}

.rh-group-block.level-3, .group-pill.level-3 {
  --lvl-main: #f0ad4e;
  --lvl-bg: #fdf8e4;
  --lvl-border: #faebcc;
  --lvl-badge-bg: #fcf8e3;
}

/* Fallback/Default para as pills na zona ativa */
.group-pill.level-0 {
  background: #d9534f;
  color: white;
  border: 1px solid #d43f3a;
}
.group-pill.level-1 {
  background: #337ab7;
  color: white;
  border: 1px solid #2e6da4;
}
.group-pill.level-2 {
  background: #5cb85c;
  color: white;
  border: 1px solid #4cae4c;
}
.group-pill.level-3 {
  background: #f0ad4e;
  color: white;
  border: 1px solid #eea236;
}

.group-pill.level-0 .remove-pill:hover,
.group-pill.level-1 .remove-pill:hover,
.group-pill.level-2 .remove-pill:hover,
.group-pill.level-3 .remove-pill:hover {
  color: #ffffff;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 50%;
}


/* Base do Bloco */
.rh-group-block {
  border: 1px solid var(--lvl-border, var(--border-subtle));
  border-radius: 6px;
  background: var(--bg-card);
  margin-bottom: 0.5rem;
  overflow: hidden;
}

.rh-group-block.level-1,
.rh-group-block.level-2,
.rh-group-block.level-3 {
  margin: 0.5rem;
}

.rh-group-content {
  border-top: 1px solid var(--lvl-border, var(--border-subtle));
}

.rh-group-header {
  background: var(--lvl-bg, rgba(0,0,0,0.02));
  color: var(--lvl-main, var(--text-primary));
  padding: 0.6rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-weight: 500;
}

.rh-group-header strong {
  font-weight: 600;
}

.rh-group-header .tab-badge {
  background: var(--lvl-badge-bg, var(--bg-main));
  color: var(--lvl-main, var(--text-primary));
  border: none;
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 600;
}
.rh-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-base);
}

.rh-modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.rh-modal {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: var(--space-2xl);
  width: 90%;
  max-width: 500px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
  transform: translateY(20px) scale(0.95);
  transition: all var(--transition-base);
}

.rh-modal-overlay.active .rh-modal {
  transform: translateY(0) scale(1);
}

.rh-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-xl);
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--border-subtle);
}

.rh-modal-header h3 {
  margin: 0;
  font-size: 1.25rem;
  color: var(--text-primary);
}

.rh-modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
  padding: 0.2rem;
}

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

.rh-modal-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.rh-detail-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

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

.rh-detail-value {
  font-size: 1rem;
  color: var(--text-primary);
  background: var(--bg-secondary);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}


/* Estilos Auxiliares para Compras/FAQ */
.btn-back-home-general {
  margin-top: 1.5rem;
}


/* =============================================
   SIDEBAR - Submenu de Colaboradores (RH)
   ============================================= */

/* Link pai com chevron em vez de seta */
.tool-link-parent {
  position: relative;
}

.tool-chevron {
  font-size: 0.7rem;
  opacity: 0.5;
  transition: transform 0.25s ease, opacity 0.25s ease;
  margin-left: auto;
}

.tool-link-parent.open .tool-chevron {
  transform: rotate(180deg);
  opacity: 0.9;
}

.tool-link-parent.open {
  background-color: rgba(255,255,255,0.06);
  color: #fff;
}

/* Submenu colapsavel */
.tool-submenu {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.3s ease, opacity 0.25s ease;
  opacity: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  padding-left: 0.75rem;
}

.tool-submenu.open {
  max-height: 300px;
  opacity: 1;
}

/* Links filhos do submenu (sem margem de icone, mais compactos) */
.tool-link-sub {
  padding: 0.5rem 0.75rem;
  gap: 0.6rem;
  border-left: 2px solid rgba(255,255,255,0.1);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  margin-bottom: 2px;
}

.tool-link-sub:hover:not(.disabled) {
  border-left-color: var(--fpp-red);
}

.tool-link-sub.active {
  border-left-color: #fff !important;
  background-color: rgba(204, 0, 0, 0.8) !important;
}

.tool-link-sub .tool-icon {
  font-size: 0.95rem;
}

.tool-link-sub .tool-text {
  font-size: 0.88rem;
}

/* Badge lateral (contador de colaboradores) */
.tab-badge-side {
  font-size: 0.7rem;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.15);
  color: rgba(255,255,255,0.7);
  padding: 1px 7px;
  border-radius: 20px;
  margin-left: auto;
  min-width: 22px;
  text-align: center;
  line-height: 1.6;
}

.avisos-side-badge {
  background: rgba(245, 158, 11, 0.25);
  color: #f59e0b;
}

