/* ==========================================================================
   MITHUNRAM TEX CRM - DESIGN SYSTEM & BRAND STYLING
   ========================================================================== */

/* --- CSS Theme Variables --- */
:root {
  /* Fonts */
  --font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  
  /* Color Palette - Light Mode Default (will be updated dynamically) */
  --hue-primary: 260; /* Indigo base */
  --hue-accent: 320;  /* Magenta/Pink print base */
  
  --bg-app: hsl(210, 40%, 98%);
  --bg-sidebar: hsl(222, 20%, 90%);
  --bg-card: hsl(0, 0%, 100%);
  --bg-input: hsl(210, 40%, 95%);
  --border-color: hsl(210, 30%, 88%);
  
  --text-main: hsl(222, 47%, 12%);
  --text-muted: hsl(222, 20%, 45%);
  --text-light: hsl(0, 0%, 100%);
  
  --color-primary: hsl(var(--hue-primary), 85%, 50%);
  --color-primary-hover: hsl(var(--hue-primary), 90%, 42%);
  --color-accent: hsl(var(--hue-accent), 85%, 55%);
  
  --color-success: hsl(145, 80%, 40%);
  --color-warning: hsl(38, 95%, 50%);
  --color-danger: hsl(354, 85%, 50%);
  
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 8px 20px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 16px 36px rgba(0, 0, 0, 0.12);
  --glass-bg: rgba(255, 255, 255, 0.7);
  --glass-border: rgba(255, 255, 255, 0.5);
  --glass-blur: blur(12px);
  
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-pill: 9999px;
  
  --transition-fast: 0.15s ease;
  --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.5s ease;
}

[data-theme="dark"] {
  /* Color Palette - Dark Mode */
  --bg-app: hsl(222, 47%, 10%);
  --bg-sidebar: hsl(223, 47%, 13%);
  --bg-card: hsl(223, 47%, 15%);
  --bg-input: hsl(222, 40%, 8%);
  --border-color: hsl(222, 30%, 20%);
  
  --text-main: hsl(210, 40%, 98%);
  --text-muted: hsl(210, 25%, 70%);
  
  --color-primary: hsl(var(--hue-primary), 85%, 60%);
  --color-primary-hover: hsl(var(--hue-primary), 90%, 70%);
  --color-accent: hsl(var(--hue-accent), 80%, 60%);
  
  --color-success: hsl(145, 75%, 45%);
  --color-warning: hsl(38, 90%, 55%);
  --color-danger: hsl(354, 85%, 55%);
  
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 8px 30px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 16px 50px rgba(0, 0, 0, 0.45);
  
  --glass-bg: rgba(30, 30, 45, 0.45);
  --glass-border: rgba(255, 255, 255, 0.08);
}

/* --- Base Resets & Typography --- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-app);
  color: var(--text-main);
  overflow-x: hidden;
  transition: background-color var(--transition-normal), color var(--transition-normal);
  -webkit-tap-highlight-color: transparent;
}

button, input, textarea, select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  outline: none;
}

a {
  text-decoration: none;
  color: inherit;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-app);
}
::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: var(--radius-pill);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* --- Layout Architecture --- */
#app {
  display: flex;
  min-height: 100vh;
  position: relative;
}

.app-container {
  display: flex;
  width: 100%;
  position: relative;
}

/* Initial Fullscreen Loader */
.initial-loader {
  position: fixed;
  inset: 0;
  background: var(--bg-app);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}
.loader-content {
  text-align: center;
  width: 280px;
}
.loader-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--color-primary);
  margin-bottom: 24px;
}
.logo-icon-spin {
  width: 32px;
  height: 32px;
  border: 4px solid var(--border-color);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: spin 1s infinite linear;
}
.loader-text {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.loader-bar {
  height: 4px;
  background: var(--border-color);
  border-radius: var(--radius-pill);
  overflow: hidden;
}
.loader-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--color-primary), var(--color-accent));
  width: 40%;
  animation: loading-bar 1.5s infinite ease-in-out;
}

/* Sidebar (Desktop) */
.sidebar {
  width: 260px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
  z-index: 100;
  transition: transform var(--transition-normal), background var(--transition-normal);
}
.sidebar-header {
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border-color);
}
.logo-box {
  background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-light);
  font-weight: 800;
  font-size: 1.25rem;
  box-shadow: var(--shadow-sm);
}
.brand-name {
  font-weight: 700;
  font-size: 1.2rem;
  background: linear-gradient(to right, var(--text-main), var(--color-accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.sidebar-menu {
  list-style: none;
  padding: 24px 16px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.menu-item a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-weight: 500;
  color: var(--text-muted);
  transition: all var(--transition-fast);
}
.menu-item.active a {
  background: linear-gradient(135deg, rgba(95, 61, 196, 0.15), rgba(200, 30, 150, 0.05));
  color: var(--color-primary);
  border-left: 4px solid var(--color-primary);
  padding-left: 12px;
}
.menu-item:not(.active) a:hover {
  background: var(--bg-card);
  color: var(--text-main);
  transform: translateX(4px);
}
.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border-color);
}
.user-profile-widget {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-card);
  padding: 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}
.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--color-primary);
}
.user-info {
  flex: 1;
  min-width: 0;
}
.user-name {
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-role {
  font-size: 0.75rem;
  color: var(--text-muted);
}
.btn-logout {
  background: none;
  border: none;
  color: var(--color-danger);
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition-fast);
}
.btn-logout:hover {
  background: rgba(230, 50, 50, 0.1);
}

/* Main Area */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100vh;
}
.header {
  padding-top: env(safe-area-inset-top, 0px);
  min-height: calc(70px + env(safe-area-inset-top, 0px));
  border-bottom: 1px solid var(--border-color);
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  position: sticky;
  top: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-left: 32px;
  padding-right: 32px;
  box-sizing: border-box;
}
.page-title-box h1 {
  font-size: 1.4rem;
  font-weight: 700;
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}
.btn-header-action {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: all var(--transition-fast);
}
.btn-header-action:hover {
  background: var(--border-color);
  color: var(--color-primary);
  transform: scale(1.05);
}
.badge-dot {
  position: absolute;
  top: 0;
  right: 0;
  width: 10px;
  height: 10px;
  background: var(--color-danger);
  border: 2px solid var(--bg-card);
  border-radius: 50%;
}

.main-content {
  flex: 1;
  padding: 32px;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

/* Bottom Navigation (Mobile Only) */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  border-top: 1px solid var(--border-color);
  min-height: calc(64px + env(safe-area-inset-bottom, 0px));
  z-index: 100;
  justify-content: space-around;
  align-items: center;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  box-sizing: border-box;
}
.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-muted);
  gap: 4px;
  padding: 8px;
}
.bottom-nav-item.active {
  color: var(--color-primary);
}

/* --- Common UI Components --- */

/* Grid and Cards */
.grid-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 24px;
  margin-bottom: 32px;
}
.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-normal);
  position: relative;
  overflow: hidden;
}
.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--color-primary);
}
.kpi-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
  border-color: rgba(95, 61, 196, 0.3);
}
.kpi-card.kpi-new::before { background: var(--color-primary); }
.kpi-card.kpi-exist::before { background: var(--color-accent); }
.kpi-card.kpi-due::before { background: var(--color-warning); }
.kpi-card.kpi-overdue::before { background: var(--color-danger); }

.kpi-info h3 {
  font-size: 0.85rem;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}
.kpi-info .kpi-value {
  font-size: 2.2rem;
  font-weight: 800;
  line-height: 1.1;
}
.kpi-icon-box {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-app);
}
.kpi-card.kpi-new .kpi-icon-box { color: var(--color-primary); background: rgba(95, 61, 196, 0.1); }
.kpi-card.kpi-exist .kpi-icon-box { color: var(--color-accent); background: rgba(200, 30, 150, 0.1); }
.kpi-card.kpi-due .kpi-icon-box { color: var(--color-warning); background: rgba(230, 126, 34, 0.1); }
.kpi-card.kpi-overdue .kpi-icon-box { color: var(--color-danger); background: rgba(230, 50, 50, 0.1); }

/* Section Header */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}
.section-header h2 {
  font-size: 1.25rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Glassmorphic Base Card */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  transition: background var(--transition-normal), border var(--transition-normal);
  position: relative;
}
.card-glass {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
}

/* Charts Section */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 24px;
  margin-bottom: 32px;
}
.chart-container {
  height: 300px;
  position: relative;
  width: 100%;
}

/* Lists and Tables */
.table-container {
  overflow-x: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-card);
}
.table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}
.table th, .table td {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
}
.table th {
  background: var(--bg-sidebar);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}
.table tr:last-child td {
  border-bottom: none;
}
.table tbody tr {
  transition: background var(--transition-fast);
}
.table tbody tr:hover {
  background: rgba(95, 61, 196, 0.03);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-priority-high { background: rgba(230, 50, 50, 0.1); color: var(--color-danger); }
.badge-priority-medium { background: rgba(230, 126, 34, 0.1); color: var(--color-warning); }
.badge-priority-low { background: rgba(95, 61, 196, 0.1); color: var(--color-primary); }

.badge-type-new { background: rgba(95, 61, 196, 0.1); color: var(--color-primary); }
.badge-type-existing { background: rgba(200, 30, 150, 0.1); color: var(--color-accent); }

.badge-status-pending { background: rgba(230, 126, 34, 0.1); color: var(--color-warning); }
.badge-status-completed { background: rgba(46, 204, 113, 0.1); color: var(--color-success); }
.badge-status-overdue { background: rgba(230, 50, 50, 0.1); color: var(--color-danger); }

/* --- Forms & Buttons --- */
.form-group {
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.form-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}
.form-control {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 0.95rem;
  transition: all var(--transition-fast);
}
.form-control:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(95, 61, 196, 0.15);
  background: var(--bg-card);
}
textarea.form-control {
  resize: vertical;
  min-height: 100px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-normal);
  border: none;
  font-size: 0.95rem;
}
.btn-primary {
  background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
  color: var(--text-light);
  box-shadow: 0 4px 15px rgba(95, 61, 196, 0.3);
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(95, 61, 196, 0.45);
  filter: brightness(1.1);
}
.btn-secondary {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-main);
}
.btn-secondary:hover {
  background: var(--border-color);
}
.btn-danger {
  background: var(--color-danger);
  color: var(--text-light);
}
.btn-danger:hover {
  filter: brightness(1.1);
}

.btn:active {
  transform: translateY(0);
}

/* Floating Action Button (FAB) */
.fab-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
  color: var(--text-light);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  z-index: 80;
  border: none;
  transition: transform var(--transition-fast);
}
.fab-btn:hover {
  transform: scale(1.1) rotate(90deg);
}

/* File Upload & Dropzone */
.dropzone {
  border: 2px dashed var(--border-color);
  background: var(--bg-input);
  border-radius: var(--radius-md);
  padding: 32px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-normal);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.dropzone:hover, .dropzone.active {
  border-color: var(--color-primary);
  background: rgba(95, 61, 196, 0.05);
}
.dropzone-icon {
  font-size: 2rem;
  color: var(--color-primary);
}
.file-list {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
}

/* --- OCR Scanning Overlay & Modal --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn 0.25s ease;
}
.modal-container {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 800px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}
.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-header h3 {
  font-size: 1.2rem;
  font-weight: 700;
}
.btn-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
}
.btn-close:hover {
  color: var(--text-main);
}
.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-sidebar);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* OCR Modal Split Layout */
.ocr-split-layout {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 24px;
}
.ocr-preview-panel {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  background: var(--bg-input);
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 50vh;
  overflow: hidden;
}
.ocr-image-preview {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
  border-radius: var(--radius-sm);
}
.ocr-suggested-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.ocr-field-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  padding: 12px;
  border-radius: var(--radius-sm);
  transition: border-color var(--transition-fast);
}
.ocr-field-row:hover {
  border-color: var(--color-primary);
}
.ocr-checkbox-wrapper {
  margin-top: 4px;
}
.ocr-field-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ocr-field-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.ocr-field-label {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--color-primary);
}
.ocr-field-badge {
  font-size: 0.65rem;
  font-weight: 600;
  background: rgba(46, 204, 113, 0.15);
  color: var(--color-success);
  padding: 2px 6px;
  border-radius: var(--radius-pill);
}
.ocr-field-input {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 0.9rem;
}
.ocr-field-input:focus {
  border-color: var(--color-accent);
}

/* OCR Scan Loader screen */
.ocr-scan-loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 48px;
  text-align: center;
  position: relative;
}
.scan-animation-box {
  width: 180px;
  height: 180px;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  position: relative;
  overflow: hidden;
  background: var(--bg-input);
}
.scan-line {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: linear-gradient(to right, transparent, var(--color-accent), transparent);
  animation: scan 2s infinite ease-in-out;
}
.scan-progress-bar {
  width: 100%;
  max-width: 300px;
  height: 6px;
  background: var(--border-color);
  border-radius: var(--radius-pill);
  overflow: hidden;
  margin-top: 12px;
}
.scan-progress-fill {
  height: 100%;
  background: var(--color-accent);
  transition: width 0.3s ease;
}

/* --- Search & Advanced Filters Bar --- */
.search-filter-bar {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.search-row {
  display: flex;
  gap: 12px;
}
.search-input-wrapper {
  flex: 1;
  position: relative;
}
.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}
.search-input-wrapper .form-control {
  padding-left: 44px;
  width: 100%;
}
.filters-toggle-btn {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  padding: 0 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
}
.filters-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  border-top: 1px solid var(--border-color);
  padding-top: 16px;
  animation: slideDown 0.2s ease;
}

/* --- Notification Drawer --- */
.notification-drawer {
  position: fixed;
  top: 70px;
  right: 32px;
  width: 380px;
  max-height: 500px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 900;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slideDown 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.notif-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
}
.notif-list {
  overflow-y: auto;
  max-height: 400px;
}
.notif-item {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  gap: 12px;
  position: relative;
  transition: background var(--transition-fast);
}
.notif-item:hover {
  background: rgba(95, 61, 196, 0.03);
}
.notif-item.unread {
  background: rgba(95, 61, 196, 0.05);
}
.notif-icon-circle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.notif-item.due .notif-icon-circle { background: rgba(230, 126, 34, 0.1); color: var(--color-warning); }
.notif-item.overdue .notif-icon-circle { background: rgba(230, 50, 50, 0.1); color: var(--color-danger); }
.notif-item.upcoming .notif-icon-circle { background: rgba(95, 61, 196, 0.1); color: var(--color-primary); }

.notif-content {
  flex: 1;
}
.notif-title {
  font-weight: 600;
  font-size: 0.85rem;
  margin-bottom: 4px;
}
.notif-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.3;
}
.notif-time {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 6px;
}
.notif-empty {
  padding: 32px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* PWA Installation Toast */
.pwa-toast {
  position: fixed;
  bottom: 24px;
  left: 24px;
  background: var(--bg-card);
  border: 1px solid var(--color-primary);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  max-width: 350px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: slideUp 0.3s ease;
}
.pwa-toast-header {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
  font-size: 0.95rem;
}
.pwa-toast-body {
  font-size: 0.85rem;
  color: var(--text-muted);
}
.pwa-toast-actions {
  display: flex;
  gap: 10px;
}

/* Login Page Layout */
.login-container {
  display: flex;
  min-height: 100vh;
  width: 100%;
  align-items: center;
  justify-content: center;
  position: relative;
  background: radial-gradient(circle at 10% 20%, rgba(95, 61, 196, 0.15) 0%, transparent 40%),
              radial-gradient(circle at 90% 80%, rgba(200, 30, 150, 0.12) 0%, transparent 40%);
}
.login-card {
  width: 100%;
  max-width: 420px;
  padding: 40px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}
.login-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
}
.login-logo .logo-box {
  width: 56px;
  height: 56px;
  font-size: 1.8rem;
  border-radius: var(--radius-md);
}
.login-logo h2 {
  font-size: 1.6rem;
  font-weight: 800;
}
.login-logo p {
  font-size: 0.85rem;
  color: var(--text-muted);
}
.login-error {
  background: rgba(230, 50, 50, 0.1);
  border: 1px solid var(--color-danger);
  color: var(--color-danger);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  margin-bottom: 20px;
  text-align: center;
}
.demo-accounts {
  margin-top: 24px;
  border-top: 1px solid var(--border-color);
  padding-top: 16px;
}
.demo-accounts-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 12px;
  text-align: center;
}
.demo-buttons-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.btn-demo-account {
  font-size: 0.8rem;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: center;
  font-weight: 500;
  transition: all var(--transition-fast);
}
.btn-demo-account:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

/* Reports layout styling */
.report-preview-box {
  margin-top: 24px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  padding: 24px;
  overflow: hidden;
}
.report-header-preview {
  text-align: center;
  margin-bottom: 24px;
  border-bottom: 2px solid var(--border-color);
  padding-bottom: 16px;
}
.report-header-preview h2 {
  color: var(--color-primary);
  font-size: 1.5rem;
}
.report-metadata {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 8px;
}

/* Lead Detail Panel styling */
.lead-detail-modal-grid {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 24px;
}
.lead-detail-meta-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.lead-detail-meta-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 10px;
}
.lead-detail-meta-item:last-child {
  border-bottom: none;
}
.lead-detail-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 700;
}
.lead-detail-val {
  font-size: 1rem;
  font-weight: 500;
}
.lead-detail-remarks {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  padding: 16px;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  line-height: 1.5;
}

/* --- KEYFRAME ANIMATIONS --- */
@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes loading-bar {
  0% { transform: translateX(-100%); }
  50% { transform: translateX(150%); }
  100% { transform: translateX(300%); }
}
@keyframes scan {
  0% { top: 0; }
  50% { top: 180px; }
  100% { top: 0; }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
@keyframes slideDown {
  from { transform: translateY(-10px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* --- RESPONSIVE ADJUSTMENTS (Mobile First) --- */
@media (max-width: 768px) {
  .sidebar {
    display: none; /* Hide desktop sidebar */
  }
  
  .header {
    padding-left: 16px;
    padding-right: 16px;
    padding-top: env(safe-area-inset-top, 0px);
    min-height: calc(60px + env(safe-area-inset-top, 0px));
    height: auto;
    box-sizing: border-box;
  }
  
  .page-title-box h1 {
    font-size: 1.15rem;
  }
  
  .main-content {
    padding: 16px;
    padding-bottom: 96px; /* Space for bottom nav */
  }
  
  .bottom-nav {
    display: flex;
  }
  
  .charts-grid {
    grid-template-columns: 1fr;
  }
  
  .ocr-split-layout, .lead-detail-modal-grid {
    grid-template-columns: 1fr;
  }
  
  .ocr-preview-panel {
    max-height: 35vh;
  }
  
  .table-container {
    border: none;
  }
  .table th, .table td {
    padding: 12px 14px;
    font-size: 0.85rem;
  }
  
  .kpi-card {
    padding: 16px;
  }
  .kpi-info .kpi-value {
    font-size: 1.8rem;
  }
  
  .pwa-toast {
    left: 16px;
    right: 16px;
    max-width: none;
    bottom: 80px; /* Above mobile navbar */
  }
}

/* --- PRINT-SPECIFIC CSS (For Reports PDF exports) --- */
@media print {
  body {
    background: #fff !important;
    color: #000 !important;
  }
  .sidebar, .header, .bottom-nav, .fab-btn, .btn, .search-filter-bar, .modal-footer, .btn-header-action {
    display: none !important;
  }
  .main-wrapper {
    min-height: 0;
  }
  .main-content {
    padding: 0 !important;
    max-width: 100% !important;
  }
  .card, .table-container, .report-preview-box {
    border: none !important;
    box-shadow: none !important;
    background: transparent !important;
    padding: 0 !important;
  }
  .table th {
    background: #f0f0f0 !important;
    color: #000 !important;
    border-bottom: 2px solid #000 !important;
  }
  .table td {
    border-bottom: 1px solid #ddd !important;
  }
  .report-header-preview {
    border-bottom-color: #000 !important;
  }
  .report-header-preview h2 {
    color: #000 !important;
  }
}

/* Autocomplete suggestions dropdown styles */
.autocomplete-container {
  position: relative;
}
.autocomplete-suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  max-height: 220px;
  overflow-y: auto;
  z-index: 1000;
  box-shadow: var(--shadow-md);
  margin-top: 4px;
}
.suggestion-item {
  transition: background var(--transition-fast), color var(--transition-fast);
  color: var(--text-main);
  border-bottom: 1px solid var(--border-color);
}
.suggestion-item:last-child {
  border-bottom: none;
}
.suggestion-item:hover {
  background: rgba(95, 61, 196, 0.08) !important;
  color: var(--color-primary) !important;
}

/* User avatar initials badges styling */
.user-avatar-initials {
  border-radius: 50%;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.15);
}
.user-avatar-initials.large {
  width: 80px;
  height: 80px;
  font-size: 2.2rem;
  box-shadow: var(--shadow-sm);
}
