/**
 * Cross Blade CRM - Apple Human Interface Design System
 * Inspired by WWDC Design Guidelines & Apple OS Aesthetics
 */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  --apple-font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Inter", -apple-system, sans-serif;
  
  /* System Colors */
  --apple-blue: #0071e3;
  --apple-blue-hover: #0077ed;
  --apple-blue-light: rgba(0, 113, 227, 0.08);
  --apple-green: #34c759;
  --apple-green-light: rgba(52, 199, 89, 0.12);
  --apple-orange: #ff9500;
  --apple-orange-light: rgba(255, 149, 0, 0.12);
  --apple-red: #ff3b30;
  --apple-red-light: rgba(255, 59, 48, 0.12);
  --apple-purple: #af52de;
  --apple-purple-light: rgba(175, 82, 222, 0.12);
  --apple-indigo: #5856d6;
  --apple-indigo-light: rgba(88, 86, 214, 0.12);
  --apple-gray: #8e8e93;

  /* Surfaces & Backgrounds */
  --bg-primary: #f5f5f7;
  --bg-secondary: #ffffff;
  --bg-tertiary: #fbfbfd;
  --card-bg: rgba(255, 255, 255, 0.82);
  --card-border: rgba(0, 0, 0, 0.07);
  --card-border-focus: rgba(0, 113, 227, 0.45);
  --glass-header: rgba(245, 245, 247, 0.8);

  /* Typography */
  --text-main: #1d1d1f;
  --text-secondary: #6e6e73;
  --text-muted: #86868b;
  --text-inverse: #ffffff;

  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.09);
  --shadow-sheet: 0 24px 60px rgba(0, 0, 0, 0.16);

  /* Radii */
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --radius-full: 980px;

  /* Physics / Spring */
  --ease-apple: cubic-bezier(0.16, 1, 0.3, 1);
}

/* Base Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--apple-font);
  background-color: var(--bg-primary);
  color: var(--text-main);
  line-height: 1.5;
  font-size: 14px;
  min-height: 100vh;
  overflow-x: hidden;
}

a {
  color: var(--apple-blue);
  text-decoration: none;
  transition: opacity 0.15s ease;
}
a:hover {
  text-decoration: underline;
}

button {
  font-family: inherit;
  border: none;
  background: transparent;
  outline: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.25);
}

/* App Shell */
.app-container {
  display: flex;
  min-height: 100vh;
}

/* Translucent Navigation Bar */
.apple-nav {
  position: sticky;
  top: 0;
  width: 100%;
  height: 64px;
  background: var(--glass-header);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--card-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  z-index: 900;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-brand img {
  height: 38px;
  width: auto;
  object-fit: contain;
  border-radius: 6px;
}

.nav-title {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--text-main);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Segmented Control / Apple Tabs */
.segmented-control {
  display: inline-flex;
  background: rgba(0, 0, 0, 0.05);
  padding: 3px;
  border-radius: 10px;
  border: 1px solid rgba(0, 0, 0, 0.04);
}

.segment-item {
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
  border-radius: 7px;
  color: var(--text-secondary);
  cursor: pointer;
  border: none;
  background: transparent;
  transition: all 0.2s var(--ease-apple);
}

.segment-item.active {
  background: #ffffff;
  color: var(--text-main);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
  font-weight: 600;
}

/* Buttons */
.apple-btn {
  font-family: var(--apple-font);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 18px;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius-full);
  border: 1px solid transparent;
  cursor: pointer;
  outline: none;
  transition: transform 0.15s var(--ease-apple), background 0.15s ease, box-shadow 0.15s ease;
  user-select: none;
}

.apple-btn:active {
  transform: scale(0.97);
  transition: transform 100ms ease-out;
}

.btn-primary {
  background: var(--apple-blue);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(0, 113, 227, 0.25);
}
.btn-primary:hover {
  background: var(--apple-blue-hover);
}

.btn-secondary {
  background: rgba(0, 0, 0, 0.05);
  color: var(--text-main);
}
.btn-secondary:hover {
  background: rgba(0, 0, 0, 0.08);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover {
  background: rgba(0, 0, 0, 0.04);
  color: var(--text-main);
}

.btn-success {
  background: var(--apple-green);
  color: #ffffff;
}
.btn-success:hover {
  background: #2cb34e;
}

.btn-danger {
  background: var(--apple-red-light);
  color: var(--apple-red);
}
.btn-danger:hover {
  background: rgba(255, 59, 48, 0.2);
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-full);
}

/* Layout */
.main-content {
  flex: 1;
  padding: 28px 36px 64px;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

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

.page-title {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--text-main);
}

.page-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* Apple Cards */
.apple-card {
  background: var(--card-bg);
  backdrop-filter: blur(25px);
  -webkit-backdrop-filter: blur(25px);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s var(--ease-apple), box-shadow 0.2s var(--ease-apple);
}

.apple-card.interactive {
  cursor: pointer;
}
.apple-card.interactive:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: rgba(0, 113, 227, 0.2);
}
.apple-card.interactive:active {
  transform: scale(0.99);
}

/* Metric / Stat Card */
.stat-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 130px;
  position: relative;
  overflow: hidden;
}

.stat-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
  font-size: 20px;
}

.stat-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.stat-value {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-main);
}

.stat-hint {
  font-size: 12px;
  color: var(--apple-blue);
  margin-top: 6px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Stat Card Grids */
.stats-grid-primary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
  margin-bottom: 24px;
}

.stats-grid-funnel {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 14px;
  margin-bottom: 28px;
}

/* Apple Status Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  border-radius: var(--radius-full);
  line-height: 1;
}

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.badge-pitch_done {
  background: var(--apple-blue-light);
  color: var(--apple-blue);
}
.badge-pitch_done .badge-dot { background: var(--apple-blue); }

.badge-in_followup {
  background: var(--apple-orange-light);
  color: var(--apple-orange);
}
.badge-in_followup .badge-dot { background: var(--apple-orange); }

.badge-closed {
  background: var(--apple-green-light);
  color: #248a3d;
}
.badge-closed .badge-dot { background: #248a3d; }

.badge-later {
  background: var(--apple-purple-light);
  color: var(--apple-purple);
}
.badge-later .badge-dot { background: var(--apple-purple); }

.badge-lead_bad {
  background: rgba(142, 142, 147, 0.14);
  color: #555558;
}
.badge-lead_bad .badge-dot { background: #8e8e93; }

.badge-deal_lost {
  background: var(--apple-red-light);
  color: var(--apple-red);
}
.badge-deal_lost .badge-dot { background: var(--apple-red); }

.badge-agency {
  background: var(--apple-indigo-light);
  color: var(--apple-indigo);
}
.badge-personal {
  background: rgba(0, 113, 227, 0.1);
  color: var(--apple-blue);
}

/* Filter Bar */
.filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: #ffffff;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  border: 1px solid var(--card-border);
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
  flex-wrap: wrap;
}

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

.apple-input, .apple-select, .apple-textarea {
  font-family: var(--apple-font);
  background: #fbfbfd;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 13px;
  color: var(--text-main);
  outline: none;
  transition: all 0.15s ease;
}

.apple-input:focus, .apple-select:focus, .apple-textarea:focus {
  background: #ffffff;
  border-color: var(--apple-blue);
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.15);
}

.search-box {
  position: relative;
  width: 240px;
}
.search-box input {
  width: 100%;
  padding-left: 34px;
}
.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

/* Modern Apple Table */
.table-container {
  background: #ffffff;
  border-radius: var(--radius-lg);
  border: 1px solid var(--card-border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.apple-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.apple-table th {
  background: #fbfbfd;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  padding: 14px 18px;
  border-bottom: 1px solid var(--card-border);
  white-space: nowrap;
}

.apple-table td {
  padding: 16px 18px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
  font-size: 13px;
  vertical-align: middle;
}

.apple-table tbody tr {
  transition: background 0.15s ease;
}
.apple-table tbody tr:hover {
  background: #f8f9fb;
}
.apple-table tbody tr:last-child td {
  border-bottom: none;
}

/* Sheet / Modal (Apple Style) */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s var(--ease-apple), visibility 0.25s var(--ease-apple);
  padding: 20px;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.apple-modal {
  background: #ffffff;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sheet);
  border: 1px solid rgba(255, 255, 255, 0.8);
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.95) translateY(10px);
  transition: transform 0.3s var(--ease-apple);
}

.apple-modal.modal-large {
  max-width: 860px;
}

.modal-overlay.active .apple-modal {
  transform: scale(1) translateY(0);
}

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

.modal-title {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--text-main);
}

.modal-close {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.05);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-secondary);
  transition: background 0.15s ease;
}
.modal-close:hover {
  background: rgba(0, 0, 0, 0.1);
  color: var(--text-main);
}

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

.modal-footer {
  padding: 16px 28px;
  background: #fbfbfd;
  border-top: 1px solid var(--card-border);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* Forms in Modal */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
.form-col-span-2 {
  grid-column: span 2;
}

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

.form-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-label.required::after {
  content: ' *';
  color: var(--apple-red);
}

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

/* Source Type Selector Cards */
.source-choice-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 18px;
}

.source-card {
  border: 2px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  background: #fbfbfd;
  transition: all 0.2s var(--ease-apple);
}

.source-card:hover {
  border-color: rgba(0, 113, 227, 0.3);
  background: #ffffff;
}

.source-card.selected {
  border-color: var(--apple-blue);
  background: rgba(0, 113, 227, 0.04);
}

.source-card-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}

/* Audio Player & Recording System */
.audio-player-card {
  background: #fbfbfd;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.audio-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.audio-icon-box {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(0, 113, 227, 0.1);
  color: var(--apple-blue);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* File Upload Dropzone */
.apple-dropzone {
  border: 2px dashed rgba(0, 0, 0, 0.12);
  border-radius: var(--radius-md);
  padding: 24px;
  text-align: center;
  cursor: pointer;
  background: #fafafc;
  transition: all 0.2s ease;
}
.apple-dropzone:hover {
  border-color: var(--apple-blue);
  background: rgba(0, 113, 227, 0.02);
}

/* Drilldown Slide-out Drawer / Details View */
.drawer-overlay {
  position: fixed;
  top: 0;
  right: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s var(--ease-apple), visibility 0.25s var(--ease-apple);
}

.drawer-overlay.active {
  opacity: 1;
  visibility: visible;
}

.apple-drawer {
  position: absolute;
  top: 0;
  right: 0;
  width: 100%;
  max-width: 620px;
  height: 100vh;
  background: #ffffff;
  box-shadow: -12px 0 36px rgba(0, 0, 0, 0.12);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.35s var(--ease-apple);
}

.drawer-overlay.active .apple-drawer {
  transform: translateX(0);
}

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

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

/* Timeline */
.timeline {
  position: relative;
  padding-left: 24px;
}
.timeline::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 10px;
  bottom: 10px;
  width: 2px;
  background: rgba(0, 0, 0, 0.08);
}

.timeline-item {
  position: relative;
  margin-bottom: 24px;
}
.timeline-item:last-child {
  margin-bottom: 0;
}

.timeline-dot {
  position: absolute;
  left: -24px;
  top: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ffffff;
  border: 3px solid var(--apple-blue);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.08);
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 2000;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  min-width: 300px;
  background: rgba(29, 29, 31, 0.94);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  color: #ffffff;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  animation: toastIn 0.3s var(--ease-apple);
}

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

/* Mobile First & Responsive Design */
:root {
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

/* iOS Bottom Tab Bar (Visible on mobile/tablet) */
.ios-tab-bar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(60px + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(25px) saturate(180%);
  -webkit-backdrop-filter: blur(25px) saturate(180%);
  border-top: 1px solid var(--card-border);
  z-index: 950;
  justify-content: space-around;
  align-items: center;
}

.ios-tab-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 500;
  padding: 6px 12px;
  cursor: pointer;
  outline: none;
  transition: color 0.15s ease, transform 0.1s var(--ease-apple);
  -webkit-tap-highlight-color: transparent;
}

.ios-tab-item:active {
  transform: scale(0.92);
}

.ios-tab-item svg {
  width: 22px;
  height: 22px;
  transition: stroke 0.15s ease;
}

.ios-tab-item.active {
  color: var(--apple-blue);
  font-weight: 600;
}
.ios-tab-item.active svg {
  stroke: var(--apple-blue);
}

/* Mobile Quick Add Floating Action Button */
.mobile-fab {
  display: none;
  position: fixed;
  bottom: calc(72px + var(--safe-bottom));
  right: 20px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--apple-blue);
  color: #ffffff;
  box-shadow: 0 8px 24px rgba(0, 113, 227, 0.45);
  border: none;
  align-items: center;
  justify-content: center;
  z-index: 940;
  cursor: pointer;
  transition: transform 0.15s var(--ease-apple), box-shadow 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.mobile-fab:active {
  transform: scale(0.92);
}

/* Mobile Lead Card Layout */
.leads-mobile-list {
  display: none;
  flex-direction: column;
  gap: 12px;
}

.lead-mobile-card {
  background: #ffffff;
  border-radius: var(--radius-lg);
  border: 1px solid var(--card-border);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: transform 0.15s var(--ease-apple);
  -webkit-tap-highlight-color: transparent;
}

.lead-mobile-card:active {
  transform: scale(0.985);
  background: #fbfbfd;
}

.lead-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.lead-card-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 6px;
}

.lead-card-phone {
  font-size: 13px;
  color: var(--apple-blue);
  font-weight: 500;
  margin-top: 2px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.lead-card-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  background: #f7f7f9;
  border-radius: 10px;
  padding: 10px;
  text-align: center;
  gap: 4px;
}

.lead-metric-item {
  display: flex;
  flex-direction: column;
}

.lead-metric-label {
  font-size: 10px;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
}

.lead-metric-value {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
}

.lead-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--text-secondary);
  border-top: 1px solid rgba(0, 0, 0, 0.05);
  padding-top: 8px;
}

/* Direct Microphone Voice Recorder on Mobile */
.mic-recorder-box {
  background: #fbfbfd;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.mic-record-btn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--apple-blue);
  color: #ffffff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 113, 227, 0.35);
  transition: all 0.2s var(--ease-apple);
}

.mic-record-btn.recording {
  background: var(--apple-red);
  box-shadow: 0 0 0 8px rgba(255, 59, 48, 0.2);
  animation: pulse 1.2s infinite;
}

@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

.mic-timer {
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-main);
}

/* Mobile Sheet Drag Handle */
.sheet-drag-handle {
  width: 36px;
  height: 5px;
  background: rgba(0, 0, 0, 0.15);
  border-radius: 980px;
  margin: 8px auto 14px;
  display: none;
}

/* Mobile Screen Breakpoint (< 768px) */
@media (max-width: 768px) {
  body {
    padding-bottom: calc(75px + var(--safe-bottom));
  }

  .main-content {
    padding: 16px 14px 40px;
  }

  .apple-nav {
    padding: 0 16px;
    height: 54px;
  }

  .nav-brand img {
    height: 30px;
  }

  .nav-title {
    font-size: 15px;
  }

  /* Hide desktop segmented control & actions on mobile top bar */
  .segmented-control {
    display: none;
  }
  #btnAddLead {
    display: none;
  }

  /* Show iOS Bottom Tab Bar & FAB */
  .ios-tab-bar {
    display: flex;
  }
  .mobile-fab {
    display: flex;
  }

  /* Cards on mobile */
  .stats-grid-primary {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .stats-grid-funnel {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 18px;
  }

  .page-title {
    font-size: 22px;
  }

  .filter-bar {
    padding: 12px;
    gap: 10px;
  }

  .search-box {
    width: 100%;
  }

  .filter-group {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
  }

  .filter-group select, .filter-group input {
    width: 100%;
  }

  /* Hide Desktop Table on Mobile and show sleek iOS cards */
  .table-container.desktop-only-table {
    display: none;
  }
  .leads-mobile-list {
    display: flex;
  }

  /* Apple Bottom Sheet Modal on Mobile */
  .modal-overlay {
    align-items: flex-end;
    padding: 0;
  }

  .apple-modal {
    max-height: 92vh;
    border-radius: 24px 24px 0 0;
    transform: translateY(100%);
    max-width: 100%;
    border-bottom: none;
    padding-bottom: var(--safe-bottom);
  }

  .modal-overlay.active .apple-modal {
    transform: translateY(0);
  }

  .sheet-drag-handle {
    display: block;
  }

  .drawer-overlay {
    align-items: flex-end;
  }

  .apple-drawer {
    top: auto;
    bottom: 0;
    max-width: 100%;
    height: 92vh;
    border-radius: 24px 24px 0 0;
    transform: translateY(100%);
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.15);
    padding-bottom: var(--safe-bottom);
  }

  .drawer-overlay.active .apple-drawer {
    transform: translateY(0);
  }

  .modal-header, .drawer-header {
    padding: 16px 20px;
  }

  .modal-body, .drawer-body {
    padding: 18px;
  }

  .form-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .form-col-span-2 {
    grid-column: span 1;
  }

  .source-choice-grid {
    grid-template-columns: 1fr;
  }

  .apple-input, .apple-select, .apple-textarea {
    font-size: 16px; /* Prevents auto-zoom on iOS Safari */
    padding: 10px 14px;
  }
}

/* ==========================================================
 *  DEDICATED LEAD SCREEN (FULL PAGE FLOW)
 * ========================================================== */
.lead-screen-container {
  max-width: 900px;
  margin: 0 auto;
  padding: 8px 0 60px;
}

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

.lead-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: rgba(0, 0, 0, 0.05);
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.15s ease;
}

.lead-back-btn:hover {
  background: rgba(0, 0, 0, 0.09);
  transform: translateX(-2px);
}

.lead-screen-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.lead-form-card {
  padding: 24px 28px;
  margin-bottom: 22px;
  border-radius: var(--radius-lg);
  background: #ffffff;
  border: 1px solid var(--card-border);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s ease;
}

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

.lead-card-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.lead-card-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.lead-card-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-main);
  margin: 0 0 2px;
  letter-spacing: -0.01em;
}

.lead-card-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
  margin: 0;
}

.lead-screen-footer {
  display: flex;
  justify-content: flex-end;
  gap: 14px;
  padding: 16px 24px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: var(--radius-lg);
  border: 1px solid var(--card-border);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
  position: sticky;
  bottom: 20px;
  z-index: 40;
  margin-top: 14px;
}

@media (max-width: 768px) {
  .lead-screen-container {
    padding: 0 0 100px;
  }
  .lead-form-card {
    padding: 18px 16px;
    margin-bottom: 16px;
  }
  .lead-screen-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
    margin-bottom: 18px;
  }
  .lead-screen-header-actions {
    width: 100%;
    justify-content: space-between;
  }
  .lead-screen-header-actions .apple-btn {
    flex: 1;
  }
  .lead-screen-footer {
    bottom: 84px; /* Sits right above the iOS bottom navigation bar */
    padding: 12px 16px;
  }
  .lead-screen-footer .apple-btn {
    flex: 1;
  }
}

/* ==========================================================
 *  iOS BOTTOM NAVIGATION TAB BAR (MOBILE ONLY)
 * ========================================================== */
.ios-tab-bar {
  display: none; /* Hidden on desktop */
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 990;
  height: calc(60px + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-top: 0.5px solid rgba(0, 0, 0, 0.12);
  box-shadow: 0 -2px 16px rgba(0, 0, 0, 0.05);
  align-items: center;
  justify-content: space-around;
  user-select: none;
  -webkit-user-select: none;
}

.ios-tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: 100%;
  padding: 6px 0;
  border: none !important;
  background: transparent !important;
  color: #8e8e93;
  font-size: 10.5px;
  font-weight: 500;
  cursor: pointer;
  outline: none !important;
  transition: color 0.18s ease, transform 0.12s ease;
  -webkit-tap-highlight-color: transparent;
}

.ios-tab-item svg {
  width: 22px;
  height: 22px;
  stroke: #8e8e93;
  stroke-width: 2;
  transition: stroke 0.18s ease, transform 0.18s ease;
}

.ios-tab-item span {
  line-height: 1;
  letter-spacing: -0.01em;
}

.ios-tab-item.active {
  color: #0071e3 !important;
  font-weight: 600;
}

.ios-tab-item.active svg {
  stroke: #0071e3 !important;
  stroke-width: 2.3;
  transform: scale(1.08);
}

.ios-tab-item:active {
  transform: scale(0.92);
}

/* ==========================================================
 *  MOBILE FLOATING ACTION BUTTON (+ ADD LEAD)
 * ========================================================== */
.mobile-fab {
  display: none; /* Hidden on desktop */
  position: fixed;
  right: 18px;
  bottom: calc(74px + env(safe-area-inset-bottom, 0px));
  z-index: 980;
  width: 56px;
  height: 56px;
  border-radius: 28px;
  background: linear-gradient(135deg, #0071e3, #0056b3);
  color: #ffffff !important;
  border: none !important;
  box-shadow: 0 6px 20px rgba(0, 113, 227, 0.45), 0 2px 6px rgba(0, 0, 0, 0.15);
  align-items: center;
  justify-content: center;
  cursor: pointer;
  outline: none !important;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.mobile-fab svg {
  width: 26px;
  height: 26px;
  stroke: #ffffff;
}

.mobile-fab:active {
  transform: scale(0.90);
  box-shadow: 0 3px 12px rgba(0, 113, 227, 0.35);
}

/* ==========================================================
 *  5-STEP LEAD CREATION WIZARD
 * ========================================================== */
.wizard-progress-card {
  background: #ffffff;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  margin-bottom: 22px;
  box-shadow: var(--shadow-sm);
}

.wizard-progress-track {
  width: 100%;
  height: 5px;
  background: rgba(0, 0, 0, 0.06);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 14px;
}

.wizard-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #0071e3, #34c759);
  border-radius: 999px;
  transition: width 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.wizard-steps-pills {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}

.wizard-steps-pills::-webkit-scrollbar {
  display: none;
}

.wizard-step-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: rgba(0, 0, 0, 0.04);
  border: 1px solid rgba(0, 0, 0, 0.05) !important;
  border-radius: var(--radius-full);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
  outline: none !important;
}

.wizard-step-pill .pill-number {
  width: 20px;
  height: 20px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.08);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  transition: all 0.2s ease;
}

.wizard-step-pill.active {
  background: rgba(0, 113, 227, 0.1) !important;
  border-color: rgba(0, 113, 227, 0.3) !important;
  color: #0071e3 !important;
  font-weight: 600;
}

.wizard-step-pill.active .pill-number {
  background: #0071e3;
  color: #ffffff;
}

.wizard-step-pill.completed {
  background: rgba(52, 199, 89, 0.08) !important;
  border-color: rgba(52, 199, 89, 0.25) !important;
  color: #248a3d !important;
}

.wizard-step-pill.completed .pill-number {
  background: #34c759;
  color: #ffffff;
}

.wizard-step-pane {
  animation: fadeInPane 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.wizard-pane-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 26px;
  padding-top: 18px;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}

/* Step 5 Summary Card */
.lead-summary-box {
  background: #fbfbfd;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  margin-bottom: 20px;
}

.lead-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  font-size: 13px;
}

.lead-summary-grid .sum-label {
  color: var(--text-secondary);
  font-size: 12px;
  display: block;
  margin-bottom: 2px;
}

.lead-summary-grid strong {
  color: var(--text-main);
  font-weight: 600;
  word-break: break-word;
}

/* ==========================================================
 *  RESPONSIVE MOBILE STYLES (< 768px)
 * ========================================================== */
@media (max-width: 768px) {
  body {
    padding-bottom: calc(70px + env(safe-area-inset-bottom, 0px));
  }

  .apple-nav {
    padding: 10px 14px;
    height: 56px;
  }

  .apple-nav .segmented-control {
    display: none !important; /* Managed by bottom tab bar */
  }

  .nav-title {
    font-size: 15px;
  }

  .nav-brand img {
    height: 24px;
  }

  .nav-actions {
    gap: 8px;
  }

  .nav-actions #btnAddLead {
    padding: 6px 12px;
    font-size: 12.5px;
  }

  .nav-actions #btnAdminSettings span {
    display: none; /* Show only icon on small mobile screens */
  }

  .ios-tab-bar {
    display: flex !important;
  }

  .mobile-fab {
    display: flex !important;
  }

  .app-container {
    padding: 12px 14px 40px;
  }

  .desktop-only-table {
    display: none !important;
  }

  .leads-mobile-list {
    display: flex !important;
    flex-direction: column;
    gap: 12px;
  }

  /* Wizard Pills Scroll on Mobile */
  .wizard-progress-card {
    padding: 12px 14px;
    margin-bottom: 16px;
  }

  .wizard-step-pill {
    padding: 6px 10px;
    font-size: 11.5px;
  }

  .wizard-step-pill .pill-label {
    display: none; /* Show numbers only on phone to avoid overflow */
  }

  .wizard-step-pill.active .pill-label {
    display: inline; /* Show label only for current active step */
  }

  .wizard-pane-footer {
    flex-direction: column-reverse;
    gap: 10px;
  }

  .wizard-pane-footer .apple-btn {
    width: 100%;
    justify-content: center;
  }
}


