/* ==========================================================================
   UGO LEAD MANAGEMENT CRM - MODERN SAAS DESIGN SYSTEM
   Supports Light Mode & Dark Mode, Responsive Layouts, Dynamic Components
   ========================================================================== */

:root {
  /* Brand Palette */
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --primary-border: #bfdbfe;
  
  --secondary: #64748b;
  --accent: #0ea5e9;
  
  /* Status Colors */
  --status-new: #3b82f6;
  --status-contacted: #06b6d4;
  --status-qualified: #8b5cf6;
  --status-sitevisit: #f59e0b;
  --status-quotation: #ec4899;
  --status-negotiation: #6366f1;
  --status-won: #10b981;
  --status-lost: #ef4444;
  
  /* Priority Colors */
  --priority-hot: #ef4444;
  --priority-warm: #f59e0b;
  --priority-cold: #3b82f6;
  
  /* Neutral Theme Variables - Light Mode Default */
  --bg-body: #f8fafc;
  --bg-sidebar: #0f172a;
  --bg-sidebar-active: #1e293b;
  --text-sidebar: #94a3b8;
  --text-sidebar-active: #ffffff;
  
  --bg-card: #ffffff;
  --bg-header: #ffffff;
  --bg-input: #ffffff;
  --bg-hover: #f1f5f9;
  
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  
  --border-color: #e2e8f0;
  --border-light: #f1f5f9;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-full: 9999px;
  
  --sidebar-width: 260px;
  --sidebar-collapsed-width: 72px;
  --header-height: 64px;
  
  --transition-speed: 0.2s;
  --font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

[data-theme="dark"] {
  --bg-body: #090d16;
  --bg-card: #131b2e;
  --bg-header: #131b2e;
  --bg-input: #1e293b;
  --bg-hover: #1e293b;
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-light: #64748b;
  
  --border-color: #1e293b;
  --border-light: #0f172a;
  
  --primary-light: #1e293b;
  --primary-border: #3b82f6;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
}

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

html, body {
  height: 100%;
  font-family: var(--font-family);
  font-size: 14px;
  line-height: 1.5;
  background-color: var(--bg-body);
  color: var(--text-main);
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--primary);
  text-decoration: none;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

input, select, textarea {
  font-family: inherit;
  font-size: 0.9rem;
}

/* Application Layout */
#app {
  display: flex;
  min-height: 100vh;
  width: 100vw;
  overflow-x: hidden;
}

/* Sidebar Styles */
.sidebar {
  width: var(--sidebar-width);
  background-color: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  transition: width var(--transition-speed) ease;
  border-right: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-header {
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #ffffff;
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}

.brand-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 800;
  box-shadow: 0 4px 10px rgba(59, 130, 246, 0.4);
}

.toggle-sidebar-btn {
  color: var(--text-sidebar);
  padding: 6px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition-speed), color var(--transition-speed);
}

.toggle-sidebar-btn:hover {
  background-color: var(--bg-sidebar-active);
  color: #ffffff;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-section-title {
  color: #64748b;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 12px 12px 6px 12px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  color: var(--text-sidebar);
  border-radius: var(--radius-md);
  font-weight: 500;
  transition: all var(--transition-speed) ease;
  position: relative;
  text-decoration: none;
}

.nav-item:hover {
  background-color: rgba(255, 255, 255, 0.06);
  color: #f8fafc;
}

.nav-item.active {
  background: linear-gradient(90deg, var(--primary) 0%, #3b82f6 100%);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}

.nav-item svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.nav-badge {
  margin-left: auto;
  background-color: var(--status-lost);
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-full);
}

/* Collapsed Sidebar */
body.sidebar-collapsed .sidebar {
  width: var(--sidebar-collapsed-width);
}

body.sidebar-collapsed .brand-text,
body.sidebar-collapsed .nav-text,
body.sidebar-collapsed .nav-section-title,
body.sidebar-collapsed .nav-badge {
  display: none;
}

body.sidebar-collapsed .main-wrapper {
  margin-left: var(--sidebar-collapsed-width);
}

/* Main Content Wrapper */
.main-wrapper {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-width: 0;
  transition: margin-left var(--transition-speed) ease;
}

/* Header Navbar */
.top-header {
  height: var(--header-height);
  background-color: var(--bg-header);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 90;
  box-shadow: var(--shadow-sm);
}

/* Desktop Left-Aligned Search Bar */
.header-search {
  position: relative;
  width: 360px;
  margin-left: 16px;
  margin-right: auto;
}

/* Supabase Connection Status Badge */
.db-status-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background-color: var(--bg-hover);
  border: 1px solid var(--border-color);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.db-status-badge:hover {
  border-color: var(--primary);
}

.db-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.db-status-dot.online {
  background-color: var(--status-won);
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.6);
}

.db-status-dot.offline {
  background-color: var(--status-lost);
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.6);
}

.mobile-search-btn {
  display: none !important;
}

.mobile-search-overlay {
  display: none;
  position: sticky;
  top: var(--header-height);
  z-index: 89;
  background-color: var(--bg-card);
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-color);
  box-shadow: var(--shadow-md);
}

body.mobile-search-open .mobile-search-overlay {
  display: block;
}

.mobile-search-inner {
  display: flex;
  align-items: center;
  gap: 8px;
}

.search-input-wrapper {
  display: flex;
  align-items: center;
  background-color: var(--bg-body);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  padding: 0 14px;
  height: 38px;
  gap: 10px;
  transition: border-color var(--transition-speed), box-shadow var(--transition-speed);
}

.search-input-wrapper:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.search-input-wrapper svg {
  color: var(--text-muted);
  width: 18px;
  height: 18px;
}

.search-input {
  border: none;
  background: transparent;
  width: 100%;
  color: var(--text-main);
  outline: none;
}

.search-results-dropdown {
  position: absolute;
  top: 46px;
  left: 0;
  right: 0;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  max-height: 320px;
  overflow-y: auto;
  display: none;
  z-index: 100;
}

.search-results-dropdown.active {
  display: block;
}

.search-result-item {
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
}

.search-result-item:hover {
  background-color: var(--bg-hover);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  background-color: var(--bg-body);
  border: 1px solid var(--border-color);
  position: relative;
  transition: all var(--transition-speed) ease;
}

.icon-btn:hover {
  background-color: var(--bg-hover);
  color: var(--primary);
}

.badge-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 9px;
  height: 9px;
  background-color: var(--status-lost);
  border-radius: 50%;
  border: 2px solid var(--bg-card);
}

.btn-primary {
  background-color: var(--primary);
  color: #ffffff;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: background-color var(--transition-speed) ease, box-shadow var(--transition-speed) ease;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
}

.btn-primary:hover {
  background-color: var(--primary-hover);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}

.btn-secondary {
  background-color: var(--bg-body);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: background-color var(--transition-speed) ease;
}

.btn-secondary:hover {
  background-color: var(--bg-hover);
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-md);
  transition: background var(--transition-speed);
}

.user-profile:hover {
  background-color: var(--bg-hover);
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, #4f46e5, #3b82f6);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  overflow: hidden;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

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

.user-name {
  font-weight: 600;
  font-size: 0.9rem;
  line-height: 1.2;
}

.user-role {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Page Views Container */
.page-container {
  flex: 1;
  padding: 24px;
  max-width: 1600px;
  margin: 0 auto;
  width: 100%;
}

.view-section {
  display: none;
}

.view-section.active {
  display: block;
  animation: fadeIn 0.25s ease-in-out;
}

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

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 16px;
}

.page-title-group h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.page-title-group p {
  color: var(--text-muted);
  font-size: 0.88rem;
  margin-top: 2px;
}

/* Cards & Grid Containers */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.card {
  background-color: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-speed), box-shadow var(--transition-speed);
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.kpi-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.kpi-title {
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.kpi-value {
  font-size: 1.6rem;
  font-weight: 800;
  margin-top: 4px;
  letter-spacing: -0.02em;
}

.kpi-change {
  font-size: 0.78rem;
  font-weight: 600;
  margin-top: 4px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.kpi-change.positive { color: var(--status-won); }
.kpi-change.negative { color: var(--status-lost); }

.kpi-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--primary-light);
  color: var(--primary);
  flex-shrink: 0;
}

/* Dashboard Charts Grid */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 20px;
  margin-bottom: 24px;
}

.col-12 { grid-column: span 12; }
.col-8  { grid-column: span 8; }
.col-6  { grid-column: span 6; }
.col-4  { grid-column: span 4; }

.chart-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.chart-card-header h3 {
  font-size: 1rem;
  font-weight: 700;
}

.chart-body {
  position: relative;
  min-height: 250px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Table Styles */
.table-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.table-toolbar {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border-color);
  background-color: var(--bg-card);
}

.toolbar-left, .toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.custom-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  white-space: nowrap;
}

.custom-table th {
  background-color: var(--bg-body);
  padding: 12px 16px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
}

.custom-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-main);
  vertical-align: middle;
}

.custom-table tbody tr:hover {
  background-color: var(--bg-hover);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-priority-hot { background-color: rgba(239, 68, 68, 0.12); color: var(--priority-hot); }
.badge-priority-warm { background-color: rgba(245, 158, 11, 0.12); color: var(--priority-warm); }
.badge-priority-cold { background-color: rgba(59, 130, 246, 0.12); color: var(--priority-cold); }

.badge-source {
  background-color: var(--bg-body);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
}

.badge-stage {
  color: #ffffff;
  font-size: 0.72rem;
  padding: 3px 8px;
}

/* Kanban Board Styles */
.kanban-board {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding-bottom: 16px;
  min-height: calc(100vh - 220px);
}

.kanban-column {
  flex: 0 0 280px;
  background-color: var(--bg-body);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 200px);
}

.kanban-column-header {
  padding: 14px 16px;
  border-bottom: 2px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: var(--bg-card);
  border-top-left-radius: var(--radius-lg);
  border-top-right-radius: var(--radius-lg);
}

.kanban-column-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 0.9rem;
}

.kanban-count {
  background-color: var(--bg-hover);
  color: var(--text-muted);
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.kanban-cards-container {
  flex: 1;
  padding: 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.kanban-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px;
  box-shadow: var(--shadow-sm);
  cursor: grab;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.kanban-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.kanban-card.dragging {
  opacity: 0.4;
  cursor: grabbing;
}

.kanban-card-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-main);
  margin-bottom: 6px;
}

.kanban-card-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
}

.kanban-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border-light);
  padding-top: 8px;
  margin-top: 6px;
}

.kanban-value {
  font-weight: 700;
  color: var(--primary);
  font-size: 0.85rem;
}

/* Modals & Drawers */
.modal-overlay, .drawer-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.active, .drawer-overlay.active {
  display: flex;
  animation: fadeIn 0.2s ease;
}

.modal-container {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 650px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-container form {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.modal-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h2 {
  font-size: 1.2rem;
  font-weight: 700;
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  background-color: var(--bg-body);
}

/* Sliding Drawer */
.drawer-container {
  position: fixed;
  top: 0;
  right: -550px;
  bottom: 0;
  width: 520px;
  background-color: var(--bg-card);
  box-shadow: var(--shadow-lg);
  border-left: 1px solid var(--border-color);
  z-index: 210;
  display: flex;
  flex-direction: column;
  transition: right 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.drawer-container.active {
  right: 0;
}

.drawer-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: var(--bg-body);
}

.drawer-body {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
}

/* Timeline Components */
.timeline {
  position: relative;
  padding-left: 24px;
  margin-top: 16px;
}

.timeline::before {
  content: '';
  position: absolute;
  top: 6px;
  bottom: 6px;
  left: 7px;
  width: 2px;
  background-color: var(--border-color);
}

.timeline-item {
  position: relative;
  margin-bottom: 20px;
}

.timeline-dot {
  position: absolute;
  left: -24px;
  top: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background-color: var(--primary);
  border: 3px solid var(--bg-card);
  box-shadow: 0 0 0 2px var(--border-color);
}

.timeline-content {
  background-color: var(--bg-body);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}

.timeline-title {
  font-weight: 700;
  font-size: 0.88rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.timeline-date {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.timeline-note {
  margin-top: 4px;
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* Form Controls */
.form-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

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

.form-control {
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background-color: var(--bg-input);
  color: var(--text-main);
  outline: none;
  transition: border-color var(--transition-speed);
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.duplicate-alert {
  background-color: rgba(239, 68, 68, 0.1);
  border: 1px solid var(--status-lost);
  color: var(--status-lost);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

/* Toast Notifications */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background-color: var(--bg-sidebar);
  color: #ffffff;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 500;
  font-size: 0.88rem;
  min-width: 280px;
  animation: slideUp 0.25s ease-out;
  border-left: 4px solid var(--primary);
}

.toast.success { border-left-color: var(--status-won); }
.toast.error { border-left-color: var(--status-lost); }
.toast.warning { border-left-color: var(--status-sitevisit); }

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

/* Action Shortcuts (WhatsApp / Phone) */
.btn-action-whatsapp {
  background-color: #25d366;
  color: #ffffff;
  padding: 6px 12px;
  border-radius: var(--radius-md);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-action-call {
  background-color: var(--primary);
  color: #ffffff;
  padding: 6px 12px;
  border-radius: var(--radius-md);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* Responsive Breakpoints & Mobile App Layout System */

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mobile-menu-btn {
  display: none;
  padding: 8px;
  border-radius: var(--radius-md);
  color: var(--text-main);
  background-color: var(--bg-hover);
}

.mobile-brand {
  display: none;
  font-weight: 800;
  font-size: 1.05rem;
  background: linear-gradient(135deg, #2563eb, #0ea5e9);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.mobile-close-btn {
  display: none;
  color: var(--text-sidebar);
  padding: 6px;
  font-size: 1.2rem;
}

.btn-label-mobile {
  display: none;
}

/* Sidebar Overlay Backdrop */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 99;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

body.mobile-menu-open .sidebar-overlay {
  opacity: 1;
  pointer-events: auto;
}

/* Mobile Bottom Navigation Bar */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 62px;
  background-color: var(--bg-card);
  border-top: 1px solid var(--border-color);
  z-index: 90;
  box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.06);
  padding: 4px 4px;
  justify-content: space-around;
  align-items: center;
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--text-muted);
  font-size: 0.68rem;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: var(--radius-md);
  transition: all 0.2s ease;
  text-decoration: none;
  border: none;
  background: none;
}

.bottom-nav-item svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.bottom-nav-item.active {
  color: var(--primary);
  background-color: var(--primary-light);
}

.bottom-nav-item:active {
  transform: scale(0.95);
}

/* Kanban Mobile Stage Selector Tabs */
.kanban-mobile-tabs {
  display: none;
  gap: 8px;
  overflow-x: auto;
  padding: 8px 4px;
  margin-bottom: 12px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.kanban-mobile-tabs::-webkit-scrollbar {
  display: none;
}

.kanban-stage-pill {
  padding: 7px 14px;
  border-radius: var(--radius-full);
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
}

.kanban-stage-pill.active {
  background-color: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

/* Universal Filter Bar Container & Mobile Trigger Button */
.filter-bar-container {
  margin-bottom: 20px;
  background-color: var(--bg-body);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  padding: 12px 18px;
}

.mobile-filter-trigger {
  display: none;
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  font-weight: 700;
  font-size: 0.85rem;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}

.filter-options-content {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* RESPONSIVE MEDIA QUERIES */

@media (max-width: 1024px) {
  .charts-grid {
    grid-template-columns: 1fr;
  }
  .col-8, .col-6, .col-4 {
    grid-column: span 12;
  }
  .stats-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

@media (max-width: 768px) {
  /* Show Mobile Filter Button */
  .mobile-filter-trigger {
    display: flex;
  }

  .filter-options-content {
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
  }

  .filter-options-content.open {
    display: flex;
  }
  /* Show Mobile Header Controls & Search Icon */
  .mobile-menu-btn {
    display: flex;
  }
  .mobile-search-btn {
    display: flex !important;
  }
  .mobile-brand {
    display: block;
  }
  .mobile-close-btn {
    display: block;
  }
  .bottom-nav {
    display: flex;
  }

  /* DB Status Badge: dot only on mobile — no text, no background */
  .db-status-badge {
    padding: 0;
    background: transparent;
    border: none;
    gap: 0;
  }
  .db-status-badge:hover {
    border: none;
  }
  .db-status-text {
    display: none;
  }
  .db-status-dot {
    width: 10px;
    height: 10px;
  }
  .db-status-dot.online {
    box-shadow: 0 0 10px 3px rgba(16, 185, 129, 0.8);
  }
  .db-status-dot.offline {
    box-shadow: 0 0 10px 3px rgba(239, 68, 68, 0.8);
  }

  /* Sidebar Drawer on Mobile */
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: 280px;
    z-index: 100;
    transform: translateX(-100%);
    box-shadow: 0 0 25px rgba(0, 0, 0, 0.3);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  }

  body.mobile-menu-open .sidebar {
    transform: translateX(0);
  }

  .main-wrapper {
    margin-left: 0 !important;
  }

  /* Adjust Page Padding for Bottom Nav Bar Clearance */
  .page-container {
    padding: 16px 12px 76px 12px !important;
  }

  /* Header adjustments */
  .top-header {
    padding: 0 12px;
    gap: 8px;
  }

  /* Hide search bar on header on mobile as requested */
  .header-search {
    display: none !important;
  }

  .user-info {
    display: none;
  }

  .btn-label-desktop {
    display: none;
  }

  .btn-label-mobile {
    display: inline;
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--text-muted);
    line-height: 1;
  }

  .header-quick-btn {
    background: transparent !important;
    background-color: transparent !important;
    border: none !important;
    box-shadow: none !important;
    color: var(--text-muted) !important;
    padding: 4px 8px !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .header-quick-btn:hover,
  .header-quick-btn:focus,
  .header-quick-btn:active {
    background: transparent !important;
    color: var(--text-main) !important;
  }

  /* Form & Grid Layouts */
  .form-grid {
    grid-template-columns: 1fr !important;
  }
  .form-group[style*="grid-column"] {
    grid-column: span 12 !important;
  }

  /* Kanban / Pipeline View on Mobile */
  .kanban-mobile-tabs {
    display: flex;
  }

  .kanban-board {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    gap: 12px;
    padding-bottom: 12px;
    -webkit-overflow-scrolling: touch;
  }

  .kanban-column {
    min-width: 85vw;
    scroll-snap-align: start;
    flex-shrink: 0;
  }

  /* Mobile Data Card Views for Tables */
  .table-responsive {
    border-radius: var(--radius-md);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Filter bar & headers on mobile */
  .card-header-actions {
    flex-direction: column;
    align-items: stretch !important;
    gap: 10px;
  }

  .filter-bar, .controls-row {
    flex-direction: column;
    align-items: stretch !important;
    gap: 10px;
  }

  .filter-bar input, .filter-bar select, .controls-row input, .controls-row select {
    width: 100% !important;
  }

  /* Drawer container 100vw on mobile */
  .drawer-container {
    width: 100vw;
  }

  /* Modal container padding */
  .modal-container {
    width: 95vw;
    max-height: 90vh;
    padding: 16px;
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr !important;
  }

  .header-search {
    max-width: 130px;
  }

  .kanban-column {
    min-width: 90vw;
  }
}

