/* ==========================================================
   INSURELY — ADVANCED PRODUCT DESIGN SYSTEM & COMPONENT ENGINE
   Modern Fintech SaaS Aesthetics & Insurance Operations Workspace
   ========================================================== */

/* ----------------------------------------------------------
   1. DESIGN TOKENS (LIGHT DEFAULT)
   ---------------------------------------------------------- */
:root, [data-theme="light"] {
  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'SFMono-Regular', Menlo, Monaco, Consolas, monospace;

  /* Canvas & Surfaces (Light) */
  --color-bg: #F8FAFC;
  --color-surface: #FFFFFF;
  --color-surface-subtle: #F1F5F9;
  --color-surface-raised: #FFFFFF;
  --color-surface-hover: #F8FAFC;
  --color-overlay: rgba(15, 23, 42, 0.55);

  /* Text (Light) */
  --color-text-primary: #0F172A;
  --color-text-secondary: #334155;
  --color-text-muted: #64748B;
  --color-text-subtle: #94A3B8;
  --color-text-placeholder: #94A3B8;

  /* Borders (Light) */
  --color-border: #E2E8F0;
  --color-border-subtle: #F1F5F9;
  --color-border-strong: #CBD5E1;
  --color-border-focus: #1D4ED8;

  /* Primary Brand — Royal Cobalt (Matching Reference) */
  --color-primary: #1D4ED8;
  --color-primary-hover: #1E40AF;
  --color-primary-active: #172554;
  --color-primary-soft: #EFF6FF;
  --color-primary-border: #BFDBFE;
  --color-primary-text: #1D4ED8;

  /* Secondary Brand — Slate Navy */
  --color-secondary: #0F172A;
  --color-secondary-surface: #1E293B;
  --color-secondary-hover: #1E293B;

  /* Accent — Sky Azure */
  --color-accent: #0284C7;
  --color-accent-soft: #F0F9FF;
  --color-accent-border: #BAE6FD;

  /* Semantic Feedback (Light) - Reference Inspired */
  --color-success: #12803B;
  --color-success-light: #E6F7ED;
  --color-success-border: #A7F3D0;
  --color-success-text: #12803B;

  --color-warning: #B25E02;
  --color-warning-light: #FFF4E5;
  --color-warning-border: #FED7AA;
  --color-warning-text: #B25E02;

  --color-danger: #DC2626;
  --color-danger-light: #FEF2F2;
  --color-danger-border: #FECACA;
  --color-danger-text: #991B1B;

  --color-info: #1D4ED8;
  --color-info-light: #EFF6FF;
  --color-info-border: #BFDBFE;
  --color-info-text: #1D4ED8;

  /* Sidebar Tokens (Light — Integrated Seamless Frame) */
  --sidebar-width: 252px;
  --sidebar-collapsed-width: 64px;
  --sidebar-bg: #FFFFFF;
  --sidebar-surface: #F8FAFC;
  --sidebar-border: #E2E8F0;
  --sidebar-text: #475569;
  --sidebar-text-muted: #94A3B8;
  --sidebar-text-bright: #0F172A;
  --sidebar-hover-bg: #F1F5F9;
  --sidebar-hover-text: #0F172A;
  --sidebar-active-bg: #EFF6FF;
  --sidebar-active-text: #1D4ED8;
  --sidebar-active-icon: #1D4ED8;
  --sidebar-active-border: #BFDBFE;
  --sidebar-indicator: #2563EB;

  /* Layout Metrics */
  --header-height: 64px;

  /* Radii */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  /* Elevation Shadows (Calm, Soft, Lightweight) */
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.05), 0 1px 2px rgba(15, 23, 42, 0.03);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.06), 0 2px 4px -2px rgba(15, 23, 42, 0.03);
  --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.06), 0 4px 6px -4px rgba(15, 23, 42, 0.02);
  --shadow-xl: 0 20px 25px -5px rgba(15, 23, 42, 0.08), 0 8px 10px -6px rgba(15, 23, 42, 0.03);

  /* Transitions */
  --transition-fast: 160ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 280ms cubic-bezier(0.4, 0, 0.2, 1);

  /* Backward Compatibility Aliases */
  --bg-main: var(--color-bg);
  --bg-card: var(--color-surface);
  --bg-sidebar: var(--sidebar-bg);
  --primary: var(--color-primary);
  --primary-hover: var(--color-primary-hover);
  --primary-light: var(--color-primary-soft);
  --text-main: var(--color-text-primary);
  --text-muted: var(--color-text-muted);
  --border-color: var(--color-border);
  --sidebar-link: var(--sidebar-text);
  --sidebar-link-hover: var(--sidebar-hover-bg);
  --sidebar-active-bg: var(--sidebar-active-bg);
  --sidebar-active-text: var(--sidebar-active-text);
  --card-shadow: var(--shadow-sm);
  --success: var(--color-success);
  --warning: var(--color-warning);
  --danger: var(--color-danger);
  --info: var(--color-info);
  --success-bg: var(--color-success-light);
  --warning-bg: var(--color-warning-light);
  --danger-bg: var(--color-danger-light);
  --info-bg: var(--color-info-light);
  --success-text: var(--color-success-text);
  --warning-text: var(--color-warning-text);
  --danger-text: var(--color-danger-text);
  --info-text: var(--color-info-text);
}

/* ----------------------------------------------------------
   2. DARK THEME SPECIFICATION
   ---------------------------------------------------------- */
[data-theme="dark"] {
  --color-bg: #0B0F19;
  --color-surface: #111827;
  --color-surface-subtle: #182234;
  --color-surface-raised: #1F293D;
  --color-surface-hover: #1A2336;
  --color-overlay: rgba(0, 0, 0, 0.75);

  --color-text-primary: #F8FAFC;
  --color-text-secondary: #CBD5E1;
  --color-text-muted: #94A3B8;
  --color-text-subtle: #64748B;
  --color-text-placeholder: #475569;

  --color-border: #1E293B;
  --color-border-subtle: #162035;
  --color-border-strong: #334155;
  --color-border-focus: #60A5FA;

  /* Sidebar Tokens (Dark — Deep Midnight Slate) */
  --sidebar-bg: #0C101D;
  --sidebar-surface: #111726;
  --sidebar-border: rgba(255, 255, 255, 0.08);
  --sidebar-text: #94A3B8;
  --sidebar-text-muted: #64748B;
  --sidebar-text-bright: #F8FAFC;
  --sidebar-hover-bg: rgba(255, 255, 255, 0.05);
  --sidebar-hover-text: #FFFFFF;
  --sidebar-active-bg: rgba(37, 99, 235, 0.16);
  --sidebar-active-text: #93C5FD;
  --sidebar-active-icon: #60A5FA;
  --sidebar-active-border: rgba(37, 99, 235, 0.35);
  --sidebar-indicator: #3B82F6;

  --color-primary-soft: rgba(37, 99, 235, 0.18);
  --color-primary-border: rgba(37, 99, 235, 0.35);
  --color-primary-text: #93C5FD;

  --color-success-light: rgba(18, 128, 59, 0.18);
  --color-success-border: rgba(18, 128, 59, 0.35);
  --color-success-text: #6EE7B7;

  --color-warning-light: rgba(178, 94, 2, 0.18);
  --color-warning-border: rgba(178, 94, 2, 0.35);
  --color-warning-text: #FCD34D;

  --color-danger-light: rgba(220, 38, 38, 0.18);
  --color-danger-border: rgba(220, 38, 38, 0.35);
  --color-danger-text: #FCA5A5;

  --color-info-light: rgba(29, 78, 216, 0.18);
  --color-info-border: rgba(29, 78, 216, 0.35);
  --color-info-text: #93C5FD;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.45), 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 12px 24px rgba(0, 0, 0, 0.6);
  --shadow-xl: 0 20px 40px rgba(0, 0, 0, 0.7);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --color-bg: #0B0F19;
    --color-surface: #111827;
    --color-surface-subtle: #182234;
    --color-surface-raised: #1F293D;
    --color-surface-hover: #1A2336;
    --color-overlay: rgba(0, 0, 0, 0.75);

    --color-text-primary: #F8FAFC;
    --color-text-secondary: #CBD5E1;
    --color-text-muted: #94A3B8;
    --color-text-subtle: #64748B;
    --color-text-placeholder: #475569;

    --color-border: #1E293B;
    --color-border-subtle: #162035;
    --color-border-strong: #334155;
    --color-border-focus: #60A5FA;

    --sidebar-bg: #0C101D;
    --sidebar-surface: #111726;
    --sidebar-border: rgba(255, 255, 255, 0.08);
    --sidebar-text: #94A3B8;
    --sidebar-text-muted: #64748B;
    --sidebar-text-bright: #F8FAFC;
    --sidebar-hover-bg: rgba(255, 255, 255, 0.05);
    --sidebar-hover-text: #FFFFFF;
    --sidebar-active-bg: rgba(37, 99, 235, 0.16);
    --sidebar-active-text: #93C5FD;
    --sidebar-active-icon: #60A5FA;
    --sidebar-active-border: rgba(37, 99, 235, 0.35);
    --sidebar-indicator: #3B82F6;

    --color-primary-soft: rgba(37, 99, 235, 0.18);
    --color-primary-border: rgba(37, 99, 235, 0.35);
    --color-primary-text: #93C5FD;

    --color-success-light: rgba(18, 128, 59, 0.18);
    --color-success-border: rgba(18, 128, 59, 0.35);
    --color-success-text: #6EE7B7;

    --color-warning-light: rgba(178, 94, 2, 0.18);
    --color-warning-border: rgba(178, 94, 2, 0.35);
    --color-warning-text: #FCD34D;

    --color-danger-light: rgba(220, 38, 38, 0.18);
    --color-danger-border: rgba(220, 38, 38, 0.35);
    --color-danger-text: #FCA5A5;

    --color-info-light: rgba(29, 78, 216, 0.18);
    --color-info-border: rgba(29, 78, 216, 0.35);
    --color-info-text: #93C5FD;

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.35);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.45), 0 1px 2px rgba(0, 0, 0, 0.35);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 12px 24px rgba(0, 0, 0, 0.6);
    --shadow-xl: 0 20px 40px rgba(0, 0, 0, 0.7);
  }
}
/* ----------------------------------------------------------
   3. BASE & RESET (ZERO FLICKER INITIAL RENDER)
   ---------------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background-color: #F8FAFC;
  background-color: var(--color-bg);
  color: var(--color-text-primary);
}

html {
  font-size: 14px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

html[data-theme="dark"], body[data-theme="dark"] {
  background-color: #0B0F19;
}

body {
  font-family: var(--font-sans);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  min-height: 100vh;
}

/* Instant Collapsed Sidebar Initial State (No Layout Shift) */
html.sidebar-is-collapsed .app-sidebar:not(:hover) {
  width: var(--sidebar-collapsed-width);
}

html.sidebar-is-collapsed .app-main {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  will-change: margin-left;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  transition: margin-left 280ms cubic-bezier(0.16, 1, 0.3, 1);
  background-color: var(--color-bg);
}

/* Tabular numbers for financial and date precision */
.tnum, .tabular-nums, .stat-value, .cell-value, .ref-code, .amount-cell {
  font-variant-numeric: tabular-nums;
  -webkit-font-feature-settings: "tnum";
  font-feature-settings: "tnum";
}

/* Reference Codes & Badges */
.ref-code {
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--color-text-primary);
  letter-spacing: -0.01em;
  background: var(--color-surface-subtle);
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--color-border);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.ref-code .copy-btn {
  cursor: pointer;
  color: var(--color-text-subtle);
  font-size: 10px;
  transition: color var(--transition-fast);
}

.ref-code .copy-btn:hover {
  color: var(--color-primary);
}

/* ----------------------------------------------------------
   4. APP SHELL & LAYOUT
   ---------------------------------------------------------- */
.app-container {
  display: flex;
  min-height: 100vh;
  position: relative;
}

/* ----------------------------------------------------------
   5. SIDEBAR NAVIGATION & INTERACTIVE ENGINE
   ---------------------------------------------------------- */
.app-sidebar {
  width: var(--sidebar-width);
  height: 100vh;
  background-color: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 900;
  will-change: width, transform;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  transition: width 280ms cubic-bezier(0.16, 1, 0.3, 1), transform 280ms cubic-bezier(0.16, 1, 0.3, 1), box-shadow 280ms cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
}

.sidebar-brand {
  height: var(--header-height);
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  border-bottom: 1px solid var(--sidebar-border);
  background-color: var(--sidebar-bg);
  position: relative;
  overflow: hidden;
  will-change: padding;
  transition: padding 280ms cubic-bezier(0.16, 1, 0.3, 1);
}

.sidebar-brand-link {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  min-width: 0;
  width: 100%;
  transition: gap 280ms cubic-bezier(0.16, 1, 0.3, 1), opacity var(--transition-fast);
}

.sidebar-brand-link:hover {
  opacity: 0.9;
}

.brand-text-wrap {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  max-width: 180px;
  opacity: 1;
  transform: translateX(0);
  transition: opacity 200ms cubic-bezier(0.16, 1, 0.3, 1) 40ms, transform 200ms cubic-bezier(0.16, 1, 0.3, 1) 40ms, max-width 280ms cubic-bezier(0.16, 1, 0.3, 1);
}

.sidebar-logo-img {
  height: 32px;
  width: auto;
  max-width: 140px;
  object-fit: contain;
  border-radius: var(--radius-xs);
  flex-shrink: 0;
  transition: max-width 280ms cubic-bezier(0.16, 1, 0.3, 1), max-height 280ms cubic-bezier(0.16, 1, 0.3, 1), margin 280ms cubic-bezier(0.16, 1, 0.3, 1);
}

[data-theme="dark"] .sidebar-logo-img.invert-on-dark {
  filter: brightness(0) invert(1);
}

.brand-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--color-primary), #1D4ED8);
  color: #fff;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(29, 78, 216, 0.25);
  transition: transform 0.16s ease;
}

.brand-icon:hover {
  transform: scale(1.04);
}

.brand-title {
  font-size: 14px;
  font-weight: 800;
  color: var(--sidebar-text-bright);
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-subtitle {
  font-size: 9.5px;
  color: var(--sidebar-text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 700;
}

.sidebar-collapse-btn {
  background: var(--color-surface-subtle);
  border: 1px solid var(--color-border);
  color: var(--sidebar-text-muted);
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.sidebar-collapse-btn:hover {
  background: var(--color-primary-soft);
  border-color: var(--color-primary-border);
  color: var(--color-primary);
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  will-change: padding;
  transition: padding 280ms cubic-bezier(0.16, 1, 0.3, 1);
}

.sidebar-nav::-webkit-scrollbar {
  width: 4px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 4px;
}

.nav-section-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--sidebar-text-muted);
  padding: 14px 10px 5px;
  transition: opacity 0.2s ease;
}

.nav-link-custom {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  min-height: 38px;
  width: 100%;
  color: var(--sidebar-text);
  text-decoration: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  position: relative;
  box-sizing: border-box;
  transition: width 280ms cubic-bezier(0.16, 1, 0.3, 1), padding 280ms cubic-bezier(0.16, 1, 0.3, 1), margin 280ms cubic-bezier(0.16, 1, 0.3, 1), gap 280ms cubic-bezier(0.16, 1, 0.3, 1), background-color 160ms cubic-bezier(0.4, 0, 0.2, 1), color 160ms cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-link-custom i {
  font-size: 14px;
  width: 20px;
  min-width: 20px;
  text-align: center;
  color: var(--sidebar-text-muted);
  flex-shrink: 0;
  transition: color 160ms cubic-bezier(0.4, 0, 0.2, 1), transform 160ms cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-link-custom:hover {
  background-color: var(--sidebar-hover-bg);
  color: var(--sidebar-hover-text);
}

.nav-link-custom:hover i {
  color: var(--color-primary);
  transform: translateX(1.5px);
}

/* Active navigation item with smooth accent pill */
.nav-link-custom.active {
  background-color: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
  font-weight: 600;
}

.nav-link-custom.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 3px;
  background-color: var(--sidebar-indicator);
  border-radius: 0 3px 3px 0;
}

.nav-link-custom.active i {
  color: var(--sidebar-active-icon);
}

.nav-link-badge {
  margin-left: auto;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  background: var(--color-primary-soft);
  color: var(--color-primary-text);
}



/* Sidebar Footer */
.sidebar-footer {
  padding: 12px 10px;
  border-top: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--sidebar-surface);
  will-change: padding;
  transition: padding 280ms cubic-bezier(0.16, 1, 0.3, 1);
}

.sidebar-plan-badge {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--color-surface);
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
}

.plan-label {
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  font-weight: 700;
}

.plan-name {
  font-size: 12px;
  font-weight: 700;
  color: var(--color-text-primary);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  width: 100%;
  border-radius: var(--radius-sm);
  text-decoration: none;
  box-sizing: border-box;
  transition: width 280ms cubic-bezier(0.16, 1, 0.3, 1), padding 280ms cubic-bezier(0.16, 1, 0.3, 1), margin 280ms cubic-bezier(0.16, 1, 0.3, 1), gap 280ms cubic-bezier(0.16, 1, 0.3, 1), background-color 160ms cubic-bezier(0.4, 0, 0.2, 1);
}

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

.sidebar-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--color-primary), #1E40AF);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.1);
}

.sidebar-user-info {
  min-width: 0;
  flex: 1;
}

.sidebar-user-name {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--color-text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  font-size: 11px;
  color: var(--color-text-muted);
  font-weight: 500;
}

/* ==========================================================
   COLLAPSED SIDEBAR MODE (SILKY-SMOOTH EXPAND & DOCK TRANSITIONS)
   ========================================================== */
.app-sidebar.collapsed,
html.sidebar-is-collapsed .app-sidebar {
  width: var(--sidebar-collapsed-width);
  transition: width 280ms cubic-bezier(0.16, 1, 0.3, 1), box-shadow 280ms cubic-bezier(0.16, 1, 0.3, 1);
  overflow-x: hidden;
}

/* On Hover: Gently and smoothly expand the collapsed sidebar as a floating flyout */
.app-sidebar.collapsed:hover,
html.sidebar-is-collapsed .app-sidebar:hover {
  width: var(--sidebar-width) !important;
  box-shadow: 0 16px 40px -8px rgba(15, 23, 42, 0.22), 0 0 0 1px var(--sidebar-border);
  z-index: 950;
  transition: width 280ms cubic-bezier(0.16, 1, 0.3, 1), box-shadow 280ms cubic-bezier(0.16, 1, 0.3, 1) !important;
}

/* Base text element smooth transitions - prevents abrupt popping or ellipsis jitter */
.brand-text-wrap,
.brand-title,
.brand-subtitle,
.nav-section-title,
.nav-link-custom span,
.nav-link-badge,
.sidebar-plan-badge,
.sidebar-user-info,
.collapse-strip-label,
.collapse-kbd,
.sidebar-user-chevron {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip;
  transition: opacity 180ms cubic-bezier(0.16, 1, 0.3, 1), transform 180ms cubic-bezier(0.16, 1, 0.3, 1), max-width 280ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* Silky smooth fade & glide when collapsed (NOT hovering) */
.app-sidebar.collapsed:not(:hover) .brand-text-wrap,
.app-sidebar.collapsed:not(:hover) .brand-title,
.app-sidebar.collapsed:not(:hover) .brand-subtitle,
.app-sidebar.collapsed:not(:hover) .nav-section-title,
.app-sidebar.collapsed:not(:hover) .nav-link-custom span,
.app-sidebar.collapsed:not(:hover) .nav-link-badge,
.app-sidebar.collapsed:not(:hover) .sidebar-plan-badge,
.app-sidebar.collapsed:not(:hover) .sidebar-user-info,
.app-sidebar.collapsed:not(:hover) .collapse-strip-label,
.app-sidebar.collapsed:not(:hover) .collapse-kbd,
.app-sidebar.collapsed:not(:hover) .sidebar-user-chevron,
html.sidebar-is-collapsed .app-sidebar:not(:hover) .brand-text-wrap,
html.sidebar-is-collapsed .app-sidebar:not(:hover) .brand-title,
html.sidebar-is-collapsed .app-sidebar:not(:hover) .brand-subtitle,
html.sidebar-is-collapsed .app-sidebar:not(:hover) .nav-section-title,
html.sidebar-is-collapsed .app-sidebar:not(:hover) .nav-link-custom span,
html.sidebar-is-collapsed .app-sidebar:not(:hover) .nav-link-badge,
html.sidebar-is-collapsed .app-sidebar:not(:hover) .sidebar-plan-badge,
html.sidebar-is-collapsed .app-sidebar:not(:hover) .sidebar-user-info,
html.sidebar-is-collapsed .app-sidebar:not(:hover) .collapse-strip-label,
html.sidebar-is-collapsed .app-sidebar:not(:hover) .collapse-kbd,
html.sidebar-is-collapsed .app-sidebar:not(:hover) .sidebar-user-chevron {
  opacity: 0 !important;
  max-width: 0 !important;
  transform: translateX(-6px) !important;
  pointer-events: none !important;
  visibility: hidden !important;
  transition: opacity 120ms ease-out, transform 120ms ease-out, max-width 280ms cubic-bezier(0.16, 1, 0.3, 1) !important;
}

/* Silky smooth glide-in on expand or hover */
.app-sidebar.collapsed:hover .brand-text-wrap,
.app-sidebar.collapsed:hover .brand-title,
.app-sidebar.collapsed:hover .brand-subtitle,
.app-sidebar.collapsed:hover .nav-link-custom span,
.app-sidebar.collapsed:hover .nav-link-badge,
.app-sidebar.collapsed:hover .sidebar-plan-badge,
.app-sidebar.collapsed:hover .sidebar-user-info,
.app-sidebar.collapsed:hover .collapse-strip-label,
.app-sidebar.collapsed:hover .collapse-kbd,
.app-sidebar.collapsed:hover .sidebar-user-chevron,
html.sidebar-is-collapsed .app-sidebar:hover .brand-text-wrap,
html.sidebar-is-collapsed .app-sidebar:hover .brand-title,
html.sidebar-is-collapsed .app-sidebar:hover .brand-subtitle,
html.sidebar-is-collapsed .app-sidebar:hover .nav-link-custom span,
html.sidebar-is-collapsed .app-sidebar:hover .nav-link-badge,
html.sidebar-is-collapsed .app-sidebar:hover .sidebar-plan-badge,
html.sidebar-is-collapsed .app-sidebar:hover .sidebar-user-info,
html.sidebar-is-collapsed .app-sidebar:hover .collapse-strip-label,
html.sidebar-is-collapsed .app-sidebar:hover .collapse-kbd,
html.sidebar-is-collapsed .app-sidebar:hover .sidebar-user-chevron {
  opacity: 1 !important;
  max-width: 220px !important;
  transform: translateX(0) !important;
  visibility: visible !important;
  pointer-events: auto !important;
  transition: opacity 220ms cubic-bezier(0.16, 1, 0.3, 1) 40ms, transform 220ms cubic-bezier(0.16, 1, 0.3, 1) 40ms, max-width 280ms cubic-bezier(0.16, 1, 0.3, 1) !important;
}

.app-sidebar.collapsed:hover .nav-section-title,
html.sidebar-is-collapsed .app-sidebar:hover .nav-section-title {
  display: block !important;
  opacity: 1 !important;
  max-width: 220px !important;
  transform: translateX(0) !important;
  visibility: visible !important;
  transition: opacity 220ms cubic-bezier(0.16, 1, 0.3, 1) 40ms, transform 220ms cubic-bezier(0.16, 1, 0.3, 1) 40ms !important;
}

/* --- BRAND LOGO AREA (COLLAPSED) --- */
.app-sidebar.collapsed:not(:hover) .sidebar-brand,
html.sidebar-is-collapsed .app-sidebar:not(:hover) .sidebar-brand {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0;
  width: 100%;
  height: var(--header-height);
  transition: padding 280ms cubic-bezier(0.16, 1, 0.3, 1);
}

.app-sidebar.collapsed:hover .sidebar-brand,
html.sidebar-is-collapsed .app-sidebar:hover .sidebar-brand {
  justify-content: flex-start;
  padding: 0 18px;
  transition: padding 280ms cubic-bezier(0.16, 1, 0.3, 1);
}

.app-sidebar.collapsed:not(:hover) .sidebar-brand-link,
html.sidebar-is-collapsed .app-sidebar:not(:hover) .sidebar-brand-link {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 100%;
  margin: 0 auto;
  padding: 0;
  gap: 0;
  transition: gap 280ms cubic-bezier(0.16, 1, 0.3, 1);
}

.app-sidebar.collapsed:hover .sidebar-brand-link,
html.sidebar-is-collapsed .app-sidebar:hover .sidebar-brand-link {
  justify-content: flex-start;
  gap: 12px;
  transition: gap 280ms cubic-bezier(0.16, 1, 0.3, 1);
}

.app-sidebar.collapsed:not(:hover) .sidebar-logo-img,
html.sidebar-is-collapsed .app-sidebar:not(:hover) .sidebar-logo-img {
  max-width: 32px;
  max-height: 32px;
  width: auto;
  height: auto;
  margin: 0 auto;
  display: block;
  object-fit: contain;
  border-radius: var(--radius-xs);
  transition: max-width 280ms cubic-bezier(0.16, 1, 0.3, 1), max-height 280ms cubic-bezier(0.16, 1, 0.3, 1);
}

.app-sidebar.collapsed:hover .sidebar-logo-img,
html.sidebar-is-collapsed .app-sidebar:hover .sidebar-logo-img {
  max-width: 140px;
  max-height: 32px;
  margin: 0;
  transition: max-width 280ms cubic-bezier(0.16, 1, 0.3, 1), max-height 280ms cubic-bezier(0.16, 1, 0.3, 1);
}

.app-sidebar.collapsed .sidebar-collapse-btn,
html.sidebar-is-collapsed .app-sidebar .sidebar-collapse-btn {
  display: none !important;
}

/* --- NAV ITEMS (COLLAPSED) --- */
.app-sidebar.collapsed:not(:hover) .sidebar-nav,
html.sidebar-is-collapsed .app-sidebar:not(:hover) .sidebar-nav {
  padding: 12px 11px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transition: padding 280ms cubic-bezier(0.16, 1, 0.3, 1);
}

.app-sidebar.collapsed:hover .sidebar-nav,
html.sidebar-is-collapsed .app-sidebar:hover .sidebar-nav {
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 2px;
  transition: padding 280ms cubic-bezier(0.16, 1, 0.3, 1);
}

.app-sidebar.collapsed:not(:hover) .nav-link-custom,
html.sidebar-is-collapsed .app-sidebar:not(:hover) .nav-link-custom {
  width: 42px;
  height: 38px;
  min-height: 38px;
  padding: 0;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  border-radius: var(--radius-sm);
  gap: 0 !important;
  transform: none !important;
  transition: width 280ms cubic-bezier(0.16, 1, 0.3, 1), padding 280ms cubic-bezier(0.16, 1, 0.3, 1), margin 280ms cubic-bezier(0.16, 1, 0.3, 1), gap 280ms cubic-bezier(0.16, 1, 0.3, 1);
}

.app-sidebar.collapsed:hover .nav-link-custom,
html.sidebar-is-collapsed .app-sidebar:hover .nav-link-custom {
  width: 100%;
  height: auto;
  min-height: 38px;
  justify-content: flex-start;
  padding: 8px 12px;
  gap: 10px;
  margin: 0;
  transition: width 280ms cubic-bezier(0.16, 1, 0.3, 1), padding 280ms cubic-bezier(0.16, 1, 0.3, 1), margin 280ms cubic-bezier(0.16, 1, 0.3, 1), gap 280ms cubic-bezier(0.16, 1, 0.3, 1);
}

.app-sidebar.collapsed:not(:hover) .nav-link-custom i,
html.sidebar-is-collapsed .app-sidebar:not(:hover) .nav-link-custom i {
  font-size: 14.5px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  min-width: 20px;
  text-align: center;
  transform: none !important;
}

.app-sidebar.collapsed:hover .nav-link-custom i,
html.sidebar-is-collapsed .app-sidebar:hover .nav-link-custom i {
  width: 20px;
  min-width: 20px;
  font-size: 14px;
  margin: 0;
  text-align: center;
}

/* Eliminate active left indicator line in collapsed mode */
.app-sidebar.collapsed:not(:hover) .nav-link-custom.active::before,
html.sidebar-is-collapsed .app-sidebar:not(:hover) .nav-link-custom.active::before {
  display: none !important;
}

.app-sidebar.collapsed:not(:hover) .nav-link-custom.active,
html.sidebar-is-collapsed .app-sidebar:not(:hover) .nav-link-custom.active {
  background-color: var(--sidebar-active-bg) !important;
  color: var(--sidebar-active-text) !important;
  border: 1px solid var(--sidebar-active-border);
  box-shadow: none !important;
}

/* Tooltip on Collapsed Nav Items */
.app-sidebar.collapsed .nav-link-custom[data-tooltip]::after,
html.sidebar-is-collapsed .app-sidebar .nav-link-custom[data-tooltip]::after {
  display: none !important;
}

/* --- FOOTER & ADVISOR PROFILE (COLLAPSED) --- */
.app-sidebar.collapsed:not(:hover) .sidebar-footer,
html.sidebar-is-collapsed .app-sidebar:not(:hover) .sidebar-footer {
  padding: 10px 0 14px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  gap: 0;
  transition: padding 280ms cubic-bezier(0.16, 1, 0.3, 1);
}

.app-sidebar.collapsed:hover .sidebar-footer,
html.sidebar-is-collapsed .app-sidebar:hover .sidebar-footer {
  padding: 12px 10px;
  align-items: stretch;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: padding 280ms cubic-bezier(0.16, 1, 0.3, 1);
}

.app-sidebar.collapsed:not(:hover) .sidebar-user,
html.sidebar-is-collapsed .app-sidebar:not(:hover) .sidebar-user {
  justify-content: center;
  align-items: center;
  padding: 0;
  width: 42px;
  height: 42px;
  margin: 0 auto;
  display: flex;
  border-radius: var(--radius-full);
  gap: 0;
  transition: all 280ms cubic-bezier(0.16, 1, 0.3, 1);
}

.app-sidebar.collapsed:hover .sidebar-user,
html.sidebar-is-collapsed .app-sidebar:hover .sidebar-user {
  justify-content: flex-start;
  width: 100%;
  height: auto;
  padding: 6px 8px;
  gap: 10px;
  border-radius: var(--radius-sm);
  transition: all 280ms cubic-bezier(0.16, 1, 0.3, 1);
}

.app-sidebar.collapsed:not(:hover) .sidebar-user-avatar,
html.sidebar-is-collapsed .app-sidebar:not(:hover) .sidebar-user-avatar {
  margin: 0 auto;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 700;
  border-radius: var(--radius-full);
  transition: all 280ms cubic-bezier(0.16, 1, 0.3, 1);
}

.app-sidebar.collapsed:hover .sidebar-user-avatar,
html.sidebar-is-collapsed .app-sidebar:hover .sidebar-user-avatar {
  margin: 0;
  width: 32px;
  height: 32px;
  font-size: 12px;
  transition: all 280ms cubic-bezier(0.16, 1, 0.3, 1);
}
/* ----------------------------------------------------------
   6. MAIN WORKSPACE & HEADER
   ---------------------------------------------------------- */
.app-main {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  will-change: margin-left;
  transition: margin-left 260ms cubic-bezier(0.16, 1, 0.3, 1);
  background-color: var(--color-bg);
}

.app-sidebar.collapsed ~ .app-main {
  margin-left: var(--sidebar-collapsed-width);
}

.app-header {
  height: var(--header-height);
  background-color: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 800;
}

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

.header-action-btn {
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: var(--radius-sm);
  background: var(--color-surface-subtle);
  border: 1px solid var(--color-border);
  color: var(--color-text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  font-size: 13.5px;
  transition: all var(--transition-fast);
  outline: none;
  flex-shrink: 0;
}

.header-action-btn:hover {
  background: var(--color-surface);
  border-color: var(--color-border-strong);
  color: var(--color-primary);
  box-shadow: var(--shadow-xs);
  transform: translateY(-1px);
}

.header-action-btn:active {
  transform: translateY(0);
  background: var(--color-surface-subtle);
}

.header-action-btn:focus-visible {
  border-color: var(--color-border-focus);
  box-shadow: 0 0 0 2px var(--color-primary-soft);
}

.header-search {
  display: flex;
  align-items: center;
  background: var(--color-surface-subtle);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 6px 12px;
  gap: 8px;
  cursor: pointer;
  width: 100%;
  max-width: 340px;
  transition: all var(--transition-fast);
}

.header-search:hover {
  border-color: var(--color-border-strong);
  background: var(--color-surface);
}

.header-search i {
  color: var(--color-text-muted);
  font-size: 13px;
  flex-shrink: 0;
}

.header-search input {
  background: transparent;
  border: none;
  outline: none;
  font-size: 13px;
  color: var(--color-text-primary);
  flex: 1;
  min-width: 0;
  cursor: pointer;
}

.header-search-shortcut {
  font-size: 11px;
  font-weight: 700;
  font-family: inherit;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xs);
  padding: 2px 7px;
  color: var(--color-text-secondary);
  box-shadow: var(--shadow-xs);
  white-space: nowrap;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1.3;
  letter-spacing: 0.02em;
}

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

/* Theme Switcher Button */
.theme-switch-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--color-surface-subtle);
  border: 1px solid var(--color-border);
  color: var(--color-text-secondary);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.theme-switch-btn:hover {
  background: var(--color-surface);
  border-color: var(--color-border-strong);
  color: var(--color-text-primary);
}

/* Quick Create Button */
.btn-quick-create {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--color-primary);
  color: #fff;
  border: none;
  font-size: 12.5px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background-color var(--transition-fast);
}

.btn-quick-create:hover {
  background: var(--color-primary-hover);
}

/* Notification Bell */
.notification-bell-btn {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  background: var(--color-surface-subtle);
  border: 1px solid var(--color-border);
  color: var(--color-text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  font-size: 13px;
  transition: all var(--transition-fast);
}

.notification-bell-btn:hover {
  background: var(--color-surface);
  color: var(--color-text-primary);
}

.notification-badge-pill {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--color-danger);
  color: #fff;
  font-size: 9px;
  font-weight: 800;
  height: 16px;
  min-width: 16px;
  padding: 0 4px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--color-surface);
}

/* Header Dropdowns */
.header-dropdown {
  position: absolute;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 1000;
}

.quick-create-dropdown {
  position: absolute;
  top: 42px;
  right: 0;
  width: 200px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  display: none;
  z-index: 1000;
}

.quick-create-dropdown.open {
  display: block;
}

.quick-create-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  color: var(--color-text-primary);
  text-decoration: none;
  font-size: 12.5px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  transition: background-color var(--transition-fast);
}

.quick-create-item:hover {
  background: var(--color-surface-subtle);
  color: var(--color-primary);
}

.quick-create-item i {
  font-size: 12px;
  width: 16px;
  color: var(--color-text-muted);
}

/* User Profile Header */
.header-user-profile {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background-color var(--transition-fast);
}

.header-user-profile:hover {
  background: var(--color-surface-subtle);
}

.header-user-profile .user-avatar {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--color-primary), #1D4ED8);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
}

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

.header-user-profile .user-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-primary);
  line-height: 1.2;
}

.header-user-profile .user-role {
  font-size: 10px;
  color: var(--color-text-muted);
}

.header-dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  color: var(--color-text-primary);
  text-decoration: none;
  font-size: 12px;
  font-weight: 500;
  border: none;
  background: transparent;
  width: 100%;
  cursor: pointer;
  border-radius: var(--radius-xs);
  text-align: left;
}

.header-dropdown-item:hover {
  background: var(--color-surface-subtle);
}

.header-dropdown-item.danger {
  color: var(--color-danger);
}

.header-dropdown-item.danger:hover {
  background: var(--color-danger-light);
}

/* SWR Indicator */
.swr-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--color-accent);
  background: var(--color-accent-soft);
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-weight: 600;
}

/* ----------------------------------------------------------
   7. BREADCRUMBS & PAGE HEADERS
   ---------------------------------------------------------- */
.page-body {
  flex: 1;
  padding: 24px;
}

.app-breadcrumbs {
  margin-bottom: 12px;
}

.app-breadcrumbs ol {
  display: flex;
  align-items: center;
  list-style: none;
  gap: 6px;
  font-size: 12px;
}

.app-breadcrumbs a {
  color: var(--color-text-muted);
  text-decoration: none;
  transition: color var(--transition-fast);
}

.app-breadcrumbs a:hover {
  color: var(--color-primary);
}

.app-breadcrumbs .separator {
  color: var(--color-text-subtle);
  font-size: 9px;
}

.app-breadcrumbs .current {
  color: var(--color-text-primary);
  font-weight: 600;
}

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

.page-title {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--color-text-primary);
  line-height: 1.2;
}

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

.page-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ----------------------------------------------------------
   8. BUTTONS
   ---------------------------------------------------------- */
.btn-crm,
.btn-primary-custom,
.btn-secondary-custom,
.btn-danger-custom,
.btn-crm-primary,
.btn-crm-secondary,
.btn-crm-danger,
.btn-crm-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: var(--font-sans);
  font-size: 12.5px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
  transition: all var(--transition-fast);
  border: 1px solid transparent;
  line-height: 1.3;
}

.btn-crm-sm {
  padding: 4px 10px;
  font-size: 11.5px;
  border-radius: var(--radius-xs);
}

.btn-crm-lg {
  padding: 10px 20px;
  font-size: 14px;
  border-radius: var(--radius-md);
}

/* Primary Button */
.btn-primary-custom,
.btn-crm-primary {
  background-color: var(--color-primary);
  color: #FFFFFF;
  border-color: var(--color-primary);
  box-shadow: 0 1px 2px rgba(37, 99, 235, 0.2);
}

.btn-primary-custom:hover,
.btn-crm-primary:hover {
  background-color: var(--color-primary-hover);
  border-color: var(--color-primary-hover);
  color: #FFFFFF;
}

.btn-primary-custom:active,
.btn-crm-primary:active {
  background-color: var(--color-primary-active);
}

/* Secondary / Outline Button */
.btn-secondary-custom,
.btn-crm-secondary {
  background-color: var(--color-surface);
  border-color: var(--color-border);
  color: var(--color-text-secondary);
  box-shadow: var(--shadow-xs);
}

.btn-secondary-custom:hover,
.btn-crm-secondary:hover {
  background-color: var(--color-surface-subtle);
  border-color: var(--color-border-strong);
  color: var(--color-text-primary);
}

/* Danger Button */
.btn-danger-custom,
.btn-crm-danger {
  background-color: var(--color-danger);
  color: #FFFFFF;
  border-color: var(--color-danger);
}

.btn-danger-custom:hover,
.btn-crm-danger:hover {
  background-color: #B91C1C;
  border-color: #B91C1C;
  color: #FFFFFF;
}

/* Ghost Button */
.btn-crm-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--color-text-muted);
}

.btn-crm-ghost:hover {
  background: var(--color-surface-subtle);
  color: var(--color-text-primary);
}

/* Link Button */
.btn-link {
  background: none;
  border: none;
  color: var(--color-primary);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  padding: 0;
  font-size: 12.5px;
}

.btn-link:hover {
  text-decoration: underline;
}

/* Tab Navigation Component */
.tab-nav {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 24px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.tab-btn {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  transition: all var(--transition-fast);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.tab-btn:hover {
  color: var(--color-primary);
  background: var(--color-surface-subtle);
}

.tab-btn.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
  font-weight: 700;
  background: var(--color-primary-soft);
}

/* ----------------------------------------------------------
   9. KPI STAT CARDS & ATTENTION CENTER
   ---------------------------------------------------------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card, .crm-kpi-card {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  box-shadow: var(--shadow-xs);
  position: relative;
  overflow: hidden;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.stat-card:hover, .crm-kpi-card:hover {
  box-shadow: var(--shadow-sm);
}

.stat-card.primary-kpi {
  border-left: 3px solid var(--color-primary);
}

.stat-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
}

.stat-value {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--color-text-primary);
  margin: 6px 0 2px;
  line-height: 1.1;
}

.stat-subtext {
  font-size: 11.5px;
  color: var(--color-text-muted);
}

.stat-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: var(--radius-full);
}

.stat-badge.success {
  background: var(--color-success-light);
  color: var(--color-success-text);
}

.stat-badge.warning {
  background: var(--color-warning-light);
  color: var(--color-warning-text);
}

/* Attention Center */
.attention-center {
  background: linear-gradient(135deg, rgba(217, 119, 6, 0.08) 0%, rgba(245, 158, 11, 0.04) 100%);
  border: 1px solid var(--color-warning-border);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  margin-bottom: 24px;
}

.attention-center-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--color-warning-text);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.attention-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0;
  border-top: 1px solid rgba(217, 119, 6, 0.15);
  font-size: 12.5px;
  color: var(--color-text-primary);
}

.attention-item a {
  font-weight: 600;
  color: var(--color-warning-text);
  text-decoration: none;
  font-size: 12px;
}

.attention-item a:hover {
  text-decoration: underline;
}

/* ----------------------------------------------------------
   10. CARDS, PANELS & SECTIONS
   ---------------------------------------------------------- */
.crm-card {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}

.crm-card-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background-color: var(--color-surface);
}

.crm-card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--color-text-primary);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.crm-card-body {
  padding: 18px 20px;
}

/* Information Detail Grid */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px 20px;
}

.detail-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.detail-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
}

.detail-value {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-primary);
}

/* Signature High-Impact Hero Card (Financial SaaS Highlight) */
.crm-card-hero {
  background: linear-gradient(135deg, #1E3A8A 0%, #1D4ED8 55%, #2563EB 100%);
  color: #FFFFFF;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-xl);
  padding: 24px 28px;
  box-shadow: 0 10px 25px -5px rgba(37, 99, 235, 0.28), 0 4px 6px -2px rgba(15, 23, 42, 0.05);
  position: relative;
  overflow: hidden;
}

[data-theme="dark"] .crm-card-hero {
  background: linear-gradient(135deg, #0F172A 0%, #1E3A8A 60%, #1D4ED8 100%);
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow: 0 12px 28px -5px rgba(0, 0, 0, 0.6);
}

.crm-card-hero::after {
  content: '';
  position: absolute;
  top: -40%;
  right: -20%;
  width: 320px;
  height: 320px;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.12) 0%, rgba(255, 255, 255, 0) 70%);
  pointer-events: none;
}

.crm-card-hero-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 20px;
  align-items: center;
}

.crm-card-hero-metric {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.crm-card-hero-val {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: #FFFFFF;
}

.crm-card-hero-label {
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: rgba(255, 255, 255, 0.8);
}

.crm-card-hero-progress-track {
  width: 100%;
  height: 6px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.22);
  margin: 18px 0 10px;
  overflow: hidden;
}

.crm-card-hero-progress-bar {
  height: 100%;
  background: #FFFFFF;
  border-radius: var(--radius-full);
  transition: width 0.3s ease;
}

.crm-card-hero-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 20px;
}

.crm-btn-hero-white {
  background: #FFFFFF;
  color: #1D4ED8 !important;
  font-weight: 700;
  font-size: 13px;
  padding: 9px 20px;
  border-radius: var(--radius-md);
  border: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
  text-decoration: none;
}

.crm-btn-hero-white:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
  color: #1E40AF !important;
}

.crm-btn-hero-outline {
  background: rgba(255, 255, 255, 0.12);
  color: #FFFFFF !important;
  font-weight: 600;
  font-size: 13px;
  padding: 9px 20px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.35);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast);
  text-decoration: none;
}

.crm-btn-hero-outline:hover {
  background: rgba(255, 255, 255, 0.22);
  border-color: rgba(255, 255, 255, 0.55);
}

/* ----------------------------------------------------------
   11. DATA TABLES & DATA WORKSPACE
   ---------------------------------------------------------- */
.crm-table-container {
  overflow-x: auto;
  position: relative;
}

.crm-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 12.5px;
}

.crm-table thead {
  background-color: var(--color-surface-subtle);
  border-bottom: 1px solid var(--color-border);
}

.crm-table th {
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  white-space: nowrap;
}

.crm-table tbody tr {
  border-bottom: 1px solid var(--color-border);
  transition: background-color var(--transition-fast);
}

.crm-table tbody tr:hover {
  background-color: var(--color-surface-hover);
}

.crm-table tbody tr.selected {
  background-color: var(--color-primary-soft);
}

.crm-table td {
  padding: 12px 14px;
  vertical-align: middle;
  color: var(--color-text-primary);
}

/* Row Content Hierarchy */
.cell-primary {
  font-weight: 700;
  color: var(--color-text-primary);
  line-height: 1.3;
}

.cell-secondary {
  font-size: 11.5px;
  color: var(--color-text-muted);
  margin-top: 2px;
}

.cell-value {
  font-weight: 700;
  color: var(--color-primary);
}

/* Row Actions Cluster */
.row-actions-group {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  white-space: nowrap;
}

.row-action-btn {
  padding: 4px 8px;
  font-size: 11.5px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xs);
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.row-action-btn:hover {
  background: var(--color-surface-subtle);
  border-color: var(--color-border-strong);
  color: var(--color-text-primary);
}

/* Contextual Bulk Action Floating Bar */
.bulk-actions-toolbar {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--color-secondary);
  color: #fff;
  padding: 10px 20px;
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-xl);
  display: flex;
  align-items: center;
  gap: 16px;
  z-index: 850;
  transition: transform var(--transition-normal);
  font-size: 13px;
  font-weight: 600;
}

.bulk-actions-toolbar.visible {
  transform: translateX(-50%) translateY(0);
}

.bulk-actions-toolbar .bulk-count {
  background: rgba(255, 255, 255, 0.2);
  padding: 2px 10px;
  border-radius: var(--radius-full);
  font-size: 12px;
}

/* ----------------------------------------------------------
   12. FILTER BAR & ACTIVE FILTER CHIPS
   ---------------------------------------------------------- */
.filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 12px 16px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

.filter-chips {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 16px;
  background: var(--color-surface-subtle);
  border-bottom: 1px solid var(--color-border);
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--color-text-secondary);
}

.filter-chip .chip-remove {
  cursor: pointer;
  color: var(--color-text-muted);
  font-size: 11px;
}

.filter-chip .chip-remove:hover {
  color: var(--color-danger);
}

.clear-all-filters {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--color-danger);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0 4px;
}

.clear-all-filters:hover {
  text-decoration: underline;
}

/* ----------------------------------------------------------
   13. STATUS PILLS & BADGES (CALM, ACCESSIBLE TINTED SYSTEM)
   ---------------------------------------------------------- */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  letter-spacing: 0.02em;
}

.status-pill::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Success / Active / Approved / Renewed / Settled / Won / Paid */
.status-pill.active,
.status-pill.approved,
.status-pill.success,
.status-pill.renewed,
.status-pill.settled,
.status-pill.won,
.status-pill.paid {
  background-color: var(--color-success-light);
  color: var(--color-success-text);
  border: 1px solid var(--color-success-border);
}
.status-pill.active::before,
.status-pill.approved::before,
.status-pill.success::before,
.status-pill.renewed::before,
.status-pill.settled::before,
.status-pill.won::before,
.status-pill.paid::before {
  background-color: var(--color-success);
}

/* Warning / Under Review / Renewal Due / Pending / Survey */
.status-pill.pending,
.status-pill.under-review,
.status-pill.warning,
.status-pill.renewal-due,
.status-pill.survey {
  background-color: var(--color-warning-light);
  color: var(--color-warning-text);
  border: 1px solid var(--color-warning-border);
}
.status-pill.pending::before,
.status-pill.under-review::before,
.status-pill.warning::before,
.status-pill.renewal-due::before,
.status-pill.survey::before {
  background-color: var(--color-warning);
}

/* Danger / Lapsed / Expired / Rejected / Lost / Cancelled / Unpaid */
.status-pill.lapsed,
.status-pill.inactive,
.status-pill.danger,
.status-pill.rejected,
.status-pill.lost,
.status-pill.cancelled,
.status-pill.unpaid,
.status-pill.expired {
  background-color: var(--color-danger-light);
  color: var(--color-danger-text);
  border: 1px solid var(--color-danger-border);
}
.status-pill.lapsed::before,
.status-pill.inactive::before,
.status-pill.danger::before,
.status-pill.rejected::before,
.status-pill.lost::before,
.status-pill.cancelled::before,
.status-pill.unpaid::before,
.status-pill.expired::before {
  background-color: var(--color-danger);
}

/* Info / Lead / Documents / Processing */
.status-pill.info,
.status-pill.lead,
.status-pill.processing {
  background-color: var(--color-info-light);
  color: var(--color-info-text);
  border: 1px solid var(--color-info-border);
}
.status-pill.info::before,
.status-pill.lead::before,
.status-pill.processing::before {
  background-color: var(--color-info);
}
/* ----------------------------------------------------------
   14. FORMS & INPUT CONTROLS
   ---------------------------------------------------------- */
.form-section {
  padding: 18px 20px;
  margin-bottom: 16px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  transition: all var(--transition-fast);
}

.form-section:hover {
  border-color: var(--color-border-strong);
}

.form-section:last-child {
  margin-bottom: 0;
}

.form-section-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--color-text-primary);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.form-section-title i {
  color: var(--color-primary);
  font-size: 13.5px;
}

.form-section-subtitle {
  font-size: 12px;
  color: var(--color-text-muted);
  margin-bottom: 14px;
  line-height: 1.4;
}

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

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

.form-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

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

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

.form-label-custom .required-star {
  color: var(--color-danger);
}

.form-input-custom,
.form-select-custom,
textarea.form-input-custom {
  width: 100%;
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--color-text-primary);
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 8.5px 12px;
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background-color var(--transition-fast);
}

.form-input-custom:focus,
.form-select-custom:focus,
textarea.form-input-custom:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-soft);
  background-color: var(--color-surface);
}

.form-input-custom[readonly],
.form-select-custom[disabled] {
  background-color: var(--color-surface-subtle);
  color: var(--color-text-muted);
  cursor: not-allowed;
}

/* Input Addon Groups (₹ Currency Prefix, % Suffix) */
.input-group-custom {
  display: flex;
  align-items: stretch;
  width: 100%;
}

.input-addon {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  background-color: var(--color-surface-subtle);
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  font-size: 12.5px;
  font-weight: 700;
}

.input-addon.prefix {
  border-right: none;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

.input-addon.suffix {
  border-left: none;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.input-group-custom .form-input-custom {
  border-radius: 0;
}

.input-group-custom .form-input-custom:first-child {
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

.input-group-custom .form-input-custom:last-child {
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* Drag & Drop File Upload Zone */
.file-upload-zone {
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-md);
  padding: 20px;
  text-align: center;
  background: var(--color-surface-subtle);
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
}

.file-upload-zone:hover {
  border-color: var(--color-primary);
  background: var(--color-primary-soft);
}

.file-upload-icon {
  font-size: 24px;
  color: var(--color-primary);
  margin-bottom: 6px;
}

.file-upload-text {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--color-text-primary);
}

.file-upload-hint {
  font-size: 11px;
  color: var(--color-text-muted);
  margin-top: 2px;
}

/* ----------------------------------------------------------
   15. MODALS & SLIDE-OVER DRAWERS
   ---------------------------------------------------------- */
.modal-backdrop-custom {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1100;
  padding: 20px;
  animation: modalFadeIn 180ms cubic-bezier(0.16, 1, 0.3, 1);
}

[data-theme="dark"] .modal-backdrop-custom {
  background: rgba(2, 6, 23, 0.82);
}

@keyframes modalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

.modal-backdrop-custom.active {
  display: flex;
}

.modal-dialog-custom {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.28), 0 0 0 1px rgba(255, 255, 255, 0.06);
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalPopIn 220ms cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
}

.modal-header-custom {
  padding: 18px 24px;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: var(--color-surface);
  position: sticky;
  top: 0;
  z-index: 10;
}

.modal-title-custom {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--color-text-primary);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-close-custom {
  background: var(--color-surface-subtle);
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  font-size: 16px;
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  line-height: 1;
}

.modal-close-custom:hover {
  background: var(--color-danger-soft);
  color: var(--color-danger);
  border-color: var(--color-danger-soft-border);
  transform: rotate(90deg);
}

.modal-footer-custom {
  padding: 16px 24px;
  border-top: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  background: var(--color-surface);
  position: sticky;
  bottom: 0;
  z-index: 10;
}

/* Slide-Over Drawer */
.crm-drawer-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--color-overlay);
  backdrop-filter: blur(3px);
  z-index: 1100;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}

.crm-drawer-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.crm-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 480px;
  max-width: 90vw;
  background: var(--color-surface);
  border-left: 1px solid var(--color-border);
  box-shadow: var(--shadow-xl);
  z-index: 1200;
  transform: translateX(100%);
  transition: transform var(--transition-normal);
  display: flex;
  flex-direction: column;
}

.crm-drawer-backdrop.open .crm-drawer {
  transform: translateX(0);
}

/* ----------------------------------------------------------
   16. COMMAND PALETTE (CTRL+K)
   ---------------------------------------------------------- */
.command-palette-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--color-overlay);
  backdrop-filter: blur(4px);
  z-index: 1500;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding-top: 12vh;
}

.command-palette-backdrop.open {
  display: flex;
}

.command-palette {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 580px;
  overflow: hidden;
  animation: scaleUp var(--transition-fast) ease-out;
}

.command-palette-input-wrap {
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--color-border);
}

.command-palette-input-wrap i {
  color: var(--color-primary);
  font-size: 15px;
}

.command-palette-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-size: 14px;
  color: var(--color-text-primary);
  font-family: var(--font-sans);
}

.command-palette-shortcut {
  font-size: 10px;
  font-weight: 700;
  background: var(--color-surface-subtle);
  border: 1px solid var(--color-border);
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  color: var(--color-text-muted);
}

.command-palette-results {
  max-height: 340px;
  overflow-y: auto;
  padding: 8px;
}

.command-palette-group-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  padding: 8px 10px 4px;
}

.command-palette-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-primary);
  transition: all var(--transition-fast);
}

.command-palette-item i {
  color: var(--color-text-muted);
  font-size: 13px;
  width: 18px;
  text-align: center;
}

.command-palette-item:hover,
.command-palette-item.highlighted {
  background-color: var(--color-primary-soft);
  color: var(--color-primary-text);
}

.command-palette-item:hover i,
.command-palette-item.highlighted i {
  color: var(--color-primary);
}

.command-palette-empty {
  padding: 32px 16px;
  text-align: center;
  color: var(--color-text-muted);
  font-size: 13px;
}

.command-palette-footer {
  padding: 8px 16px;
  background: var(--color-surface-subtle);
  border-top: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 11px;
  color: var(--color-text-muted);
}

.command-palette-footer kbd {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  padding: 1px 5px;
  border-radius: var(--radius-xs);
  font-family: var(--font-mono);
  font-size: 10px;
}

/* ----------------------------------------------------------
   17. EMPTY STATES, SKELETON LOADERS & TOASTS
   ---------------------------------------------------------- */
.empty-state {
  padding: 48px 24px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.empty-state-icon {
  width: 54px;
  height: 54px;
  border-radius: var(--radius-full);
  background: var(--color-surface-subtle);
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  margin-bottom: 12px;
}

.empty-state-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--color-text-primary);
  margin-bottom: 4px;
}

.empty-state-text {
  font-size: 12.5px;
  color: var(--color-text-muted);
  max-width: 360px;
  margin-bottom: 16px;
}

/* Skeleton Loading Shimmer */
.skeleton-box {
  display: inline-block;
  background: linear-gradient(90deg, var(--color-surface-subtle) 25%, var(--color-border) 50%, var(--color-surface-subtle) 75%);
  background-size: 200% 100%;
  animation: skeletonShimmer 1.5s infinite;
  border-radius: var(--radius-xs);
}

@keyframes skeletonShimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Toasts */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--color-surface);
  color: var(--color-text-primary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 10px 16px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
  font-weight: 600;
  min-width: 240px;
  animation: slideInRight var(--transition-fast) ease-out;
}

.toast.success {
  border-left: 4px solid var(--color-success);
}

.toast.error {
  border-left: 4px solid var(--color-danger);
}

.toast.info {
  border-left: 4px solid var(--color-info);
}

.toast.warning {
  border-left: 4px solid var(--color-warning);
}

/* ----------------------------------------------------------
   18. TIMELINES & ACTIVITY FEEDS
   ---------------------------------------------------------- */
.crm-timeline {
  display: flex;
  flex-direction: column;
  position: relative;
  padding-left: 24px;
}

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

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

.timeline-item:last-child {
  padding-bottom: 0;
}

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

.timeline-content {
  background: var(--color-surface-subtle);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  border: 1px solid var(--color-border);
}

.timeline-header {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 700;
  color: var(--color-text-primary);
}

.timeline-time {
  font-size: 11px;
  color: var(--color-text-muted);
  font-weight: 500;
}

.timeline-desc {
  font-size: 12px;
  color: var(--color-text-secondary);
  margin-top: 4px;
}

/* Horizontal Workflow Stepper (Claims & Multi-Stage Pipelines) */
.workflow-stepper-wrap {
  position: relative;
  padding: 12px 16px 20px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  margin-bottom: 20px;
}

.workflow-stepper {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  position: relative;
  margin-top: 10px;
}

.workflow-stepper-line {
  position: absolute;
  top: 15px;
  left: 36px;
  right: 36px;
  height: 3px;
  background: var(--color-border);
  z-index: 1;
  border-radius: var(--radius-full);
}

.workflow-stepper-progress {
  height: 100%;
  background: var(--color-primary);
  border-radius: var(--radius-full);
  transition: width 0.3s ease;
}

.workflow-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  z-index: 2;
  flex: 1;
  text-align: center;
}

.workflow-step-node {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  color: var(--color-text-muted);
  transition: all var(--transition-fast);
}

.workflow-step.completed .workflow-step-node {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #FFFFFF;
}

.workflow-step.active .workflow-step-node {
  background: var(--color-surface);
  border: 3px solid var(--color-primary);
  color: var(--color-primary);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.18);
}

.workflow-step-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--color-text-muted);
  margin-top: 8px;
  line-height: 1.3;
}

.workflow-step.completed .workflow-step-label {
  color: var(--color-primary);
  font-weight: 600;
}

.workflow-step.active .workflow-step-label {
  color: var(--color-text-primary);
  font-weight: 700;
}

.workflow-step-subtext {
  font-size: 10px;
  color: var(--color-text-muted);
  margin-top: 2px;
}

/* ----------------------------------------------------------
   19. ANIMATIONS & KEYFRAMES
   ---------------------------------------------------------- */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes scaleUp {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

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

/* ----------------------------------------------------------
   20. RESPONSIVE BREAKPOINTS (320px, 768px, 1024px, 1440px)
   ---------------------------------------------------------- */
@media (max-width: 1024px) {
  .app-sidebar {
    transform: translateX(-100%);
  }

  .app-sidebar.open {
    transform: translateX(0);
  }

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

  .sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--color-overlay);
    z-index: 890;
    display: none;
  }

  .sidebar-overlay.open {
    display: block;
  }

  #sidebarToggleBtn {
    display: flex !important;
  }
}

@media (max-width: 768px) {
  .page-body {
    padding: 16px;
  }

  .form-grid-2, .form-grid-3, .form-grid-4 {
    grid-template-columns: 1fr !important;
  }

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

  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }
}

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

  .page-header {
    flex-direction: column;
    align-items: stretch;
  }

  .page-actions {
    justify-content: flex-start;
  }
}

/* Period & Date Quick Filter Active State */
.period-btn.active,
.date-filter-btn.active {
  background: var(--color-primary) !important;
  color: #ffffff !important;
  border-color: var(--color-primary) !important;
  box-shadow: 0 1px 4px rgba(37, 99, 235, 0.35);
}

/* Tabular Numbers Utility */
.tnum,
.tabular-nums {
  font-variant-numeric: tabular-nums !important;
  font-feature-settings: "tnum" 1 !important;
}

/* ----------------------------------------------------------
   GORGEOUS MICRO-DIVIDERS & DOCK ACCENTS (COLLAPSED SIDEBAR)
   ---------------------------------------------------------- */
.sidebar-plan-compact-icon {
  display: none;
  font-size: 13.5px;
  color: #f59e0b;
  position: relative;
  transition: transform 0.2s ease;
}

.sidebar-plan-compact-icon .plan-status-dot {
  position: absolute;
  top: -2px;
  right: -3px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 6px #10b981;
}

/* Elegant Glowing Hairline Micro-Divider between Icon Groups */
.app-sidebar.collapsed:not(:hover) .nav-section-title,
html.sidebar-is-collapsed .app-sidebar:not(:hover) .nav-section-title {
  display: flex !important;
  align-items: center;
  justify-content: center;
  height: 18px !important;
  width: 32px !important;
  margin: 6px auto !important;
  padding: 0 !important;
  font-size: 0 !important;
  line-height: 0 !important;
  color: transparent !important;
  opacity: 1 !important;
  visibility: visible !important;
  pointer-events: none;
  position: relative;
  background: transparent !important;
  transform: none !important;
  max-width: 32px !important;
  transition: all 280ms cubic-bezier(0.16, 1, 0.3, 1) !important;
}

.app-sidebar.collapsed:not(:hover) .nav-section-title::before,
html.sidebar-is-collapsed .app-sidebar:not(:hover) .nav-section-title::before {
  content: '' !important;
  display: block;
  width: 24px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(59, 130, 246, 0.45), transparent) !important;
}

.app-sidebar.collapsed:not(:hover) .nav-section-title::after,
html.sidebar-is-collapsed .app-sidebar:not(:hover) .nav-section-title::after {
  content: '' !important;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 3.5px;
  height: 3.5px;
  border-radius: 50%;
  background: var(--color-primary) !important;
  box-shadow: 0 0 6px rgba(59, 130, 246, 0.9) !important;
}

/* Compact Luxury Plan Gem in Dock Mode */
.app-sidebar.collapsed:not(:hover) .sidebar-plan-compact-icon,
html.sidebar-is-collapsed .app-sidebar:not(:hover) .sidebar-plan-compact-icon {
  display: flex !important;
  align-items: center;
  justify-content: center;
}

.app-sidebar.collapsed:not(:hover) .sidebar-plan-badge,
html.sidebar-is-collapsed .app-sidebar:not(:hover) .sidebar-plan-badge {
  display: flex !important;
  align-items: center;
  justify-content: center;
  width: 38px !important;
  height: 38px !important;
  margin: 0 auto 6px auto !important;
  padding: 0 !important;
  border-radius: var(--radius-sm) !important;
  background: var(--color-surface-subtle) !important;
  border: 1px solid var(--color-border) !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08) !important;
  opacity: 1 !important;
  max-width: 38px !important;
  visibility: visible !important;
  cursor: pointer;
  transition: all 280ms cubic-bezier(0.16, 1, 0.3, 1) !important;
}

.app-sidebar.collapsed:not(:hover) .sidebar-plan-badge:hover,
html.sidebar-is-collapsed .app-sidebar:not(:hover) .sidebar-plan-badge:hover {
  background: var(--color-surface) !important;
  border-color: var(--color-primary-border) !important;
  box-shadow: 0 0 10px rgba(37, 99, 235, 0.25) !important;
}

.app-sidebar.collapsed:not(:hover) .sidebar-plan-badge .sidebar-plan-info,
.app-sidebar.collapsed:not(:hover) .sidebar-plan-badge .status-pill,
html.sidebar-is-collapsed .app-sidebar:not(:hover) .sidebar-plan-badge .sidebar-plan-info,
html.sidebar-is-collapsed .app-sidebar:not(:hover) .sidebar-plan-badge .status-pill {
  display: none !important;
}


