:root {
  /* Core Colors (Refined Bank Theme) */
  --bg-dark: #eef2f6;
  --bg-darker: #e2e8f0;
  --bg-body: #f4f7fa;
  --bg-panel: #ffffff;
  --bg-panel-hover: #f8fafc;
  
  /* Brand Accents (Deep Institutional Navy & Corporate Gold/Teal) */
  --accent-primary: #0a1c2a;
  --accent-secondary: #112b43;
  --accent-teal: #008080;
  --accent-gold: #b27d14;
  --accent-primary-rgb: 10, 28, 42;
  --accent-glow: rgba(10, 28, 42, 0.04);
  
  /* Status Colors (Refined) */
  --status-success: #10b981;
  --status-warning: #f59e0b;
  --status-danger: #ef4444;
  --status-info: #0ea5e9;
  
  /* Text */
  --text-primary: #1e293b;
  --text-secondary: #475569;
  --text-muted: #64748b;
  
  /* Borders */
  --border-light: #cbd5e1;
  --border-glow: rgba(10, 28, 42, 0.08);

  /* Geometry & Spacing (Sharper & Cleaner - Banking Style) */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-full: 9999px;
  
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --spacing-xl: 40px;
  
  /* Typography */
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

[data-theme="dark"] {
  --bg-dark: #0f172a;
  --bg-darker: #020617;
  --bg-body: #0f172a;
  --bg-panel: #1e293b;
  --bg-panel-hover: #334155;
  
  --accent-primary: #3b82f6;
  --accent-secondary: #60a5fa;
  --accent-primary-rgb: 59, 130, 246;
  --accent-glow: rgba(59, 130, 246, 0.15);
  
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  
  --border-light: #334155;
  --border-glow: rgba(59, 130, 246, 0.25);
}

/* Comprehensive Dark Mode Overrides */
[data-theme="dark"] .info-card,
[data-theme="dark"] .toast,
[data-theme="dark"] .btn-secondary,
[data-theme="dark"] .auth-tab.active,
[data-theme="dark"] .form-control,
[data-theme="dark"] .filter-select-premium,
[data-theme="dark"] .pipeline-column,
[data-theme="dark"] .pipeline-card,
[data-theme="dark"] .glass-card,
[data-theme="dark"] .glass-panel,
[data-theme="dark"] .stat-card,
[data-theme="dark"] .timeline-card,
[data-theme="dark"] .lead-info-card,
[data-theme="dark"] .card {
  background: var(--bg-panel) !important;
  border-color: var(--border-light) !important;
  color: var(--text-primary);
}

[data-theme="dark"] .app-sidebar,
[data-theme="dark"] .app-header,
[data-theme="dark"] .filters-container,
[data-theme="dark"] .mobile-bottom-nav,
[data-theme="dark"] .sticky-header {
  background: rgba(15, 23, 42, 0.85) !important;
  backdrop-filter: blur(20px);
  border-color: var(--border-light) !important;
}

[data-theme="dark"] .profile-dropdown-menu {
  background: rgba(15, 23, 42, 0.95) !important;
  border-color: var(--border-light) !important;
}

[data-theme="dark"] .glass-table th {
  background: rgba(59, 130, 246, 0.1) !important;
  border-color: var(--border-light) !important;
}

[data-theme="dark"] .glass-table td {
  border-color: rgba(255, 255, 255, 0.05) !important;
}

[data-theme="dark"] .btn-secondary:hover {
  background: var(--bg-panel-hover) !important;
  color: var(--text-primary) !important;
}

[data-theme="dark"] .form-control:focus {
  background: var(--bg-panel) !important;
}

[data-theme="dark"] .filter-actions button,
[data-theme="dark"] .action-btn {
  background: rgba(255, 255, 255, 0.05) !important;
  border-color: var(--border-light) !important;
  color: var(--text-primary) !important;
}
[data-theme="dark"] .action-btn:hover {
  background: rgba(255, 255, 255, 0.1) !important;
}

[data-theme="dark"] .modal-content, 
[data-theme="dark"] .offcanvas-content,
[data-theme="dark"] .glass-modal,
[data-theme="dark"] .glass-header,
[data-theme="dark"] .glass-footer {
  background: var(--bg-panel) !important;
  border-color: var(--border-light) !important;
}

[data-theme="dark"] .glass-badge {
  background: rgba(255, 255, 255, 0.08) !important;
  color: var(--text-primary) !important;
}

[data-theme="dark"] #globalHeaderSearch {
  background: rgba(0, 0, 0, 0.25) !important;
  color: var(--text-primary) !important;
  border-color: var(--border-light) !important;
}
[data-theme="dark"] #globalHeaderSearch::placeholder {
  color: var(--text-muted) !important;
}

[data-theme="dark"] .bg-white,
[data-theme="dark"] .glass-header,
[data-theme="dark"] .glass-footer {
  background-color: var(--bg-panel) !important;
  background: var(--bg-panel) !important;
}

[data-theme="dark"] .glass-body {
  color: var(--text-primary);
}

[data-theme="dark"] label, 
[data-theme="dark"] h1, 
[data-theme="dark"] h2, 
[data-theme="dark"] h3, 
[data-theme="dark"] h4, 
[data-theme="dark"] h5, 
[data-theme="dark"] h6, 
[data-theme="dark"] p, 
[data-theme="dark"] span {
  color: var(--text-primary);
}

[data-theme="dark"] .text-muted {
  color: var(--text-muted) !important;
}

[data-theme="dark"] .text-secondary {
  color: var(--text-secondary) !important;
}

[data-theme="dark"] .global-page-loader {
  background: rgba(15, 23, 42, 0.85) !important;
}

[data-theme="dark"] .glass-loader-card {
  background: rgba(30, 41, 59, 0.9) !important;
  border-color: rgba(255, 255, 255, 0.05) !important;
}

@media (max-width: 768px) {
  :root {
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 12px;
    --spacing-lg: 16px;
    --spacing-xl: 20px;
  }
  .page-content {
    padding: 12px !important;
    padding-bottom: 100px !important;
  }
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: var(--font-family);
  background: var(--bg-body);
  color: var(--text-primary);
  min-height: 100vh;
  background-attachment: fixed;
  scroll-behavior: smooth;
  opacity: 0;
  transition: opacity 0.35s ease-out;
  /* Fallback: ensure page becomes visible even if JS fails to add .loaded */
  animation: forceVisible 0s 2s forwards;
}

@keyframes forceVisible {
  to { opacity: 1; }
}

body.loaded {
  opacity: 1;
  animation: none;
}

/* Page Transition */
.page-transitioning .page-content {
  opacity: 0 !important;
  transform: translateY(-4px) !important;
  transition: opacity 0.15s ease, transform 0.15s ease !important;
}

.page-content {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.2s ease 0.05s, transform 0.2s ease 0.05s;
}

/* Typography Scale */
h1 { font-size: 2.25rem; font-weight: 700; line-height: 1.2; letter-spacing: -0.02em; }
h2 { font-size: 1.875rem; font-weight: 600; line-height: 1.3; letter-spacing: -0.01em; }
h3 { font-size: 1.5rem; font-weight: 600; line-height: 1.4; }
h4 { font-size: 1.25rem; font-weight: 500; line-height: 1.5; }
p { font-size: 1rem; line-height: 1.6; color: var(--text-secondary); }
small { font-size: 0.875rem; color: var(--text-muted); }

/* Links */
a { color: var(--accent-primary); text-decoration: none; transition: all 0.2s ease; }
a:hover { color: var(--accent-secondary); }

/* Base Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--spacing-sm);
  padding: 12px 24px; border-radius: var(--radius-md); font-family: var(--font-family);
  font-size: 0.95rem; font-weight: 700; cursor: pointer; border: none; outline: none;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
  letter-spacing: 0.2px;
}

.btn-primary {
  background: var(--accent-primary);
  color: #fff; 
  box-shadow: 0 2px 6px rgba(var(--accent-primary-rgb), 0.2);
}

.btn-primary:hover {
  background: var(--accent-secondary);
  transform: translateY(-1px); 
  box-shadow: 0 4px 12px rgba(var(--accent-primary-rgb), 0.3);
}

.btn-primary:active { transform: translateY(0); box-shadow: none; }

.btn-secondary {
  background: var(--bg-panel); color: var(--text-secondary);
  border: 1px solid var(--border-light);
}

.btn-secondary:hover {
  background: var(--bg-dark); color: var(--text-primary);
  border-color: var(--text-muted);
}

.btn-danger {
  background: var(--status-danger);
  color: #ffffff !important;
  box-shadow: 0 2px 6px rgba(225, 29, 72, 0.2);
}
.btn-danger:hover {
  background: #be123c;
  color: #ffffff !important;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(225, 29, 72, 0.3);
}

.btn-success {
  background: var(--status-success);
  color: #ffffff !important;
}
.btn-success:hover {
  background: #047857;
  color: #ffffff !important;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
}

.btn-xs {
  padding: 4px 8px;
  font-size: 0.72rem;
}

/* Auth Segmented Tabs */
.auth-tabs {
  display: flex;
  background: rgba(0, 0, 0, 0.04);
  padding: 4px;
  border-radius: 14px;
  margin-bottom: var(--spacing-lg);
  border: 1px solid rgba(0, 0, 0, 0.02);
}

.auth-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px;
  border: none;
  background: transparent;
  border-radius: 10px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  color: var(--text-muted);
}

.auth-tab i {
  font-size: 0.9rem;
  opacity: 0.7;
}

.auth-tab.active {
  background: var(--bg-panel);
  color: var(--accent-primary);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.auth-tab.active i {
  opacity: 1;
  color: var(--accent-primary);
}

.auth-tab:not(.active):hover {
  background: rgba(0, 0, 0, 0.02);
  color: var(--text-primary);
}

/* Inputs */
.form-group { margin-bottom: var(--spacing-md); }
.form-label { display: block; font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); margin-bottom: 6px; }

.form-control {
  width: 100%; padding: 10px 14px;
  background: var(--bg-panel); border: 1px solid var(--border-light);
  border-radius: var(--radius-sm); color: var(--text-primary);
  font-family: var(--font-family); font-size: 0.9rem; transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.form-control::placeholder { color: var(--text-muted); opacity: 0.7; }
.form-control:focus {
  outline: none; border-color: var(--accent-primary);
  box-shadow: 0 0 0 1.5px var(--accent-primary), 0 0 0 4px var(--accent-glow); background: var(--bg-panel);
}

/* Utility Classes */
.text-center { text-align: center; }
.text-right { text-align: right; }
.mb-1 { margin-bottom: var(--spacing-sm); }
.mb-2 { margin-bottom: var(--spacing-md); }
.mb-3 { margin-bottom: var(--spacing-lg); }
.mb-4 { margin-bottom: var(--spacing-xl); }
.mt-1 { margin-top: var(--spacing-sm); }
.mt-2 { margin-top: var(--spacing-md); }

/* Custom Scrollbar - Light Theme */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* Animations */
@keyframes pulse {
  0% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.05); }
  100% { opacity: 1; transform: scale(1); }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 9999;
}

.toast {
  background: var(--bg-panel);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  min-width: 280px;
  max-width: 380px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.1);
  transform: translateX(120%);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.toast.show {
  transform: translateX(0);
  opacity: 1;
}

.toast-icon { font-size: 1.1rem; flex-shrink: 0; margin-top: 2px; }
.toast-content { flex: 1; }
.toast-title { font-weight: 600; margin-bottom: 2px; color: var(--text-primary); font-size: 0.88rem; }
.toast-message { color: var(--text-secondary); font-size: 0.82rem; line-height: 1.4; }

.toast-close {
  background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 4px; border-radius: 4px; transition: background 0.2s;
}
.toast-close:hover { background: rgba(0,0,0,0.05); color: var(--text-primary); }

.toast.success .toast-icon { color: var(--status-success); }
.toast.error .toast-icon { color: var(--status-danger); }
.toast.info .toast-icon { color: var(--status-info); }
.toast.warning .toast-icon { color: var(--status-warning); }

@media (max-width: 520px) {
  .toast-container {
    left: max(12px, env(safe-area-inset-left));
    right: max(12px, env(safe-area-inset-right));
    bottom: max(80px, env(safe-area-inset-bottom));
  }
  .toast { min-width: 0; max-width: none; width: 100%; }
}

/* Global FAB */
.global-fab {
  position: fixed;
  bottom: 80px;
  right: 24px;
  background: var(--accent-primary);
  color: white;
  border-radius: 50px;
  padding: 12px 24px;
  box-shadow: 0 4px 16px rgba(var(--accent-primary-rgb), 0.35);
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 1000;
  text-decoration: none;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  font-weight: 600;
  font-size: 0.88rem;
}
.global-fab:hover {
  transform: translateY(-2px);
  background: var(--accent-secondary);
  box-shadow: 0 6px 20px rgba(var(--accent-primary-rgb), 0.4);
  color: white;
}
@media (max-width: 768px) {
  .global-fab {
    padding: 14px;
    border-radius: 50%;
    bottom: calc(80px + env(safe-area-inset-bottom));
    right: 16px;
    width: 52px;
    height: 52px;
  }
  .global-fab span { display: none; }
}

/* ─── Process Type Badges ─── */
.process-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.process-badge.clear-file { background: #dcfce7; color: #166534; }
.process-badge.mbdf { background: #fef3c7; color: #92400e; }
.process-badge.bdf { background: #fee2e2; color: #991b1b; }

/* ─── Card Styles ─── */
.info-card {
  background: var(--bg-panel);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: var(--spacing-md);
  transition: all 0.2s;
}
.info-card:hover {
  border-color: rgba(var(--accent-primary-rgb), 0.3);
  box-shadow: 0 4px 12px rgba(0,0,0,0.04);
}

/* ─── Empty State ─── */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}
.empty-state i { font-size: 2.5rem; margin-bottom: var(--spacing-md); opacity: 0.25; }
.empty-state h4 { color: var(--text-secondary); margin-bottom: 6px; font-size: 1rem; }
.empty-state p { font-size: 0.85rem; max-width: 320px; margin: 0 auto; }

/* ─── Glass Table Styles ─── */
.glass-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin-top: 12px;
}
.glass-table th {
  background: var(--bg-dark) !important;
  color: var(--accent-primary) !important;
  text-align: left;
  padding: 10px 14px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 2px solid var(--border-light) !important;
}
.glass-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--bg-dark);
  vertical-align: middle;
  color: var(--text-secondary);
  transition: all 0.2s;
  background: var(--bg-panel);
}
.glass-table tbody tr:nth-child(even) td {
  background: var(--bg-panel-hover);
}
.glass-table tr:hover td {
  background: rgba(10, 28, 42, 0.04) !important;
  color: var(--text-primary);
}
/* ─── Pendings Blinking Alert ─── */
@keyframes pending-blink {
  0% { border-color: rgba(225, 29, 72, 0.2); box-shadow: 0 0 0px rgba(225, 29, 72, 0); }
  50% { border-color: rgba(225, 29, 72, 1); box-shadow: 0 0 12px rgba(225, 29, 72, 0.4); background-color: rgba(225, 29, 72, 0.05); }
  100% { border-color: rgba(225, 29, 72, 0.2); box-shadow: 0 0 0px rgba(225, 29, 72, 0); }
}

.blinking-pending {
  animation: pending-blink 1.5s infinite ease-in-out;
  border-width: 2px !important;
  position: relative;
}

.pending-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  background: var(--status-danger);
  color: white;
  font-size: 0.65rem;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: var(--radius-full);
  box-shadow: 0 2px 6px rgba(225, 29, 72, 0.4);
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 4px;
}

.pending-badge i { font-size: 0.6rem; animation: pulse 1s infinite; }

/* ─── Data Loss Prevention (DLP) Security Settings ─── */
body {
    -webkit-user-select: none;
    -ms-user-select: none;
    user-select: none;
}
/* Allow selection in inputs and textareas */
input, textarea, [contenteditable="true"] {
    -webkit-user-select: auto;
    -ms-user-select: auto;
    user-select: auto;
}

@media print {
    html, body {
        display: none !important;
        opacity: 0 !important;
        visibility: hidden !important;
    }
}

/* ─── Global Page Loader Overlay ─── */
.global-page-loader {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(248, 250, 252, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.4s ease;
    opacity: 1;
}
.global-page-loader.fade-out {
    opacity: 0;
    pointer-events: none;
}
.glass-loader-card {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.5);
    padding: 30px 40px;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}
.loader-spinner {
    width: 44px;
    height: 44px;
    border: 3.5px solid rgba(var(--accent-primary-rgb), 0.1);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s infinite linear;
}
.loader-text {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--accent-primary);
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

/* Address Fetching Block Styling */
.address-fetching-block {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.address-mode-toggle {
    display: flex;
    background: rgba(0, 0, 0, 0.03);
    padding: 4px;
    border-radius: 10px;
    width: fit-content;
    border: 1px solid rgba(0, 0, 0, 0.05);
}
.addr-mode-btn {
    padding: 8px 18px;
    border-radius: 8px;
    border: 1px solid transparent;
    background: transparent;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.addr-mode-btn:hover {
    color: var(--text-primary);
    background: rgba(0, 0, 0, 0.02);
}
.addr-mode-btn.active {
    background: var(--bg-panel);
    color: var(--accent-primary) !important;
    border-color: rgba(0, 0, 0, 0.05);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.04);
}
[data-theme="dark"] .addr-mode-btn.active {
    background: var(--bg-panel) !important;
    color: var(--accent-secondary) !important;
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}
@keyframes spin {
    to { transform: rotate(360deg); }
}
