/* ==========================================================
   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: #3B82F6;

  /* Primary Brand — Cobalt Sapphire */
  --color-primary: #2563EB;
  --color-primary-hover: #1D4ED8;
  --color-primary-active: #1E40AF;
  --color-primary-soft: #EFF6FF;
  --color-primary-border: #BFDBFE;
  --color-primary-text: #1E40AF;

  /* 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) */
  --color-success: #059669;
  --color-success-light: #ECFDF5;
  --color-success-border: #A7F3D0;
  --color-success-text: #065F46;

  --color-warning: #D97706;
  --color-warning-light: #FFFBEB;
  --color-warning-border: #FDE68A;
  --color-warning-text: #92400E;

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

  --color-info: #0284C7;
  --color-info-light: #F0F9FF;
  --color-info-border: #BAE6FD;
  --color-info-text: #075985;

  /* Sidebar Tokens (Light Surface Frame, High Contrast Nav) */
  --sidebar-width: 252px;
  --sidebar-collapsed-width: 64px;
  --sidebar-bg: #070A12;
  --sidebar-surface: #0F172A;
  --sidebar-border: rgba(255, 255, 255, 0.07);
  --sidebar-text: #94A3B8;
  --sidebar-text-bright: #F8FAFC;
  --sidebar-hover-bg: rgba(255, 255, 255, 0.05);

  /* 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 */
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.07), 0 2px 4px -2px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.04);
  --shadow-xl: 0 20px 25px -5px rgba(15, 23, 42, 0.09), 0 8px 10px -6px rgba(15, 23, 42, 0.04);

  /* Transitions */
  --transition-fast: 120ms ease;
  --transition-normal: 200ms ease;
  --transition-slow: 300ms ease;

  /* 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: rgba(37, 99, 235, 0.15);
  --sidebar-active-text: #60A5FA;
  --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-bg: #070A12;
  --sidebar-surface: #0F172A;
  --sidebar-border: rgba(255, 255, 255, 0.07);
  --sidebar-text: #94A3B8;
  --sidebar-text-bright: #F8FAFC;
  --sidebar-hover-bg: rgba(255, 255, 255, 0.05);

  --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(5, 150, 105, 0.18);
  --color-success-border: rgba(5, 150, 105, 0.35);
  --color-success-text: #6EE7B7;

  --color-warning-light: rgba(217, 119, 6, 0.18);
  --color-warning-border: rgba(217, 119, 6, 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(2, 132, 199, 0.18);
  --color-info-border: rgba(2, 132, 199, 0.35);
  --color-info-text: #7DD3FC;

  --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: #070A12;
    --sidebar-surface: #0F172A;
    --sidebar-border: rgba(255, 255, 255, 0.07);
    --sidebar-text: #94A3B8;
    --sidebar-text-bright: #F8FAFC;
    --sidebar-hover-bg: rgba(255, 255, 255, 0.05);

    --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(5, 150, 105, 0.18);
    --color-success-border: rgba(5, 150, 105, 0.35);
    --color-success-text: #6EE7B7;

    --color-warning-light: rgba(217, 119, 6, 0.18);
    --color-warning-border: rgba(217, 119, 6, 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(2, 132, 199, 0.18);
    --color-info-border: rgba(2, 132, 199, 0.35);
    --color-info-text: #7DD3FC;

    --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 {
  margin-left: var(--sidebar-collapsed-width);
}

/* 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);
  background-color: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 900;
  transition: width 0.22s cubic-bezier(0.4, 0, 0.2, 1), transform 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  user-select: none;
}

.sidebar-brand {
  height: var(--header-height);
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  border-bottom: 1px solid var(--sidebar-border);
  position: relative;
  overflow: hidden;
}

.sidebar-brand-link {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  min-width: 0;
  width: 100%;
  transition: opacity var(--transition-fast);
}

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

.brand-text-wrap {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.sidebar-logo-img {
  height: 32px;
  width: auto;
  max-width: 140px;
  object-fit: contain;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.sidebar-logo-img.insurely-brand-logo {
  filter: brightness(0) invert(1);
  opacity: 0.95;
}

.sidebar-logo-img.insurely-brand-logo:hover {
  opacity: 1;
}

.brand-icon {
  width: 34px;
  height: 34px;
  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: 15px;
  flex-shrink: 0;
  box-shadow: 0 2px 10px rgba(37, 99, 235, 0.4);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.brand-icon:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.55);
}

.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: 10px;
  color: var(--sidebar-text);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 700;
}

.sidebar-collapse-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--sidebar-text);
  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: rgba(37, 99, 235, 0.2);
  border-color: rgba(37, 99, 235, 0.4);
  color: #93C5FD;
  transform: scale(1.05);
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

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

.sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

.nav-section-title {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: rgba(148, 163, 184, 0.5);
  padding: 12px 10px 4px;
  transition: opacity 0.2s ease;
}

.nav-link-custom {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  color: var(--sidebar-text);
  text-decoration: none;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 500;
  transition: all 0.16s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.nav-link-custom i {
  font-size: 13.5px;
  width: 20px;
  text-align: center;
  color: var(--sidebar-text);
  transition: all 0.16s cubic-bezier(0.4, 0, 0.2, 1);
  flex-shrink: 0;
}

.nav-link-custom:hover {
  background-color: rgba(255, 255, 255, 0.06);
  color: var(--sidebar-text-bright);
  transform: translateX(3px);
}

.nav-link-custom:hover i {
  color: #93C5FD;
  transform: scale(1.12);
}

/* Active navigation item with smooth accent glow */
.nav-link-custom.active {
  background: linear-gradient(90deg, rgba(37, 99, 235, 0.18) 0%, rgba(37, 99, 235, 0.06) 100%);
  color: #93C5FD;
  font-weight: 600;
}

.nav-link-custom.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 4px;
  bottom: 4px;
  width: 3px;
  background-color: #3B82F6;
  border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.6);
}

.nav-link-custom.active i {
  color: #60A5FA;
}

.nav-link-badge {
  margin-left: auto;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  background: rgba(37, 99, 235, 0.25);
  color: #93C5FD;
}

/* Sidebar Collapse Strip (Interactive Bottom Trigger) */
.sidebar-collapse-strip {
  margin: 8px 6px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--sidebar-text);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s ease;
}

.sidebar-collapse-strip:hover {
  background: rgba(37, 99, 235, 0.12);
  border-color: rgba(37, 99, 235, 0.3);
  color: #93C5FD;
}

.sidebar-collapse-strip:hover .collapse-icon-wrap {
  background: var(--color-primary);
  color: #ffffff;
  transform: scale(1.1);
}

.collapse-icon-wrap {
  width: 22px;
  height: 22px;
  border-radius: var(--radius-xs);
  background: rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  transition: all 0.18s ease;
  flex-shrink: 0;
}

.collapse-strip-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.collapse-kbd {
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--color-text-subtle);
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 5px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 10px 8px;
  border-top: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--sidebar-surface);
}

.sidebar-plan-badge {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 10px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

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

.plan-name {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--sidebar-text-bright);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
}

.sidebar-user:hover {
  background: rgba(255, 255, 255, 0.04);
}

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

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

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

.sidebar-user-role {
  font-size: 10.5px;
  color: var(--sidebar-text);
}

/* ==========================================================
   COLLAPSED SIDEBAR MODE (SLIM DOCK WITH GENTLE HOVER EXPANSION)
   ========================================================== */
.app-sidebar.collapsed,
html.sidebar-is-collapsed .app-sidebar {
  width: var(--sidebar-collapsed-width);
  transition: width 160ms cubic-bezier(0.4, 0, 0.2, 1), box-shadow 160ms ease;
  overflow-x: hidden;
}

/* On Hover: Gently expand the collapsed sidebar */
.app-sidebar.collapsed:hover,
html.sidebar-is-collapsed .app-sidebar:hover {
  width: var(--sidebar-width) !important;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.08);
  z-index: 950;
  transition: width 240ms cubic-bezier(0.16, 1, 0.3, 1), box-shadow 240ms ease !important;
}

/* Hidden elements in collapsed state (when 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,
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 {
  display: none !important;
  opacity: 0;
  visibility: hidden;
  max-width: 0;
  pointer-events: none;
}

/* Smoothly reveal text and badges on 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-section-title,
.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,
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-section-title,
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 {
  display: flex !important;
  opacity: 1 !important;
  visibility: visible !important;
  max-width: 220px !important;
  pointer-events: auto !important;
  transition: opacity 200ms cubic-bezier(0.16, 1, 0.3, 1) 50ms, max-width 240ms 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;
}

/* --- BRAND LOGO AREA --- */
.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);
}

.app-sidebar.collapsed:hover .sidebar-brand,
html.sidebar-is-collapsed .app-sidebar:hover .sidebar-brand {
  justify-content: flex-start;
  padding: 0 16px;
  transition: padding 240ms 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;
}

.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 240ms 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: 36px;
  max-height: 36px;
  width: auto;
  height: auto;
  margin: 0 auto;
  display: block;
  object-fit: contain;
  border-radius: var(--radius-xs);
}

.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 240ms 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 --- */
.app-sidebar.collapsed:not(:hover) .sidebar-nav,
html.sidebar-is-collapsed .app-sidebar:not(:hover) .sidebar-nav {
  padding: 10px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.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: 3px;
}

.app-sidebar.collapsed:not(:hover) .nav-link-custom,
html.sidebar-is-collapsed .app-sidebar:not(:hover) .nav-link-custom {
  width: 44px;
  height: 40px;
  padding: 0;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  border-radius: var(--radius-md);
  gap: 0 !important;
  transform: none !important;
}

.app-sidebar.collapsed:hover .nav-link-custom,
html.sidebar-is-collapsed .app-sidebar:hover .nav-link-custom {
  width: 100%;
  height: auto;
  justify-content: flex-start;
  padding: 8px 10px;
  gap: 10px;
  margin: 0;
  transition: padding 240ms 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: 16px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  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;
  font-size: 13.5px;
  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: rgba(37, 99, 235, 0.25) !important;
  color: #60A5FA !important;
  border: 1px solid rgba(37, 99, 235, 0.35);
  box-shadow: 0 0 10px rgba(37, 99, 235, 0.25);
}

/* 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 --- */

/* --- FOOTER & ADVISOR PROFILE --- */
.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;
}

.app-sidebar.collapsed:hover .sidebar-footer,
html.sidebar-is-collapsed .app-sidebar:hover .sidebar-footer {
  padding: 10px 8px;
  align-items: stretch;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: padding 240ms 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: 44px;
  height: 44px;
  margin: 0 auto;
  display: flex;
  border-radius: var(--radius-full);
  gap: 0;
}

.app-sidebar.collapsed:hover .sidebar-user,
html.sidebar-is-collapsed .app-sidebar:hover .sidebar-user {
  justify-content: flex-start;
  width: 100%;
  height: auto;
  padding: 4px 6px;
  gap: 10px;
  border-radius: var(--radius-sm);
  transition: padding 240ms 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: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 14px;
  font-weight: 800;
  border-radius: var(--radius-full);
}

.app-sidebar.collapsed:hover .sidebar-user-avatar,
html.sidebar-is-collapsed .app-sidebar:hover .sidebar-user-avatar {
  margin: 0;
  width: 30px;
  height: 30px;
  font-size: 12px;
  transition: margin 240ms 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;
  transition: margin-left 0.22s cubic-bezier(0.4, 0, 0.2, 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;
}

/* ----------------------------------------------------------
   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);
}

/* ----------------------------------------------------------
   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
   ---------------------------------------------------------- */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
}

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

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

/* Warning / Renewal Due / Pending / Survey */
.status-pill.pending,
.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.warning::before,
.status-pill.renewal-due::before,
.status-pill.survey::before {
  background-color: var(--color-warning);
}

/* Danger / Lapsed / Expired / Rejected */
.status-pill.lapsed,
.status-pill.inactive,
.status-pill.danger,
.status-pill.rejected {
  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 {
  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: 16px 0;
  border-bottom: 1px solid var(--color-border);
}

.form-section:last-child {
  border-bottom: none;
}

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

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

.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: 4px;
}

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

.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: 8px 12px;
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-input-custom:focus,
.form-select-custom:focus,
textarea.form-input-custom:focus {
  border-color: var(--color-border-focus);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.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: var(--color-overlay);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1100;
  padding: 16px;
  animation: fadeIn var(--transition-fast) ease-out;
}

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

.modal-dialog-custom {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: scaleUp var(--transition-fast) ease-out;
}

.modal-header-custom {
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: var(--color-surface);
}

.modal-title-custom {
  font-size: 15px;
  font-weight: 800;
  color: var(--color-text-primary);
  margin: 0;
}

.modal-close-custom {
  background: transparent;
  border: none;
  color: var(--color-text-muted);
  font-size: 18px;
  cursor: pointer;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.modal-close-custom:hover {
  background: var(--color-surface-subtle);
  color: var(--color-text-primary);
}

.modal-footer-custom {
  padding: 14px 20px;
  border-top: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  background: var(--color-surface);
}

/* 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;
}

/* ----------------------------------------------------------
   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;
  }
}
