/* ══════════════════════════════════════════════════════════════
   Depósitos Bancarios – Premium Dark Theme
   ══════════════════════════════════════════════════════════════ */

:root {
  /* Core colors */
  --bg-primary: #06060f;
  --bg-secondary: #0c0c1d;
  --bg-card: rgba(16, 16, 40, 0.7);
  --bg-card-hover: rgba(24, 24, 56, 0.8);
  --bg-surface: rgba(20, 20, 50, 0.5);

  /* Borders */
  --border-subtle: rgba(100, 100, 200, 0.1);
  --border-accent: rgba(120, 100, 255, 0.3);

  /* Text */
  --text-primary: #e8e8f0;
  --text-secondary: #8888aa;
  --text-muted: #555570;

  /* Accent colors */
  --accent-primary: #7c5cfc;
  --accent-primary-glow: rgba(124, 92, 252, 0.3);
  --accent-secondary: #00d4aa;
  --accent-secondary-glow: rgba(0, 212, 170, 0.2);
  --accent-warn: #ff6b6b;
  --accent-warn-glow: rgba(255, 107, 107, 0.2);
  --accent-blue: #4ea8de;
  --accent-amber: #f0a050;

  /* Glassmorphism */
  --glass-bg: rgba(16, 16, 42, 0.6);
  --glass-border: rgba(120, 100, 255, 0.15);
  --glass-blur: 16px;

  /* Sizing */
  --sidebar-width: 240px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-smooth: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Reset & Base ── */

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

html {
  font-size: 14px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Background gradient animation */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background:
    radial-gradient(ellipse at 20% 20%, rgba(124, 92, 252, 0.06) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 80%, rgba(0, 212, 170, 0.04) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

/* ── Layout ── */

.app-layout {
  display: flex;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

/* ── Sidebar ── */

.sidebar {
  width: var(--sidebar-width);
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border-right: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 100;
  transition: transform var(--transition-smooth);
}

.sidebar-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-icon {
  font-size: 1.5rem;
  filter: drop-shadow(0 0 8px var(--accent-primary-glow));
}

.logo-text {
  font-size: 1.25rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.nav-links {
  list-style: none;
  padding: 1rem 0.75rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.925rem;
  transition: all var(--transition-smooth);
  position: relative;
}

.nav-link:hover {
  color: var(--text-primary);
  background: rgba(124, 92, 252, 0.08);
}

.nav-link.active {
  color: var(--text-primary);
  background: rgba(124, 92, 252, 0.12);
}

.nav-link.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background: var(--accent-primary);
  border-radius: 0 4px 4px 0;
  box-shadow: 0 0 12px var(--accent-primary-glow);
}

.nav-icon {
  font-size: 1.15rem;
  width: 24px;
  text-align: center;
}

.nav-badge {
  margin-left: auto;
  background: var(--accent-warn);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 10px;
  min-width: 20px;
  text-align: center;
}

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

/* ── Main Content ── */

.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding: 2rem;
  min-height: 100vh;
}

.content-section {
  display: none;
  animation: fadeInUp 0.4s ease;
}

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

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

/* ── Section Headers ── */

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
}

.section-title {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.section-subtitle {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-top: 0.25rem;
}

/* ── Buttons ── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-smooth);
  text-decoration: none;
}

.btn-primary {
  background: var(--accent-primary);
  color: #fff;
  box-shadow: 0 4px 16px var(--accent-primary-glow);
}

.btn-primary:hover {
  background: #8b6dff;
  transform: translateY(-1px);
  box-shadow: 0 6px 24px var(--accent-primary-glow);
}

.btn-accent {
  background: linear-gradient(135deg, var(--accent-primary), #6040d0);
  color: #fff;
  box-shadow: 0 4px 16px var(--accent-primary-glow);
}

.btn-accent:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 24px var(--accent-primary-glow);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}

.btn-ghost:hover {
  color: var(--text-primary);
  border-color: var(--border-accent);
  background: rgba(124, 92, 252, 0.06);
}

.btn-danger {
  background: rgba(255, 107, 107, 0.1);
  color: var(--accent-warn);
  border: 1px solid rgba(255, 107, 107, 0.2);
}

.btn-danger:hover {
  background: rgba(255, 107, 107, 0.2);
}

.btn-sm {
  padding: 0.4rem 0.8rem;
  font-size: 0.78rem;
}

.btn-icon {
  padding: 0.5rem;
  min-width: 36px;
  justify-content: center;
}

.btn-scan {
  width: 100%;
  justify-content: center;
  padding: 0.75rem;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

/* ── Cards ── */

.card {
  background: var(--bg-card);
  backdrop-filter: blur(8px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  transition: all var(--transition-smooth);
}

.card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-accent);
}

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

.kpi-card {
  position: relative;
  overflow: hidden;
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.kpi-card.purple::before { background: linear-gradient(90deg, var(--accent-primary), #a855f7); }
.kpi-card.green::before { background: linear-gradient(90deg, var(--accent-secondary), #34d399); }
.kpi-card.blue::before { background: linear-gradient(90deg, var(--accent-blue), #60a5fa); }
.kpi-card.amber::before { background: linear-gradient(90deg, var(--accent-amber), #fbbf24); }
.kpi-card.red::before { background: linear-gradient(90deg, var(--accent-warn), #f87171); }

.kpi-icon {
  font-size: 2rem;
  margin-bottom: 0.75rem;
  display: block;
}

.kpi-value {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.kpi-label {
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 500;
  margin-top: 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ── Tables ── */

.table-container {
  background: var(--bg-card);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
  flex-wrap: wrap;
  gap: 0.75rem;
}

.table-title {
  font-size: 1.1rem;
  font-weight: 700;
}

.table-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

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

thead th {
  position: sticky;
  top: 0;
  background: var(--bg-card);
  z-index: 10;
  text-align: left;
  padding: 0.85rem 1rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}

thead th.sortable {
  cursor: pointer;
  user-select: none;
  transition: color var(--transition-fast);
}

thead th.sortable:hover {
  color: var(--accent-primary);
}

thead th.sortable.active {
  color: var(--accent-primary);
}

thead th .sort-indicator {
  margin-left: 0.25rem;
  font-size: 0.65rem;
}

tbody td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid rgba(100, 100, 200, 0.05);
  font-size: 0.875rem;
  vertical-align: middle;
}

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

tbody tr:hover {
  background: rgba(124, 92, 252, 0.04);
}

tbody tr.ignored {
  opacity: 0.4;
}

tbody tr.manually-linked {
  border-left: 3px solid var(--accent-secondary);
}

.amount-cell {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--accent-secondary);
  white-space: nowrap;
}

.date-cell {
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
  white-space: nowrap;
}

.type-cell {
  font-size: 0.8rem;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.desc-cell {
  font-size: 0.8rem;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-secondary);
}

.account-badge {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.account-badge.acc-372 {
  background: rgba(124, 92, 252, 0.12);
  color: var(--accent-primary);
}

.account-badge.acc-501 {
  background: rgba(0, 212, 170, 0.12);
  color: var(--accent-secondary);
}

.status-badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 600;
}

.status-badge.alta {
  background: rgba(0, 212, 170, 0.12);
  color: var(--accent-secondary);
}

.status-badge.baja {
  background: rgba(255, 107, 107, 0.12);
  color: var(--accent-warn);
}

.status-badge.processed {
  background: rgba(0, 212, 170, 0.12);
  color: var(--accent-secondary);
}

.status-badge.error {
  background: rgba(255, 107, 107, 0.12);
  color: var(--accent-warn);
}

/* Estados nuevos de los controles de ingesta */
.status-badge.account_mismatch {
  background: rgba(255, 107, 107, 0.18);
  color: var(--accent-warn);
}

.status-badge.unverified {
  background: rgba(255, 193, 7, 0.15);
  color: #ffc107;
}

.status-badge.duplicate_file {
  background: rgba(255, 107, 107, 0.18);
  color: var(--accent-warn);
}

.status-badge.manual {
  background: rgba(148, 163, 184, 0.18);
  color: #94a3b8;
}

/* Bloque de sesión en la barra lateral */
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.65rem;
  margin-bottom: 0.6rem;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: rgba(124, 92, 252, 0.07);
}

.sidebar-user-avatar {
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-blue));
  color: #fff;
  font-weight: 700;
  font-size: 0.9rem;
}

.sidebar-user-data {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.sidebar-user-data strong {
  font-size: 0.8rem;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-data small {
  font-size: 0.68rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-auth-logout {
  margin-top: 0.35rem;
}

/* Con la barra colapsada sólo queda el avatar */
.sidebar.collapsed .sidebar-user {
  justify-content: center;
  padding: 0.45rem 0.2rem;
}

.sidebar.collapsed .sidebar-user-data {
  display: none;
}

/* Panel de alertas de ingesta */
.ingest-alerts {
  border: 1px solid rgba(255, 193, 7, 0.35);
  background: rgba(255, 193, 7, 0.06);
  border-radius: 10px;
  padding: 1rem 1.15rem;
  margin-bottom: 1.25rem;
}

.ingest-alerts.has-errors {
  border-color: rgba(255, 107, 107, 0.45);
  background: rgba(255, 107, 107, 0.07);
}

.ingest-alerts-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.ingest-alerts-title {
  font-size: 0.95rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.ingest-event {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  padding: 0.55rem 0.25rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 0.82rem;
}

.ingest-event:first-of-type {
  border-top: none;
}

.ingest-event-icon {
  font-size: 0.95rem;
  line-height: 1.2;
}

.ingest-event-body { flex: 1; min-width: 0; }

.ingest-event-meta {
  color: var(--text-muted);
  font-size: 0.72rem;
  margin-top: 0.15rem;
}

.ingest-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.manual-badge {
  display: inline-block;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-size: 0.65rem;
  font-weight: 600;
  background: rgba(78, 168, 222, 0.15);
  color: var(--accent-blue);
  margin-left: 0.5rem;
}

.clickable-row {
  cursor: pointer;
}

/* ── Search & Filters ── */

.search-box {
  position: relative;
}

.search-box input,
.filter-select {
  width: 100%;
  padding: 0.7rem 1rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.875rem;
  transition: all var(--transition-fast);
  outline: none;
}

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

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

.filter-bar {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}

.filter-select {
  width: auto;
  min-width: 160px;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M6 8L1 3h10z' fill='%238888aa'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2rem;
}

/* ── Date Filter ── */

.date-filter-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.date-filter-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
}

.date-input {
  padding: 0.5rem 0.6rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.8rem;
  transition: all var(--transition-fast);
  outline: none;
  width: 140px;
  color-scheme: dark;
}

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

.date-filter-sep {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.date-filter-clear {
  opacity: 0;
  pointer-events: none;
  transition: all var(--transition-fast);
  color: var(--accent-warn) !important;
  font-size: 0.9rem;
}

.date-filter-clear.visible {
  opacity: 1;
  pointer-events: auto;
}

.btn-accent {
  background: var(--accent-primary);
  color: #fff;
  font-weight: 600;
}

.btn-accent:hover {
  background: var(--accent-secondary);
  transform: translateY(-1px);
}

/* ── Charts ── */


.chart-container {
  position: relative;
  height: 280px;
  margin-top: 1rem;
}

.chart-container canvas {
  width: 100% !important;
  height: 100% !important;
}

/* ── Grid layouts ── */

.dashboard-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.dashboard-grid-full {
  grid-column: 1 / -1;
}

/* ── Modal ── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  width: 90%;
  max-width: 520px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

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

.modal-header h3 {
  font-size: 1.1rem;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.modal-close:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
}

.modal-deposit-info {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-bottom: 1rem;
  padding: 0.75rem;
  background: rgba(124, 92, 252, 0.06);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.client-search-results {
  margin-top: 1rem;
  max-height: 300px;
  overflow-y: auto;
}

.client-result-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  border: 1px solid transparent;
}

.client-result-item:hover {
  background: rgba(124, 92, 252, 0.08);
  border-color: var(--border-accent);
}

.client-result-name {
  font-weight: 600;
  font-size: 0.9rem;
}

.client-result-cuit {
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}

/* ── Toast ── */

.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 500;
  animation: toastSlideIn 0.3s ease;
  max-width: 400px;
  backdrop-filter: blur(12px);
}

@keyframes toastSlideIn {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}

.toast.success {
  background: rgba(0, 212, 170, 0.15);
  border: 1px solid rgba(0, 212, 170, 0.3);
  color: var(--accent-secondary);
}

.toast.error {
  background: rgba(255, 107, 107, 0.15);
  border: 1px solid rgba(255, 107, 107, 0.3);
  color: var(--accent-warn);
}

.toast.info {
  background: rgba(78, 168, 222, 0.15);
  border: 1px solid rgba(78, 168, 222, 0.3);
  color: var(--accent-blue);
}

/* ── Loading spinner ── */

.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-subtle);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

.loading-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4rem;
  flex-direction: column;
  gap: 1rem;
  color: var(--text-secondary);
}

/* ── Empty state ── */

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

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

.empty-state-text {
  font-size: 1rem;
  margin-bottom: 0.5rem;
}

/* ── Client detail back button ── */

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 1rem;
  cursor: pointer;
  transition: color var(--transition-fast);
}

.back-link:hover {
  color: var(--accent-primary);
}

/* ── Top clients list ── */

.top-client-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0;
  border-bottom: 1px solid rgba(100, 100, 200, 0.06);
}

.top-client-item:last-child {
  border-bottom: none;
}

.top-client-rank {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(124, 92, 252, 0.12);
  color: var(--accent-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  margin-right: 0.75rem;
  flex-shrink: 0;
}

.top-client-info {
  flex: 1;
  min-width: 0;
}

.top-client-name {
  font-weight: 600;
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-client-count {
  color: var(--text-muted);
  font-size: 0.75rem;
}

.top-client-amount {
  font-weight: 700;
  color: var(--accent-secondary);
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  margin-left: 1rem;
}

/* ── Responsive ── */

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

@media (max-width: 768px) {
  :root {
    --sidebar-width: 0px;
  }

  .sidebar {
    transform: translateX(-100%);
    width: 240px;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-content {
    margin-left: 0;
    padding: 1rem;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  table {
    font-size: 0.8rem;
  }
}

/* ── Scrollbar ── */

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

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

::-webkit-scrollbar-thumb {
  background: rgba(120, 100, 255, 0.2);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(120, 100, 255, 0.35);
}

/* ── Pagination ── */

.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem;
}

.pagination button {
  padding: 0.4rem 0.8rem;
}

.pagination .page-info {
  color: var(--text-secondary);
  font-size: 0.8rem;
  margin: 0 0.5rem;
}

/* ── Tooltip ── */

[data-tooltip] {
  position: relative;
}

[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  font-size: 0.75rem;
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  white-space: nowrap;
  z-index: 50;
  pointer-events: none;
}

/* ── Floating Sticky Bulk Action Bar ── */

.bulk-action-bar {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(120px);
  z-index: 9000;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 0.85rem 1.75rem;
  background: rgba(18, 24, 43, 0.96);
  border: 1.5px solid var(--accent-primary);
  border-radius: 40px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6), 0 0 30px rgba(124, 92, 252, 0.35);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
}

.bulk-action-bar.visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.bulk-count {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent-primary);
}

/* ── Styled Checkboxes ── */

.checkbox-styled {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border: 2px solid var(--border-accent);
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
  position: relative;
  transition: all var(--transition-fast);
  vertical-align: middle;
}

.checkbox-styled:hover {
  border-color: var(--accent-primary);
  background: rgba(124, 92, 252, 0.1);
}

.checkbox-styled:checked {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
}

.checkbox-styled:checked::after {
  content: '✓';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
}

/* ── Selected Rows ── */

tbody tr.row-selected {
  background: rgba(124, 92, 252, 0.08);
  border-left: 3px solid var(--accent-primary);
}

tbody tr.row-selected:hover {
  background: rgba(124, 92, 252, 0.12);
}

/* ── Connection Setup Screen ── */

.btn-icon-setting {
  background: none;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0.35rem 0.5rem;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast), transform var(--transition-fast);
  color: var(--text-secondary);
}

.btn-icon-setting:hover {
  background: rgba(255, 255, 255, 0.08);
  transform: rotate(45deg);
}

.connection-setup-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(10, 14, 26, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  overflow-y: auto;
  animation: fadeInOverlay 0.3s ease;
}

@keyframes fadeInOverlay {
  from { opacity: 0; }
  to { opacity: 1; }
}

.connection-setup-card {
  width: 100%;
  max-width: 580px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-modal), 0 0 40px rgba(124, 92, 252, 0.15);
  padding: 2.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  animation: modalSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.connection-header {
  text-align: center;
}

.connection-icon {
  font-size: 3rem;
  margin-bottom: 0.5rem;
  display: inline-block;
  background: rgba(124, 92, 252, 0.12);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-accent);
}

.connection-header h2 {
  font-size: 1.4rem;
  font-weight: 800;
  margin-bottom: 0.4rem;
  background: linear-gradient(135deg, var(--text-primary), var(--accent-primary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.connection-subtitle {
  color: var(--text-secondary);
  font-size: 0.88rem;
  line-height: 1.4;
}

.connection-form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
}

.form-control {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: inherit;
  width: 100%;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-control:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(124, 92, 252, 0.2);
}

.input-with-action {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.input-with-action input {
  flex: 1;
}

.form-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.form-hint code {
  background: rgba(255, 255, 255, 0.06);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  color: var(--accent-blue);
  font-size: 0.75rem;
}

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

.btn-lg {
  padding: 0.85rem 1.5rem;
  font-size: 0.95rem;
  font-weight: 700;
}

/* Live Validation Result Card */

.validation-result-card {
  background: rgba(18, 26, 44, 0.8);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  animation: fadeInOverlay 0.2s ease;
}

.validation-result-card.success {
  border-color: rgba(0, 212, 170, 0.4);
  background: rgba(0, 212, 170, 0.06);
}

.validation-result-card.error {
  border-color: rgba(255, 107, 107, 0.4);
  background: rgba(255, 107, 107, 0.06);
}

.val-status-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
  font-size: 0.95rem;
}

.val-status-header.success {
  color: var(--accent-secondary);
}

.val-status-header.error {
  color: var(--accent-warn);
}

.val-message {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.val-details {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px dashed rgba(255, 255, 255, 0.1);
}

.val-detail-item {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
}

.val-detail-label {
  color: var(--text-muted);
}

.val-detail-val {
  font-weight: 700;
  color: var(--text-primary);
}

.val-accounts-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.25rem;
}

.val-account-chip {
  font-size: 0.75rem;
  padding: 0.2rem 0.6rem;
  border-radius: 12px;
  background: rgba(124, 92, 252, 0.15);
  border: 1px solid var(--border-accent);
  color: var(--accent-primary);
  font-weight: 600;
}

/* ── Protocol Form Rows & Dynamic Fieldsets ── */

.form-row {
  display: flex;
  gap: 0.85rem;
}

.flex-1 { flex: 1; }
.flex-2 { flex: 2; }

.protocol-fieldset {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  animation: fadeInOverlay 0.25 ease;
}

.btn-toggle-pw {
  padding: 0 0.6rem;
  font-size: 1rem;
}

/* ── Live Folder Tree View ── */

.folder-tree-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent-primary);
  margin-top: 0.5rem;
}

.folder-tree-view {
  background: rgba(10, 15, 28, 0.9);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.8rem;
  max-height: 160px;
  overflow-y: auto;
  font-family: monospace;
  font-size: 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.tree-node {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--text-primary);
}

.tree-node.is-dir {
  font-weight: 600;
  color: var(--accent-secondary);
}

.tree-node-icon {
  font-size: 0.9rem;
}

.tree-node-badge {
  margin-left: auto;
  font-size: 0.7rem;
  background: rgba(124, 92, 252, 0.2);
  color: var(--accent-primary);
  padding: 0.15rem 0.45rem;
  border-radius: 10px;
  font-weight: 700;
}

/* ── Quick Connection Confirmation Card ── */

.quick-connection-card {
  background: rgba(0, 212, 170, 0.06);
  border: 1px solid rgba(0, 212, 170, 0.3);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.quick-conn-badge {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.quick-conn-info {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.quick-conn-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.quick-conn-path {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-family: monospace;
}

.quick-conn-actions {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 0.25rem;
}

/* Sidebar Footer Logout Button */

.sidebar-footer {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.btn-logout {
  width: 100%;
  color: var(--accent-warn);
  border: 1px solid rgba(255, 107, 107, 0.2);

  transition: all var(--transition-fast);
}

.btn-logout:hover {
  background: rgba(255, 107, 107, 0.1);
  border-color: rgba(255, 107, 107, 0.4);
}

/* ── Global Sync & Dashboard Locking Overlay ── */

.sync-progress-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(10, 14, 26, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  animation: fadeInOverlay 0.3s ease;
}

.sync-progress-card {
  width: 100%;
  max-width: 480px;
  background: var(--bg-card);
  border: 1px solid var(--accent-primary);
  border-radius: var(--radius-lg);
  box-shadow: 0 0 50px rgba(124, 92, 252, 0.25);
  padding: 2.5rem 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 1.25rem;
}

.sync-spinner-lg {
  width: 54px;
  height: 54px;
  border: 4px solid rgba(124, 92, 252, 0.2);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

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

.sync-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
}

.sync-msg {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.sync-lock-badge {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent-warn);
  background: rgba(255, 107, 107, 0.12);
  border: 1px solid rgba(255, 107, 107, 0.3);
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ── Sidebar Collapsible & Nav Categorization ── */

.sidebar {
  transition: width var(--transition-smooth);
}

.main-content {
  transition: margin-left var(--transition-smooth);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-header-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.nav-category-title {
  padding: 0.85rem 1.25rem 0.35rem 1.25rem;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  text-transform: uppercase;
  user-select: none;
  transition: opacity var(--transition-fast);
}

.nav-badge-usd {
  background: #10b981;
  color: #06060f;
}

/* Collapsed Sidebar State */
.sidebar.collapsed {
  width: 72px;
}

.sidebar.collapsed ~ .main-content {
  margin-left: 72px;
}

.sidebar.collapsed .logo-text,
.sidebar.collapsed .nav-label,
.sidebar.collapsed .nav-category-title,
.sidebar.collapsed .btn-scan-label,
.sidebar.collapsed .btn-logout-label {
  display: none !important;
}

.sidebar.collapsed .sidebar-header {
  padding: 1rem 0.5rem;
  justify-content: center;
  flex-direction: column;
  gap: 0.5rem;
}

.sidebar.collapsed .sidebar-header-actions {
  flex-direction: column;
}

.sidebar.collapsed .nav-link {
  justify-content: center;
  padding: 0.75rem 0.5rem;
  gap: 0;
}

.sidebar.collapsed .nav-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  margin-left: 0;
  font-size: 0.6rem;
  padding: 0.1rem 0.35rem;
}

.sidebar.collapsed .sidebar-footer {
  padding: 0.75rem 0.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.sidebar.collapsed .btn-scan,
.sidebar.collapsed .btn-logout {
  padding: 0.6rem 0.2rem;
  justify-content: center;
}

/* Date Preset Buttons for USD Expenses */
.btn-date-preset {
  background-color: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-color);
  padding: 0.4rem 0.8rem;
  border-radius: var(--border-radius-sm, 6px);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all var(--transition-fast, 0.2s ease);
}

.btn-date-preset:hover {
  background-color: rgba(var(--primary-rgb, 59, 130, 246), 0.1);
  border-color: var(--primary-color, #3b82f6);
}

.btn-date-preset.active {
  background-color: var(--primary-color, #3b82f6);
  color: white;
  border-color: var(--primary-color, #3b82f6);
  box-shadow: 0 2px 4px rgba(var(--primary-rgb, 59, 130, 246), 0.3);
}

.date-filters-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
  align-items: center;
}

.custom-date-range {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: 0.5rem;
  padding-left: 0.5rem;
  border-left: 1px solid var(--border-color);
}

.custom-date-range input[type="date"] {
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm, 6px);
  background-color: var(--card-bg);
  color: var(--text-color);
  font-size: 0.85rem;
}
