/* ================================================================
   SIGMA CRM — Design System
   DRY, reusable component library for all CRM pages
   ================================================================ */

/* ---- Variables ---- */
:root {
  --crm-primary: #696cff;
  --crm-primary-light: #696cff12;
  --crm-secondary: #8592a3;
  --crm-success: #71dd37;
  --crm-success-light: #71dd3712;
  --crm-danger: #ff3e1d;
  --crm-danger-light: #ff3e1d12;
  --crm-warning: #ffab00;
  --crm-warning-light: #ffab0012;
  --crm-info: #03c3ec;
  --crm-info-light: #03c3ec12;
  --crm-cyan: #03c3ec;
  --crm-violet: #8b5cf6;
  --crm-violet-light: #8b5cf612;
  --crm-pink: #e91e8b;
  --crm-pink-light: #e91e8b12;
  --crm-teal: #0d9488;
  --crm-amber: #f59e0b;
  --crm-lime: #84cc16;
  --crm-dark: #233446;
  --crm-text: #1e293b;
  --crm-text-muted: #64748b;
  --crm-text-light: #94a3b8;
  --crm-border: #e2e8f0;
  --crm-bg: #f1f5f9;
  --crm-card: #ffffff;
  --crm-radius: 12px;
  --crm-radius-lg: 16px;
  --crm-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.06);
  --crm-shadow-lg: 0 4px 20px rgba(0,0,0,0.08);
  --crm-transition: all 0.2s ease;
  --crm-sidebar-width: 260px;
}

/* ---- Reset & Base ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--crm-bg);
  color: var(--crm-text);
  line-height: 1.6;
  display: flex;
  min-height: 100vh;
}

/* ---- Sidebar ---- */
.crm-sidebar {
  width: var(--crm-sidebar-width);
  background: var(--crm-card);
  border-right: 1px solid var(--crm-border);
  height: 100vh;
  position: fixed;
  top: 0;
  left: 0;
  overflow-y: auto;
  z-index: 100;
  display: flex;
  flex-direction: column;
}
.crm-sidebar-brand {
  padding: 20px;
  border-bottom: 1px solid var(--crm-border);
  display: flex;
  align-items: center;
  gap: 12px;
}
.crm-sidebar-brand-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--crm-primary), var(--crm-violet));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 20px;
}
.crm-sidebar-brand-text {
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--crm-text);
}
.crm-sidebar-brand-text small {
  display: block;
  font-size: 0.7rem;
  font-weight: 400;
  color: var(--crm-text-muted);
}
.crm-nav-section {
  padding: 16px 12px 6px;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--crm-text-light);
}
.crm-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  margin: 2px 8px;
  border-radius: 8px;
  color: var(--crm-text-muted);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  transition: var(--crm-transition);
}
.crm-nav-item:hover { background: var(--crm-primary-light); color: var(--crm-primary); }
.crm-nav-item.active { background: var(--crm-primary); color: #fff; box-shadow: 0 2px 8px rgba(105,108,255,0.3); }
.crm-nav-item i { font-size: 18px; width: 22px; text-align: center; }
.crm-nav-badge {
  margin-left: auto;
  font-size: 0.65rem;
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: 600;
}
.crm-nav-badge-danger { background: var(--crm-danger); color: #fff; }
.crm-nav-badge-success { background: var(--crm-success); color: #fff; }
.crm-nav-badge-info { background: var(--crm-info); color: #fff; }

/* ---- Main Content ---- */
.crm-main {
  margin-left: var(--crm-sidebar-width);
  flex: 1;
  min-width: 0; /* allow the flex item to shrink to the viewport so wide children (charts/tables) don't force horizontal page scroll */
  padding: 0;
  min-height: 100vh;
}
/* Belt-and-suspenders: never let the page itself scroll sideways */
.crm-content { max-width: 100%; }

/* ---- Page Header ---- */
.crm-page-header {
  background: linear-gradient(135deg, var(--crm-primary) 0%, var(--crm-violet) 50%, var(--crm-info) 100%);
  padding: 28px 32px;
  color: #fff;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}
.crm-page-title { font-size: 1.5rem; font-weight: 800; }
.crm-page-subtitle { font-size: 0.85rem; opacity: 0.8; margin-top: 4px; }

/* ---- Content Area ---- */
.crm-content { padding: 24px 32px; }

/* ---- Cards ---- */
.crm-card {
  background: var(--crm-card);
  border-radius: var(--crm-radius);
  box-shadow: var(--crm-shadow);
  border: 1px solid var(--crm-border);
  overflow: hidden;
}
.crm-card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--crm-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.crm-card-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--crm-text);
  display: flex;
  align-items: center;
  gap: 8px;
}
.crm-card-body { padding: 20px; }
.crm-card-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--crm-border);
  background: #fafbfc;
}

/* ---- KPI Cards ---- */
.crm-kpi-grid { display: grid; gap: 16px; margin-bottom: 24px; }
.crm-kpi-grid-4 { grid-template-columns: repeat(4, 1fr); }
.crm-kpi-grid-5 { grid-template-columns: repeat(5, 1fr); }
.crm-kpi-grid-6 { grid-template-columns: repeat(6, 1fr); }
.crm-kpi {
  background: var(--crm-card);
  border-radius: var(--crm-radius);
  padding: 18px 20px;
  box-shadow: var(--crm-shadow);
  border: 1px solid var(--crm-border);
  display: flex;
  align-items: flex-start;
  gap: 14px;
  transition: var(--crm-transition);
}
.crm-kpi:hover { box-shadow: var(--crm-shadow-lg); transform: translateY(-2px); }
.crm-kpi-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.crm-kpi-label { font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--crm-text-muted); margin-bottom: 4px; }
.crm-kpi-value { font-size: 1.4rem; font-weight: 800; color: var(--crm-text); line-height: 1.2; }
.crm-kpi-change { font-size: 0.72rem; font-weight: 600; margin-top: 4px; display: flex; align-items: center; gap: 4px; }
.crm-kpi-up { color: var(--crm-success); }
.crm-kpi-down { color: var(--crm-danger); }

/* ---- Color Utilities ---- */
.crm-bg-primary { background: var(--crm-primary-light); color: var(--crm-primary); }
.crm-bg-success { background: var(--crm-success-light); color: var(--crm-success); }
.crm-bg-danger { background: var(--crm-danger-light); color: var(--crm-danger); }
.crm-bg-warning { background: var(--crm-warning-light); color: var(--crm-warning); }
.crm-bg-info { background: var(--crm-info-light); color: var(--crm-info); }
.crm-bg-violet { background: var(--crm-violet-light); color: var(--crm-violet); }
.crm-bg-pink { background: var(--crm-pink-light); color: var(--crm-pink); }

.crm-text-primary { color: var(--crm-primary); }
.crm-text-success { color: var(--crm-success); }
.crm-text-danger { color: var(--crm-danger); }
.crm-text-warning { color: var(--crm-warning); }
.crm-text-info { color: var(--crm-info); }
.crm-text-violet { color: var(--crm-violet); }
.crm-text-muted { color: var(--crm-text-muted); }

/* ---- Grid Layouts ---- */
.crm-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-bottom: 24px; }
.crm-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 24px; margin-bottom: 24px; }
.crm-grid-7-5 { display: grid; grid-template-columns: 7fr 5fr; gap: 24px; margin-bottom: 24px; }
.crm-grid-5-7 { display: grid; grid-template-columns: 5fr 7fr; gap: 24px; margin-bottom: 24px; }
.crm-grid-4-8 { display: grid; grid-template-columns: 4fr 8fr; gap: 24px; margin-bottom: 24px; }
.crm-grid-8-4 { display: grid; grid-template-columns: 8fr 4fr; gap: 24px; margin-bottom: 24px; }

/* ---- Tables ---- */
.crm-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.crm-table thead th {
  padding: 10px 14px;
  text-align: left;
  font-weight: 700;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--crm-text-muted);
  background: #f8fafc;
  border-bottom: 2px solid var(--crm-border);
}
.crm-table tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--crm-border);
  vertical-align: middle;
}
.crm-table tbody tr:hover { background: #f8fafc; }
.crm-table tbody tr:last-child td { border-bottom: none; }
.crm-table .text-right { text-align: right; }
.crm-table .text-center { text-align: center; }
.crm-table .fw-bold { font-weight: 700; }

/* ---- Badges ---- */
.crm-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 600;
  white-space: nowrap;
}
.crm-badge-primary { background: var(--crm-primary-light); color: var(--crm-primary); }
.crm-badge-success { background: var(--crm-success-light); color: #2e7d32; }
.crm-badge-danger { background: var(--crm-danger-light); color: var(--crm-danger); }
.crm-badge-warning { background: var(--crm-warning-light); color: #b45309; }
.crm-badge-info { background: var(--crm-info-light); color: #0369a1; }
.crm-badge-violet { background: var(--crm-violet-light); color: var(--crm-violet); }
.crm-badge-dark { background: #23344612; color: var(--crm-dark); }
.crm-badge-solid-primary { background: var(--crm-primary); color: #fff; }
.crm-badge-solid-success { background: var(--crm-success); color: #fff; }
.crm-badge-solid-danger { background: var(--crm-danger); color: #fff; }
.crm-badge-solid-warning { background: var(--crm-warning); color: #fff; }
.crm-badge-solid-info { background: var(--crm-info); color: #fff; }
.crm-badge-solid-violet { background: var(--crm-violet); color: #fff; }

/* ---- Buttons ---- */
.crm-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: var(--crm-transition);
  text-decoration: none;
}
.crm-btn-primary { background: var(--crm-primary); color: #fff; }
.crm-btn-primary:hover { background: #5a5eda; box-shadow: 0 4px 12px rgba(105,108,255,0.3); }
.crm-btn-outline { background: transparent; color: #fff; border: 1.5px solid rgba(255,255,255,0.4); }
.crm-btn-outline:hover { background: rgba(255,255,255,0.1); border-color: #fff; }
.crm-btn-sm { padding: 5px 12px; font-size: 0.75rem; border-radius: 6px; }
.crm-btn-success { background: var(--crm-success); color: #fff; }
.crm-btn-danger { background: var(--crm-danger); color: #fff; }
.crm-btn-warning { background: var(--crm-warning); color: #fff; }
.crm-btn-ghost { background: var(--crm-primary-light); color: var(--crm-primary); }
.crm-btn-ghost:hover { background: var(--crm-primary); color: #fff; }

/* ---- Progress Bars ---- */
.crm-progress { height: 8px; border-radius: 4px; background: #e2e8f0; overflow: hidden; }
.crm-progress-bar { height: 100%; border-radius: 4px; transition: width 0.6s ease; }
.crm-progress-thin { height: 5px; }
.crm-progress-thick { height: 12px; }

/* ---- Timeline ---- */
.crm-timeline { position: relative; padding-left: 24px; }
.crm-timeline::before { content: ''; position: absolute; left: 7px; top: 8px; bottom: 8px; width: 2px; background: var(--crm-border); }
.crm-timeline-item { position: relative; padding-bottom: 20px; }
.crm-timeline-item:last-child { padding-bottom: 0; }
.crm-timeline-dot { position: absolute; left: -20px; top: 6px; width: 10px; height: 10px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 2px var(--crm-border); }
.crm-timeline-dot-primary { background: var(--crm-primary); box-shadow: 0 0 0 2px var(--crm-primary); }
.crm-timeline-dot-success { background: var(--crm-success); box-shadow: 0 0 0 2px var(--crm-success); }
.crm-timeline-dot-danger { background: var(--crm-danger); box-shadow: 0 0 0 2px var(--crm-danger); }
.crm-timeline-dot-warning { background: var(--crm-warning); box-shadow: 0 0 0 2px var(--crm-warning); }

/* ---- Avatar ---- */
.crm-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}
.crm-avatar-sm { width: 32px; height: 32px; font-size: 0.72rem; }
.crm-avatar-lg { width: 56px; height: 56px; font-size: 1.1rem; }
.crm-avatar-xl { width: 80px; height: 80px; font-size: 1.5rem; }

/* ---- Flex Helpers ---- */
.crm-flex { display: flex; }
.crm-flex-col { flex-direction: column; }
.crm-flex-wrap { flex-wrap: wrap; }
.crm-flex-center { align-items: center; }
.crm-flex-between { justify-content: space-between; }
.crm-gap-8 { gap: 8px; }
.crm-gap-12 { gap: 12px; }
.crm-gap-16 { gap: 16px; }
.crm-gap-24 { gap: 24px; }

/* ---- Spacing ---- */
.crm-mb-0 { margin-bottom: 0; }
.crm-mb-8 { margin-bottom: 8px; }
.crm-mb-16 { margin-bottom: 16px; }
.crm-mb-24 { margin-bottom: 24px; }
.crm-mt-16 { margin-top: 16px; }
.crm-mt-24 { margin-top: 24px; }
.crm-p-0 { padding: 0; }

/* ---- Typography ---- */
.crm-fs-xs { font-size: 0.68rem; }
.crm-fs-sm { font-size: 0.75rem; }
.crm-fs-md { font-size: 0.85rem; }
.crm-fs-lg { font-size: 1rem; }
.crm-fs-xl { font-size: 1.25rem; }
.crm-fs-2xl { font-size: 1.5rem; }
.crm-fw-500 { font-weight: 500; }
.crm-fw-600 { font-weight: 600; }
.crm-fw-700 { font-weight: 700; }
.crm-fw-800 { font-weight: 800; }

/* ---- Alert Banners ---- */
.crm-alert {
  padding: 12px 20px;
  border-radius: var(--crm-radius);
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  font-size: 0.82rem;
}
.crm-alert-danger { background: var(--crm-danger-light); border: 1px solid #ff3e1d30; color: var(--crm-danger); }
.crm-alert-warning { background: var(--crm-warning-light); border: 1px solid #ffab0030; color: #b45309; }
.crm-alert-success { background: var(--crm-success-light); border: 1px solid #71dd3730; color: #2e7d32; }
.crm-alert-info { background: var(--crm-info-light); border: 1px solid #03c3ec30; color: #0369a1; }

/* ---- Tabs ---- */
.crm-tabs { display: flex; gap: 4px; margin-bottom: 20px; border-bottom: 2px solid var(--crm-border); padding-bottom: 0; }
.crm-tab {
  padding: 8px 18px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--crm-text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  transition: var(--crm-transition);
}
.crm-tab:hover { color: var(--crm-primary); }
.crm-tab.active { color: var(--crm-primary); border-bottom-color: var(--crm-primary); }

/* ---- Tier Colors ---- */
.crm-tier-bronze { color: #cd7f32; background: #cd7f3215; }
.crm-tier-silver { color: #757575; background: #75757515; }
.crm-tier-gold { color: #daa520; background: #daa52015; }
.crm-tier-platinum { color: #5b21b6; background: #5b21b615; }

/* ---- Segment Colors ---- */
.crm-seg-champion { background: #71dd3718; color: #2e7d32; border-left: 3px solid #71dd37; }
.crm-seg-loyal { background: #696cff18; color: #696cff; border-left: 3px solid #696cff; }
.crm-seg-potential { background: #03c3ec18; color: #0369a1; border-left: 3px solid #03c3ec; }
.crm-seg-new { background: #8b5cf618; color: #8b5cf6; border-left: 3px solid #8b5cf6; }
.crm-seg-atrisk { background: #ff3e1d18; color: #ff3e1d; border-left: 3px solid #ff3e1d; }
.crm-seg-dormant { background: #94a3b818; color: #64748b; border-left: 3px solid #94a3b8; }

/* ---- Score Circles ---- */
.crm-score-circle {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1rem;
  background: conic-gradient(var(--score-color, var(--crm-primary)) calc(var(--score, 0) * 3.6deg), #e2e8f0 0);
  position: relative;
}
.crm-score-circle::after {
  content: attr(data-score);
  position: absolute;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---- Chat Bubbles ---- */
.crm-chat-user { background: var(--crm-primary); color: #fff; border-radius: 16px 16px 4px 16px; padding: 12px 16px; max-width: 70%; margin-left: auto; }
.crm-chat-bot { background: #f1f5f9; color: var(--crm-text); border-radius: 16px 16px 16px 4px; padding: 12px 16px; max-width: 70%; }

/* ---- Pulse Animation ---- */
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
.crm-pulse { animation: pulse 2s infinite; }

/* ---- Skeleton / Shimmer ---- */
@keyframes shimmer { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }
.crm-shimmer {
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

/* ---- Mobile nav: hamburger + off-canvas drawer ---- */
.crm-hamburger {
  display: none;
  position: fixed; top: 14px; left: 14px; z-index: 105;
  width: 42px; height: 42px; border-radius: 10px;
  background: #fff; color: var(--crm-primary);
  border: 1px solid var(--crm-border); cursor: pointer;
  align-items: center; justify-content: center; font-size: 22px;
  box-shadow: var(--crm-shadow-lg); transition: transform 0.15s ease;
}
.crm-hamburger:active { transform: scale(0.93); }
.crm-nav-overlay {
  display: none; position: fixed; inset: 0; z-index: 100;
  background: rgba(15, 23, 42, 0.5); opacity: 0; transition: opacity 0.25s ease;
}
.crm-nav-overlay.show { opacity: 1; }

/* ---- Responsive ---- */
/* Tablet & mobile (<= 1200px): sidebar becomes a slide-in drawer opened by the hamburger */
@media (max-width: 1200px) {
  .crm-hamburger { display: flex; }
  .crm-nav-overlay.show { display: block; }
  .crm-sidebar { transform: translateX(-100%); transition: transform 0.28s ease; z-index: 110; }
  .crm-sidebar.open { transform: translateX(0); box-shadow: 0 0 40px rgba(0, 0, 0, 0.35); }
  .crm-main { margin-left: 0 !important; }
  .crm-page-header { padding-left: 68px; }
  .crm-kpi-grid-5, .crm-kpi-grid-6 { grid-template-columns: repeat(3, 1fr); }
  .crm-grid-7-5, .crm-grid-5-7, .crm-grid-4-8, .crm-grid-8-4 { grid-template-columns: 1fr; }
  /* add-on page two-pane layouts stack */
  .wa-grid, .jb-grid, .vs-grid { grid-template-columns: 1fr !important; }
  .phone, .flow, .cart { position: static !important; }
}
@media (max-width: 992px) {
  .crm-kpi-grid-4 { grid-template-columns: repeat(2, 1fr); }
  .crm-grid-2, .crm-grid-3 { grid-template-columns: 1fr; }
  .auto-list { grid-template-columns: 1fr !important; }
}
@media (max-width: 768px) {
  .crm-kpi-grid-4, .crm-kpi-grid-5, .crm-kpi-grid-6 { grid-template-columns: 1fr; }
  /* stack form / option rows on the add-on pages */
  .disc-type, .q-type { grid-template-columns: repeat(2, 1fr) !important; }
  .opt-row, .opt-row.two, .f-row { grid-template-columns: 1fr !important; }
  [style*="grid-template-columns:1fr 1fr"],
  [style*="grid-template-columns: 1fr 1fr"] { grid-template-columns: 1fr !important; }
  .match-grid { grid-template-columns: repeat(2, 1fr) !important; }
  /* wide tables scroll horizontally instead of overflowing */
  .crm-card-body.crm-p-0 { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .crm-table { min-width: 560px; }
}
@media (max-width: 576px) {
  .crm-content { padding: 16px; }
  .crm-page-header { padding: 20px 16px 20px 68px; }
  .crm-page-title { font-size: 1.25rem; }
  .match-grid, .ticket-grid, .nr-split { grid-template-columns: 1fr !important; }
}

/* ================================================================
   ANIMATIONS — Entrance, Hover, and Micro-interactions
   ================================================================ */

/* ---- Fade-in on scroll / page load ---- */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeInLeft {
  from { opacity: 0; transform: translateX(-20px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes fadeInScale {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Staggered entrance for KPI cards */
.crm-kpi { animation: fadeInUp 0.5s ease-out both; }
.crm-kpi:nth-child(1) { animation-delay: 0.05s; }
.crm-kpi:nth-child(2) { animation-delay: 0.1s; }
.crm-kpi:nth-child(3) { animation-delay: 0.15s; }
.crm-kpi:nth-child(4) { animation-delay: 0.2s; }
.crm-kpi:nth-child(5) { animation-delay: 0.25s; }
.crm-kpi:nth-child(6) { animation-delay: 0.3s; }

/* Cards fade in */
.crm-card { animation: fadeInScale 0.4s ease-out both; }
.crm-grid-2 > .crm-card:nth-child(1),
.crm-grid-7-5 > .crm-card:nth-child(1),
.crm-grid-5-7 > .crm-card:nth-child(1) { animation-delay: 0.1s; }
.crm-grid-2 > .crm-card:nth-child(2),
.crm-grid-7-5 > .crm-card:nth-child(2),
.crm-grid-5-7 > .crm-card:nth-child(2) { animation-delay: 0.2s; }
.crm-grid-3 > .crm-card:nth-child(1) { animation-delay: 0.1s; }
.crm-grid-3 > .crm-card:nth-child(2) { animation-delay: 0.15s; }
.crm-grid-3 > .crm-card:nth-child(3) { animation-delay: 0.2s; }

/* Page header slide down */
.crm-page-header { animation: slideDown 0.4s ease-out; }

/* Sidebar slide in */
.crm-sidebar { animation: fadeInLeft 0.3s ease-out; }

/* ---- Hover Micro-interactions ---- */

/* KPI card lift + glow */
.crm-kpi:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 25px rgba(105,108,255,0.12);
}

/* Card hover lift */
.crm-card:hover {
  box-shadow: 0 6px 24px rgba(0,0,0,0.08);
}

/* Button press effect */
.crm-btn:active { transform: scale(0.97); }

/* Nav item hover slide */
.crm-nav-item {
  position: relative;
  overflow: hidden;
}
.crm-nav-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 3px;
  background: var(--crm-primary);
  transform: scaleY(0);
  transition: transform 0.2s ease;
  border-radius: 0 2px 2px 0;
}
.crm-nav-item:hover::before { transform: scaleY(1); }
.crm-nav-item.active::before { transform: scaleY(1); background: #fff; }

/* Table row hover highlight */
.crm-table tbody tr {
  transition: background 0.15s ease, transform 0.15s ease;
}
.crm-table tbody tr:hover {
  background: #f1f5ff;
  transform: scale(1.002);
}

/* Badge pulse on danger */
.crm-badge-solid-danger { animation: badgePulse 2s infinite; }
@keyframes badgePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,62,29,0.3); }
  50% { box-shadow: 0 0 0 6px rgba(255,62,29,0); }
}

/* Progress bar animated fill */
.crm-progress-bar { animation: progressFill 1s ease-out; }
@keyframes progressFill { from { width: 0; } }

/* ---- Score Circle Animation ---- */
.crm-score-circle { animation: fadeInScale 0.6s ease-out; }

/* ---- Floating Dot (Live indicator) ---- */
@keyframes liveDot {
  0%, 100% { box-shadow: 0 0 0 0 rgba(113,221,55,0.4); }
  50% { box-shadow: 0 0 0 8px rgba(113,221,55,0); }
}
.crm-live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--crm-success);
  display: inline-block;
  animation: liveDot 2s infinite;
}

/* ---- Gradient text shimmer ---- */
@keyframes gradientShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}
.crm-page-header {
  background-size: 200% 200%;
  animation: gradientShift 6s ease infinite;
}

/* ---- Count-up number animation ---- */
@keyframes countUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.crm-kpi-value { animation: countUp 0.6s ease-out both; }
.crm-kpi:nth-child(1) .crm-kpi-value { animation-delay: 0.15s; }
.crm-kpi:nth-child(2) .crm-kpi-value { animation-delay: 0.2s; }
.crm-kpi:nth-child(3) .crm-kpi-value { animation-delay: 0.25s; }
.crm-kpi:nth-child(4) .crm-kpi-value { animation-delay: 0.3s; }
.crm-kpi:nth-child(5) .crm-kpi-value { animation-delay: 0.35s; }
.crm-kpi:nth-child(6) .crm-kpi-value { animation-delay: 0.4s; }

/* ---- Smooth icon rotation on hover ---- */
.crm-kpi-icon { transition: transform 0.3s ease; }
.crm-kpi:hover .crm-kpi-icon { transform: rotate(-8deg) scale(1.1); }

/* ---- Alert banner entrance ---- */
.crm-alert { animation: slideDown 0.4s ease-out 0.2s both; }

/* ---- Tab underline animation ---- */
.crm-tab {
  position: relative;
}
.crm-tab::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 50%;
  width: 0;
  height: 2px;
  background: var(--crm-primary);
  transition: all 0.3s ease;
  transform: translateX(-50%);
}
.crm-tab:hover::after { width: 100%; }
.crm-tab.active::after { width: 100%; }

/* ---- Timeline item stagger ---- */
.crm-timeline-item { animation: fadeInLeft 0.4s ease-out both; }
.crm-timeline-item:nth-child(1) { animation-delay: 0.1s; }
.crm-timeline-item:nth-child(2) { animation-delay: 0.2s; }
.crm-timeline-item:nth-child(3) { animation-delay: 0.3s; }
.crm-timeline-item:nth-child(4) { animation-delay: 0.4s; }
.crm-timeline-item:nth-child(5) { animation-delay: 0.5s; }

/* ---- Avatar hover ---- */
.crm-avatar { transition: transform 0.2s ease, box-shadow 0.2s ease; }
.crm-avatar:hover { transform: scale(1.1); box-shadow: 0 4px 12px rgba(0,0,0,0.15); }
