/* =========================================================
   Dealmelio — MASTER UI CONSISTENCY SYSTEM
   World-class design polish — Apple/Linear/Stripe quality
   THIS FILE IS THE SOURCE OF TRUTH FOR ALL UI STYLING
========================================================= */

/* ===========================================
   🎨 DEFINITIVE DESIGN TOKENS
   Single source of truth — no competing systems
=========================================== */
:root {
  /* ─── Typography Scale ─── */
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --text-2xs: 10px;
  --text-xs: 11px;
  --text-sm: 12px;
  --text-base: 13px;
  --text-md: 14px;
  --text-lg: 16px;
  --text-xl: 18px;
  --text-2xl: 22px;
  --text-3xl: 28px;
  
  /* ─── Font Weights ─── */
  --weight-normal: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;
  
  /* ─── Spacing Scale (8px base for perfect alignment) ─── */
  --sp-0: 0;
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-7: 28px;
  --sp-8: 32px;
  --sp-9: 36px;
  --sp-10: 40px;
  --sp-12: 48px;
  --sp-16: 64px;
  
  /* ─── Border Radius Scale ─── */
  --r-xs: 4px;
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 10px;
  --r-xl: 12px;
  --r-2xl: 16px;
  --r-full: 9999px;
  
  /* ─── Shadows (Perfect elevation system) ─── */
  --sh-xs: 0 1px 2px rgba(0,0,0,0.04);
  --sh-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --sh-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -1px rgba(0,0,0,0.04);
  --sh-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -2px rgba(0,0,0,0.04);
  --sh-xl: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);
  --sh-focus: 0 0 0 3px rgba(59, 130, 246, 0.15);
  
  /* ─── Transitions (Smooth micro-interactions) ─── */
  --tr-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --tr-base: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --tr-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);
  
  /* ─── Component Heights (Perfect vertical rhythm) ─── */
  --h-btn: 36px;
  --h-btn-sm: 28px;
  --h-btn-lg: 44px;
  --h-input: 36px;
  --h-input-sm: 30px;
  --h-input-lg: 42px;
  
  /* ─── Icon Sizes (Perfect squares) ─── */
  --icon-xs: 14px;
  --icon-sm: 16px;
  --icon-md: 18px;
  --icon-lg: 20px;
  --icon-xl: 24px;
  --icon-2xl: 32px;
  
  /* ─── Responsive Breakpoints ─── */
  --breakpoint-mobile: 767px;
  --breakpoint-tablet: 768px;
  --breakpoint-desktop: 1200px;
}

/* ===========================================
   🎯 ICON SYSTEM
   Consistent icon sizing and styling
=========================================== */
.icon,
svg.icon,
.menuBtn-icon svg,
button svg:not(.no-icon-style) {
  width: var(--icon-md);
  height: var(--icon-md);
  flex-shrink: 0;
  stroke-width: 2;
  transition: all var(--tr-fast);
}

/* Icon size variants */
.icon-xs { width: var(--icon-xs); height: var(--icon-xs); }
.icon-sm { width: var(--icon-sm); height: var(--icon-sm); }
.icon-md { width: var(--icon-md); height: var(--icon-md); }
.icon-lg { width: var(--icon-lg); height: var(--icon-lg); }
.icon-xl { width: var(--icon-xl); height: var(--icon-xl); }
.icon-2xl { width: var(--icon-2xl); height: var(--icon-2xl); }

/* Icon colors */
.icon-primary { color: var(--blue); stroke: var(--blue); }
.icon-secondary { color: var(--text-secondary); stroke: var(--text-secondary); }
.icon-success { color: var(--green); stroke: var(--green); }
.icon-warning { color: var(--orange); stroke: var(--orange); }
.icon-danger { color: var(--red); stroke: var(--red); }

/* Icon in buttons */
button .icon,
.btn .icon,
a.btn .icon {
  margin-right: var(--sp-1);
}

button:last-child .icon,
.btn:last-child .icon {
  margin-right: 0;
  margin-left: var(--sp-1);
}

/* Icon-only buttons */
.btn-icon,
button.icon-only {
  width: var(--h-btn);
  height: var(--h-btn);
  padding: 0;
  justify-content: center;
}

.btn-icon svg,
button.icon-only svg {
  margin: 0;
}

/* Avatar icons */
.avatar-icon,
.list-row-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--r-full);
  background: var(--blue);
  color: white;
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  flex-shrink: 0;
}

.avatar-icon-sm {
  width: 32px;
  height: 32px;
  font-size: var(--text-sm);
}

.avatar-icon-lg {
  width: 56px;
  height: 56px;
  font-size: var(--text-lg);
}

/* Status icons */
.status-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: var(--r-full);
  font-size: var(--text-xs);
}

.status-icon-success {
  background: var(--green);
  color: white;
}

.status-icon-warning {
  background: var(--orange);
  color: white;
}

.status-icon-danger {
  background: var(--red);
  color: white;
}

/* ===========================================
   🔤 GLOBAL TYPOGRAPHY
=========================================== */
body {
  font-family: var(--font-sans);
  font-size: var(--text-md);
  font-weight: var(--weight-normal);
  line-height: 1.5;
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* Headings */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-sans);
  font-weight: var(--weight-semibold);
  line-height: 1.3;
  color: var(--text-primary);
  margin: 0;
}

h1 { font-size: var(--text-2xl); font-weight: var(--weight-bold); letter-spacing: -0.02em; }
h2 { font-size: var(--text-xl); font-weight: var(--weight-semibold); letter-spacing: -0.01em; }
h3 { font-size: var(--text-lg); font-weight: var(--weight-semibold); }
h4 { font-size: var(--text-md); font-weight: var(--weight-semibold); }
h5, h6 { font-size: var(--text-base); font-weight: var(--weight-semibold); }

/* Labels */
label,
.label,
.label-text {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text-secondary);
  line-height: 1.4;
}

/* Muted/Secondary text */
.muted,
.text-muted,
.text-secondary {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

/* ===========================================
   🔘 UNIFIED BUTTON SYSTEM
   All buttons use these exact specs
=========================================== */
.btn,
button.btn,
.button,
.detail-action-btn,
.actions-dropdown-btn,
.export-btn,
.menuBtn:not(.headerToggle .menuBtn) {
  /* Reset */
  appearance: none;
  -webkit-appearance: none;
  margin: 0;
  
  /* Layout */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  
  /* Size */
  height: var(--h-btn);
  padding: 0 var(--sp-4);
  
  /* Typography */
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  letter-spacing: 0;
  
  /* Visual */
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--r-md);
  color: var(--text-primary);
  box-shadow: var(--sh-xs);
  
  /* Interaction */
  cursor: pointer;
  transition: all var(--tr-fast);
  user-select: none;
}

/* Hover */
.btn:hover:not(:disabled),
button.btn:hover:not(:disabled),
.detail-action-btn:hover:not(:disabled) {
  background: var(--gray-50);
  border-color: var(--border-medium);
  box-shadow: var(--sh-sm);
}

/* Active/Pressed */
.btn:active:not(:disabled),
button.btn:active:not(:disabled) {
  transform: translateY(1px);
  box-shadow: var(--sh-xs);
}

/* Focus */
.btn:focus-visible,
button.btn:focus-visible {
  outline: none;
  box-shadow: var(--sh-focus), var(--sh-xs);
}

/* Disabled */
.btn:disabled,
button.btn:disabled,
.btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* ─── Button Variants ─── */

/* Primary (Blue) */
.btn.primary,
button.btn.primary,
.btn-primary,
.detail-action-btn.edit-btn {
  background: var(--primary-600) !important;
  border-color: var(--primary-600) !important;
  color: #fff !important;
  box-shadow: 0 1px 3px rgba(37, 99, 235, 0.2) !important;
}

.btn.primary:hover:not(:disabled),
.detail-action-btn.edit-btn:hover:not(:disabled) {
  background: var(--primary-700) !important;
  border-color: var(--primary-700) !important;
  box-shadow: 0 4px 8px rgba(37, 99, 235, 0.25) !important;
}

/* Success (same as primary for unified accent) */
.btn.success,
button.btn.success {
  background: var(--primary-600);
  border-color: var(--primary-600);
  color: #fff;
}

/* Danger */
.btn.danger,
button.btn.danger,
.btn-danger,
.delete-btn,
.detail-action-btn.delete-btn {
  background: var(--surface);
  border-color: var(--danger-200);
  color: var(--danger-600);
}

.btn.danger:hover:not(:disabled),
.detail-action-btn.delete-btn:hover:not(:disabled) {
  background: var(--danger-50);
  border-color: var(--danger-300);
  color: var(--danger-700);
}

/* Cancel */
.btn.cancel-btn,
.detail-action-btn.cancel-btn {
  background: var(--danger-50);
  border-color: var(--danger-200);
  color: var(--danger-600);
}

/* Ghost */
.btn.ghost,
button.btn.ghost {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}

.btn.ghost:hover:not(:disabled) {
  background: var(--gray-100);
  border-color: var(--border-light);
}

/* ─── Button Sizes ─── */

/* Small */
.btn.small,
.btn-sm,
.btn.sm {
  height: var(--h-btn-sm);
  padding: 0 var(--sp-3);
  font-size: var(--text-sm);
  border-radius: var(--r-sm);
}

/* Large */
.btn.large,
.btn-lg,
.btn.lg {
  height: var(--h-btn-lg);
  padding: 0 var(--sp-6);
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  border-radius: var(--r-lg);
}

/* Icon-only */
.btn.icon,
.btn-icon,
.iconBtn {
  width: var(--h-btn);
  height: var(--h-btn);
  padding: 0;
  min-width: var(--h-btn);
}

.btn.icon.small,
.iconBtn.small {
  width: var(--h-btn-sm);
  height: var(--h-btn-sm);
  min-width: var(--h-btn-sm);
}

/* ===========================================
   📝 UNIFIED FORM ELEMENTS
=========================================== */
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="number"],
input[type="password"],
input[type="search"],
input[type="url"],
input[type="date"],
input[type="datetime-local"],
input[type="time"],
textarea,
select,
.input,
.select,
.textarea {
  /* Reset */
  appearance: none;
  -webkit-appearance: none;
  margin: 0;
  
  /* Size */
  width: 100%;
  height: var(--h-input);
  padding: 0 var(--sp-5);
  
  /* Typography */
  font-family: var(--font-sans);
  font-size: var(--text-md);
  font-weight: var(--weight-normal);
  line-height: 1.5;
  color: var(--text-primary);
  
  /* Visual */
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--r-md);
  box-shadow: var(--sh-xs);
  
  /* Interaction */
  transition: all var(--tr-fast);
  outline: none;
}

/* Textarea */
textarea,
.textarea {
  height: auto;
  min-height: 80px;
  padding: var(--sp-4) var(--sp-5);
  resize: vertical;
}

/* Select */
select,
.select {
  cursor: pointer;
  padding-right: var(--sp-9);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--sp-4) center;
}

/* ===========================================
   ➕ MULTI-VALUE FIELDS (Email/Phone/Address)
   Keep input + label dropdown + remove perfectly aligned
=========================================== */
.multiField [data-multi-row="1"] {
  align-items: center;
}

.multiField input,
.multiField select,
.multiField .input,
.multiField .select {
  box-sizing: border-box;
  height: var(--h-input);
  min-height: var(--h-input);
  max-height: var(--h-input);
  padding-top: 0;
  padding-bottom: 0;
  line-height: 1;
}

.multiField .btn[data-multi-remove] {
  height: var(--h-input);
  min-height: var(--h-input);
  max-height: var(--h-input);
  width: var(--h-input);
  min-width: var(--h-input);
  padding: 0;
}

/* Address: street textarea should start compact (~3 lines), but stay resizable */
.multiField textarea[data-field="street"] {
  min-height: 74px; /* ~3 lines at current type scale + padding */
  resize: vertical;
}

/* Focus */
input:focus,
textarea:focus,
select:focus,
.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--primary-500);
  box-shadow: var(--sh-focus), var(--sh-xs);
}

/* Disabled */
input:disabled,
textarea:disabled,
select:disabled {
  background: var(--gray-100);
  color: var(--text-tertiary);
  cursor: not-allowed;
  opacity: 0.7;
}

/* Placeholder */
input::placeholder,
textarea::placeholder {
  color: var(--text-tertiary);
  opacity: 0.8;
}

/* ===========================================
   🔎 SEARCH + FILTER (joined, crisp end-cap)
=========================================== */
.filters .searchWrap {
  display: flex;
  align-items: stretch;
  width: 100%;
  height: 42px; /* matches existing compact filter sizing */
  background: var(--gray-50);
  border: 1px solid var(--border-light);
  border-radius: var(--r-full);
  overflow: hidden;
  box-shadow: var(--sh-xs);
}

.filters .searchWrap:focus-within {
  background: var(--surface);
  border-color: var(--primary-500);
  box-shadow: var(--sh-focus), var(--sh-xs);
}

/* Search input inside the joined control */
.filters .searchWrap #searchInput {
  flex: 1;
  min-width: 0;
  height: 42px !important;
  border: none !important;
  box-shadow: none !important;
  background: transparent !important;
  border-radius: 0 !important;
  padding: 0 var(--sp-6) 0 var(--sp-7) !important;
  font-size: var(--text-md) !important;
}

.filters .searchWrap #searchInput:focus {
  outline: none;
}

/* Filter button becomes a clean end-cap */
.filters .searchWrap #filterBtn.filterIconBtn {
  position: static !important;
  transform: none !important;
  width: 44px !important;
  height: 42px !important;
  min-width: 44px !important;
  padding: 0 !important;
  margin: 0 !important;
  border: none !important;
  border-left: 1px solid var(--border-light) !important;
  background: transparent !important;
  border-radius: 0 !important;
  color: var(--text-secondary) !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
}

.filters .searchWrap #filterBtn.filterIconBtn:hover:not(:disabled) {
  background: rgba(15, 23, 42, 0.04) !important;
  color: var(--text-primary) !important;
}

.filters .searchWrap #filterBtn.filterIconBtn:active:not(:disabled) {
  background: rgba(15, 23, 42, 0.06) !important;
}

.filters .searchWrap #filterBtn.filterIconBtn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

/* Icon crispness */
.filters .searchWrap .tuneIcon {
  width: 18px;
  height: 18px;
}
.filters .searchWrap .tuneIcon * {
  vector-effect: non-scaling-stroke;
  shape-rendering: geometricPrecision;
}

/* ===========================================
   🎴 UNIFIED CARDS & PANELS
=========================================== */
.card,
.panel,
.detailCard,
.detailSection {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-sm);
}

/* Detail sections */
.detailSection {
  padding: var(--sp-4);
  margin-bottom: var(--sp-4);
  background: var(--gray-50);
  border-radius: var(--r-lg);
  border: 1px solid var(--border-light);
}

/* Ensure all detail sections (Relationships/Deals/Documents/etc) are identical full width */
#detailContent,
#detailContent .detailSection {
  width: 100%;
  box-sizing: border-box;
}

.detailSection:last-child {
  margin-bottom: 0;
}

.detailSection h3 {
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0 0 var(--sp-3) 0;
  padding-bottom: var(--sp-3);
  border-bottom: 1px solid var(--border-light);
}

/* Detail card items */
.detailCard {
  padding: var(--sp-4);
  border-radius: var(--r-lg);
}

/* ===========================================
   🏷️ UNIFIED PILLS & BADGES
=========================================== */
.pill,
.badge,
.tag,
.tagChip {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  padding: 3px var(--sp-3);
  font-size: var(--text-2xs);
  font-weight: var(--weight-semibold);
  line-height: 1.4;
  border-radius: var(--r-full);
  background: var(--gray-100);
  color: var(--text-secondary);
  border: 1px solid var(--border-light);
  white-space: nowrap;
}

/* Owner pill */
.pill.ownerPill {
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-size: 9px;
}

.pill.ownerPill.me {
  background: var(--primary-50);
  color: var(--primary-700);
  border-color: var(--primary-200);
}

.pill.ownerPill.empty {
  background: var(--danger-50);
  color: var(--danger-600);
  border-color: var(--danger-200);
}

/* Folder count pill */
.folderCountPill {
  font-size: 10px;
  font-weight: var(--weight-semibold);
  padding: 2px var(--sp-3);
  background: var(--gray-100);
  color: var(--text-secondary);
  border-radius: var(--r-full);
}

/* Tag chips */
.tagChip {
  padding: var(--sp-2) var(--sp-4);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  cursor: pointer;
  transition: all var(--tr-fast);
}

.tagChip:hover {
  background: var(--gray-200);
}

.tagChip.active {
  background: var(--primary-100);
  color: var(--primary-700);
  border-color: var(--primary-500);
}

/* ===========================================
   📋 CONTACT LIST ROWS
=========================================== */
.row {
  display: flex;
  align-items: center;
  gap: var(--sp-5);
  padding: var(--sp-4) var(--sp-5);
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--r-lg);
  cursor: pointer;
  transition: all var(--tr-fast);
}

.row:hover {
  background: var(--gray-50);
  border-color: var(--border-medium);
  box-shadow: var(--sh-sm);
}

.row.selected {
  background: var(--primary-50);
  border-color: var(--primary-500);
  box-shadow: var(--sh-focus);
}

/* Avatar */
.row .avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--r-md);
  background: linear-gradient(135deg, var(--primary-500), var(--primary-700));
  color: #fff;
  font-weight: var(--weight-bold);
  font-size: var(--text-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.rowMain {
  flex: 1;
  min-width: 0;
}

.rowName {
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rowSub {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

/* ===========================================
   🎭 MODALS
=========================================== */
.backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: var(--sp-8);
}

.backdrop.show {
  display: flex;
}

.modal {
  background: var(--surface);
  border-radius: var(--r-2xl);
  box-shadow: var(--sh-xl);
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Fullscreen Modal Mode - Higher specificity to override all other modal styles */
.backdrop .modal.modal-fullscreen {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  max-width: 100vw !important;
  max-height: 100vh !important;
  margin: 0 !important;
  border-radius: 0 !important;
  transform: none !important;
}

.backdrop:has(.modal.modal-fullscreen) {
  padding: 0 !important;
  background: rgba(0, 0, 0, 0.95) !important;
}

.backdrop .modal.modal-fullscreen .modalBody {
  max-height: calc(100vh - 130px) !important;
}

.modalHead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-7) var(--sp-8);
  border-bottom: 1px solid var(--border-light);
  background: var(--gray-50);
  flex-shrink: 0;
}

.modalTitle {
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
  margin: 0;
}

.modalBody {
  padding: var(--sp-8);
  overflow-y: auto;
  flex: 1;
  min-height: 0; /* CRITICAL: allows flexbox scrolling to work properly */
}

.modalFoot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--sp-4);
  padding: var(--sp-6) var(--sp-8);
  border-top: 1px solid var(--border-light);
  background: var(--gray-50);
  flex-shrink: 0;
}

/* ===========================================
   🎯 HEADER ALIGNMENT (Perfect match)
=========================================== */

/* All pane headers */
.paneHead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-5) var(--sp-6);
  min-height: 56px;
  border-bottom: 1px solid var(--border-light);
  background: var(--gray-50);
  box-sizing: border-box;
}

.paneHead-left {
  display: flex;
  align-items: baseline;
  gap: var(--sp-4);
  flex: 1;
  min-width: 0;
}

.paneHead-right {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-shrink: 0;
}

.paneTitle {
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
}

.paneSub {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

/* Detail top strip */
.detailTopStrip {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-5) 0;
  margin-bottom: var(--sp-6);
  border-bottom: 1px solid var(--border-light);
}

.detailTopActions {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-wrap: wrap;
}

/* Sort select in header */
#sortSelect {
  height: var(--h-btn);
  min-width: 130px;
}

/* ===========================================
   🎨 HEADER GAP FIX
=========================================== */
body > div.app-shell > div > header,
.app-header {
  gap: 0 !important;
}

/* ===========================================
   📁 COLLAPSIBLE FOLDER PANE
=========================================== */

/* Hamburger button styling */
.hamburger-menu.folder-toggle {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4px;
  width: 36px;
  height: 36px;
  padding: 8px;
  background: transparent;
  border: 1px solid var(--border-light);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: all var(--tr-fast);
}

.hamburger-menu.folder-toggle:hover {
  background: var(--gray-100);
}

.hamburger-menu.folder-toggle span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--text-secondary);
  border-radius: 2px;
  transition: all var(--tr-fast);
}

/* When collapsed (active), turn hamburger into X */
.hamburger-menu.folder-toggle.active span:nth-child(1) {
  transform: rotate(45deg) translateY(6px);
}

.hamburger-menu.folder-toggle.active span:nth-child(2) {
  opacity: 0;
}

.hamburger-menu.folder-toggle.active span:nth-child(3) {
  transform: rotate(-45deg) translateY(-6px);
}

/* Folder pane collapsed state */
.folderPane.collapsed {
  width: 60px !important;
  min-width: 60px !important;
  max-width: 60px !important;
  overflow: hidden;
}

/* Hide text labels when collapsed - show only icons */
.folderPane.collapsed .paneHead-right,
.folderPane.collapsed .folderName,
.folderPane.collapsed .folderCountPill,
.folderPane.collapsed .folderRowRight {
  display: none !important;
}

/* Center the folder icons when collapsed */
.folderPane.collapsed .folderRow {
  display: flex !important;
  justify-content: center !important;
  align-items: center !important;
  padding: 12px 0 !important;
  grid-template-columns: none !important;
}

.folderPane.collapsed .folderRowLeft {
  display: flex !important;
  justify-content: center !important;
  align-items: center !important;
  width: 100% !important;
  gap: 0 !important;
}

.folderPane.collapsed .folderIcon {
  font-size: 22px !important;
  margin: 0 auto !important;
  text-align: center !important;
}

/* Hide folder menu button when collapsed */
.folderPane.collapsed .folderMenuBtn {
  display: none !important;
}

/* Center the header hamburger when collapsed */
.folderPane.collapsed .paneHead {
  justify-content: center !important;
  padding: 12px 8px !important;
}

.folderPane.collapsed .paneHead-left {
  margin: 0 auto !important;
}

/* Hide divider line in collapsed state */
.folderPane.collapsed .folderDivider {
  margin: 8px 12px !important;
}

/* Adjust main grid when folders collapsed */
.app-shell.folders-collapsed {
  /* Grid now has smaller folder column */
}

.app-shell.folders-collapsed .folderPane {
  width: 60px !important;
  min-width: 60px !important;
  max-width: 60px !important;
}

/* Tooltip for collapsed folders (show name on hover) */
.folderPane.collapsed .folderRow {
  position: relative;
}

.folderPane.collapsed .folderRow::after {
  content: attr(data-folder-name);
  position: absolute;
  left: 100%;
  top: 50%;
  transform: translateY(-50%);
  background: var(--gray-900);
  color: white;
  padding: 6px 12px;
  border-radius: var(--r-md);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: all var(--tr-fast);
  z-index: 1000;
  margin-left: 8px;
  pointer-events: none;
}

.folderPane.collapsed .folderRow:hover::after {
  opacity: 1;
  visibility: visible;
}

/* Mobile overlay */
.folder-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 99;
  opacity: 0;
  visibility: hidden;
  transition: all var(--tr-base);
}

.folder-overlay.show {
  opacity: 1;
  visibility: visible;
}

/* Mobile folder pane slide-in */
@media (max-width: 768px) {
  .folderPane {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform var(--tr-base);
    width: 280px !important;
    max-width: 80vw;
  }
  
  .folderPane.show {
    transform: translateX(0);
  }
}

/* ===========================================
   🎨 NAVIGATION TABS
=========================================== */
.menuToggle.headerToggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  background: var(--gray-100);
  border-radius: var(--r-lg);
  margin-left: 0; /* centered */
}

/* Header right-side actions should never wrap to a second line */
.app-header .header-actions {
  flex-wrap: nowrap;
  white-space: nowrap;
}

.menuToggle.headerToggle .menuBtn {
  /* All top nav tabs must match exactly */
  height: var(--h-btn);
  min-height: var(--h-btn);
  padding: 0 14px;
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  color: var(--text-secondary);
  background: transparent;
  border: none;
  border-radius: var(--r-full);
  cursor: pointer;
  transition: all var(--tr-fast);
  box-shadow: none;
}

.menuToggle.headerToggle .menuBtn:hover {
  color: var(--text-primary);
  background: var(--gray-200);
}

.menuToggle.headerToggle .menuBtn.active {
  background: var(--surface);
  color: var(--primary-600);
  font-weight: var(--weight-bold);
  box-shadow: var(--sh-sm);
}

/* Tools dropdown open state (should NOT look like the active view tab) */
.menuToggle.headerToggle .menuBtn.is-open {
  background: var(--gray-200);
  color: var(--text-primary);
  font-weight: var(--weight-semibold);
  box-shadow: none;
}

/* Tools dropdown button (with inline chevron) */
.menuBtn.menuBtn-dropdown {
  display: inline-flex !important;
  align-items: center !important;
  gap: 4px !important;
  white-space: nowrap !important;
  padding: 0 12px !important;
}

.menuBtn.menuBtn-dropdown span {
  display: inline;
}

.menuBtn.menuBtn-dropdown .dropdown-chevron {
  flex-shrink: 0;
  width: 12px;
  height: 12px;
  opacity: 0.7;
  transition: transform var(--tr-fast);
}

.menuBtn.menuBtn-dropdown.is-open .dropdown-chevron {
  transform: rotate(180deg);
}

/* ===========================================
   🔧 FIX: Remove unwanted dot separator on auth email
=========================================== */
#authEmail::before {
  content: none !important;
  display: none !important;
}

.authLine #authEmail::before {
  content: none !important;
  display: none !important;
}

/* ===========================================
   📊 DEAL INTELLIGENCE ACCORDION
=========================================== */
.detailSection.dealIntelligence {
  padding: 0;
  overflow: hidden;
}

.dealIntelHead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-5) var(--sp-6);
  cursor: pointer;
  user-select: none;
  transition: background var(--tr-fast);
}

.dealIntelHead:hover {
  background: var(--gray-100);
}

.dealIntelHeadLeft {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
}

.dealIntelHeadLeft h3 {
  margin: 0;
  padding: 0;
  border: 0;
  font-size: var(--text-base);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
  text-transform: none;
  letter-spacing: normal;
}

.dealIntelChevron {
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  border-radius: var(--r-full);
  background: var(--gray-100);
  color: var(--text-secondary);
  transition: transform var(--tr-base);
}

.dealIntelHead.expanded .dealIntelChevron {
  transform: rotate(90deg);
}

.dealIntelBody {
  overflow: hidden;
  transition: all var(--tr-slow);
}

.dealIntelBodyInner {
  padding: 0 var(--sp-6) var(--sp-6);
}

/* ===========================================
   📁 FOLDER SIDEBAR
=========================================== */
.folderRow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-3) var(--sp-4);
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  color: var(--text-primary);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background var(--tr-fast);
  margin-bottom: 2px;
  border: none;
}

/* Ensure folder labels share the same usable width, and counts align perfectly */
.folderRowLeft {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex: 1 1 auto;
  min-width: 0;
}

.folderName {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/*
  Always reserve the kebab-menu slot so system folders (which don't render a menu)
  line up their count pills with user folders.
*/
.folderRowRight {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex: 0 0 auto;
  padding-right: 34px; /* reserved space for the 32px menu + breathing room */
}

.folderRowRight .folderMenuBtn {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
}

.folderRow:hover {
  background: var(--gray-100);
}

.folderRow.active {
  background: var(--primary-50);
  color: var(--primary-700);
  font-weight: var(--weight-semibold);
}

.folderRow.active .folderCountPill {
  background: var(--primary-100);
  color: var(--primary-700);
}

/* ===========================================
   ✨ MICROINTERACTIONS
=========================================== */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.fade-in { animation: fadeIn var(--tr-base) ease-out; }
.slide-up { animation: slideUp var(--tr-base) ease-out; }
.scale-in { animation: scaleIn var(--tr-base) ease-out; }

/* ===========================================
   🔧 DETAIL FORM FIELDS
=========================================== */
.label-row {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: var(--sp-5);
  align-items: center;
  margin-bottom: var(--sp-5);
}

.label-col {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}

.detailRow {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: var(--sp-5);
  padding: var(--sp-3) 0;
  border-bottom: 1px solid rgba(0,0,0,0.04);
}

.detailRow:last-child {
  border-bottom: none;
}

.detailRow .label {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text-secondary);
  text-transform: uppercase;
}

.detailRow .value {
  font-size: var(--text-md);
  font-weight: var(--weight-medium);
  color: var(--text-primary);
}

.detailRow .value a {
  color: var(--primary-600);
  text-decoration: none;
}

.detailRow .value a:hover {
  text-decoration: underline;
}

/* ===========================================
   🎯 ACTION SECTION BUTTONS (Add deal, etc.)
=========================================== */
.detailSection .btn.action-btn {
  height: var(--h-btn);
  padding: 0 var(--sp-5);
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  background: var(--primary-600);
  border-color: var(--primary-600);
  color: #fff;
  border-radius: var(--r-md);
}

.detailSection .btn.action-btn:hover {
  background: var(--primary-700);
  border-color: var(--primary-700);
}

/* ===========================================
   📱 RESPONSIVE - Mobile Touch Targets
=========================================== */
@media (max-width: 767px) {
  :root {
    /* Increase button heights for touch - Apple/Google recommend 44px minimum */
    --h-btn: 44px;
    --h-btn-sm: 40px;
    --h-btn-lg: 48px;
    --h-input: 44px;
    --h-input-sm: 40px;
    
    /* Readable text on mobile */
    --text-base: 15px;
    --text-sm: 13px;
    --text-md: 16px;
  }
  
  .btn {
    padding: 0 var(--sp-4);
    font-size: var(--text-md);
  }
  
  input, select, textarea {
    font-size: var(--text-md);
  }
  
  /* Larger tap areas for list rows */
  .contactRow,
  .dealCard,
  .taskRow,
  .row {
    min-height: 56px;
    padding: 12px;
  }
  
  .row .avatar,
  .list-row-avatar {
    width: 40px;
    height: 40px;
    font-size: var(--text-base);
  }
  
  /* Horizontal scroll for tables */
  .table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  table {
    min-width: 600px; /* Force horizontal scroll instead of breaking layout */
  }
}

/* Tablet adjustments */
@media (max-width: 768px) and (min-width: 768px) {
  :root {
    --h-btn: 38px;
    --h-btn-sm: 32px;
    --h-input: 38px;
  }
}

/* ===========================================
   📱 MOBILE NAVIGATION BAR
=========================================== */
.mobile-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 60px;
  background: white;
  border-top: 1px solid #e2e8f0;
  z-index: 100;
  grid-template-columns: repeat(3, 1fr);
  box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
  /* Simple layout: Contacts | Pipeline | Detail */
}

.is-mobile .mobile-nav {
  display: grid;
}

.mobile-nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: none;
  background: transparent;
  color: #64748b;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.mobile-nav-btn svg {
  width: 24px;
  height: 24px;
  stroke-width: 2;
}

.mobile-nav-btn.active {
  color: #3b82f6;
}

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

/* Add padding to body on mobile to account for bottom nav */
.is-mobile .app-shell {
  padding-bottom: 60px;
}

/* ===========================================
   📱 MOBILE - HIDE COMPLEX FEATURES
=========================================== */
@media (max-width: 767px) {
  /* ===== SIMPLIFIED MOBILE NAVIGATION ===== */
  /* Hide the entire top header/navigation bar on mobile - use bottom nav instead */
  .app-header,
  .header-nav,
  .header-user-area {
    display: none !important;
  }
  
  /* Hide all complex menu items - keep only Contacts, Pipeline, Projects */
  #menuAnalyticsBtn,
  #menuCalendarBtn,
  #menuReportsBtn,
  #menuLeadsBtn,
  #menuFormsBtn,
  #menuTemplatesBtn,
  #menuToolsBtn,
  #menuCampaignsBtn,
  .power-actions-btn,
  .bulk-actions-bar,
  #bulkBarMount,
  #settingsBtn,
  #activityFeedBtn {
    display: none !important;
  }
  
  /* Simplify header nav - hide utility buttons and divider */
  .header-nav .nav-group-utility,
  .header-nav .nav-divider,
  .nav-more-dropdown {
    display: none !important;
  }
  
  /* Keep only essential navigation visible */
  #menuContactsBtn,
  #menuPipelineBtn,
  #menuProjectsBtn {
    display: flex !important;
  }
  
  /* Ensure filters/search section is visible and styled properly on mobile */
  #filtersSection,
  .filters-modern {
    display: block !important;
    width: 100% !important;
    padding: 12px !important;
    background: white;
    border-bottom: 1px solid #e2e8f0;
    position: sticky;
    top: 0;
    z-index: 50;
  }
  
  /* Optimize filter bar for mobile */
  .filter-bar-main {
    flex-wrap: wrap !important;
    gap: 8px !important;
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
  }
  
  .filter-search-wrap {
    flex: 1 1 100% !important;
    min-width: 100% !important;
    margin-bottom: 4px !important;
  }
  
  /* Make search input full width on mobile */
  .filter-search-input {
    width: 100% !important;
    font-size: 16px !important; /* Prevents zoom on iOS */
  }
  
  /* Second row: fit on one line */
  #ownerFilterDropdown,
  .filter-sort-wrap {
    flex: 0 1 auto !important;
    min-width: auto !important;
    width: auto !important;
  }
  
  .filter-add-btn {
    margin-left: auto !important;
  }
  
  .filter-add-btn {
    width: auto !important;
    white-space: nowrap !important;
  }
  
  /* Hide less critical elements to save space on mobile */
  #clearFilterBtn,
  .filter-quick-pills {
    display: none !important;
  }
  
  /* Adjust filter buttons for mobile */
  .filter-sort-wrap,
  .actions-dropdown {
    font-size: 14px !important;
  }
  
  /* Make dropdown buttons more compact */
  .actions-dropdown-btn {
    padding: 8px 10px !important;
    font-size: 14px !important;
  }
  
  /* Hide folder pane on mobile by default */
  .folderPane {
    display: none !important;
  }
  
  /* Adjust main column for mobile without header */
  .mainColumn {
    padding-top: 0 !important;
  }
  
  /* Make modals full-screen on mobile */
  .modal,
  .modalDialog,
  #settingsModal .modal,
  .campaign-modal,
  .form-builder-modal {
    width: 100vw !important;
    height: 100vh !important;
    max-width: 100vw !important;
    max-height: 100vh !important;
    margin: 0 !important;
    border-radius: 0 !important;
  }
  
  .modalHead,
  .modal-header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: white;
    border-bottom: 1px solid #e2e8f0;
  }
  
  .modalBody,
  .modal-body {
    height: calc(100vh - 60px);
    overflow-y: auto;
  }
}

/* ===========================================
   🍞 TOAST NOTIFICATIONS
=========================================== */
.crm-toast {
  position: fixed;
  top: var(--sp-8);
  left: 50%;
  transform: translateX(-50%);
  background: var(--primary-600);
  color: #fff;
  padding: var(--sp-5) var(--sp-8);
  border-radius: var(--r-lg);
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  box-shadow: var(--sh-lg), 0 8px 24px rgba(37, 99, 235, 0.25);
  z-index: 999999;
  pointer-events: none;
  transition: all 300ms ease;
}

/* ===========================================
   ✅ HARD GUARANTEE: panes reach the bottom
   styles-master.css loads last, so this wins.
=========================================== */
.mainSplit{
  align-items: stretch !important;
}
.mainSplit > *{
  align-self: stretch !important;
}
#detailPanel.detailPane,
.detailPane{
  max-height: none !important;
  height: 100% !important;
}

/* ===========================================
   ✅ Detail top strip should span full width
   (detailContent has padding; we negate it for the top strip only)
=========================================== */
#detailContent > .detailTopStrip {
  margin-left: -14px !important;
  margin-right: -14px !important;
  width: calc(100% + 28px) !important;
}

/* ===========================================
   🎴 DETAIL CARDS (override inline styles)
=========================================== */
.detailCard {
  padding: var(--sp-6) !important;
  border: 1px solid var(--border-light) !important;
  border-radius: var(--r-xl) !important;
  box-shadow: var(--sh-sm) !important;
  background: var(--surface) !important;
  margin-bottom: var(--sp-5) !important;
}

.detailCard + .detailCard {
  margin-top: var(--sp-5) !important;
}

/* Card title */
.detailCard > div:first-child,
.detailCard .detailCardTitle,
[style*="font-weight:1000"] {
  font-size: var(--text-md) !important;
  font-weight: var(--weight-bold) !important;
  color: var(--text-primary) !important;
  margin-bottom: var(--sp-4) !important;
}

/* ===========================================
   📊 INLINE STYLE OVERRIDES
   Force consistency on elements with inline styles
=========================================== */

/* Deal context row */
#contextRow {
  margin-bottom: var(--sp-5) !important;
  padding: var(--sp-4) !important;
  background: var(--gray-50) !important;
  border-radius: var(--r-md) !important;
  font-size: var(--text-base) !important;
}

/* Deal documents section */
[style*="background:#f0f9ff"],
[style*="background: #f0f9ff"] {
  background: var(--primary-50) !important;
  border-color: var(--primary-200) !important;
  border-radius: var(--r-lg) !important;
}

/* Custom fields section */
[style*="background: linear-gradient(135deg, var(--primary-50)"] {
  background: var(--gray-50) !important;
  border: 1px solid var(--border-light) !important;
  border-radius: var(--r-lg) !important;
}

/* Multiselect fields */
.cf-multiselect {
  display: flex !important;
  flex-wrap: wrap !important;
  gap: var(--sp-3) !important;
  padding: var(--sp-3) !important;
  background: var(--surface) !important;
  border: 1px solid var(--border-light) !important;
  border-radius: var(--r-md) !important;
}

.cf-multiselect label {
  display: flex !important;
  align-items: center !important;
  gap: var(--sp-2) !important;
  padding: var(--sp-1) var(--sp-3) !important;
  background: var(--gray-50) !important;
  border-radius: var(--r-sm) !important;
  font-size: var(--text-base) !important;
  cursor: pointer !important;
}

.cf-multiselect label:has(input:checked) {
  background: var(--primary-100) !important;
}

/* ===========================================
   🔢 FORM FIELD LABELS (consistency)
=========================================== */
.label-text {
  font-size: var(--text-sm) !important;
  font-weight: var(--weight-semibold) !important;
  color: var(--text-secondary) !important;
}

.label-col {
  display: flex !important;
  flex-direction: column !important;
  gap: var(--sp-1) !important;
}

/* ===========================================
   📋 DEAL/DOCUMENT LIST ITEMS
=========================================== */
.dealItem,
.documentItem,
[style*="display:flex;justify-content:space-between;align-items:center;padding:8px;background:white;border:1px solid"] {
  display: flex !important;
  justify-content: space-between !important;
  align-items: center !important;
  padding: var(--sp-3) !important;
  background: var(--surface) !important;
  border: 1px solid var(--border-light) !important;
  border-radius: var(--r-md) !important;
  margin-bottom: var(--sp-2) !important;
  cursor: pointer !important;
  transition: all var(--tr-fast) !important;
}

.dealItem:hover,
.documentItem:hover {
  background: var(--gray-50) !important;
  border-color: var(--border-medium) !important;
}

/* ===========================================
   📊 STAGE PICKER ITEMS
=========================================== */
.stage-option {
  padding: var(--sp-4) !important;
  border-radius: var(--r-md) !important;
  cursor: pointer !important;
  transition: all var(--tr-fast) !important;
}

.stage-option:hover {
  transform: translateY(-1px) !important;
  box-shadow: var(--sh-sm) !important;
}

/* ===========================================
   🏷️ INLINE TAGS (Deal Linked, Sent, etc.)
=========================================== */
[style*="background:#dbeafe;color:#1e40af;padding:2px 6px;border-radius:4px;font-size:10px"],
[style*="background:#dcfce7;color:#15803d;padding:2px 6px;border-radius:4px;font-size:10px"] {
  padding: 2px var(--sp-3) !important;
  border-radius: var(--r-xs) !important;
  font-size: var(--text-2xs) !important;
  font-weight: var(--weight-semibold) !important;
}

/* ===========================================
   📝 QUILL EDITOR IMPROVEMENTS
=========================================== */
.ql-container {
  font-family: var(--font-sans) !important;
  font-size: var(--text-md) !important;
}

.ql-editor {
  font-size: var(--text-md) !important;
  line-height: 1.6 !important;
}

.ql-toolbar {
  border-radius: var(--r-lg) var(--r-lg) 0 0 !important;
  border-color: var(--border-light) !important;
  background: var(--gray-50) !important;
}

.ql-container {
  border-radius: 0 0 var(--r-lg) var(--r-lg) !important;
  border-color: var(--border-light) !important;
}

/* ===========================================
   📊 ANALYTICS & PIPELINE CARDS
=========================================== */
.analyticsMetricCard,
.pipelineCard {
  background: var(--surface) !important;
  border: 1px solid var(--border-light) !important;
  border-radius: var(--r-xl) !important;
  padding: var(--sp-7) !important;
  box-shadow: var(--sh-sm) !important;
}

.analyticsMetricCard:hover,
.pipelineCard:hover {
  box-shadow: var(--sh-md) !important;
}

/* ===========================================
   🎨 CALENDAR STYLING
=========================================== */
.calDay {
  border-radius: var(--r-md) !important;
}

.calMiniItem,
.calWeekItem,
.calDayItem,
.calAgendaItem {
  padding: var(--sp-2) var(--sp-3) !important;
  border-radius: var(--r-sm) !important;
  font-size: var(--text-sm) !important;
  font-weight: var(--weight-medium) !important;
}

/* Calendar header buttons */
#calPrevBtn,
#calTodayBtn,
#calNextBtn {
  height: 28px !important;
  padding: 0 var(--sp-4) !important;
  border-radius: var(--r-md) !important;
  font-size: var(--text-sm) !important;
}

/* Calendar view mode select */
#calViewMode {
  height: 28px !important;
  padding: 0 var(--sp-5) !important;
  border-radius: var(--r-md) !important;
  font-weight: var(--weight-semibold) !important;
  font-size: var(--text-sm) !important;
}

/* ===========================================
   📊 PIPELINE STYLING
=========================================== */
.pipelinePanel {
  background: var(--surface) !important;
  border: 1px solid var(--border-light) !important;
  border-radius: var(--r-2xl) !important;
}

.pipelineHeader {
  padding: var(--sp-6) !important;
  border-bottom: 1px solid var(--border-light) !important;
}

.pipelineColumn {
  background: var(--gray-50) !important;
  border-radius: var(--r-lg) !important;
  padding: var(--sp-4) !important;
}

.pipelineColumnHeader {
  padding: var(--sp-4) !important;
  font-weight: var(--weight-bold) !important;
  font-size: var(--text-md) !important;
  border-radius: var(--r-md) !important;
}

/* Pipeline card items */
.pipelineCard {
  background: var(--surface) !important;
  border: 1px solid var(--border-light) !important;
  border-radius: var(--r-lg) !important;
  padding: var(--sp-5) !important;
  margin-bottom: var(--sp-3) !important;
  cursor: pointer !important;
  transition: all var(--tr-fast) !important;
}

.pipelineCard:hover {
  border-color: var(--border-medium) !important;
  box-shadow: var(--sh-sm) !important;
}

/* Pipeline summary strip */
#pipelineSummary .pill {
  font-weight: var(--weight-bold) !important;
  font-size: var(--text-2xs) !important;
}

/* Pipeline refresh button */
#pipeRefreshBtn {
  padding: var(--sp-3) var(--sp-4) !important;
  border-radius: var(--r-md) !important;
  height: var(--h-btn-sm) !important;
}

/* ===========================================
   🖼️ TEMPLATE CARDS
=========================================== */
.template-card {
  background: var(--surface) !important;
  border: 1px solid var(--border-light) !important;
  border-radius: var(--r-xl) !important;
  overflow: hidden !important;
  transition: all var(--tr-fast) !important;
}

.template-card:hover {
  box-shadow: var(--sh-md) !important;
  transform: translateY(-2px) !important;
}

/* ===========================================
   🔧 SETTINGS PAGE
=========================================== */
.settingsSection {
  background: var(--surface) !important;
  border: 1px solid var(--border-light) !important;
  border-radius: var(--r-xl) !important;
  padding: var(--sp-8) !important;
  margin-bottom: var(--sp-7) !important;
}

.settingsSection h3 {
  font-size: var(--text-lg) !important;
  font-weight: var(--weight-bold) !important;
  margin-bottom: var(--sp-6) !important;
  padding-bottom: var(--sp-4) !important;
  border-bottom: 1px solid var(--border-light) !important;
}

/* ===========================================
   ⚙️ SETTINGS MODAL (Left sidebar layout)
=========================================== */
#settingsModal .modal {
  /* Fixed 90% of viewport - does NOT resize based on content */
  width: 90vw !important;
  max-width: 1400px !important;
  height: 90vh !important;
  max-height: 90vh !important;
}

#settingsModal .modalBody {
  /* Override default modalBody padding/scroll so we can control it per-pane */
  padding: 0;
  overflow: hidden;
  display: grid;
  grid-template-columns: 240px 1fr;
  flex: 1; /* Fill remaining space after modalHead */
  min-height: 0; /* Allow flexbox to constrain height */
}

#settingsTabs {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding: var(--sp-6);
  background: var(--gray-50);
  border-right: 1px solid var(--border-light);
  overflow: auto;
}

#settingsBody {
  padding: var(--sp-8);
  overflow: auto;
  min-width: 0;
}

/* Sidebar tab buttons (don’t inherit the pill-row look) */
#settingsTabs .tab {
  width: 100%;
  justify-content: flex-start;
  height: var(--h-btn-lg);
  padding: 0 var(--sp-5);
  border-radius: var(--r-lg);
  border: 1px solid transparent;
  background: transparent;
  box-shadow: none;
  color: var(--text-secondary);
  font-weight: var(--weight-medium);
}

#settingsTabs .tab:hover {
  background: rgba(15, 23, 42, 0.04);
  color: var(--text-primary);
}

#settingsTabs .tab.active {
  background: var(--surface);
  border-color: var(--border-light);
  color: var(--text-primary);
  font-weight: var(--weight-semibold);
  box-shadow: var(--sh-sm);
}

@media (max-width: 900px) {
  #settingsModal .modal {
    width: 95vw !important;
    height: 95vh !important;
  }
  #settingsModal .modalBody {
    grid-template-columns: 1fr;
  }
  #settingsTabs {
    flex-direction: row;
    align-items: center;
    gap: var(--sp-2);
    padding: var(--sp-4);
    border-right: none;
    border-bottom: 1px solid var(--border-light);
    overflow-x: auto;
    overflow-y: hidden;
  }
  #settingsTabs .tab {
    width: auto;
    height: var(--h-btn);
    padding: 0 var(--sp-4);
    border-radius: var(--r-full);
  }
  #settingsBody {
    padding: var(--sp-6);
  }
}

/* ===========================================
   🔔 EMPTY STATES
=========================================== */
.empty,
.emptyState {
  /* Don't force `display` — UI JS toggles empty states via inline style (none/grid). */
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  padding: var(--sp-10) var(--sp-8) !important;
  text-align: center !important;
}

.emptyTitle {
  font-size: var(--text-lg) !important;
  font-weight: var(--weight-semibold) !important;
  color: var(--text-primary) !important;
  margin-bottom: var(--sp-3) !important;
}

.emptySub {
  font-size: var(--text-md) !important;
  color: var(--text-secondary) !important;
}

/* ===========================================
   🎯 FORCE BUTTON CONSISTENCY
   Override any stray button styles
=========================================== */
button:not(.ql-formats button):not([class*="hamburger"]):not(.folderMenuBtn) {
  font-family: var(--font-sans);
  font-weight: var(--weight-semibold);
}

/* Ensure all buttons in detail sections match */
.detailSection button.btn,
.detailTopStrip button.btn,
.detailTopActions button.btn {
  height: var(--h-btn);
  padding: 0 var(--sp-5);
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  border-radius: var(--r-md);
}

/* Action buttons (Add deal, Add document, etc.) */
.btn.action-btn {
  background: var(--primary-600) !important;
  border-color: var(--primary-600) !important;
  color: #fff !important;
}

.btn.action-btn:hover {
  background: var(--primary-700) !important;
  border-color: var(--primary-700) !important;
}

/* ===========================================
   📱 SCROLLBAR CONSISTENCY
=========================================== */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--gray-300) transparent;
}

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

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

*::-webkit-scrollbar-thumb {
  background: var(--gray-300);
  border-radius: var(--r-full);
}

*::-webkit-scrollbar-thumb:hover {
  background: var(--gray-400);
}

/* ===========================================
   📣 CAMPAIGN MANAGER
=========================================== */
.campaign-manager-modal {
  border-radius: var(--r-2xl);
}

.campaign-tabs {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  background: var(--gray-100);
  border-radius: var(--r-full);
}

.campaign-tab {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  padding: 6px 10px;
  border-radius: var(--r-lg);
  cursor: pointer;
  transition: all var(--tr-fast);
  height: 30px;
  display: inline-flex;
  align-items: center;
}

.campaign-tab:hover {
  background: var(--gray-200);
  color: var(--text-primary);
}

.campaign-tab.active {
  background: var(--surface);
  color: var(--primary-600);
  font-weight: var(--weight-bold);
  box-shadow: var(--sh-xs);
}

.campaign-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  align-items: start;
}

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

.campaign-card {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-sm);
  overflow: hidden;
}

.campaign-card-head {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-light);
  background: var(--gray-50);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.campaign-card-title {
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.campaign-card-body {
  padding: 14px;
}

.campaign-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.campaign-stat {
  background: var(--gray-50);
  border: 1px solid var(--border-light);
  border-radius: var(--r-lg);
  padding: 10px 12px;
}

.campaign-stat-num {
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  letter-spacing: -0.01em;
}

.campaign-stat-label {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: var(--weight-semibold);
}

.campaign-preview {
  background: var(--gray-50);
  border: 1px solid var(--border-light);
  border-radius: var(--r-lg);
  padding: 12px;
}

.campaign-preview-label {
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.campaign-preview-value {
  margin-top: 6px;
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
}

/* Progress UI */
.campaign-progress {
  width: 100%;
  height: 10px;
  background: var(--gray-100);
  border: 1px solid var(--border-light);
  border-radius: var(--r-full);
  overflow: hidden;
}

.campaign-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary-600), var(--primary-500));
  transition: width var(--tr-fast);
}

.campaign-current-send strong {
  color: var(--text-primary);
}

/* Small spacing helpers inside campaign manager previews */
.campaign-manager-modal .campaign-preview .pill {
  margin: 0 6px 6px 0;
}

.campaign-manager-modal input[type="datetime-local"] {
  font-variant-numeric: tabular-nums;
}

.campaign-sendrow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border-light);
  margin-top: 6px;
}

.campaign-info {
  background: var(--primary-50);
  border: 1px solid var(--primary-200);
  color: var(--text-primary);
  border-radius: var(--r-lg);
  padding: 12px 12px;
  font-size: var(--text-md);
}

.campaign-list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border-light);
  border-radius: var(--r-lg);
  background: var(--surface);
}

.campaign-list-name {
  font-weight: var(--weight-bold);
  font-size: var(--text-md);
}

.campaign-list-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

.campaign-row {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border-light);
  border-radius: var(--r-lg);
  background: var(--surface);
  cursor: pointer;
  text-align: left;
  transition: all var(--tr-fast);
}

.campaign-row:hover {
  background: var(--gray-50);
  border-color: var(--border-medium);
}

.campaign-row.is-active {
  border-color: rgba(37,99,235,0.35);
  box-shadow: var(--sh-focus);
}

.campaign-row-main {
  min-width: 0;
  flex: 1;
}

.campaign-row-name {
  font-weight: var(--weight-bold);
  font-size: var(--text-md);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.campaign-row-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.campaign-audit-head {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 2fr;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-light);
  background: var(--gray-50);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.campaign-audit-body {
  display: grid;
}

.campaign-audit-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 2fr;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(15,23,42,0.06);
  align-items: center;
}

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

.campaign-cal {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-sm);
  overflow: hidden;
}

.campaign-cal-head {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-light);
  background: var(--gray-50);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.campaign-cal-title {
  font-weight: var(--weight-bold);
  font-size: var(--text-md);
}

.campaign-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.campaign-cal-dow {
  padding: 8px 10px;
  font-size: var(--text-xs);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: var(--weight-bold);
  border-bottom: 1px solid var(--border-light);
  background: var(--surface);
}

.campaign-cal-cell {
  height: 86px;
  border: none;
  border-bottom: 1px solid rgba(15,23,42,0.06);
  border-right: 1px solid rgba(15,23,42,0.06);
  background: var(--surface);
  padding: 10px;
  text-align: left;
  cursor: pointer;
  transition: background var(--tr-fast);
  position: relative;
}
.campaign-cal-cell:hover {
  background: var(--gray-50);
}
.campaign-cal-cell.is-out {
  background: rgba(15,23,42,0.02);
  color: rgba(15,23,42,0.45);
}
.campaign-cal-num {
  font-weight: var(--weight-bold);
}
.campaign-cal-pill {
  position: absolute;
  right: 10px;
  top: 10px;
  font-size: 11px;
  font-weight: var(--weight-bold);
  padding: 2px 8px;
  border-radius: var(--r-full);
  background: var(--primary-100);
  color: var(--primary-700);
  border: 1px solid var(--primary-200);
}
.campaign-cal-foot {
  padding: 10px 14px;
  border-top: 1px solid var(--border-light);
  background: var(--surface);
}

/* ===========================================
   ⚡ ACTIVITY FEED PANEL
=========================================== */
.activity-feed-panel {
  position: fixed;
  top: 0;
  right: -400px;
  width: 400px;
  height: 100vh;
  background: var(--surface);
  border-left: 1px solid var(--border-light);
  box-shadow: var(--sh-xl);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  transition: right 300ms ease;
}

.activity-feed-panel.active {
  right: 0;
}

.activity-feed-panel.hidden {
  display: flex !important;
  visibility: visible !important;
  opacity: 1 !important;
  pointer-events: auto !important;
}

.activity-feed-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(2px);
  z-index: 9999;
  opacity: 0;
  transition: opacity 300ms ease;
  pointer-events: none;
}

.activity-feed-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.activity-feed-backdrop.hidden {
  display: block !important;
  visibility: visible !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

.activity-feed-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-6) var(--sp-7);
  border-bottom: 1px solid var(--border-light);
  background: var(--gray-50);
  flex-shrink: 0;
}

.activity-feed-title {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
}

.activity-feed-title svg {
  color: var(--primary-600);
}

.activity-feed-title h2 {
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  margin: 0;
}

.activity-feed-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: var(--r-md);
  font-size: 18px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--tr-fast);
}

.activity-feed-close:hover {
  background: var(--gray-100);
  color: var(--text-primary);
}

.activity-feed-filters {
  display: flex;
  gap: var(--sp-2);
  padding: var(--sp-4) var(--sp-6);
  border-bottom: 1px solid var(--border-light);
  background: var(--surface);
  flex-shrink: 0;
}

.activity-filter-btn {
  padding: var(--sp-2) var(--sp-4);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  background: transparent;
  border: 1px solid var(--border-light);
  border-radius: var(--r-full);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--tr-fast);
}

.activity-filter-btn:hover {
  background: var(--gray-50);
  border-color: var(--border-medium);
}

.activity-filter-btn.active {
  background: var(--primary-600);
  border-color: var(--primary-600);
  color: #fff;
}

.activity-feed-content {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-4);
}

.activity-feed-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--sp-10);
  color: var(--text-secondary);
}

.loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--primary-600);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: var(--sp-4);
}

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

.activity-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--sp-10);
  text-align: center;
  color: var(--text-secondary);
}

.activity-empty svg {
  width: 48px;
  height: 48px;
  margin-bottom: var(--sp-4);
  opacity: 0.3;
}

.activity-empty h3 {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  margin-bottom: var(--sp-2);
}

.activity-empty p {
  font-size: var(--text-md);
  margin: 0;
}

.activity-group {
  margin-bottom: var(--sp-6);
}

.activity-group-header {
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-tertiary);
  padding: var(--sp-3) var(--sp-4);
  margin-bottom: var(--sp-2);
}

.activity-item {
  display: flex;
  gap: var(--sp-4);
  padding: var(--sp-4);
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--r-lg);
  margin-bottom: var(--sp-3);
  cursor: pointer;
  transition: all var(--tr-fast);
}

.activity-item:hover {
  background: var(--gray-50);
  border-color: var(--border-medium);
}

.activity-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gray-100);
  border-radius: var(--r-md);
  font-size: 16px;
  flex-shrink: 0;
}

.activity-icon.deal {
  background: var(--primary-50);
}

.activity-icon.contact {
  background: var(--gray-100);
}

.activity-icon.activity {
  background: var(--warning-50);
}

.activity-icon.won {
  background: #dcfce7;
}

.activity-icon.lost {
  background: var(--danger-50);
}

.activity-content {
  flex: 1;
  min-width: 0;
}

.activity-title {
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.activity-meta {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-top: 2px;
}

.activity-user {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.activity-time {
  flex-shrink: 0;
  font-size: var(--text-xs);
  color: var(--text-tertiary);
}

/* Activity toggle button style */
.activity-feed-toggle {
  display: inline-flex !important;
  align-items: center !important;
  gap: var(--sp-2) !important;
}

.activity-feed-toggle svg {
  color: var(--warning-600);
}

/* ===========================================
   🧰 TOOLS MENU (Header)
=========================================== */
.tools-menu {
  position: fixed;
  z-index: 10060;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-xl);
  padding: 6px;
  min-width: 220px;
}

.tools-menu-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: var(--text-md);
  font-weight: var(--weight-medium);
  border-radius: var(--r-lg);
  cursor: pointer;
  text-align: left;
  transition: background var(--tr-fast), color var(--tr-fast);
}

.tools-menu-item:hover:not(:disabled) {
  background: var(--gray-50);
  color: var(--primary-600);
}

.tools-menu-item:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.tools-menu-sep {
  height: 1px;
  background: var(--border-light);
  margin: 6px;
}
