/* ── CRM Pro Custom Styles ─────────────────────────────────────────────── */
/* Design Tokens from uiux-rules.md */
:root {
  /* Spacing Scale */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;

  /* Border Radius Scale */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-circle: 50%;

  /* Shadow / Elevation Scale */
  --shadow-elevation-0: none;
  --shadow-elevation-1: 0 1px 3px rgba(0,0,0,.08);
  --shadow-elevation-2: 0 4px 12px rgba(0,0,0,.12);
  --shadow-elevation-3: 0 4px 20px rgba(0,0,0,.20);
  --shadow-elevation-4: 0 8px 32px rgba(0,0,0,.24);

  /* Z-Index Stack */
  --z-base: 0;
  --z-sticky: 100;
  --z-sidebar: 1020;
  --z-navbar: 1025;
  --z-bottom-nav: 1030;
  --z-fab: 1035;
  --z-dropdown: 1050;
  --z-overlay: 1055;
  --z-modal: 1060;
  --z-toast: 1070;
  --z-tooltip: 1080;
}

/* Sidebar */
#sidebar {
  width: 220px;
  min-height: 100vh;
  transition: width 0.25s cubic-bezier(.4,0,.2,1);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  flex-shrink: 0;
  z-index: var(--z-sidebar);
  border-radius: var(--radius-md);
}

#sidebar .nav-link {
  border-radius: var(--radius-sm);
  padding: .5rem .75rem;
  font-size: .875rem;
  white-space: nowrap;
  overflow: hidden;
  transition: background .15s ease-out;
}

#sidebar .nav-link:hover { background: rgba(255,255,255,.1); }
#sidebar .nav-link.active {
  background: rgba(255,255,255,.12) !important;
  color: white;
  font-weight: 500;
}

#sidebar .sidebar-brand { min-height: 60px; }

/* Collapsed sidebar */
.sidebar-collapsed #sidebar { width: 60px; }
.sidebar-collapsed #sidebar .d-none.d-xl-block,
.sidebar-collapsed #sidebar .d-none.d-xl-inline { display: none !important; }
.sidebar-collapsed #sidebar .d-xl-block { display: none !important; }

#page-content { overflow-x: hidden; }

/* ── Lead Card (Mobile List) — Rule 6.1 ───────────────────────────────────── */
.lead-card {
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-3);
  border: 1px solid var(--bs-border-color);
  background: var(--bs-body-bg);
  box-shadow: var(--shadow-elevation-1);
  transition: box-shadow .15s ease-out, transform .1s ease-out;
  overflow: hidden;
}

.lead-card:active {
  box-shadow: var(--shadow-elevation-2);
  transform: scale(0.99);
}

/* Left border accent for urgency — Rule 6.1 & 7.3 */
.lead-card.urgency-overdue   { border-left: 4px solid var(--bs-danger); }
.lead-card.urgency-due-today { border-left: 4px solid var(--bs-warning); }
.lead-card.urgency-this-week { border-left: 4px solid var(--bs-info); }
.lead-card.urgency-completed { border-left: 4px solid var(--bs-success); }
.lead-card.urgency-none       { border-left: 4px solid transparent; }

.lead-card .lc-header { padding: var(--space-4) var(--space-4) var(--space-2); }

.lead-initials {
  width: 40px; height: 40px;
  border-radius: var(--radius-circle);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .875rem; flex-shrink: 0;
  background: var(--bs-primary); color: #fff;
  box-shadow: 0 2px 6px rgba(13,110,253,.25);
}

.lead-card .lc-name {
  font-size: 1rem; font-weight: 600;
  line-height: 1.2; color: var(--bs-body-color);
  margin-bottom: 2px;
  text-decoration: none;
  display: inline;
}

.lead-card .lc-name:hover { text-decoration: underline; }

.lead-card .lc-meta {
  font-size: .8rem; color: var(--bs-secondary);
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2);
  margin-top: 2px;
}

.lead-card .lc-meta i { font-size: .75rem; }

.lead-card .lc-status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-xl);
  font-size: .65rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .03em;
  margin-top: var(--space-1);
}

/* Action row — Rule 6.1 exact spec */
.lead-card .lc-actions {
  display: flex;
  border-top: 1px solid var(--bs-border-color);
  background: var(--bs-light);
  min-height: 52px;
}

.lead-card .lc-actions a,
.lead-card .lc-actions button {
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 3px; padding: var(--space-2) 4px;
  font-size: .65rem; font-weight: 700;
  border: none; background: none;
  color: var(--bs-secondary);
  text-decoration: none;
  border-right: 1px solid var(--bs-border-color);
  cursor: pointer;
  transition: background .15s ease-out, color .15s ease-out, transform .1s;
  min-height: 52px;
  -webkit-tap-highlight-color: transparent;
}

.lead-card .lc-actions a:last-child,
.lead-card .lc-actions button:last-child { border-right: none; }

.lead-card .lc-actions a i,
.lead-card .lc-actions button i { font-size: 1.15rem; }

.lead-card .lc-actions .lca-call   { color: #2e7d32; }
.lead-card .lc-actions .lca-wa     { color: #33691e; }
.lead-card .lc-actions .lca-log    { color: #1565c0; }
.lead-card .lc-actions .lca-fu     { color: #e65100; }
.lead-card .lc-actions .lca-view   { color: var(--bs-primary); }
.lead-card .lc-actions .lca-note   { color: #6a1b9a; }

.lead-card .lc-actions a:active,
.lead-card .lc-actions button:active {
  background: rgba(0,0,0,.04);
  transform: scale(0.95);
}

[data-bs-theme="dark"] .lead-card .lc-actions { background: rgba(255,255,255,.03); }
[data-bs-theme="dark"] .lead-card .lc-actions a:active,
[data-bs-theme="dark"] .lead-card .lc-actions button:active {
  background: rgba(255,255,255,.06);
}

/* ── Mobile Action Hub — Rule 4.3 ─────────────────────────────────────────── */
.mobile-action-hub { display: none; }
@media (max-width: 767px) {
  .mobile-action-hub {
    display: flex;
    gap: 4px;
    margin-bottom: var(--space-4);
    border-top: 1px solid var(--bs-border-color);
    border-bottom: 1px solid var(--bs-border-color);
    padding: var(--space-2) 0;
  }
  .action-hub-btn {
    flex: 1;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 4px;
    padding: var(--space-2) 4px;
    border-radius: 12px; /* Rule 4.3 specifies 12px for action hub slots */
    border: 1.5px solid transparent;
    font-size: .7rem; font-weight: 700;
    min-height: 56px;
    text-decoration: none;
    transition: background .15s ease-out, color .15s ease-out, transform .1s ease-out;
    -webkit-tap-highlight-color: transparent;
  }
  .action-hub-btn:active {
    transform: scale(0.95);
    opacity: .9;
  }
  .action-hub-btn i { font-size: 1.3rem; }

  /* Color-coded slots per Rule 4.3 table */
  .ahb-call   { background: #e8f5e9; color: #2e7d32; border-color: #a5d6a7; }
  .ahb-wa     { background: #f1f8e9; color: #33691e; border-color: #aed581; }
  .ahb-fu     { background: #fff3e0; color: #e65100; border-color: #ffcc80; }
  .ahb-status { background: #e3f2fd; color: #1565c0; border-color: #90caf9; }
  .ahb-note   { background: #f3e5f5; color: #6a1b9a; border-color: #ce93d8; }

  /* Dark mode variants — Rule 12 */
  [data-bs-theme="dark"] .ahb-call   { background: rgba(46,125,50,.15); color: #81c784; border-color: #2e5234; }
  [data-bs-theme="dark"] .ahb-wa     { background: rgba(51,105,30,.15); color: #aed581; border-color: #2d5238; }
  [data-bs-theme="dark"] .ahb-fu     { background: rgba(230,81,0,.15); color: #ffb74d; border-color: #5c3c0d; }
  [data-bs-theme="dark"] .ahb-status { background: rgba(21,101,192,.15); color: #64b5f6; border-color: #1c3a5c; }
  [data-bs-theme="dark"] .ahb-note   { background: rgba(106,27,154,.15); color: #ce93d8; border-color: #4a2060; }
}

/* ── Sticky Form Action Bar — Rule 5.8 ─────────────────────────────────────── */
.sticky-action-bar {
  position: sticky;
  bottom: 60px;
  z-index: 100;
  background: var(--bs-body-bg);
  border-top: 1px solid var(--bs-border-color);
  padding: var(--space-3) var(--space-4);
  box-shadow: 0 -4px 12px rgba(0,0,0,.08);
}
@media (min-width: 992px) {
  .sticky-action-bar { display: none; }
}

/* ── Mobile Form Section Navigation — Rule 5.4 ─────────────────────────────── */
.lead-form-mobile-nav .list-group-item {
  border: none;
  border-bottom: 1px solid var(--bs-border-color);
  border-radius: 0;
  padding: var(--space-3) var(--space-4);
  font-weight: 600;
  color: var(--bs-body-color);
  transition: background .15s ease-out;
}
.lead-form-mobile-nav .list-group-item:first-child {
  border-top-left-radius: var(--radius-md);
  border-top-right-radius: var(--radius-md);
}
.lead-form-mobile-nav .list-group-item:last-child {
  border-bottom: none;
  border-bottom-left-radius: var(--radius-md);
  border-bottom-right-radius: var(--radius-md);
}
.lead-form-mobile-nav .list-group-item:hover { background: var(--bs-light); }
.lead-form-mobile-nav .list-group-item.active {
  background: var(--bs-light);
  border-left: 3px solid var(--bs-primary);
  color: var(--bs-primary);
}

/* Stat cards */
.stat-card {
  border-left: 4px solid transparent;
  transition: transform .15s;
}
.stat-card:hover { transform: translateY(-2px); }
.stat-card.border-primary { border-left-color: var(--bs-primary); }
.stat-card.border-success { border-left-color: var(--bs-success); }
.stat-card.border-warning { border-left-color: var(--bs-warning); }
.stat-card.border-danger  { border-left-color: var(--bs-danger); }
.stat-card.border-info    { border-left-color: var(--bs-info); }

/* Kanban board */
.kanban-board { overflow-x: auto; }
.kanban-column {
  min-width: 260px;
  max-width: 300px;
  background: var(--bs-secondary-bg);
  border-radius: 8px;
}
.kanban-column-header {
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: .6rem 1rem;
  border-radius: 8px 8px 0 0;
}
.kanban-card {
  cursor: pointer;
  transition: box-shadow .15s;
}
.kanban-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,.15) !important; }

/* Lead capture form */
.capture-form-wrapper {
  max-width: 560px;
  margin: 0 auto;
}

/* Status badges */
.badge-status-new          { background-color: #0d6efd; }
.badge-status-contacted    { background-color: #6610f2; }
.badge-status-qualified    { background-color: #198754; }
.badge-status-unqualified  { background-color: #6c757d; }
.badge-status-converted    { background-color: #20c997; }
.badge-status-lost         { background-color: #dc3545; }

/* Priority indicators */
.priority-urgent { color: #dc3545; }
.priority-high   { color: #fd7e14; }
.priority-medium { color: #ffc107; }
.priority-low    { color: #6c757d; }

/* Funnel chart */
.funnel-bar { min-width: 40px; transition: width .5s; }

/* Timeline */
.timeline { position: relative; padding-left: 2rem; }
.timeline::before {
  content: '';
  position: absolute;
  left: .6rem;
  top: 0; bottom: 0;
  width: 2px;
  background: var(--bs-border-color);
}
.timeline-item { position: relative; margin-bottom: 1.25rem; }
.timeline-icon {
  position: absolute;
  left: -2rem;
  width: 24px; height: 24px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .7rem;
}

/* Calling list progress */
.calling-progress .progress { height: 8px; border-radius: 4px; }

/* Responsive tables */
@media (max-width: 767px) {
  .table-responsive-stack td::before {
    content: attr(data-label);
    font-weight: 600;
    display: block;
    font-size: .75rem;
    color: var(--bs-secondary);
  }
}

/* Chart containers */
.chart-container { position: relative; }

/* Auth pages */
.auth-wrapper {
  min-height: 100vh;
  background: linear-gradient(135deg, #0d6efd22 0%, #6610f222 100%);
}
.auth-card {
  max-width: 440px;
  width: 100%;
  border: none;
  box-shadow: 0 8px 40px rgba(0,0,0,.12);
}

/* Scrollable sidebar on small screens */
@media (max-width: 991px) {
  #sidebar {
    position: fixed;
    left: -220px;
    z-index: 1040;
    height: 100%;
    transition: left .25s ease;
  }
  #sidebar.open { left: 0; }
  #page-content { margin-left: 0 !important; }
}

/* Sidebar backdrop (mobile) */
#sidebarBackdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 1039;
}
#sidebarBackdrop.show { display: block; }

/* ── Mobile touch targets ─────────────────────────────────────────────────── */
@media (max-width: 991px) {
  .btn, .nav-link, .dropdown-item, .list-group-item-action {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }
  .form-control, .form-select {
    min-height: 44px;
    font-size: 1rem;
  }
  .btn-xs { min-height: 36px; padding: .3rem .55rem; }
  /* Bottom nav padding so content isn't hidden */
  #page-content { padding-bottom: 70px; }
}

/* ── Bottom Navigation Bar (mobile only) ─────────────────────────────────── */
#bottomNav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 60px;
  background: var(--bs-body-bg);
  border-top: 1px solid var(--bs-border-color);
  z-index: 1030;
  padding: 0;
}
#bottomNav .bn-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: var(--bs-secondary-color);
  font-size: .65rem;
  gap: 2px;
  padding: 6px 0;
  border: none;
  background: none;
  transition: color .15s;
}
#bottomNav .bn-item i { font-size: 1.25rem; }
#bottomNav .bn-item.active, #bottomNav .bn-item:active { color: var(--bs-primary); }
#bottomNav .bn-badge {
  position: absolute;
  top: 4px; right: calc(50% - 18px);
  font-size: .6rem;
  padding: .15em .35em;
}
@media (max-width: 991px) {
  #bottomNav { display: flex; }
}

/* ── Floating Action Button ──────────────────────────────────────────────── */
#fabNewLead {
  display: none;
  position: fixed;
  bottom: 72px; right: 16px;
  width: 52px; height: 52px;
  border-radius: 50%;
  z-index: 1035;
  box-shadow: 0 4px 16px rgba(0,0,0,.25);
  font-size: 1.4rem;
  line-height: 1;
}
@media (max-width: 991px) {
  #fabNewLead { display: flex; align-items: center; justify-content: center; }
}

/* ── Voice Input Button ───────────────────────────────────────────────────── */
.btn-voice {
  padding: .25rem .45rem;
  font-size: .85rem;
  border-radius: 50%;
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.btn-voice.listening {
  color: #fff;
  background: #dc3545;
  border-color: #dc3545;
  animation: voice-pulse 1s ease-in-out infinite;
}
@keyframes voice-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220,53,69,.6); }
  50%       { box-shadow: 0 0 0 8px rgba(220,53,69,0); }
}

/* ── Status Quick-Select Chips — Rule 4.4 ──────────────────────────────────── */
.status-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 4px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.status-chips::-webkit-scrollbar { display: none; }

.status-chip {
  border: 2px solid var(--bs-border-color);
  border-radius: var(--radius-xl);
  padding: 5px 14px;
  font-size: .8rem; font-weight: 600;
  cursor: pointer;
  transition: all .15s ease-out;
  background: transparent;
  color: var(--bs-body-color);
  white-space: nowrap;
  line-height: 1.2;
}
.status-chip.active {
  border-color: var(--bs-primary);
  background: var(--bs-primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(13,110,253,.3);
}
.status-chip:hover:not(.active) {
  border-color: var(--bs-primary);
  color: var(--bs-primary);
  background: rgba(13,110,253,.04);
}

/* ── Next-Action Banner (Overdue Follow-up) — Rule 6.3 ─────────────────────── */
.next-action-banner {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  background: linear-gradient(135deg, var(--bs-danger) 0%, #fd7e14 100%);
  color: #fff;
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-4);
  text-decoration: none;
  transition: opacity .15s ease-out, transform .1s ease-out;
  box-shadow: 0 3px 12px rgba(220,53,69,.3);
  cursor: pointer;
}
.next-action-banner:hover {
  opacity: .92;
  color: #fff;
  transform: translateY(-1px);
  text-decoration: none;
}
.next-action-banner:active { transform: scale(0.98); }
.next-action-banner .ban-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
}
.next-action-banner .ban-label {
  font-size: .7rem;
  opacity: .88;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: .04em;
}
.next-action-banner .ban-text {
  font-size: .95rem;
  font-weight: 700;
  line-height: 1.2;
  flex: 1;
}

/* Dark mode overrides — Rule 12 */
[data-bs-theme="dark"] .next-action-banner {
  box-shadow: 0 3px 12px rgba(0,0,0,.4);
}

/* ── Lead Identity Card (mobile only) — Rule 6.2 ──────────────────────────── */
.lead-identity-card {
  display: none;
}
@media (max-width: 767px) {
  .lead-identity-card {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    background: linear-gradient(135deg, var(--bs-primary) 0%, #6f42c1 100%);
    color: #fff;
    border-radius: 16px; /* spec override */
    padding: 1.1rem 1.25rem;
    margin-bottom: var(--space-4);
    box-shadow: 0 4px 20px rgba(13,110,253,.28);
  }
  .lead-identity-card .lead-avatar {
    width: 52px; height: 52px;
    border-radius: var(--radius-circle);
    background: rgba(255,255,255,.22);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.25rem; font-weight: 700; flex-shrink: 0;
    letter-spacing: -.5px;
    border: 2px solid rgba(255,255,255,.4);
    box-shadow: 0 2px 8px rgba(0,0,0,.12);
  }
  .lead-identity-card .lead-name {
    font-size: 1.2rem; font-weight: 700; line-height: 1.2;
    color: #fff;
  }
  .lead-identity-card .lead-meta {
    font-size: .8rem; opacity: .85;
    margin-top: 2px;
    display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2);
  }
  .lead-identity-card .lead-meta i { font-size: .75rem; }
  .lead-identity-card .lead-status-pill {
    display: inline-block;
    padding: 3px 10px;
    border-radius: var(--radius-xl);
    background: rgba(255,255,255,.2);
    border: 1px solid rgba(255,255,255,.4);
    font-size: .75rem; font-weight: 600;
    margin-top: var(--space-1);
    white-space: nowrap;
  }
}

/* ── Skeleton Loading — Rule 8.1 ───────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg,
    var(--bs-secondary-bg) 25%,
    rgba(255,255,255,.7) 50%,
    var(--bs-secondary-bg) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-wave 1.4s linear infinite;
  border-radius: 4px;
  color: transparent;
  pointer-events: none;
}
@keyframes skeleton-wave {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
.sk-line  { height: 12px; margin-bottom: 6px; border-radius: 4px; }
.sk-title { height: 18px; margin-bottom: 8px; border-radius: 4px; }
.sk-avatar { width: 40px; height: 40px; border-radius: 50%; }
.sk-badge { height: 20px; width: 60px; border-radius: var(--radius-xl); }
.sk-btn   { height: 36px; width: 80px; border-radius: var(--radius-sm); }

/* Dark mode skeleton — Rule 12 */
[data-bs-theme="dark"] .skeleton {
  background: linear-gradient(90deg,
    rgba(255,255,255,.08) 25%,
    rgba(255,255,255,.15) 50%,
    rgba(255,255,255,.08) 75%
  );
  background-size: 200% 100%;
}

/* ── Autosave Indicator — Rule 5.6 ─────────────────────────────────────────── */
.autosave-indicator {
  font-size: .75rem;
  color: var(--bs-secondary);
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: var(--space-1);
}
.autosave-indicator .spinner-grow {
  width: 1rem; height: 1rem;
  font-size: .6rem;
}
.autosave-indicator.saved { color: var(--bs-success); }

/* ── Draft Restore Banner — Rule 5.6 ───────────────────────────────────────── */
.draft-restore-banner {
  background: var(--bs-info);
  color: inherit;
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.draft-restore-banner .draft-actions {
  margin-left: auto;
  display: flex;
  gap: var(--space-2);
}

/* ── Timeline / Interaction Feed — Rule 6.4 ─────────────────────────────────── */
.activity-timeline {
  position: relative;
  padding-left: 2.5rem;
}
.activity-timeline::before {
  content: '';
  position: absolute;
  left: 1rem;
  top: 0; bottom: 0;
  width: 2px;
  background: var(--bs-border-color);
}
.activity-item {
  position: relative;
  margin-bottom: 1rem;
}
.activity-dot {
  position: absolute;
  left: -2.5rem;
  width: 32px; height: 32px;
  border-radius: var(--radius-circle);
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--bs-body-bg);
  box-shadow: 0 0 0 2px var(--bs-border-color);
  background: var(--bs-light);
  font-size: .75rem;
}
.activity-dot.icon-call    { color: #2e7d32; }
.activity-dot.icon-whatsapp{ color: #25D366; }
.activity-dot.icon-note    { color: #6a1b9a; }
.activity-dot.icon-visit   { color: #1565c0; }
.activity-dot.icon-payment { color: #e65100; }
.activity-dot.icon-status  { color: var(--bs-secondary); }
.activity-dot.icon-app     { color: var(--bs-primary); }

.activity-body {
  background: var(--bs-secondary-bg);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  font-size: .875rem;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.activity-time {
  font-size: .7rem;
  color: var(--bs-secondary);
  margin-top: var(--space-1);
  text-align: right;
}

/* Dark mode timeline */
[data-bs-theme="dark"] .activity-dot {
  background: #2d3238;
  border-color: #1a1d20;
}

/* ── Mobile Follow-Up Cards (for reference in detail sidebar) ────────────── */
@media (max-width: 767px) {
  .fu-mobile-list { display: block; }
  .fu-desktop-table { display: none !important; }
}
.fu-card {
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-3);
  border: 1px solid var(--bs-border-color);
  overflow: hidden;
  box-shadow: var(--shadow-elevation-1);
  background: var(--bs-body-bg);
}
.fu-card.fu-overdue   { border-left: 4px solid var(--bs-danger); }
.fu-card.fu-pending   { border-left: 4px solid var(--bs-warning); }
.fu-card.fu-completed { border-left: 4px solid var(--bs-success); opacity: .7; }
.fu-card .fu-body { padding: var(--space-3) var(--space-4); display: flex; align-items: center; gap: var(--space-3); }
.fu-complete-btn {
  width: 52px; height: 52px;
  border-radius: var(--radius-circle);
  flex-shrink: 0;
  border: 2px solid var(--bs-success);
  background: none; color: var(--bs-success);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.35rem; cursor: pointer;
  transition: all .15s ease-out;
}
.fu-complete-btn:active {
  background: var(--bs-success); color: #fff;
  transform: scale(0.88);
}
.fu-complete-btn.done { background: var(--bs-success); color: #fff; opacity: .6; }

[data-bs-theme="dark"] .fu-card { box-shadow: 0 1px 4px rgba(0,0,0,.25); }

/* ── Dashboard mobile stat grid ───────────────────────────────────────────── */
@media (max-width: 767px) {
  .dash-charts-section { display: none; }
  .dash-charts-section.show { display: block; }
}
.stat-mini {
  background: var(--bs-secondary-bg);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--bs-border-color);
}
.stat-mini .sm-number {
  font-size: 1.75rem; font-weight: 800; line-height: 1;
}
.stat-mini .sm-label {
  font-size: .68rem; text-transform: uppercase; font-weight: 700;
  color: var(--bs-secondary); margin-top: 2px;
  letter-spacing: .04em;
}

/* ── Bottom Navigation Bar (mobile) — Rule 2.1 ─────────────────────────────── */
#bottomNav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 60px;
  background: var(--bs-body-bg);
  border-top: 1px solid var(--bs-border-color);
  z-index: var(--z-bottom-nav);
  padding: 0;
}
#bottomNav .bn-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center; justify-content: center;
  text-decoration: none;
  color: var(--bs-secondary);
  font-size: .65rem;
  gap: 2px;
  padding: 6px 0;
  border: none;
  background: none;
  transition: color .15s ease-out;
  position: relative;
}
#bottomNav .bn-item i { font-size: 1.375rem; }
#bottomNav .bn-item.active,
#bottomNav .bn-item:active { color: var(--bs-primary); }

/* Overdue badge on bottom nav — Rule 2.1 */
.bn-overdue-badge {
  position: absolute;
  top: 4px; right: calc(50% - 20px);
  min-width: 18px; height: 18px;
  padding: 0 4px;
  border-radius: var(--radius-circle);
  background: var(--bs-danger);
  color: #fff;
  font-size: .6rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  line-height: 1;
}
.bn-overdue-badge.pill-shape {
  border-radius: 9px;
  min-width: auto;
  padding: 0 5px;
}
@media (max-width: 991px) {
  #bottomNav { display: flex; }
}

/* ── Floating Action Button (mobile) — Rule 2.4 ─────────────────────────────── */
#fabNewLead {
  display: none;
  position: fixed;
  bottom: 72px; right: 16px;
  width: 52px; height: 52px;
  border-radius: var(--radius-circle);
  z-index: var(--z-fab);
  box-shadow: var(--shadow-elevation-3);
  background: var(--bs-primary);
  border: none; color: #fff;
  font-size: 1.4rem; line-height: 1;
  transition: transform .1s ease-out, box-shadow .1s ease-out;
  align-items: center; justify-content: center;
  text-decoration: none;
}
#fabNewLead:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(13,110,253,.35);
}
#fabNewLead:active {
  transform: scale(0.92);
  box-shadow: var(--shadow-elevation-2);
}
@media (max-width: 991px) {
  #fabNewLead { display: flex; }
}

/* ── Floating Help Button (mobile) ─────────────────────────────────────────── */
#crmHelpBtn {
  display: none;
  position: fixed;
  bottom: 72px; left: 16px;
  width: 44px; height: 44px;
  border-radius: var(--radius-circle);
  background: var(--bs-body-bg);
  border: 1.5px solid var(--bs-border-color);
  color: var(--bs-secondary);
  box-shadow: 0 2px 12px rgba(0,0,0,.12);
  z-index: var(--z-fab);
  cursor: pointer;
  align-items: center; justify-content: center;
  font-size: 1.1rem;
  transition: border-color .2s ease, color .2s ease, box-shadow .2s ease;
}
#crmHelpBtn:hover {
  border-color: var(--bs-primary); color: var(--bs-primary);
  box-shadow: 0 4px 16px rgba(13,110,253,.25);
}
@media (max-width: 991px) { #crmHelpBtn { display: flex; } }

/* ── Table styles — Rule 6.5 ───────────────────────────────────────────────── */
.table-responsive.desktop-table { overflow-x: auto; }
.table-hover tbody tr:hover { background: var(--bs-light); }
[data-bs-theme="dark"] .table-hover tbody tr:hover {
  background: rgba(255,255,255,.03);
}
.table-hover tbody tr.selected { background: rgba(13,110,253,.07); }

/* ── Form Field — Rule 5.1 & 5.2 ─────────────────────────────────────────────── */
.form-label {
  font-size: .875rem;
  font-weight: 500;
  margin-bottom: 4px;
  color: var(--bs-body-color);
}
.form-control, .form-select {
  height: 44px;
  padding: 10px 12px;
  font-size: 1rem;
  border-radius: var(--radius-sm);
  transition: border-color .15s ease-in-out, box-shadow .15s ease-in-out;
}
.form-control:focus, .form-select:focus {
  border-color: var(--bs-primary);
  box-shadow: 0 0 0 2px rgba(13,110,253,.15);
  outline: none;
}
.form-control.is-invalid, .form-select.is-invalid {
  border-color: var(--bs-danger);
}
.invalid-feedback {
  font-size: .75rem;
  color: var(--bs-danger);
  margin-top: 4px;
  display: block;
}
.crm-field-hint {
  font-size: .75rem;
  color: var(--bs-secondary);
  margin-top: 4px;
  display: block;
}

/* Button base — Rule 4.1 */
.btn {
  border-radius: var(--radius-sm);
  padding: 10px 20px;
  font-weight: 500;
  transition: transform .1s ease-out, opacity .15s;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn:active { transform: scale(0.97); }
.btn-sm { padding: 8px 16px; font-size: .875rem; min-height: 36px; }
.btn-primary {
  background: var(--bs-primary);
  border: none; color: #fff;
}
.btn-primary:hover { background: color-mix(in srgb, var(--bs-primary) 92%, black); }
.btn-primary:disabled, .btn-primary.disabled {
  opacity: .45; cursor: not-allowed;
  pointer-events: none;
}

/* Loading spinner in button */
.btn .spinner-border-sm {
  width: 1rem; height: 1rem;
  margin-right: .5rem;
}

/* Grid system reference — Rule 1.4 */
@media (min-width: 992px) {
  .row { --bs-gutter-x: 24px; }
}

/* ── Dark mode overrides — Rule 12 ─────────────────────────────────────────── */
[data-bs-theme="dark"] #sidebar { background: #1a1d20 !important; }
[data-bs-theme="dark"] .navbar { background: #212529 !important; border-color: #2d3238 !important; }
[data-bs-theme="dark"] .lead-identity-card { box-shadow: 0 4px 20px rgba(0,0,0,.4); }
[data-bs-theme="dark"] .mobile-action-hub .action-hub-btn { border-width: 1px; }
[data-bs-theme="dark"] .sticky-action-bar { border-color: rgba(255,255,255,.1); }

/* ═══════════════════════════════════════════════════════════════════════════
   DAY FLOW  —  JTBD-derived components (uiux-rules §16–19)
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Quick Log Drawer — Rule §17.5 ─────────────────────────────────────────── */
#quickLogBackdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 1064;
  opacity: 0;
  transition: opacity .2s ease;
}
#quickLogBackdrop.show { display: block; opacity: 1; }

#quickLogDrawer {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 1065;
  background: var(--bs-body-bg);
  border-radius: 20px 20px 0 0;
  box-shadow: var(--shadow-elevation-4);
  max-height: 88vh;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform 250ms cubic-bezier(.4,0,.2,1);
}
#quickLogDrawer.show { transform: translateY(0); }
.qld-handle {
  width: 40px; height: 4px;
  background: var(--bs-border-color);
  border-radius: 2px;
  margin: 12px auto 4px;
}
.qld-body { padding: 8px 20px 40px; }
.qld-section-title {
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--bs-secondary);
  margin: 16px 0 8px;
}
.qld-chips {
  display: flex; gap: 6px;
  overflow-x: auto; scrollbar-width: none;
  padding-bottom: 2px; flex-wrap: wrap;
}
.qld-chip {
  padding: 6px 14px;
  border-radius: 20px;
  border: 2px solid var(--bs-border-color);
  font-size: .8rem; font-weight: 500;
  white-space: nowrap;
  background: transparent;
  color: var(--bs-body-color);
  cursor: pointer;
  transition: background .12s, border-color .12s, color .12s;
  line-height: 1.4;
}
.qld-chip.active {
  background: var(--bs-primary); color: #fff;
  border-color: var(--bs-primary);
}
.qld-chip:active { transform: scale(0.95); }
.qld-lead-selector {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  border: 1.5px solid var(--bs-border-color);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color .15s;
  background: var(--bs-body-bg);
}
.qld-lead-selector:hover { border-color: var(--bs-primary); }
.qld-lead-name { font-weight: 600; font-size: .95rem; flex: 1; }
.qld-voice-wrap { position: relative; }
.qld-voice-wrap textarea {
  padding-right: 40px;
  resize: none;
  min-height: 72px;
  font-size: .9rem;
}
.qld-mic-btn {
  position: absolute; bottom: 8px; right: 8px;
  width: 28px; height: 28px;
  border-radius: 50%; border: none;
  background: transparent;
  color: var(--bs-secondary);
  display: flex; align-items: center; justify-content: center;
  font-size: .9rem; cursor: pointer;
  transition: color .15s;
}
.qld-mic-btn:hover { color: var(--bs-primary); }
.qld-fu-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  border: 1.5px solid var(--bs-border-color);
  border-radius: var(--radius-sm);
  background: var(--bs-light);
}
[data-bs-theme="dark"] .qld-fu-row { background: rgba(255,255,255,.05); }
[data-bs-theme="dark"] #quickLogDrawer { box-shadow: 0 -8px 40px rgba(0,0,0,.5); }

/* ── Morning Check-In Overlay — Rule §17.6 ──────────────────────────────────── */
#morningCheckin {
  display: none;
  position: fixed; inset: 0;
  z-index: 1090;
  background: var(--bs-body-bg);
  flex-direction: column;
  align-items: center; justify-content: center;
  padding: 40px 24px 32px;
  text-align: center;
  overflow-y: auto;
}
#morningCheckin.show { display: flex; }
.mc-greeting { font-size: 1.5rem; font-weight: 700; line-height: 1.3; }
.mc-date { font-size: .9rem; color: var(--bs-secondary); margin-top: 4px; }
.mc-stat-grid {
  display: grid; grid-template-columns: 1fr 1fr 1fr;
  gap: 10px; width: 100%; max-width: 340px;
  margin: 24px 0;
}
.mc-stat-box {
  background: var(--bs-light);
  border-radius: 12px;
  padding: 14px 10px;
  display: flex; flex-direction: column;
  align-items: center; gap: 4px;
}
[data-bs-theme="dark"] .mc-stat-box { background: rgba(255,255,255,.07); }
.mc-stat-num { font-size: 1.75rem; font-weight: 700; line-height: 1; }
.mc-stat-label { font-size: .7rem; color: var(--bs-secondary); font-weight: 500; }
.mc-start-btn {
  width: 100%; max-width: 340px;
  padding: 14px;
  font-size: 1rem; font-weight: 600;
  border-radius: var(--radius-sm);
}

/* ── End-of-Day Banner — Rule §17.4 ────────────────────────────────────────── */
#eodBanner {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 1065;
  background: linear-gradient(135deg, #1565c0, #6a1b9a);
  color: #fff;
  padding: 18px 20px 32px;
  border-radius: 20px 20px 0 0;
  box-shadow: var(--shadow-elevation-4);
  transform: translateY(100%);
  transition: transform 250ms cubic-bezier(.4,0,.2,1);
}
#eodBanner.show { transform: translateY(0); }
.eod-title { font-size: 1rem; font-weight: 700; margin-bottom: 4px; }
.eod-sub { font-size: .85rem; opacity: .85; margin-bottom: 16px; }
.eod-actions { display: flex; gap: 10px; }
.eod-btn-log {
  flex: 1; padding: 12px; border-radius: var(--radius-sm);
  background: #fff; color: #1565c0;
  font-weight: 700; font-size: .9rem;
  border: none; cursor: pointer;
  transition: opacity .15s;
}
.eod-btn-log:active { opacity: .85; }
.eod-btn-later {
  padding: 12px 18px; border-radius: var(--radius-sm);
  background: rgba(255,255,255,.15); color: #fff;
  font-weight: 600; font-size: .9rem;
  border: 1px solid rgba(255,255,255,.3); cursor: pointer;
}

/* ── Streak Chip — Rule §15.2 ──────────────────────────────────────────────── */
.streak-chip {
  display: inline-flex; align-items: center;
  padding: 4px 12px;
  border-radius: 20px;
  background: rgba(255,152,0,.12);
  border: 1px solid rgba(255,152,0,.3);
  color: #e65100;
  font-size: .8rem; font-weight: 600;
  white-space: nowrap;
}

/* ── Lead Score Dots — Rule §19.3 ──────────────────────────────────────────── */
.lead-initials { position: relative; }
.lead-score-dot {
  width: 11px; height: 11px;
  border-radius: 50%;
  position: absolute; bottom: -1px; right: -1px;
  border: 2px solid var(--bs-body-bg);
  flex-shrink: 0;
}
.lead-score-hot  { background: #e65100; }
.lead-score-warm { background: #ffc107; }

/* ── Interrupt Recovery Chip — Rule §19.4 ──────────────────────────────────── */
#interruptChipArea { min-height: 0; }
.interrupt-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px 6px 10px;
  border-radius: 20px;
  background: var(--bs-light);
  border: 1px solid var(--bs-border-color);
  font-size: .8rem; font-weight: 500;
  text-decoration: none; color: var(--bs-body-color);
  transition: background .15s, border-color .15s, color .15s;
  margin-bottom: 10px;
}
.interrupt-chip:hover {
  background: var(--bs-primary); color: #fff;
  border-color: var(--bs-primary);
}
.interrupt-chip .btn-close { font-size: .45rem; opacity: .6; }
.interrupt-chip:hover .btn-close { filter: invert(1); opacity: .8; }

/* ── Alert Row (dashboard) — Rule §14.2 ────────────────────────────────────── */
.dash-alert-row {
  display: flex; gap: 10px; flex-wrap: wrap;
  margin-bottom: 12px;
}
.dash-alert-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: .82rem; font-weight: 600;
  text-decoration: none;
  transition: opacity .15s;
}
.dash-alert-pill:active { opacity: .8; }
.dash-alert-overdue {
  background: rgba(220,53,69,.12); color: #b02a37;
  border: 1.5px solid rgba(220,53,69,.25);
}
.dash-alert-today {
  background: rgba(255,193,7,.12); color: #997404;
  border: 1.5px solid rgba(255,193,7,.3);
}
[data-bs-theme="dark"] .dash-alert-overdue { background: rgba(220,53,69,.18); color: #f08080; }
[data-bs-theme="dark"] .dash-alert-today   { background: rgba(255,193,7,.15);  color: #ffc107; }

/* ── Daily Target Bar — Rule §15.1 ─────────────────────────────────────────── */
.daily-target-wrap {
  display: flex; align-items: center; gap: 10px;
  margin: 6px 0 14px;
}
.daily-target-track {
  flex: 1; height: 6px; border-radius: 3px;
  background: var(--bs-light); overflow: hidden;
}
[data-bs-theme="dark"] .daily-target-track { background: rgba(255,255,255,.1); }
.daily-target-fill {
  height: 100%; border-radius: 3px;
  background: var(--bs-primary);
  transition: width .6s ease-out, background .3s;
  width: 0;
}
.daily-target-fill.achieved { background: var(--bs-success); }
.daily-target-label { font-size: .75rem; color: var(--bs-secondary); white-space: nowrap; }

/* ── Tomorrow Preview (wind-down) — Rule §17.4 ─────────────────────────────── */
.tomorrow-preview {
  border-left: 3px solid var(--bs-primary);
  padding-left: 12px;
  margin-top: 4px;
}
.tomorrow-preview .tp-row {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 0;
  border-bottom: 1px solid var(--bs-border-color);
  font-size: .82rem;
}
.tomorrow-preview .tp-row:last-child { border-bottom: none; }
.tp-type-chip {
  font-size: .65rem; font-weight: 600;
  padding: 2px 7px; border-radius: 10px;
  background: var(--bs-light);
  color: var(--bs-secondary);
  white-space: nowrap;
}

/* ── Follow-up compact rows (dashboard) ─────────────────────────────────────── */
.dash-fu-row {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--bs-border-color);
  transition: background .12s;
}
.dash-fu-row:last-child { border-bottom: none; }
.dash-fu-row:hover { background: var(--bs-light); }
[data-bs-theme="dark"] .dash-fu-row:hover { background: rgba(255,255,255,.03); }
.dash-fu-avatar {
  width: 34px; height: 34px; flex-shrink: 0;
  border-radius: 50%; background: var(--bs-primary);
  color: #fff; font-size: .72rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.dash-fu-meta { flex: 1; min-width: 0; }
.dash-fu-name { font-size: .875rem; font-weight: 600; line-height: 1.3; }
.dash-fu-sub  { font-size: .72rem; color: var(--bs-secondary); }
.dash-fu-actions { display: flex; gap: 6px; flex-shrink: 0; }
.dash-fu-call, .dash-fu-done {
  width: 32px; height: 32px; border-radius: 50%;
  border: 1.5px solid var(--bs-border-color);
  background: transparent;
  display: flex; align-items: center; justify-content: center;
  font-size: .85rem; cursor: pointer;
  text-decoration: none;
  transition: background .12s, border-color .12s, color .12s;
}
.dash-fu-call { color: #2e7d32; }
.dash-fu-call:hover { background: #e8f5e9; border-color: #2e7d32; }
.dash-fu-done { color: var(--bs-success); }
.dash-fu-done:hover { background: rgba(25,135,84,.1); border-color: var(--bs-success); }
.dash-fu-done.completed { background: rgba(25,135,84,.12); border-color: var(--bs-success); opacity: .6; }
.dash-fu-overdue .dash-fu-avatar { background: var(--bs-danger); }
.dash-fu-overdue .dash-fu-name { color: var(--bs-danger); }

/* ── Toast mobile positioning fix — Rule §9.1 ──────────────────────────────── */
@media (max-width: 767px) {
  #toast-container {
    left: 50% !important;
    right: auto !important;
    bottom: auto !important;
    top: 16px !important;
    transform: translateX(-50%) !important;
    width: calc(100% - 32px) !important;
    padding: 0 !important;
  }
}

/* ── Sidebar mobile text visibility — show text when sidebar.open ───────────── */
@media (max-width: 1199px) {
  #sidebar.open .nav-link span,
  #sidebar.open .nav-link small {
    display: inline !important;
  }
  #sidebar.open .sidebar-brand span {
    display: block !important;
  }
}
