/* ═══════════════════════════════════════════════════════════════════
   MIS Chatbot — Unified Stylesheet
   Merged from: mis-tokens.css + app.css + chat.css
   Single file for all pages. Edit here for global changes.
═══════════════════════════════════════════════════════════════════ */

/* ── SECTION 1: Design Tokens (variables, colors, spacing) ── */
/* ==========================================================================
   MIS.work - Design System Variables
   Foundation file - Contains all design tokens
   ========================================================================== */

:root {
  /* ==========================================================================
     COLORS - Brand Palette
     ========================================================================== */
  
  /* Primary Brand Blue (Refined - more premium) */
  --color-primary-50:  #EBF8FF;
  --color-primary-100: #BEE3F8;
  --color-primary-200: #90CDF4;
  --color-primary-300: #63B3ED;
  --color-primary-400: #00A4D2;  /* Main brand color - kept */
  --color-primary-500: #0086B3;
  --color-primary-600: #006A91;  /* Refined deeper */
  --color-primary-700: #014A60;
  --color-primary-800: #013040;
  --color-primary-900: #001620;

  /* Premium Dark Navy (For sophisticated accents) */
  --color-navy-50:  #F5F7FA;
  --color-navy-100: #E4E7EB;
  --color-navy-200: #CBD2D9;
  --color-navy-300: #9AA5B1;
  --color-navy-400: #7B8794;
  --color-navy-500: #616E7C;
  --color-navy-600: #52606D;
  --color-navy-700: #3E4C59;
  --color-navy-800: #323F4B;
  --color-navy-900: #1F2933;
  --color-navy-950: #0F1419;

  /* Refined Neutral Grays (Linear/Vercel inspired) */
  --color-gray-50:  #FAFAFA;
  --color-gray-100: #F4F4F5;
  --color-gray-200: #E4E4E7;
  --color-gray-300: #D4D4D8;
  --color-gray-400: #A1A1AA;
  --color-gray-500: #71717A;
  --color-gray-600: #52525B;
  --color-gray-700: #3F3F46;
  --color-gray-800: #27272A;
  --color-gray-900: #18181B;
  --color-gray-950: #09090B;

  /* Semantic Colors */
  --color-success: #10B981;
  --color-success-light: #D1FAE5;
  --color-warning: #F59E0B;
  --color-warning-light: #FEF3C7;
  --color-error: #EF4444;
  --color-error-light: #FEE2E2;
  --color-info: #3B82F6;
  --color-info-light: #DBEAFE;

  /* Surface Colors */
  --color-bg-primary: #FFFFFF;
  --color-bg-secondary: var(--color-gray-50);
  --color-bg-tertiary: var(--color-gray-100);
  
  /* Text Colors */
  --color-text-primary: var(--color-gray-900);
  --color-text-secondary: var(--color-gray-600);
  --color-text-tertiary: var(--color-gray-500);
  --color-text-inverse: #FFFFFF;
  --color-text-brand: var(--color-primary-400);

  /* Border Colors */
  --color-border-light: var(--color-gray-200);
  --color-border-medium: var(--color-gray-300);
  --color-border-strong: var(--color-gray-400);

  /* ==========================================================================
     GRADIENTS - Refined for premium look
     ========================================================================== */
  
  --gradient-primary: linear-gradient(135deg, #00A4D2 0%, #006A91 100%);
  --gradient-primary-soft: linear-gradient(135deg, rgba(0,164,210,0.08) 0%, rgba(0,106,145,0.04) 100%);
  --gradient-hero: linear-gradient(135deg, #00A4D2 0%, #014A60 100%);
  --gradient-bg-subtle: linear-gradient(180deg, #FAFAFA 0%, #F4F4F5 100%);
  --gradient-text: linear-gradient(135deg, #00A4D2 0%, #006A91 100%);
  --gradient-glow: radial-gradient(circle at center, rgba(0,164,210,0.3) 0%, transparent 70%);
  
  /* Premium dark gradient (for footer, dark sections) */
  --gradient-dark: linear-gradient(135deg, #0F1419 0%, #1F2933 100%);
  
  /* Animated gradient for special sections */
  --gradient-animated: linear-gradient(270deg, #00A4D2, #006A91, #63B3ED, #00A4D2);

  /* ==========================================================================
     TYPOGRAPHY
     ========================================================================== */
  
  /* Font Families */
  --font-primary: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-display: 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  /* Font Weights */
  --font-weight-regular: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;
  --font-weight-extrabold: 800;

  /* Font Sizes - Fluid Typography (clamp for responsive) */
  --text-xs:   0.75rem;     /* 12px */
  --text-sm:   0.875rem;    /* 14px */
  --text-base: 1rem;        /* 16px */
  --text-lg:   1.125rem;    /* 18px */
  --text-xl:   1.25rem;     /* 20px */
  --text-2xl:  1.5rem;      /* 24px */
  --text-3xl:  1.875rem;    /* 30px */
  --text-4xl:  2.25rem;     /* 36px */
  --text-5xl:  3rem;        /* 48px */
  --text-6xl:  3.75rem;     /* 60px */
  --text-7xl:  4.5rem;      /* 72px */

  /* Responsive Heading Sizes (clamp: min, fluid, max) */
  --heading-h1: clamp(2.5rem, 5vw, 4rem);       /* 40-64px */
  --heading-h2: clamp(2rem, 4vw, 3rem);         /* 32-48px */
  --heading-h3: clamp(1.5rem, 3vw, 2rem);       /* 24-32px */
  --heading-h4: clamp(1.25rem, 2vw, 1.5rem);    /* 20-24px */
  --heading-h5: 1.125rem;                       /* 18px */
  --heading-h6: 1rem;                           /* 16px */

  /* Line Heights */
  --leading-none: 1;
  --leading-tight: 1.2;       /* Headings */
  --leading-snug: 1.375;
  --leading-normal: 1.5;      /* Small text */
  --leading-relaxed: 1.6;     /* Body text */
  --leading-loose: 1.8;       /* Long form */

  /* Letter Spacing */
  --tracking-tighter: -0.05em;
  --tracking-tight: -0.025em;
  --tracking-normal: 0;
  --tracking-wide: 0.025em;
  --tracking-wider: 0.05em;
  --tracking-widest: 0.1em;

  /* ==========================================================================
     SPACING SYSTEM (8px Grid)
     ========================================================================== */
  
  --space-0:   0;
  --space-px:  1px;
  --space-0-5: 0.125rem;   /* 2px */
  --space-1:   0.25rem;    /* 4px */
  --space-1-5: 0.375rem;   /* 6px */
  --space-2:   0.5rem;     /* 8px */
  --space-2-5: 0.625rem;   /* 10px */
  --space-3:   0.75rem;    /* 12px */
  --space-4:   1rem;       /* 16px */
  --space-5:   1.25rem;    /* 20px */
  --space-6:   1.5rem;     /* 24px */
  --space-7:   1.75rem;    /* 28px */
  --space-8:   2rem;       /* 32px */
  --space-10:  2.5rem;     /* 40px */
  --space-12:  3rem;       /* 48px */
  --space-14:  3.5rem;     /* 56px */
  --space-16:  4rem;       /* 64px */
  --space-20:  5rem;       /* 80px */
  --space-24:  6rem;       /* 96px */
  --space-28:  7rem;       /* 112px */
  --space-32:  8rem;       /* 128px */
  --space-40:  10rem;      /* 160px */
  --space-48:  12rem;      /* 192px */

  /* Section Padding (Responsive) */
  --section-padding-y: clamp(3rem, 8vw, 6rem);
  --section-padding-x: clamp(1rem, 4vw, 2rem);

  /* ==========================================================================
     SHADOWS - Depth & Elevation
     ========================================================================== */
  
  --shadow-xs:  0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-sm:  0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
  --shadow-md:  0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
  --shadow-lg:  0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
  --shadow-xl:  0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  --shadow-2xl: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  --shadow-inner: inset 0 2px 4px 0 rgba(0, 0, 0, 0.05);

  /* Premium glow effects (brand color) */
  --shadow-glow-sm: 0 0 20px rgba(0, 164, 210, 0.3);
  --shadow-glow-md: 0 0 40px rgba(0, 164, 210, 0.4);
  --shadow-glow-lg: 0 0 60px rgba(0, 164, 210, 0.5);

  /* Soft shadows for cards */
  --shadow-card: 0 4px 20px -2px rgba(0, 0, 0, 0.08);
  --shadow-card-hover: 0 12px 40px -4px rgba(0, 0, 0, 0.15);

  /* ==========================================================================
     BORDER RADIUS
     ========================================================================== */
  
  --radius-none: 0;
  --radius-xs:   0.125rem;   /* 2px */
  --radius-sm:   0.25rem;    /* 4px */
  --radius-md:   0.5rem;     /* 8px */
  --radius-lg:   0.75rem;    /* 12px */
  --radius-xl:   1rem;       /* 16px */
  --radius-2xl:  1.5rem;     /* 24px */
  --radius-3xl:  2rem;       /* 32px */
  --radius-full: 9999px;     /* Pill */

  /* ==========================================================================
     ANIMATION & TRANSITIONS
     ========================================================================== */
  
  /* Durations */
  --duration-instant: 50ms;
  --duration-fast:    150ms;
  --duration-normal:  300ms;
  --duration-slow:    500ms;
  --duration-slower:  700ms;
  --duration-slowest: 1000ms;

  /* Easing Functions */
  --ease-linear:    linear;
  --ease-in:        cubic-bezier(0.4, 0, 1, 1);
  --ease-out:       cubic-bezier(0, 0, 0.2, 1);
  --ease-in-out:    cubic-bezier(0.4, 0, 0.2, 1);
  --ease-bounce:    cubic-bezier(0.68, -0.55, 0.265, 1.55);
  --ease-smooth:    cubic-bezier(0.25, 0.1, 0.25, 1);
  --ease-spring:    cubic-bezier(0.175, 0.885, 0.32, 1.275);

  /* Common Transitions */
  --transition-base: all var(--duration-normal) var(--ease-smooth);
  --transition-fast: all var(--duration-fast) var(--ease-smooth);
  --transition-slow: all var(--duration-slow) var(--ease-smooth);
  --transition-colors: color var(--duration-normal) var(--ease-smooth),
                       background-color var(--duration-normal) var(--ease-smooth),
                       border-color var(--duration-normal) var(--ease-smooth);
  --transition-transform: transform var(--duration-normal) var(--ease-smooth);
  --transition-opacity: opacity var(--duration-normal) var(--ease-smooth);

  /* ==========================================================================
     GLASSMORPHISM (Backdrop blur)
     ========================================================================== */
  
  --blur-sm: 4px;
  --blur-md: 8px;
  --blur-lg: 16px;
  --blur-xl: 24px;
  --blur-2xl: 40px;

  /* Glass surfaces */
  --glass-bg-light: rgba(255, 255, 255, 0.7);
  --glass-bg-dark: rgba(0, 0, 0, 0.5);
  --glass-bg-primary: rgba(0, 164, 210, 0.1);
  --glass-border-light: rgba(255, 255, 255, 0.3);
  --glass-border-dark: rgba(255, 255, 255, 0.1);

  /* ==========================================================================
     BREAKPOINTS (For reference - use in media queries)
     ========================================================================== */
  
  /* 
   * --bp-sm:  640px;   Small tablets
   * --bp-md:  768px;   Tablets
   * --bp-lg:  1024px;  Small laptops
   * --bp-xl:  1280px;  Laptops
   * --bp-2xl: 1536px;  Large screens
   */

  /* ==========================================================================
     Z-INDEX SYSTEM
     ========================================================================== */
  
  --z-hide:         -1;
  --z-base:         0;
  --z-content:      1;
  --z-dropdown:     10;
  --z-sticky:       20;
  --z-fixed:        30;
  --z-modal-bg:     40;
  --z-modal:        50;
  --z-popover:      60;
  --z-tooltip:      70;
  --z-notification: 80;
  --z-max:          9999;

  /* ==========================================================================
     CONTAINER WIDTHS
     ========================================================================== */
  
  --container-sm: 640px;
  --container-md: 768px;
  --container-lg: 1024px;
  --container-xl: 1280px;
  --container-2xl: 1400px;
  --container-max: 1536px;

  /* ==========================================================================
     COMPONENT-SPECIFIC TOKENS
     ========================================================================== */
  
  /* Buttons */
  --btn-padding-x-sm: var(--space-3);
  --btn-padding-y-sm: var(--space-2);
  --btn-padding-x-md: var(--space-5);
  --btn-padding-y-md: var(--space-3);
  --btn-padding-x-lg: var(--space-6);
  --btn-padding-y-lg: var(--space-4);
  --btn-radius: var(--radius-lg);
  --btn-font-weight: var(--font-weight-semibold);

  /* Cards */
  --card-padding: var(--space-6);
  --card-radius: var(--radius-xl);
  --card-bg: var(--color-bg-primary);
  --card-border: 1px solid var(--color-border-light);
  --card-shadow: var(--shadow-card);
  --card-shadow-hover: var(--shadow-card-hover);

  /* Forms */
  --input-height: 48px;
  --input-padding-x: var(--space-4);
  --input-radius: var(--radius-md);
  --input-border: 1px solid var(--color-border-medium);
  --input-border-focus: 2px solid var(--color-primary-400);
  --input-bg: var(--color-bg-primary);
  --input-font-size: var(--text-base);

  /* Header */
  --header-height: 80px;
  --header-height-mobile: 64px;
  --header-bg: rgba(255, 255, 255, 0.8);
  --header-blur: var(--blur-lg);

  /* Focus Ring (Accessibility) */
  --focus-ring: 0 0 0 3px rgba(0, 164, 210, 0.4);
  --focus-ring-offset: 2px;
}

/* ==========================================================================
   REDUCED MOTION (Accessibility)
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  :root {
    --duration-instant: 0ms;
    --duration-fast: 0ms;
    --duration-normal: 0ms;
    --duration-slow: 0ms;
    --duration-slower: 0ms;
    --duration-slowest: 0ms;
  }
  
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ── SECTION 2: App Styles (layout, components, pages) ── */
/* ============================================================
   MIS × Apple — Application Design System
   Builds on top of mis-tokens.css with Apple-grade discipline:
   - More whitespace, less density
   - Single accent (brand cyan), no rainbows in chrome
   - Tight typography, subtle shadows, spring motion
   ============================================================ */


/* ---------- Apple-discipline overrides ---------- */
:root {
  /* Layout */
  --sidebar-w: 260px;
  --topbar-h: 68px;

  /* Premium motion */
  --motion-fast: 180ms;
  --motion-base: 280ms;
  --motion-slow: 480ms;
  --ease-apple: cubic-bezier(0.32, 0.72, 0, 1);
  --ease-pop: cubic-bezier(0.175, 0.885, 0.32, 1.275);

  /* Apple-tight spacing additions */
  --gap-card: 24px;
  --gap-section: 32px;
  --gap-page: 48px;

  /* Surfaces */
  --surface-canvas: #FBFBFD;
  --surface-card: #FFFFFF;
  --surface-glass: rgba(255, 255, 255, 0.72);
  --surface-glass-strong: rgba(255, 255, 255, 0.86);
  --hairline: rgba(0, 0, 0, 0.06);
  --hairline-strong: rgba(0, 0, 0, 0.10);

  /* Brand glow (subtle, used sparingly) */
  --glow-brand: 0 0 0 4px rgba(0, 164, 210, 0.12);
  --glow-brand-strong: 0 8px 32px rgba(0, 164, 210, 0.22);
}

/* Dark mode — MIS dark gradient + Apple iOS dark surfaces */
[data-theme="dark"] {
  --surface-canvas: #000000;
  --surface-card: #1C1C1E;
  --surface-glass: rgba(28, 28, 30, 0.72);
  --surface-glass-strong: rgba(28, 28, 30, 0.92);
  --hairline: rgba(255, 255, 255, 0.08);
  --hairline-strong: rgba(255, 255, 255, 0.14);

  --color-text-primary: #F5F5F7;
  --color-text-secondary: #A1A1A6;
  --color-text-tertiary: #6E6E73;
  --color-bg-primary: #1C1C1E;
  --color-bg-secondary: #000000;

  --shadow-card: 0 4px 20px -2px rgba(0, 0, 0, 0.5);
  --shadow-card-hover: 0 12px 40px -4px rgba(0, 0, 0, 0.65);
}

/* ---------- Reset additions ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--surface-canvas);
  color: var(--color-text-primary, #1D1D1F);
  font-family: var(--font-primary, 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, textarea, select { font-family: inherit; }
a { color: var(--color-primary-400); text-decoration: none; }

/* ---------- Typography (Apple-tight) ---------- */
.t-display {
  font-size: clamp(32px, 4.5vw, 44px);
  font-weight: 600;
  letter-spacing: -0.022em;
  line-height: 1.08;
}
.t-h1 {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.019em;
  line-height: 1.15;
}
/* Used by drill-down pages (sales/outstanding/stock/ledger) above the
   page-grid. Keeps consistent spacing without each page re-declaring. */
.page-header { margin: 0 0 22px; }
.page-header .t-h1 { margin: 0; }
.page-header .t-meta { margin-top: 6px; color: var(--color-text-secondary); font-size: 14px; }
.t-h2 {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.014em;
  line-height: 1.25;
}
.t-h3 {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.011em;
  line-height: 1.3;
}
.t-body {
  font-size: 15px;
  font-weight: 400;
  line-height: 1.55;
}
.t-meta {
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-secondary);
}
.t-caption {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-tertiary);
}
.t-mono {
  font-family: var(--font-mono);
  font-feature-settings: 'tnum' 1, 'cv11' 1;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.005em;
  transition: transform var(--motion-fast) var(--ease-apple),
              box-shadow var(--motion-fast) var(--ease-apple),
              background var(--motion-fast) var(--ease-apple);
  user-select: none;
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--color-primary-400);
  color: #fff;
  box-shadow: 0 1px 0 rgba(255,255,255,0.16) inset, 0 4px 14px rgba(0,164,210,0.25);
}
.btn-primary:hover {
  background: var(--color-primary-500);
  box-shadow: 0 1px 0 rgba(255,255,255,0.16) inset, var(--glow-brand-strong);
}
.btn-primary:focus-visible {
  outline: none;
  box-shadow: var(--glow-brand), 0 4px 14px rgba(0,164,210,0.25);
}

.btn-ghost {
  background: transparent;
  color: var(--color-text-primary);
  border: 1px solid var(--hairline-strong);
}
.btn-ghost:hover {
  background: var(--color-gray-50);
  border-color: var(--color-gray-300);
}
[data-theme="dark"] .btn-ghost:hover { background: rgba(255,255,255,0.06); }

.btn-link {
  background: none;
  color: var(--color-primary-400);
  padding: 6px 8px;
  font-weight: 500;
}
.btn-link:hover { color: var(--color-primary-500); }

.btn-icon {
  width: 40px; height: 40px; padding: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--color-text-secondary);
  border: 1px solid transparent;
}
.btn-icon:hover {
  background: var(--color-gray-100);
  color: var(--color-text-primary);
}
[data-theme="dark"] .btn-icon:hover { background: rgba(255,255,255,0.08); }

/* ---------- Inputs ---------- */
.input {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--hairline-strong);
  border-radius: 12px;
  background: var(--surface-card);
  color: var(--color-text-primary);
  font-size: 15px;
  transition: border-color var(--motion-fast) var(--ease-apple),
              box-shadow var(--motion-fast) var(--ease-apple),
              background var(--motion-fast) var(--ease-apple);
}
.input::placeholder { color: var(--color-text-tertiary); }
.input:focus {
  outline: none;
  border-color: var(--color-primary-400);
  box-shadow: var(--glow-brand);
}

.input-group {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--hairline-strong);
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface-card);
  transition: border-color var(--motion-fast) var(--ease-apple),
              box-shadow var(--motion-fast) var(--ease-apple);
}
.input-group:focus-within {
  border-color: var(--color-primary-400);
  box-shadow: var(--glow-brand);
}
.input-group .prefix {
  display: flex; align-items: center;
  padding: 0 14px;
  font-weight: 600;
  font-size: 15px;
  color: var(--color-text-secondary);
  border-right: 1px solid var(--hairline);
  background: var(--color-gray-50);
}
[data-theme="dark"] .input-group .prefix {
  background: rgba(255,255,255,0.04);
  color: var(--color-text-secondary);
}
.input-group input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  padding: 14px 16px;
  font-size: 15px;
  color: var(--color-text-primary);
}

.field-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-secondary);
  margin-bottom: 6px;
}

/* ---------- Cards ---------- */
.card {
  background: var(--surface-card);
  border: 1px solid var(--hairline);
  border-radius: 16px;
  padding: var(--gap-card);
  box-shadow: var(--shadow-card);
  transition: box-shadow var(--motion-base) var(--ease-apple),
              transform var(--motion-base) var(--ease-apple);
}
.card-hoverable:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-card-hover);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

/* ---------- KPI Card ---------- */
.kpi {
  position: relative;
  background: var(--surface-card);
  border: 1px solid var(--hairline);
  border-radius: 16px;
  padding: 20px 22px 18px;
  overflow: hidden;
  box-shadow: var(--shadow-card);
  transition: box-shadow var(--motion-base) var(--ease-apple),
              transform var(--motion-base) var(--ease-apple);
}
.kpi:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-card-hover);
}
.kpi::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(circle at 100% 0%, rgba(0,164,210,0.08), transparent 50%);
  opacity: 0;
  transition: opacity var(--motion-base) var(--ease-apple);
  pointer-events: none;
}
.kpi:hover::after { opacity: 1; }
.kpi-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-text-tertiary);
}
.kpi-value {
  font-family: var(--font-mono);
  font-feature-settings: 'tnum' 1;
  font-size: 32px;
  font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--color-text-primary);
  margin: 8px 0 6px;
  line-height: 1.1;
}
.kpi-delta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-secondary);
}
.kpi-delta.up    { color: var(--color-success); }
.kpi-delta.down  { color: var(--color-error); }
.kpi-delta.neutral { color: var(--color-text-tertiary); }
.kpi-spark {
  margin-top: 14px;
  height: 32px;
  width: 100%;
}
.kpi-pulse {
  position: absolute;
  top: 22px; right: 22px;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--color-success);
  box-shadow: 0 0 0 0 rgba(16,185,129,0.6);
  animation: pulse-dot 2s var(--ease-apple) infinite;
}
@keyframes pulse-dot {
  0%   { box-shadow: 0 0 0 0    rgba(16,185,129,0.55); }
  70%  { box-shadow: 0 0 0 10px rgba(16,185,129,0);    }
  100% { box-shadow: 0 0 0 0    rgba(16,185,129,0);    }
}

/* ---------- Layout: Sidebar + Topbar ---------- */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--surface-glass-strong);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-right: 1px solid var(--hairline);
  display: flex;
  flex-direction: column;
  padding: 0 16px 18px;             /* zero top — sidebar-brand handles its own height to align with topbar */
  z-index: 10;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  height: var(--topbar-h);          /* match topbar height so content sits on the same Y-axis */
  padding: 0 10px;                  /* horizontal-only — height now controls vertical centring */
  border-bottom: 1px solid var(--hairline);
  margin-bottom: 14px;
}
.sidebar-brand .logo {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--color-primary-400), var(--color-primary-600));
  display: grid; place-items: center;
  color: white;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.02em;
}
.sidebar-brand .name {
  font-weight: 600;
  font-size: 16px;
  letter-spacing: -0.01em;
}
.sidebar-brand .tag {
  font-size: 11px;
  color: var(--color-text-tertiary);
  margin-top: 1px;
}

.nav-section {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 6px;
}
.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-tertiary);
  padding: 14px 10px 6px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: 10px;
  color: var(--color-text-secondary);
  font-size: 14px;
  font-weight: 500;
  transition: background var(--motion-fast) var(--ease-apple),
              color var(--motion-fast) var(--ease-apple);
  cursor: pointer;
  position: relative;
}
.nav-item svg {
  width: 18px; height: 18px;
  flex-shrink: 0;
  stroke-width: 1.75;
}
.nav-item:hover {
  background: rgba(0,0,0,0.04);
  color: var(--color-text-primary);
}
[data-theme="dark"] .nav-item:hover { background: rgba(255,255,255,0.06); }
.nav-item.active {
  background: rgba(0,164,210,0.10);
  color: var(--color-primary-400);
}
.nav-item.active::before {
  content: "";
  position: absolute;
  left: -16px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 18px;
  background: var(--color-primary-400);
  border-radius: 0 2px 2px 0;
}
.nav-item .badge {
  margin-left: auto;
  background: var(--color-primary-400);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 999px;
  min-width: 18px;
  text-align: center;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--hairline);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13px;
  color: var(--color-text-secondary);
  cursor: pointer;
  user-select: none;
}
.theme-toggle:hover { background: var(--color-gray-100); }
[data-theme="dark"] .theme-toggle:hover { background: rgba(255,255,255,0.04); }
.toggle-switch {
  width: 36px; height: 20px;
  background: var(--color-gray-200);
  border-radius: 999px;
  position: relative;
  transition: background var(--motion-fast) var(--ease-apple);
  cursor: pointer;
}
.toggle-switch::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  background: white;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.18);
  transition: transform var(--motion-fast) var(--ease-pop);
}
.toggle-switch.on { background: var(--color-primary-400); }
.toggle-switch.on::after { transform: translateX(16px); }

/* Main content area */
.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.topbar {
  position: sticky;
  top: 0;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  background: var(--surface-glass);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--hairline);
  z-index: 9;
}
.topbar .greeting {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.topbar .greeting .who {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.011em;
}
.topbar .greeting .when {
  font-size: 12px;
  color: var(--color-text-tertiary);
  font-weight: 500;
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-primary-400), var(--color-primary-600));
  display: grid; place-items: center;
  color: white;
  font-weight: 600;
  font-size: 13px;
  letter-spacing: -0.01em;
}

.page {
  padding: 32px 32px 64px;
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
}

/* ---------- Auth pages (login/register) ---------- */
.auth-stage {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  position: relative;
  overflow: hidden;
}
.auth-stage::before,
.auth-stage::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.55;
  pointer-events: none;
}
.auth-stage::before {
  width: 480px; height: 480px;
  background: radial-gradient(circle, rgba(0,164,210,0.32), transparent 60%);
  top: -180px; right: -120px;
  animation: aurora-1 14s var(--ease-apple) infinite alternate;
}
.auth-stage::after {
  width: 420px; height: 420px;
  background: radial-gradient(circle, rgba(99,179,237,0.28), transparent 60%);
  bottom: -160px; left: -120px;
  animation: aurora-2 16s var(--ease-apple) infinite alternate;
}
@keyframes aurora-1 {
  0%   { transform: translate(0, 0) scale(1); }
  100% { transform: translate(-40px, 60px) scale(1.15); }
}
@keyframes aurora-2 {
  0%   { transform: translate(0, 0) scale(1); }
  100% { transform: translate(50px, -40px) scale(1.12); }
}
[data-theme="dark"] .auth-stage::before { opacity: 0.32; }
[data-theme="dark"] .auth-stage::after { opacity: 0.26; }

.auth-card {
  position: relative;
  z-index: 1;
  width: min(100%, 420px);
  background: var(--surface-glass-strong);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid var(--hairline);
  border-radius: 24px;
  padding: 40px 32px 32px;
  box-shadow: 0 30px 80px -20px rgba(0,0,0,0.18), 0 0 0 1px rgba(0,0,0,0.02);
  animation: lift-in 700ms var(--ease-apple) both;
}
@keyframes lift-in {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
.auth-card .brand {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 28px;
}
.auth-card .brand .logo {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--color-primary-400), var(--color-primary-600));
  display: grid; place-items: center;
  color: white; font-weight: 700;
  letter-spacing: 0.02em;
  box-shadow: 0 6px 16px rgba(0,164,210,0.28);
}
.auth-card .brand .name {
  font-weight: 600;
  font-size: 18px;
  letter-spacing: -0.012em;
}

.auth-card h1 {
  margin: 0 0 6px;
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.019em;
}
.auth-card .sub {
  margin: 0 0 28px;
  color: var(--color-text-secondary);
  font-size: 15px;
}

.auth-card .form-row { display: block; grid-template-columns: none; margin-bottom: 16px; }
.auth-card .btn-primary { background: var(--color-primary-400); border-radius: 12px; padding: 12px 20px; font-size: 15px; width: 100%; }
.auth-card .actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 8px;
}
.auth-card .footer-link {
  margin-top: 22px;
  text-align: center;
  font-size: 14px;
  color: var(--color-text-secondary);
}
.auth-card .footer-link a {
  font-weight: 600;
  color: var(--color-primary-400);
}

/* ---------- Status / Toast ---------- */
.status {
  margin-top: 14px;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13.5px;
  display: none;
}
.status.show { display: block; animation: lift-in 280ms var(--ease-apple) both; }
.status.error   { background: var(--color-error-light); color: #B91C1C; }
.status.success { background: var(--color-success-light); color: #065F46; }
.status.info    { background: var(--color-info-light); color: #1D4ED8; }

/* ---------- Stepper (Register) ---------- */
.stepper {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 24px;
}
.step-pill {
  flex: 1;
  height: 4px;
  border-radius: 999px;
  background: var(--color-gray-200);
  overflow: hidden;
  position: relative;
}
.step-pill.done::after,
.step-pill.active::after {
  content: "";
  position: absolute; inset: 0;
  background: var(--color-primary-400);
  transition: transform var(--motion-base) var(--ease-apple);
}
.step-pill.active::after { transform: scaleX(0.5); transform-origin: left; }
.step-pill.done::after   { transform: scaleX(1); transform-origin: left; }

/* ---------- Dashboard grid ---------- */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
  margin-bottom: var(--gap-section);
}
.widget-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 20px;
  margin-bottom: var(--gap-section);
}
.widget-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}

.empty-state {
  display: grid;
  place-items: center;
  text-align: center;
  padding: 32px;
  color: var(--color-text-tertiary);
}
.empty-state svg { opacity: 0.4; margin-bottom: 8px; }

/* Skeleton shimmer */
.skel {
  background: linear-gradient(90deg, var(--color-gray-100) 0%, var(--color-gray-200) 50%, var(--color-gray-100) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.6s linear infinite;
  border-radius: 6px;
}
[data-theme="dark"] .skel {
  background: linear-gradient(90deg, rgba(255,255,255,0.04) 0%, rgba(255,255,255,0.10) 50%, rgba(255,255,255,0.04) 100%);
  background-size: 200% 100%;
}
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
  .widget-grid { grid-template-columns: 1fr; }
  .widget-grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .page { padding: 20px 16px 48px; }
  .topbar { padding: 0 16px; }
}

/* ---------- Utilities ---------- */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; }
.mb-1 { margin-bottom: 4px; } .mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; }
.text-secondary { color: var(--color-text-secondary); }
.text-tertiary  { color: var(--color-text-tertiary); }
.hidden { display: none !important; }


/* ════════════════════════════════════════════════════════════════════════════
   PHASE 20 — PREMIUM ANIMATIONS, COLOR SYSTEM, FUTURISTIC EFFECTS
   ════════════════════════════════════════════════════════════════════════════ */

/* ---------- 1. KPI Accent Color System ---------- */
:root {
  --accent-emerald: #10B981; --accent-emerald-soft: rgba(16,185,129,0.12); --accent-emerald-glow: rgba(16,185,129,0.30);
  --accent-amber:   #F59E0B; --accent-amber-soft:   rgba(245,158,11,0.12);  --accent-amber-glow:   rgba(245,158,11,0.30);
  --accent-indigo:  #6366F1; --accent-indigo-soft:  rgba(99,102,241,0.12);  --accent-indigo-glow:  rgba(99,102,241,0.30);
  --accent-violet:  #8B5CF6; --accent-violet-soft:  rgba(139,92,246,0.12);  --accent-violet-glow:  rgba(139,92,246,0.30);
  --accent-rose:    #F43F5E; --accent-rose-soft:    rgba(244,63,94,0.12);   --accent-rose-glow:    rgba(244,63,94,0.30);
  --accent-cyan:    #00A4D2; --accent-cyan-soft:    rgba(0,164,210,0.12);   --accent-cyan-glow:    rgba(0,164,210,0.30);
  --accent-sky:     #0EA5E9; --accent-sky-soft:     rgba(14,165,233,0.12);  --accent-sky-glow:     rgba(14,165,233,0.30);
  --accent-fuchsia: #D946EF; --accent-fuchsia-soft: rgba(217,70,239,0.12);  --accent-fuchsia-glow: rgba(217,70,239,0.30);
}
[data-theme="dark"] {
  --accent-emerald-soft: rgba(16,185,129,0.18);
  --accent-amber-soft:   rgba(245,158,11,0.18);
  --accent-indigo-soft:  rgba(99,102,241,0.20);
  --accent-violet-soft:  rgba(139,92,246,0.20);
  --accent-rose-soft:    rgba(244,63,94,0.18);
  --accent-cyan-soft:    rgba(0,164,210,0.20);
}

/* ---------- 2. Premium KPI Card (with icon box, sparkline) ---------- */
.kpi {
  position: relative;
  overflow: hidden;
  /* magnetic hover prep */
  transform-style: preserve-3d;
  transition: transform 480ms cubic-bezier(0.22, 1, 0.36, 1),
              box-shadow 320ms cubic-bezier(0.22, 1, 0.36, 1),
              border-color 320ms ease;
}
.kpi::before {
  /* radial glow following accent on hover */
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: inherit;
  background: radial-gradient(140px circle at var(--mx, 50%) var(--my, 0%), var(--kpi-glow, transparent), transparent 60%);
  opacity: 0;
  transition: opacity 380ms ease;
  pointer-events: none;
  z-index: 0;
}
.kpi > * { position: relative; z-index: 1; }
.kpi:hover {
  transform: translateY(-4px) scale(1.012);
  box-shadow: 0 18px 48px -12px var(--kpi-glow, rgba(0,0,0,0.18)),
              0 4px 12px rgba(0,0,0,0.04);
  border-color: var(--kpi-color, var(--color-primary-300));
}
.kpi:hover::before { opacity: 1; }

.kpi-top {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.kpi-icon-box {
  width: 38px; height: 38px;
  border-radius: 11px;
  background: var(--kpi-soft, var(--color-primary-50));
  color: var(--kpi-color, var(--color-primary-400));
  display: grid; place-items: center;
  transition: transform 320ms cubic-bezier(0.22, 1, 0.36, 1);
}
.kpi-icon-box svg { width: 18px; height: 18px; stroke-width: 2; }
.kpi:hover .kpi-icon-box {
  transform: scale(1.08) rotate(-3deg);
}

.kpi-pulse-live {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent-emerald);
  position: relative;
}
.kpi-pulse-live::after {
  content: '';
  position: absolute; inset: -4px;
  border-radius: 50%;
  background: var(--accent-emerald);
  opacity: 0.4;
  animation: kpiPulse 1.6s ease-out infinite;
}
@keyframes kpiPulse {
  0%   { transform: scale(0.7); opacity: 0.6; }
  100% { transform: scale(2.2); opacity: 0;   }
}

.kpi-spark-canvas {
  width: 100%; height: 38px;
  margin-top: 14px;
  display: block;
}

/* ---------- 3. Stagger entrance for cards ---------- */
@keyframes cardRise {
  from { opacity: 0; transform: translateY(16px) scale(0.985); }
  to   { opacity: 1; transform: translateY(0)    scale(1);     }
}
.stagger-in {
  animation: cardRise 620ms cubic-bezier(0.22, 1, 0.36, 1) both;
}
.stagger-in[data-i="0"] { animation-delay: 0ms; }
.stagger-in[data-i="1"] { animation-delay: 60ms; }
.stagger-in[data-i="2"] { animation-delay: 120ms; }
.stagger-in[data-i="3"] { animation-delay: 180ms; }
.stagger-in[data-i="4"] { animation-delay: 240ms; }
.stagger-in[data-i="5"] { animation-delay: 300ms; }
.stagger-in[data-i="6"] { animation-delay: 360ms; }
.stagger-in[data-i="7"] { animation-delay: 420ms; }

/* ---------- 4. Aurora moving gradient (briefing card) ---------- */
.briefing-aurora {
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(135deg,
      rgba(0,164,210,0.08) 0%,
      rgba(99,102,241,0.06) 35%,
      rgba(139,92,246,0.05) 70%,
      rgba(16,185,129,0.06) 100%);
  border: 1px solid rgba(0,164,210,0.14);
  border-radius: 18px;
  padding: 20px 24px;
  display: flex; gap: 16px; align-items: flex-start;
}
.briefing-aurora::before {
  content: '';
  position: absolute;
  top: -50%; left: -25%; right: -25%; bottom: -50%;
  background:
    radial-gradient(35% 40% at 20% 30%,  rgba(0,164,210,0.18),  transparent 60%),
    radial-gradient(35% 40% at 80% 70%,  rgba(139,92,246,0.16), transparent 60%),
    radial-gradient(30% 30% at 50% 90%,  rgba(16,185,129,0.10), transparent 60%);
  filter: blur(36px);
  animation: auroraDrift 14s ease-in-out infinite alternate;
  pointer-events: none;
  z-index: 0;
}
.briefing-aurora > * { position: relative; z-index: 1; }
@keyframes auroraDrift {
  0%   { transform: translate(0, 0) rotate(0deg)   scale(1);    }
  50%  { transform: translate(8%, -4%) rotate(20deg) scale(1.08); }
  100% { transform: translate(-6%, 6%) rotate(-15deg) scale(1.04); }
}
.briefing-aurora .ic {
  width: 40px; height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-indigo));
  color: white;
  display: grid; place-items: center;
  flex-shrink: 0;
  box-shadow: 0 6px 18px rgba(0,164,210,0.35);
}
.briefing-aurora .ic svg { width: 20px; height: 20px; stroke-width: 1.75; }
.briefing-aurora .label {
  font-size: 11px; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase;
  background: linear-gradient(90deg, var(--accent-cyan), var(--accent-violet));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 5px;
}
.briefing-aurora .text {
  font-size: 14.5px; color: var(--color-text-primary); line-height: 1.55;
  font-weight: 500;
}

/* ---------- 5. Glassmorphism (sidebar + topbar) ---------- */
.sidebar.glass {
  background: rgba(255,255,255,0.72);
  backdrop-filter: blur(28px) saturate(140%);
  -webkit-backdrop-filter: blur(28px) saturate(140%);
}
[data-theme="dark"] .sidebar.glass {
  background: rgba(20,20,22,0.78);
  border-right: 1px solid rgba(255,255,255,0.06);
}
.topbar.glass {
  background: rgba(255,255,255,0.62);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  border-bottom: 1px solid rgba(0,0,0,0.04);
}
[data-theme="dark"] .topbar.glass {
  background: rgba(20,20,22,0.72);
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

/* ---------- 6. Spring iOS-style range toggle ---------- */
.pill-toggle {
  position: relative;
  display: inline-flex;
  background: var(--color-gray-100);
  padding: 3px;
  border-radius: 999px;
  border: 1px solid var(--hairline);
}
[data-theme="dark"] .pill-toggle { background: rgba(255,255,255,0.05); }
.pill-toggle button {
  position: relative;
  padding: 7px 16px;
  border-radius: 999px;
  font-size: 13px; font-weight: 500;
  color: var(--color-text-secondary);
  z-index: 1;
  transition: color 280ms ease;
}
.pill-toggle button.active { color: var(--color-text-primary); font-weight: 600; }
.pill-toggle .slider {
  position: absolute;
  top: 3px; bottom: 3px;
  background: var(--surface-card);
  border-radius: 999px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08), 0 0 0 1px rgba(0,0,0,0.04);
  transition: left 480ms cubic-bezier(0.34, 1.56, 0.64, 1),
              width 480ms cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 0;
}
[data-theme="dark"] .pill-toggle .slider { background: rgba(255,255,255,0.10); box-shadow: none; }

/* ---------- 7. Floating chat FAB with pulse ring ---------- */
.floating-chat {
  position: fixed;
  bottom: 28px; right: 28px;
  width: 58px; height: 58px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-cyan) 0%, var(--accent-indigo) 100%);
  color: white;
  display: grid; place-items: center;
  box-shadow: 0 10px 32px rgba(0,164,210,0.42), 0 4px 12px rgba(99,102,241,0.20);
  cursor: pointer;
  transition: transform 320ms cubic-bezier(0.34, 1.56, 0.64, 1),
              box-shadow 320ms ease;
  z-index: 50;
}
.floating-chat::before {
  content: '';
  position: absolute; inset: -4px;
  border-radius: 50%;
  border: 2px solid rgba(0,164,210,0.45);
  animation: fabPulse 2.4s ease-out infinite;
  pointer-events: none;
}
@keyframes fabPulse {
  0%   { transform: scale(0.95); opacity: 0.9; }
  70%  { transform: scale(1.45); opacity: 0;   }
  100% { transform: scale(1.45); opacity: 0;   }
}
.floating-chat:hover {
  transform: scale(1.08) rotate(-6deg);
  box-shadow: 0 16px 44px rgba(0,164,210,0.55), 0 6px 18px rgba(99,102,241,0.32);
}
.floating-chat svg { width: 24px; height: 24px; }

/* ---------- 8. Drill-down + Spotlight modals ---------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.42);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 200;
  opacity: 0; pointer-events: none;
  transition: opacity 280ms ease;
  display: grid; place-items: flex-start center;
  padding: 8vh 24px 24px;
}
.modal-backdrop.open { opacity: 1; pointer-events: auto; }
.modal-card {
  width: 100%; max-width: 720px;
  background: var(--surface-card);
  border: 1px solid var(--hairline);
  border-radius: 20px;
  box-shadow: 0 32px 80px rgba(0,0,0,0.32);
  transform: translateY(20px) scale(0.96);
  transition: transform 380ms cubic-bezier(0.22, 1, 0.36, 1);
  overflow: hidden;
}
.modal-backdrop.open .modal-card { transform: translateY(0) scale(1); }

/* ⌘K Spotlight specifics */
.spotlight {
  display: flex; flex-direction: column;
  max-height: 70vh;
}
.spotlight-input-row {
  display: flex; align-items: center; gap: 12px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--hairline);
  position: relative;
}
.spotlight-input-row::before {
  /* gradient border glow */
  content: '';
  position: absolute; left: 0; right: 0; bottom: -1px; height: 2px;
  background: linear-gradient(90deg, var(--accent-cyan), var(--accent-violet), var(--accent-fuchsia));
  opacity: 0.7;
}
.spotlight-input {
  flex: 1;
  background: transparent;
  border: none; outline: none;
  font-size: 17px; font-weight: 500;
  color: var(--color-text-primary);
}
.spotlight-input::placeholder { color: var(--color-text-tertiary); }
.spotlight-list {
  overflow-y: auto;
  padding: 6px 0;
}
.spotlight-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 22px;
  cursor: pointer;
  transition: background 180ms ease;
}
.spotlight-item:hover, .spotlight-item.active {
  background: var(--accent-cyan-soft);
}
.spotlight-item .ic-mini {
  width: 28px; height: 28px;
  border-radius: 7px;
  background: var(--accent-cyan-soft);
  color: var(--accent-cyan);
  display: grid; place-items: center;
}
.spotlight-item .ic-mini svg { width: 14px; height: 14px; }
.spotlight-item .label { flex: 1; font-size: 14px; font-weight: 500; }
.spotlight-item .kbd {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--color-gray-100);
  color: var(--color-text-tertiary);
}
[data-theme="dark"] .spotlight-item .kbd { background: rgba(255,255,255,0.08); }

/* Drill-down modal */
.drill-modal {
  display: flex; flex-direction: column;
  max-height: 80vh;
}
.drill-head {
  padding: 22px 28px 16px;
  border-bottom: 1px solid var(--hairline);
  display: flex; align-items: center; gap: 14px;
}
.drill-head .ic-lg {
  width: 44px; height: 44px;
  border-radius: 13px;
  background: var(--kpi-soft, var(--color-primary-50));
  color: var(--kpi-color, var(--color-primary-400));
  display: grid; place-items: center;
}
.drill-head .ic-lg svg { width: 22px; height: 22px; stroke-width: 2; }
.drill-head .t-h2 { font-size: 22px; font-weight: 700; letter-spacing: -0.01em; margin: 0; }
.drill-head .t-meta { font-size: 13px; color: var(--color-text-secondary); margin-top: 2px; }
.drill-body {
  padding: 22px 28px;
  overflow-y: auto;
}
.drill-stat-grid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 18px;
}
.drill-stat {
  padding: 12px 14px;
  border: 1px solid var(--hairline);
  border-radius: 12px;
  background: var(--surface-page);
}
.drill-stat .lbl { font-size: 11px; color: var(--color-text-tertiary); text-transform: uppercase; letter-spacing: 0.06em; }
.drill-stat .val { font-family: var(--font-mono); font-weight: 600; font-size: 17px; margin-top: 4px; }
.drill-canvas { width: 100%; height: 280px; }
.btn-close {
  width: 32px; height: 32px;
  border-radius: 8px;
  display: grid; place-items: center;
  margin-left: auto;
  color: var(--color-text-secondary);
  transition: background 180ms ease;
}
.btn-close:hover { background: var(--color-gray-100); color: var(--color-text-primary); }
[data-theme="dark"] .btn-close:hover { background: rgba(255,255,255,0.08); }
.btn-close svg { width: 18px; height: 18px; }

/* ---------- 9. Tip banner (Pro Tip style) ---------- */
.tip-banner {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 22px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--accent-amber-soft) 0%, var(--accent-emerald-soft) 100%);
  border: 1px solid var(--accent-amber-soft);
  margin-top: var(--gap-section);
}
.tip-banner .ic {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent-amber), var(--accent-emerald));
  color: white;
  display: grid; place-items: center;
  flex-shrink: 0;
}
.tip-banner .ic svg { width: 17px; height: 17px; }
.tip-banner .ttl { font-weight: 600; font-size: 13px; margin-bottom: 2px; }
.tip-banner .desc { font-size: 13.5px; color: var(--color-text-secondary); line-height: 1.5; }

/* ---------- 10. Magnetic / 3D tilt prep (set CSS vars from JS) ---------- */
.tilt-card {
  transform: perspective(800px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)) translateZ(0);
  transition: transform 220ms cubic-bezier(0.22, 1, 0.36, 1);
  will-change: transform;
}

/* ---------- 11. Mini chart canvas in card backgrounds ---------- */
.kpi-spark-canvas { pointer-events: none; }

/* ---------- 12. Delta chip (rounded pill) ---------- */
.delta-chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
}
.delta-chip.up   { background: var(--accent-emerald-soft); color: var(--accent-emerald); }
.delta-chip.down { background: var(--accent-rose-soft);    color: var(--accent-rose); }
.delta-chip.flat { background: var(--color-gray-100);      color: var(--color-text-tertiary); }
[data-theme="dark"] .delta-chip.flat { background: rgba(255,255,255,0.06); }

/* ---------- 13. Reduce-motion respect ---------- */
@media (prefers-reduced-motion: reduce) {
  .stagger-in, .briefing-aurora::before, .floating-chat::before { animation: none !important; }
  .kpi:hover { transform: none; }
}


/* ═══════════════════════════════════════════════════════════════════════
   FUTURISTIC DRILL-DOWN UPGRADE — neon glow, aurora backdrop, min/max
   ═══════════════════════════════════════════════════════════════════════ */

/* Premium modal shell with KPI-tinted glass + radial aurora */
.modal-card.drill-modal {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(1200px 600px at 90% -20%, var(--kpi-soft, rgba(0,164,210,0.12)) 0%, transparent 60%),
    radial-gradient(800px 400px at -10% 110%, var(--kpi-soft, rgba(0,164,210,0.08)) 0%, transparent 60%),
    var(--surface-card);
  border: 1px solid color-mix(in srgb, var(--kpi-color, #00A4D2) 22%, var(--hairline));
  box-shadow:
    0 30px 80px rgba(0,0,0,0.18),
    0 0 0 1px rgba(255,255,255,0.04) inset,
    0 80px 160px -40px color-mix(in srgb, var(--kpi-color, #00A4D2) 35%, transparent);
}

[data-theme="dark"] .modal-card.drill-modal {
  background:
    radial-gradient(1200px 600px at 90% -20%, color-mix(in srgb, var(--kpi-color, #00A4D2) 18%, transparent) 0%, transparent 60%),
    radial-gradient(800px 400px at -10% 110%, color-mix(in srgb, var(--kpi-color, #00A4D2) 12%, transparent) 0%, transparent 60%),
    #1C1C1E;
  box-shadow:
    0 30px 80px rgba(0,0,0,0.55),
    0 0 0 1px rgba(255,255,255,0.06) inset,
    0 80px 200px -40px color-mix(in srgb, var(--kpi-color, #00A4D2) 50%, transparent);
}

/* Subtle scanning gradient line at top of modal — premium touch */
.modal-card.drill-modal::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1.5px;
  background: linear-gradient(90deg,
    transparent 0%,
    var(--kpi-color, #00A4D2) 30%,
    var(--accent-fuchsia) 50%,
    var(--accent-cyan) 70%,
    transparent 100%);
  opacity: 0.7;
  pointer-events: none;
}

/* Drill head — gradient title + KPI-tinted icon glow */
.drill-head .ic-lg {
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--kpi-color, #00A4D2) 18%, var(--surface-card)),
    var(--kpi-soft, var(--color-primary-50)));
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--kpi-color, #00A4D2) 18%, transparent),
    0 8px 22px color-mix(in srgb, var(--kpi-color, #00A4D2) 28%, transparent);
  transition: transform 320ms cubic-bezier(0.34, 1.56, 0.64, 1);
}
.drill-head:hover .ic-lg { transform: scale(1.06) rotate(-3deg); }
.drill-head .t-h2 {
  background: linear-gradient(135deg, var(--color-text-primary), color-mix(in srgb, var(--kpi-color, #00A4D2) 70%, var(--color-text-primary)));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* Stat cards — premium glass + accent tint + count-up effect */
.drill-stat {
  position: relative;
  background: linear-gradient(180deg,
    var(--surface-card) 0%,
    color-mix(in srgb, var(--kpi-soft, rgba(0,164,210,0.06)) 60%, var(--surface-card)) 100%);
  border: 1px solid color-mix(in srgb, var(--kpi-color, #00A4D2) 12%, var(--hairline));
  overflow: hidden;
  transition: transform 240ms cubic-bezier(0.22,1,0.36,1), box-shadow 240ms ease;
}
.drill-stat::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: linear-gradient(180deg, var(--kpi-color, #00A4D2), color-mix(in srgb, var(--kpi-color, #00A4D2) 40%, transparent));
}
.drill-stat:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 22px color-mix(in srgb, var(--kpi-color, #00A4D2) 18%, transparent);
}
.drill-stat .val {
  font-size: 19px;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--color-text-primary), color-mix(in srgb, var(--kpi-color, #00A4D2) 35%, var(--color-text-primary)));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* Chart canvas wrapper with ambient halo + animated reveal */
.drill-chart-wrap {
  position: relative;
  width: 100%;
  height: 280px;
  border-radius: 16px;
  padding: 4px 0;
}
.drill-chart-wrap::before {
  content: "";
  position: absolute;
  inset: -10px 0 -10px 0;
  background: radial-gradient(80% 100% at 50% 100%,
    color-mix(in srgb, var(--kpi-color, #00A4D2) 14%, transparent) 0%,
    transparent 70%);
  filter: blur(20px);
  pointer-events: none;
  z-index: 0;
  opacity: 0;
  animation: chartHaloFade 900ms 200ms cubic-bezier(0.22,1,0.36,1) forwards;
}
.drill-chart-wrap canvas {
  position: relative;
  z-index: 1;
}
@keyframes chartHaloFade { to { opacity: 1; } }

/* Min/Max floating chips inside chart area */
.drill-marker {
  position: absolute;
  z-index: 3;
  pointer-events: none;
  transform: translate(-50%, -100%);
  transition: opacity 320ms ease, transform 320ms cubic-bezier(0.34,1.56,0.64,1);
  opacity: 0;
}
.drill-marker.show { opacity: 1; transform: translate(-50%, calc(-100% - 4px)); }
.drill-marker .pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font-mono);
  background: var(--surface-card);
  border: 1px solid color-mix(in srgb, var(--kpi-color, #00A4D2) 30%, var(--hairline));
  box-shadow: 0 6px 16px color-mix(in srgb, var(--kpi-color, #00A4D2) 22%, transparent);
  white-space: nowrap;
}
.drill-marker.high .pill { color: var(--accent-emerald); border-color: color-mix(in srgb, var(--accent-emerald) 28%, var(--hairline)); }
.drill-marker.low  .pill { color: var(--accent-rose);    border-color: color-mix(in srgb, var(--accent-rose) 28%, var(--hairline)); }
.drill-marker .arr {
  width: 0; height: 0;
  margin: 1px auto 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid var(--surface-card);
  filter: drop-shadow(0 1px 0 color-mix(in srgb, var(--kpi-color, #00A4D2) 30%, var(--hairline)));
}
[data-theme="dark"] .drill-marker .pill { background: rgba(28,28,30,0.95); }
[data-theme="dark"] .drill-marker .arr { border-top-color: rgba(28,28,30,0.95); }

/* Pulsing peak/trough dots */
.drill-pulse {
  position: absolute;
  z-index: 2;
  width: 10px; height: 10px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  opacity: 0;
  animation: drillPulseFade 480ms 600ms forwards;
}
.drill-pulse.high { background: var(--accent-emerald); box-shadow: 0 0 0 0 var(--accent-emerald); animation: drillPulseFade 480ms 600ms forwards, drillPulseRing 1.8s 800ms infinite; }
.drill-pulse.low  { background: var(--accent-rose);    box-shadow: 0 0 0 0 var(--accent-rose);    animation: drillPulseFade 480ms 600ms forwards, drillPulseRingRose 1.8s 800ms infinite; }
@keyframes drillPulseFade {
  to { opacity: 1; }
}
@keyframes drillPulseRing {
  0%   { box-shadow: 0 0 0 0   color-mix(in srgb, var(--accent-emerald) 50%, transparent); }
  70%  { box-shadow: 0 0 0 12px color-mix(in srgb, var(--accent-emerald) 0%, transparent); }
  100% { box-shadow: 0 0 0 0   color-mix(in srgb, var(--accent-emerald) 0%, transparent); }
}
@keyframes drillPulseRingRose {
  0%   { box-shadow: 0 0 0 0   color-mix(in srgb, var(--accent-rose) 50%, transparent); }
  70%  { box-shadow: 0 0 0 12px color-mix(in srgb, var(--accent-rose) 0%, transparent); }
  100% { box-shadow: 0 0 0 0   color-mix(in srgb, var(--accent-rose) 0%, transparent); }
}

/* Modal opening — premium spring */
.modal-backdrop.open .modal-card.drill-modal {
  animation: drillOpen 540ms cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
@keyframes drillOpen {
  0%   { opacity: 0; transform: translateY(20px) scale(0.96); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .modal-card.drill-modal::before,
  .drill-pulse, .drill-marker, .drill-chart-wrap::before { animation: none !important; transition: none !important; }
}


/* ────────────────────────────────────────────────────────────────────────
   FUTURISTIC PAGE HEADER (Phase 22 · Level-3 hero)
   Aurora background + grid overlay + glow icon + animated gradient title
   + LIVE pill + info chips + animated underline + 3D tilt + hover shimmer
   Used on: sales / outstanding / stock / ledger / calendar / settings / reports
   ──────────────────────────────────────────────────────────────────────── */

.page-header-hero {
  position: relative;
  padding: 28px 28px 22px;
  border-radius: 20px;
  overflow: hidden;
  margin: 0 0 28px;
  background: linear-gradient(135deg, rgba(255,255,255,0.65), rgba(255,255,255,0.30));
  border: 1px solid rgba(255,255,255,0.45);
  backdrop-filter: blur(18px) saturate(180%);
  -webkit-backdrop-filter: blur(18px) saturate(180%);
  box-shadow: 0 1px 0 rgba(255,255,255,0.6) inset, 0 8px 28px rgba(99,102,241,0.07);
  isolation: isolate;
  transform: perspective(1000px) rotateX(var(--hero-rx, 0deg)) rotateY(var(--hero-ry, 0deg));
  transition: transform 220ms cubic-bezier(0.22, 1, 0.36, 1);
  animation: heroReveal 600ms cubic-bezier(0.22, 1, 0.36, 1) both;
}
[data-theme="dark"] .page-header-hero {
  background: linear-gradient(135deg, rgba(28,28,30,0.72), rgba(28,28,30,0.40));
  border-color: rgba(255,255,255,0.06);
  box-shadow: 0 1px 0 rgba(255,255,255,0.04) inset, 0 8px 28px rgba(0,0,0,0.4);
}
@keyframes heroReveal {
  from { opacity: 0; transform: perspective(1000px) translateY(12px); }
  to   { opacity: 1; transform: perspective(1000px) translateY(0); }
}

/* Aurora background blobs */
.page-header-bg {
  position: absolute; inset: 0;
  z-index: -1; pointer-events: none; overflow: hidden;
}
.aurora {
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.28;
  mix-blend-mode: screen;
  animation: auroraFloat 22s ease-in-out infinite;
}
[data-theme="dark"] .aurora { opacity: 0.22; mix-blend-mode: lighten; }
.aurora-1 { width: 280px; height: 280px; background: #00A4D2; top: -110px; left: -70px; }
.aurora-2 { width: 220px; height: 220px; background: #8B5CF6; top: -50px; right: -80px; animation-delay: -8s; }
.aurora-3 { display: none; }
@keyframes auroraFloat {
  0%   { transform: translate(0,0) scale(1); }
  33%  { transform: translate(30px,-20px) scale(1.08); }
  66%  { transform: translate(-25px,15px) scale(0.95); }
  100% { transform: translate(0,0) scale(1); }
}

/* Grid pattern with radial fade */
.grid-overlay {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(to right, rgba(99,102,241,0.04) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(99,102,241,0.04) 1px, transparent 1px);
  background-size: 36px 36px;
  -webkit-mask-image: radial-gradient(ellipse 100% 80% at 50% 50%, black, transparent);
          mask-image: radial-gradient(ellipse 100% 80% at 50% 50%, black, transparent);
  pointer-events: none;
}
[data-theme="dark"] .grid-overlay {
  background-image:
    linear-gradient(to right, rgba(255,255,255,0.025) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255,255,255,0.025) 1px, transparent 1px);
}

.page-header-content {
  position: relative;
  display: flex;
  align-items: center;
  gap: 18px;
}

/* Glowing page icon */
.page-icon-glow {
  width: 56px; height: 56px;
  border-radius: 14px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #00A4D2, #6366F1, #D946EF);
  box-shadow: 0 0 24px rgba(99,102,241,0.45), 0 6px 20px rgba(0,164,210,0.28);
  flex-shrink: 0;
  animation: iconPulse 3.6s ease-in-out infinite;
}
.page-icon-glow svg { width: 28px; height: 28px; color: #fff; stroke-width: 2.2; filter: drop-shadow(0 1px 2px rgba(0,0,0,0.2)); }
@keyframes iconPulse {
  0%,100% { box-shadow: 0 0 24px rgba(99,102,241,0.45), 0 6px 20px rgba(0,164,210,0.28); }
  50%     { box-shadow: 0 0 36px rgba(99,102,241,0.65), 0 8px 28px rgba(0,164,210,0.40); }
}

.page-header-text { flex: 1; min-width: 0; }
.page-title-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

/* Animated gradient title */
.page-title-gradient {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.022em;
  margin: 0;
  background: linear-gradient(110deg, #00A4D2 0%, #6366F1 25%, #8B5CF6 50%, #D946EF 75%, #00A4D2 100%);
  background-size: 220% auto;
  -webkit-background-clip: text;
          background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  animation: titleGradient 14s linear infinite;
  position: relative;
  display: inline-block;
}
@keyframes titleGradient {
  0%   { background-position: 0% 50%; }
  100% { background-position: 220% 50%; }
}
.page-title-gradient::after {
  content: "";
  position: absolute;
  top: 0; left: -100%; width: 100%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.55), transparent);
  pointer-events: none;
  opacity: 0;
}
.page-header-hero:hover .page-title-gradient::after {
  animation: titleShimmer 1.2s ease-out;
}
@keyframes titleShimmer {
  0%   { left: -100%; opacity: 1; }
  100% { left: 100%;  opacity: 0; }
}

/* LIVE pill */
.live-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(16,185,129,0.12);
  border: 1px solid rgba(16,185,129,0.32);
  color: #10B981;
  font-size: 11px; font-weight: 700;
  letter-spacing: 0.6px; text-transform: uppercase;
}
.live-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #10B981;
  box-shadow: 0 0 0 0 rgba(16,185,129,0.5);
  animation: dotPulse 2s ease-in-out infinite;
}

/* Description */
.page-desc {
  font-size: 14px;
  color: var(--color-text-secondary);
  margin: 6px 0 12px;
  max-width: 640px;
}

/* Info chips */
.page-chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.page-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(0,164,210,0.08);
  border: 1px solid rgba(0,164,210,0.18);
  color: var(--color-text-secondary);
  font-size: 12px; font-weight: 500;
}
[data-theme="dark"] .page-chip {
  background: rgba(255,255,255,0.04);
  border-color: rgba(255,255,255,0.08);
}

/* Animated underline */
.page-underline {
  position: relative;
  height: 2px;
  margin-top: 14px;
  overflow: hidden;
  border-radius: 2px;
}
.page-underline::before {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(90deg, #00A4D2, #6366F1, #D946EF, transparent);
  transform-origin: left center;
  transform: scaleX(0);
  animation: drawUnderline 900ms 200ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
@keyframes drawUnderline { to { transform: scaleX(1); } }

@media (prefers-reduced-motion: reduce) {
  .page-header-hero, .aurora, .page-title-gradient,
  .page-underline::before, .page-icon-glow { animation: none; }
}


/* ────────────────────────────────────────────────────────────────────────
   PAGE-WIDE PREMIUM POLISH (Phase 22 · Level-3 part 2)
   KPI cards · chart cards · tables · subtle page background aurora.
   Drill pages (sales/outstanding/stock/ledger) automatically pick this up.
   ──────────────────────────────────────────────────────────────────────── */

/* ─── Subtle page background (works alongside the hero) ─── */
.page::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(circle at 8% -10%, rgba(0,164,210,0.06), transparent 40%),
    radial-gradient(circle at 92% -5%, rgba(139,92,246,0.05), transparent 40%),
    radial-gradient(circle at 50% 110%, rgba(217,70,239,0.04), transparent 50%);
}
[data-theme="dark"] .page::before {
  background:
    radial-gradient(circle at 8% -10%, rgba(0,164,210,0.10), transparent 40%),
    radial-gradient(circle at 92% -5%, rgba(139,92,246,0.08), transparent 40%),
    radial-gradient(circle at 50% 110%, rgba(217,70,239,0.06), transparent 50%);
}
.page > * { position: relative; z-index: 1; }

/* ─── KPI cards (.kpi inside .kpi-row) ─── */
.kpi-row .kpi {
  position: relative;
  background: var(--surface-card);
  border: 1px solid var(--hairline);
  border-radius: 16px;
  padding: 18px;
  transition: transform 280ms cubic-bezier(0.22,1,0.36,1),
              box-shadow 280ms cubic-bezier(0.22,1,0.36,1),
              border-color 280ms ease;
  animation: kpiReveal 600ms cubic-bezier(0.22,1,0.36,1) both;
  overflow: hidden;
}
.kpi-row .kpi:nth-child(1) { animation-delay: 0ms; }
.kpi-row .kpi:nth-child(2) { animation-delay: 80ms; }
.kpi-row .kpi:nth-child(3) { animation-delay: 160ms; }
.kpi-row .kpi:nth-child(4) { animation-delay: 240ms; }
.kpi-row .kpi:nth-child(5) { animation-delay: 320ms; }
@keyframes kpiReveal {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Animated gradient border (visible on hover) */
.kpi-row .kpi::before {
  content: "";
  position: absolute; inset: 0;
  padding: 1px;
  border-radius: 16px;
  background: linear-gradient(135deg, #00A4D2, #6366F1, #D946EF, #00A4D2);
  background-size: 220% auto;
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
          mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
          mask-composite: exclude;
  opacity: 0;
  transition: opacity 280ms ease;
  pointer-events: none;
  animation: kpiBorderShift 6s linear infinite;
}
.kpi-row .kpi:hover::before { opacity: 0.85; }
@keyframes kpiBorderShift {
  0% { background-position: 0% 50%; }
  100% { background-position: 220% 50%; }
}

.kpi-row .kpi:hover {
  transform: translateY(-3px);
  box-shadow: 0 14px 38px rgba(99,102,241,0.14), 0 2px 6px rgba(0,0,0,0.04);
  border-color: transparent;
}
[data-theme="dark"] .kpi-row .kpi:hover {
  box-shadow: 0 14px 38px rgba(0,0,0,0.5), 0 0 0 1px rgba(99,102,241,0.18);
}

/* KPI icon-box gets a subtle gradient ring */
.kpi-row .kpi .kpi-icon-box {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, rgba(0,164,210,0.10), rgba(139,92,246,0.10));
  color: var(--accent-cyan, #00A4D2);
  transition: transform 280ms ease;
}
.kpi-row .kpi:hover .kpi-icon-box { transform: scale(1.06) rotate(-3deg); }

/* ─── Chart cards ─── */
.chart-card,
.charts-row .chart-card,
.table-widget {
  position: relative;
  background: var(--surface-card);
  border: 1px solid var(--hairline);
  border-radius: 16px;
  transition: transform 280ms cubic-bezier(0.22,1,0.36,1),
              box-shadow 280ms cubic-bezier(0.22,1,0.36,1);
  animation: chartReveal 700ms 200ms cubic-bezier(0.22,1,0.36,1) both;
  overflow: hidden;
}
@keyframes chartReveal {
  from { opacity: 0; transform: translateY(16px) scale(0.99); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.chart-card:hover,
.charts-row .chart-card:hover,
.table-widget:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 40px rgba(99,102,241,0.10), 0 2px 8px rgba(0,0,0,0.04);
}
[data-theme="dark"] .chart-card:hover,
[data-theme="dark"] .charts-row .chart-card:hover,
[data-theme="dark"] .table-widget:hover {
  box-shadow: 0 18px 40px rgba(0,0,0,0.55);
}

/* Top-right "live" dot on chart cards */
.chart-card .head,
.table-widget .head { position: relative; }
.chart-card .head::after,
.table-widget .head::after {
  content: "";
  position: absolute;
  top: 0; right: 0;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #10B981;
  box-shadow: 0 0 0 0 rgba(16,185,129,0.45);
  animation: dotPulse 2.4s ease-in-out infinite;
}

/* ─── Drill page tables (Top defaulters etc.) ─── */
.invoice-table tbody tr,
.def-table tbody tr,
.stock-table tbody tr,
.ledger-table tbody tr,
.parties-table tbody tr {
  position: relative;
  transition: background 200ms ease, transform 200ms ease;
}
.invoice-table tbody tr::before,
.def-table tbody tr::before,
.stock-table tbody tr::before,
.ledger-table tbody tr::before,
.parties-table tbody tr::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: linear-gradient(180deg, #00A4D2, #6366F1, #D946EF);
  opacity: 0;
  transition: opacity 220ms ease;
}
.invoice-table tbody tr:hover::before,
.def-table tbody tr:hover::before,
.stock-table tbody tr:hover::before,
.ledger-table tbody tr:hover::before,
.parties-table tbody tr:hover::before { opacity: 1; }
.invoice-table tbody tr:hover,
.def-table tbody tr:hover,
.stock-table tbody tr:hover,
.ledger-table tbody tr:hover,
.parties-table tbody tr:hover {
  background: linear-gradient(90deg, rgba(0,164,210,0.05), rgba(139,92,246,0.03), transparent);
}
[data-theme="dark"] .invoice-table tbody tr:hover,
[data-theme="dark"] .def-table tbody tr:hover,
[data-theme="dark"] .stock-table tbody tr:hover,
[data-theme="dark"] .ledger-table tbody tr:hover,
[data-theme="dark"] .parties-table tbody tr:hover {
  background: linear-gradient(90deg, rgba(0,164,210,0.10), rgba(139,92,246,0.06), transparent);
}

/* Tabular numerals for amount columns */
.invoice-table td.num,
.def-table td.num,
.stock-table td.num,
.ledger-table td.num,
.parties-table td.num,
.kpi .kpi-value {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

/* ─── Filter bars + buttons subtle polish ─── */
.filter-bar {
  background: linear-gradient(135deg, rgba(255,255,255,0.6), rgba(255,255,255,0.3));
  border: 1px solid rgba(255,255,255,0.4);
  backdrop-filter: blur(14px) saturate(160%);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
}
[data-theme="dark"] .filter-bar {
  background: linear-gradient(135deg, rgba(28,28,30,0.6), rgba(28,28,30,0.3));
  border-color: rgba(255,255,255,0.05);
}

/* Refresh button spin while busy */
#refreshBtn.spinning svg { animation: refreshSpin 800ms linear infinite; }
@keyframes refreshSpin { to { transform: rotate(360deg); } }


/* ────────────────────────────────────────────────────────────────────────
   MOBILE RESPONSIVE — Phase 22 Level-3 hero + polish breakpoints
   ──────────────────────────────────────────────────────────────────────── */

/* Tablets and below — hero stacks icon above text */
@media (max-width: 900px) {
  .page-header-hero {
    padding: 22px 20px 18px;
    border-radius: 16px;
    margin: 0 0 20px;
  }
  .page-header-content { gap: 14px; }
  .page-icon-glow { width: 48px; height: 48px; border-radius: 12px; }
  .page-icon-glow svg { width: 24px; height: 24px; }
  .page-title-gradient { font-size: 26px; }
  .page-desc { font-size: 13.5px; margin: 4px 0 10px; }
  /* Aurora gets a touch smaller */
  .aurora-1 { width: 240px; height: 240px; top: -100px; left: -60px; }
  .aurora-2 { width: 200px; height: 200px; top: -40px; right: -70px; }
}

/* Phones — hero goes vertical, chips wrap, action button drops below */
@media (max-width: 760px) {
  .page-header-hero {
    padding: 20px 18px 14px;
    border-radius: 14px;
    /* Disable 3D tilt on touch — feels weird without precise pointer */
    transform: none !important;
  }
  .page-header-content {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  .page-icon-glow {
    width: 44px; height: 44px; border-radius: 11px;
    animation-duration: 5s;            /* slower pulse on mobile */
  }
  .page-icon-glow svg { width: 22px; height: 22px; }
  .page-title-row { gap: 8px; }
  .page-title-gradient {
    font-size: 22px;
    letter-spacing: -0.02em;
    line-height: 1.15;
    /* Disable hover shimmer on touch (no hover state) */
  }
  .page-title-gradient::after { display: none; }
  .live-pill { padding: 3px 8px; font-size: 10px; }
  .page-desc {
    font-size: 13px;
    margin: 4px 0 8px;
    max-width: 100%;
  }
  .page-chips { gap: 6px; }
  .page-chip {
    padding: 4px 9px;
    font-size: 11px;
  }
  .page-chip svg { display: none; }    /* drop icons on tight chips */
  .page-underline { margin-top: 10px; }

  /* Pages where Export button is inside the hero (outstanding/stock/ledger) —
     it now flows below the text column */
  .page-header-content > button {
    width: 100%;
    align-self: stretch !important;
  }

  /* KPI row — single column at very small screens */
  .kpi-row { grid-template-columns: 1fr; gap: 12px; }
  .kpi-row .kpi { padding: 16px; }
  .kpi-row .kpi:hover { transform: none; }   /* avoid lift jitter on tap */

  /* Charts row — stack */
  .charts-row { grid-template-columns: 1fr !important; gap: 12px; }
  .chart-card:hover, .table-widget:hover { transform: none; }

  /* Filter bar — wrap inputs */
  .filter-bar { flex-wrap: wrap; gap: 8px; padding: 12px; }

  /* Topbar — show only avatar + name, hide subtitle if tight */
  .topbar { padding: 0 14px; gap: 10px; }
  .topbar .greeting .when { font-size: 11px; }

  /* Page background blur dims (perf: backdrop-filter is expensive on mobile) */
  .page::before {
    background:
      radial-gradient(circle at 0 0, rgba(0,164,210,0.05), transparent 50%),
      radial-gradient(circle at 100% 0, rgba(139,92,246,0.04), transparent 50%);
  }
}

/* Tiny phones (≤ 380px) */
@media (max-width: 380px) {
  .page-title-gradient { font-size: 20px; }
  .page-icon-glow { width: 40px; height: 40px; }
  .page-icon-glow svg { width: 20px; height: 20px; }
  .page-header-hero { padding: 16px 14px 12px; }
}


/* ────────────────────────────────────────────────────────────────────────
   SKELETON LOADING — composite shapes used by drill pages on initial load
   Pages render these on first paint, replace via JS once data fetches.
   ──────────────────────────────────────────────────────────────────────── */
.skel-kpi {
  background: var(--surface-card);
  border: 1px solid var(--hairline);
  border-radius: 16px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.skel-kpi .skel-icon { width: 36px; height: 36px; border-radius: 10px; }
.skel-kpi .skel-label { width: 50%; height: 11px; }
.skel-kpi .skel-value { width: 70%; height: 28px; margin-top: 4px; }
.skel-kpi .skel-delta { width: 35%; height: 14px; }

.skel-chart {
  background: var(--surface-card);
  border: 1px solid var(--hairline);
  border-radius: 16px;
  padding: 18px;
  min-height: 280px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.skel-chart .skel-head { width: 40%; height: 14px; }
.skel-chart .skel-sub { width: 25%; height: 10px; }
.skel-chart .skel-body { flex: 1; min-height: 200px; border-radius: 12px; }

.skel-table {
  background: var(--surface-card);
  border: 1px solid var(--hairline);
  border-radius: 16px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.skel-table .skel-row { display: flex; gap: 10px; }
.skel-table .skel-cell { height: 14px; flex: 1; }
.skel-table .skel-cell.narrow { flex: 0 0 80px; }

/* ── SECTION 3: Chat Styles (chat page specific) ── */
/* ─────────────────────────────────────────────────────────────────────────
   chat.css — Phase 20 Sprint 3 "ChatOS" stylesheet
   Loaded after app.css (and inherits all its tokens/components).
   Owns: chat layout shell, bubbles, composer, mic waveform, suggestion chips,
         typing indicator, typewriter cursor, slide-over panel, lightbox.
   ───────────────────────────────────────────────────────────────────────── */

/* ───────────────────────── 1. CHAT PAGE LAYOUT ───────────────────────── */
.chat-page {
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--topbar-h));
  min-height: 0;
  position: relative;
}

/* Hero greeting — visible only when chat is empty */
.chat-hero {
  padding: 32px 0 18px;
  text-align: center;
  animation: heroFadeIn 600ms var(--ease-apple) both;
}
@keyframes heroFadeIn {
  0%   { opacity: 0; transform: translateY(8px); }
  100% { opacity: 1; transform: translateY(0); }
}
.chat-hero h1 {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 8px;
  background: linear-gradient(120deg, var(--accent-cyan), var(--accent-violet) 60%, var(--accent-fuchsia));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.chat-hero p {
  font-size: 14.5px;
  color: var(--color-text-secondary);
  margin: 0;
}
.chat-hero .underline {
  display: block;
  width: 56px;
  height: 3px;
  margin: 14px auto 0;
  background: linear-gradient(90deg, var(--accent-cyan), var(--accent-violet));
  border-radius: 99px;
  opacity: 0.8;
  animation: underlineGrow 800ms var(--ease-pop) both;
}
@keyframes underlineGrow {
  0%   { width: 0; opacity: 0; }
  100% { width: 56px; opacity: 0.8; }
}

/* ───────────────────────── 2. SUGGESTION CHIPS ───────────────────────── */
.chips-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  padding: 16px 24px 20px;
}
.chip {
  --chip-fg: var(--color-text-primary);
  --chip-bg: var(--surface-card);
  --chip-border: var(--hairline-strong);
  --chip-glow: var(--accent-cyan-glow);

  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border: 1px solid var(--chip-border);
  background: var(--chip-bg);
  color: var(--chip-fg);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: transform 220ms var(--ease-pop),
              border-color 220ms ease,
              box-shadow 220ms ease,
              background 220ms ease;
  box-shadow: 0 1px 2px rgba(0,0,0,0.02);
}
.chip svg { width: 14px; height: 14px; flex-shrink: 0; opacity: 0.85; }
.chip:hover {
  transform: translateY(-2px);
  border-color: transparent;
  box-shadow: 0 8px 22px var(--chip-glow), 0 0 0 1.5px var(--accent-cyan);
}
.chip:active { transform: translateY(0) scale(0.97); }

/* Magnetic gradient border on hover via pseudo */
.chip::before {
  content: "";
  position: absolute; inset: -1.5px;
  border-radius: inherit;
  padding: 1.5px;
  background: linear-gradient(120deg, var(--accent-cyan), var(--accent-violet), var(--accent-fuchsia));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
          mask-composite: exclude;
  opacity: 0;
  transition: opacity 220ms ease;
  pointer-events: none;
}
.chip:hover::before { opacity: 1; }

/* Per-kind accent tinting */
.chip[data-kind="sales"]       { --chip-glow: var(--accent-emerald-glow); }
.chip[data-kind="sales"] svg   { color: var(--accent-emerald); }
.chip[data-kind="purchases"]   { --chip-glow: var(--accent-amber-glow); }
.chip[data-kind="purchases"] svg{ color: var(--accent-amber); }
.chip[data-kind="outstanding"] { --chip-glow: var(--accent-rose-glow); }
.chip[data-kind="outstanding"] svg { color: var(--accent-rose); }
.chip[data-kind="stock"]       { --chip-glow: var(--accent-indigo-glow); }
.chip[data-kind="stock"] svg   { color: var(--accent-indigo); }
.chip[data-kind="ledger"]      { --chip-glow: var(--accent-violet-glow); }
.chip[data-kind="ledger"] svg  { color: var(--accent-violet); }
.chip[data-kind="expenses"]    { --chip-glow: var(--accent-fuchsia-glow); }
.chip[data-kind="expenses"] svg{ color: var(--accent-fuchsia); }
.chip[data-kind="generic"] svg { color: var(--accent-cyan); }
.chip[data-kind="payments"] svg{ color: var(--accent-cyan); }
.chip[data-kind="leads"] svg   { color: var(--accent-violet); }
.chip[data-kind="tasks"] svg   { color: var(--accent-indigo); }

/* Stagger entrance for chips */
.chip { opacity: 0; transform: translateY(8px); animation: chipRise 480ms var(--ease-pop) forwards; }
.chip[data-i="0"] { animation-delay: 60ms; }
.chip[data-i="1"] { animation-delay: 120ms; }
.chip[data-i="2"] { animation-delay: 180ms; }
.chip[data-i="3"] { animation-delay: 240ms; }
.chip[data-i="4"] { animation-delay: 300ms; }
.chip[data-i="5"] { animation-delay: 360ms; }
.chip[data-i="6"] { animation-delay: 420ms; }
.chip[data-i="7"] { animation-delay: 480ms; }
@keyframes chipRise {
  to { opacity: 1; transform: translateY(0); }
}

/* ───────────────────────── 3. CHAT STREAM + BUBBLES ───────────────────────── */
.chat-stream {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 8px 4vw 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}
.chat-stream::-webkit-scrollbar { width: 8px; }
.chat-stream::-webkit-scrollbar-thumb { background: var(--hairline-strong); border-radius: 4px; }
.chat-stream::-webkit-scrollbar-thumb:hover { background: var(--color-text-tertiary); }

.bubble-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  max-width: 880px;
  width: 100%;
  margin: 0 auto;
  animation: bubbleRise 460ms var(--ease-pop) both;
}
@keyframes bubbleRise {
  0%   { opacity: 0; transform: translateY(12px) scale(0.985); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}
.bubble-row.user { flex-direction: row-reverse; }

.avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 700;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.avatar.bot {
  background: linear-gradient(135deg, #1C1C1E, #3a3a3c);
  color: #fff;
}
.avatar.user {
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-indigo));
  color: #fff;
}

.bubble {
  position: relative;
  padding: 11px 16px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.55;
  max-width: 76%;
  word-break: break-word;
  white-space: pre-wrap;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
  transition: box-shadow 240ms var(--ease-apple);
}
.bubble:hover { box-shadow: 0 6px 18px rgba(0,0,0,0.06); }

.bubble.user {
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-indigo));
  color: #fff;
  border-bottom-right-radius: 6px;
}
.bubble.bot {
  background: var(--surface-card);
  border: 1px solid var(--hairline);
  color: var(--color-text-primary);
  border-bottom-left-radius: 6px;
}
[data-theme="dark"] .bubble.bot {
  background: rgba(255,255,255,0.04);
  border-color: rgba(255,255,255,0.08);
}

/* Subtle violet edge on AI bubble for premium feel */
.bubble.bot::before {
  content: "";
  position: absolute;
  left: 0; top: 8px; bottom: 8px;
  width: 3px;
  border-radius: 99px;
  background: linear-gradient(180deg, var(--accent-violet), var(--accent-indigo));
  opacity: 0.55;
}

/* HTML content (tables, charts) */
.bubble.html {
  max-width: 92%;
  padding: 12px 14px;
  background: var(--surface-card);
  border: 1px solid var(--hairline);
  overflow-x: auto;
}
.bubble.html table {
  border-collapse: collapse !important;
  font-size: 12.5px !important;
  font-family: inherit !important;
  width: 100%;
}
.bubble.html th {
  padding: 7px 10px !important;
  border: 1px solid var(--hairline-strong) !important;
  background: var(--accent-cyan-soft) !important;
  color: var(--color-text-primary) !important;
  font-weight: 600 !important;
  text-align: left !important;
  white-space: nowrap !important;
}
.bubble.html td {
  padding: 6px 10px !important;
  border: 1px solid var(--hairline) !important;
  white-space: nowrap !important;
  font-size: 12.5px !important;
}
.bubble.html tbody tr:nth-child(even) td { background: var(--surface-canvas) !important; }
.bubble.html tbody tr:hover td { background: var(--accent-cyan-soft) !important; }
.bubble.html td a { color: var(--accent-cyan); text-decoration: none; font-weight: 500; }
.bubble.html td a:hover { text-decoration: underline; }

.bubble .ts {
  font-size: 10.5px;
  color: var(--color-text-tertiary);
  margin-top: 4px;
  opacity: 0.8;
}
.bubble.user .ts { color: rgba(255,255,255,0.75); }

.bubble-col { display: flex; flex-direction: column; min-width: 0; }
.bubble-row.user .bubble-col { align-items: flex-end; }

/* Markdown bold inside bubbles */
.bubble b, .bubble strong { font-weight: 700; }
.bubble code {
  font-family: var(--font-mono);
  font-size: 12.5px;
  background: var(--accent-cyan-soft);
  padding: 1px 5px;
  border-radius: 4px;
}

/* Typewriter cursor blink (used while streaming) */
.bubble.typing-cursor::after {
  content: "▍";
  display: inline-block;
  margin-left: 2px;
  color: var(--accent-cyan);
  animation: caretBlink 900ms steps(2) infinite;
}
@keyframes caretBlink {
  0%, 49%   { opacity: 1; }
  50%, 100% { opacity: 0; }
}

/* ───────────────────────── 4. TYPING INDICATOR ───────────────────────── */
.typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 13px 16px;
}
.typing-dots span {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--color-text-tertiary);
  animation: typingBounce 1.2s infinite ease-in-out;
}
.typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.typing-dots span:nth-child(3) { animation-delay: 0.30s; }
@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30%           { transform: translateY(-6px); opacity: 1; }
}

/* ───────────────────────── 5. ATTACHMENTS ───────────────────────── */
.attachments {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}
.att-img {
  width: 100%;
  max-width: 560px;
  max-height: 420px;
  border-radius: 12px;
  border: 1px solid var(--hairline);
  cursor: zoom-in;
  object-fit: contain;
  background: var(--surface-canvas);
  transition: transform 220ms var(--ease-apple);
}
.att-img:hover { transform: scale(1.005); }
.att-caption {
  font-size: 12px;
  color: var(--color-text-secondary);
  margin-top: 2px;
}
.att-doc {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid var(--hairline);
  border-radius: 12px;
  text-decoration: none;
  color: var(--color-text-primary);
  background: var(--surface-card);
  font-size: 13px;
  transition: transform 200ms var(--ease-pop), border-color 200ms ease, box-shadow 200ms ease;
  max-width: 360px;
}
.att-doc:hover {
  transform: translateY(-1px);
  border-color: var(--accent-cyan);
  box-shadow: 0 6px 18px var(--accent-cyan-glow);
}
.att-icon { font-size: 18px; }
.att-name { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-meta { color: var(--color-text-tertiary); font-size: 11.5px; }

/* ───────────────────────── 6. COMPOSER ───────────────────────── */
.composer-wrap {
  position: sticky;
  bottom: 0;
  padding: 12px 4vw 18px;
  background: linear-gradient(180deg, transparent, var(--surface-canvas) 38%);
}
.composer {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  max-width: 880px;
  margin: 0 auto;
  padding: 8px 10px 8px 14px;
  background: var(--surface-glass-strong);
  -webkit-backdrop-filter: blur(28px) saturate(150%);
          backdrop-filter: blur(28px) saturate(150%);
  border: 1px solid var(--hairline-strong);
  border-radius: 22px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.06), 0 0 0 1px rgba(255,255,255,0.04) inset;
  transition: box-shadow 220ms ease, border-color 220ms ease, transform 220ms var(--ease-pop);
}
.composer:focus-within {
  border-color: transparent;
  box-shadow: 0 12px 44px var(--accent-cyan-glow), 0 0 0 2px var(--accent-cyan);
}

.composer-input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  resize: none;
  font: inherit;
  font-size: 14.5px;
  color: var(--color-text-primary);
  padding: 8px 4px;
  min-height: 24px;
  max-height: 180px;
  line-height: 1.5;
}
.composer-input::placeholder { color: var(--color-text-tertiary); }

.composer-btn {
  flex-shrink: 0;
  display: grid; place-items: center;
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 1px solid transparent;
  background: transparent;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: transform 200ms var(--ease-pop), background 200ms ease, color 200ms ease, box-shadow 200ms ease;
}
.composer-btn:hover {
  background: var(--accent-cyan-soft);
  color: var(--accent-cyan);
  transform: scale(1.06);
}
.composer-btn svg { width: 18px; height: 18px; }
.composer-btn.send {
  width: 42px; height: 42px;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-indigo));
  color: #fff;
  box-shadow: 0 6px 18px var(--accent-cyan-glow);
}
.composer-btn.send:hover {
  transform: translateY(-1px) scale(1.04);
  box-shadow: 0 10px 26px var(--accent-cyan-glow), 0 0 0 4px rgba(0,164,210,0.18);
}
.composer-btn.send:active { transform: scale(0.96); }
.composer-btn.send:disabled,
.composer-btn:disabled {
  opacity: 0.4; cursor: not-allowed; transform: none; box-shadow: none;
}

/* ───────────────────────── 7. MIC + WAVEFORM ───────────────────────── */
.mic-btn { position: relative; }
.mic-btn.recording {
  color: #fff;
  background: linear-gradient(135deg, var(--accent-rose), var(--accent-fuchsia));
  box-shadow: 0 0 0 0 var(--accent-rose-glow);
  animation: micPulse 1.4s ease-out infinite;
}
@keyframes micPulse {
  0%   { box-shadow: 0 0 0 0   var(--accent-rose-glow); }
  100% { box-shadow: 0 0 0 14px rgba(244,63,94,0); }
}

.waveform-wrap {
  position: absolute;
  bottom: 78px;
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  width: min(560px, 84vw);
  padding: 10px 14px;
  background: var(--surface-glass-strong);
  -webkit-backdrop-filter: blur(28px) saturate(150%);
          backdrop-filter: blur(28px) saturate(150%);
  border: 1px solid var(--hairline-strong);
  border-radius: 16px;
  box-shadow: 0 16px 40px rgba(0,0,0,0.10);
  display: none;
  align-items: center;
  gap: 12px;
  opacity: 0;
  transition: opacity 220ms ease, transform 320ms var(--ease-pop);
  z-index: 5;
}
.waveform-wrap.show {
  display: flex;
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.waveform-wrap canvas {
  flex: 1;
  height: 36px;
  display: block;
}
.waveform-wrap .rec-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--accent-rose);
  animation: dotBlink 800ms ease-in-out infinite;
}
@keyframes dotBlink {
  50% { opacity: 0.3; }
}
.waveform-wrap .rec-time {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--color-text-secondary);
  min-width: 38px;
}
.waveform-wrap .rec-stop {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: none;
  background: var(--accent-rose);
  color: #fff;
  cursor: pointer;
  display: grid; place-items: center;
}

/* ───────────────────────── 8. SLIDE-OVER PANEL ───────────────────────── */
.slideover-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.20);
  -webkit-backdrop-filter: blur(8px);
          backdrop-filter: blur(8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 280ms var(--ease-apple);
  z-index: 50;
}
.slideover-backdrop.show {
  opacity: 1;
  pointer-events: auto;
}
.slideover {
  position: fixed;
  top: 0; right: 0;
  height: 100vh;
  width: min(420px, 92vw);
  background: var(--surface-card);
  border-left: 1px solid var(--hairline-strong);
  box-shadow: -20px 0 60px rgba(0,0,0,0.10);
  transform: translateX(110%);
  transition: transform 460ms cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 51;
  display: flex;
  flex-direction: column;
}
.slideover.show { transform: translateX(0); }

.slideover-head {
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--hairline);
  display: flex; align-items: center; justify-content: space-between;
}
.slideover-head h3 {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0;
}
.slideover-close {
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 1px solid var(--hairline);
  background: transparent;
  color: var(--color-text-secondary);
  cursor: pointer;
  display: grid; place-items: center;
  transition: background 200ms, color 200ms, transform 200ms var(--ease-pop);
}
.slideover-close:hover { background: var(--accent-rose-soft); color: var(--accent-rose); transform: rotate(90deg); }

.slideover-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 22px 22px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.so-section h4 {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-tertiary);
  margin: 0 0 10px;
}
.so-card {
  border: 1px solid var(--hairline);
  border-radius: 14px;
  padding: 14px;
  background: var(--surface-card);
}
.so-input-row {
  display: flex; gap: 8px;
}
.so-input {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid var(--hairline-strong);
  border-radius: 10px;
  font: inherit; font-size: 13px;
  outline: none;
  background: var(--surface-canvas);
  color: var(--color-text-primary);
  transition: border-color 180ms, box-shadow 180ms;
}
.so-input:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 3px var(--accent-cyan-soft);
}
.so-btn {
  padding: 10px 14px;
  border-radius: 10px;
  border: none;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-indigo));
  color: #fff;
  font: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer;
  transition: transform 180ms var(--ease-pop), box-shadow 180ms;
}
.so-btn:hover { transform: translateY(-1px); box-shadow: 0 8px 22px var(--accent-cyan-glow); }
.so-btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; box-shadow: none; }
.so-btn.ghost {
  background: transparent;
  color: var(--color-text-primary);
  border: 1px solid var(--hairline-strong);
}
.so-btn.ghost:hover { background: var(--accent-cyan-soft); border-color: var(--accent-cyan); color: var(--accent-cyan); box-shadow: none; }

.so-result {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--accent-cyan-soft);
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--color-text-primary);
  white-space: pre-wrap;
  display: none;
}
.so-result.show { display: block; }

/* Drop zone */
.drop-zone {
  border: 1.5px dashed var(--hairline-strong);
  border-radius: 14px;
  padding: 22px 16px;
  text-align: center;
  background: var(--surface-canvas);
  color: var(--color-text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: border-color 200ms, background 200ms, color 200ms;
}
.drop-zone svg { width: 26px; height: 26px; margin-bottom: 6px; opacity: 0.65; }
.drop-zone:hover, .drop-zone.dragover {
  border-color: var(--accent-cyan);
  background: var(--accent-cyan-soft);
  color: var(--accent-cyan);
}

/* Sync row */
.sync-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px;
}
.sync-status {
  font-size: 12.5px;
  color: var(--color-text-secondary);
}
.sync-status .ok-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent-emerald);
  margin-right: 6px;
  vertical-align: middle;
}

/* ───────────────────────── 9. IMAGE LIGHTBOX ───────────────────────── */
.lightbox {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.78);
  -webkit-backdrop-filter: blur(20px);
          backdrop-filter: blur(20px);
  display: none;
  align-items: center; justify-content: center;
  z-index: 60;
  opacity: 0;
  transition: opacity 240ms ease;
  cursor: zoom-out;
}
.lightbox.show { display: flex; opacity: 1; }
.lightbox img {
  max-width: 96vw;
  max-height: 92vh;
  border-radius: 14px;
  box-shadow: 0 30px 80px rgba(0,0,0,0.5);
  transform: scale(0.92);
  transition: transform 380ms var(--ease-pop);
}
.lightbox.show img { transform: scale(1); }
.lightbox .close {
  position: absolute; top: 22px; right: 22px;
  width: 38px; height: 38px;
  border-radius: 50%;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.25);
  color: #fff;
  cursor: pointer;
  display: grid; place-items: center;
  font-size: 20px;
  transition: transform 200ms var(--ease-pop), background 200ms;
}
.lightbox .close:hover { background: rgba(255,255,255,0.22); transform: rotate(90deg) scale(1.05); }

/* ───────────────────────── 10. RESPONSIVE ───────────────────────── */
@media (max-width: 760px) {
  .chat-hero h1 { font-size: 24px; }
  .chip { font-size: 12.5px; padding: 9px 14px; }
  .bubble { max-width: 88%; font-size: 13.5px; }
  .composer-wrap { padding: 10px 14px 14px; }
  .composer { padding: 6px 8px 6px 12px; gap: 6px; }
  .composer-btn { width: 34px; height: 34px; }
  .composer-btn.send { width: 38px; height: 38px; }
}

@media (prefers-reduced-motion: reduce) {
  .chat-hero, .chat-hero .underline, .bubble-row, .chip,
  .typing-dots span, .lightbox img, .att-img,
  .mic-btn.recording, .waveform-wrap .rec-dot {
    animation: none !important;
    transition: none !important;
  }
}


/* ═══════════════════════════════════════════════════════════════════
   POLISH PASS (additive — does not break existing styles)
   ═══════════════════════════════════════════════════════════════════ */

/* ── Bubble polish: bigger radius, subtle gradient, deeper shadow on hover ── */
.bubble {
  border-radius: 22px;
  padding: 13px 18px;
}
.bubble.user { border-bottom-right-radius: 8px; }
.bubble.bot  { border-bottom-left-radius: 8px; }

/* AI bubble: subtle vertical gradient (top white → soft canvas) */
.bubble.bot {
  background: linear-gradient(180deg, var(--surface-card) 0%, var(--surface-canvas) 100%);
  box-shadow: 0 1px 2px rgba(0,0,0,0.03), 0 0 0 1px var(--hairline) inset;
  border: none;
}
[data-theme="dark"] .bubble.bot {
  background: linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.02));
  box-shadow: 0 1px 2px rgba(0,0,0,0.4), 0 0 0 1px rgba(255,255,255,0.06) inset;
}
.bubble.bot:hover {
  box-shadow: 0 6px 22px rgba(0,0,0,0.06), 0 0 0 1px var(--hairline-strong) inset;
  transform: translateY(-1px);
}
.bubble.user {
  box-shadow: 0 4px 14px var(--accent-cyan-glow);
}
.bubble.user:hover {
  box-shadow: 0 8px 22px var(--accent-cyan-glow);
  transform: translateY(-1px);
}

/* Slightly tighter line-height for big lists */
.bubble.bot { line-height: 1.6; }

/* Bubble row spacing bump */
.chat-stream { gap: 18px; }

/* ── Money pill — ₹X.XX values get auto-wrapped ── */
.bubble .money {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  background: var(--accent-cyan-soft);
  color: var(--color-text-primary);
  padding: 1px 7px;
  border-radius: 6px;
  white-space: nowrap;
  letter-spacing: -0.005em;
  vertical-align: 1px;
}
.bubble.user .money {
  background: rgba(255,255,255,0.20);
  color: #fff;
}

/* Larger headline-style for very big totals */
.bubble .money.big {
  font-size: 14.5px;
  background: linear-gradient(135deg, var(--accent-emerald-soft), var(--accent-cyan-soft));
  color: var(--accent-emerald);
  font-weight: 700;
  padding: 2px 10px;
}
[data-theme="dark"] .bubble .money.big {
  background: linear-gradient(135deg, rgba(16,185,129,0.18), rgba(0,164,210,0.18));
  color: #34D399;
}

/* ── Result card variant — bubbles that look like data tables ── */
.bubble.bot.result-card {
  padding: 14px 18px 16px;
  background: linear-gradient(180deg,
    var(--surface-card) 0%,
    color-mix(in srgb, var(--accent-violet-soft) 25%, var(--surface-card)) 100%);
  box-shadow:
    0 4px 18px rgba(139, 92, 246, 0.05),
    0 0 0 1px var(--hairline) inset,
    inset 0 1px 0 rgba(255,255,255,0.5);
}
[data-theme="dark"] .bubble.bot.result-card {
  background: linear-gradient(180deg,
    rgba(255,255,255,0.04) 0%,
    rgba(139,92,246,0.06) 100%);
  box-shadow: 0 4px 18px rgba(0,0,0,0.4), 0 0 0 1px rgba(255,255,255,0.06) inset;
}
.bubble.bot.result-card::before {
  /* keep existing violet edge but make it more vivid for result cards */
  background: linear-gradient(180deg, var(--accent-violet), var(--accent-fuchsia), var(--accent-cyan));
  opacity: 0.85;
  width: 3px;
  left: 0; top: 10px; bottom: 10px;
}

/* ── Cycling placeholder fade ── */
.composer-input.ph-fade::placeholder {
  animation: phFadeIn 320ms var(--ease-apple) both;
}
@keyframes phFadeIn {
  from { opacity: 0; transform: translateY(2px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Scroll-to-bottom FAB ── */
.scroll-fab {
  position: fixed;
  right: max(28px, calc(50vw - 440px - 32px));
  bottom: 92px;
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 1px solid var(--hairline-strong);
  background: var(--surface-glass-strong);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
          backdrop-filter: blur(20px) saturate(150%);
  color: var(--color-text-primary);
  cursor: pointer;
  display: grid; place-items: center;
  box-shadow: 0 8px 22px rgba(0,0,0,0.10);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px) scale(0.9);
  transition: opacity 240ms var(--ease-apple), transform 320ms var(--ease-pop);
  z-index: 30;
  animation: fabBob 3.6s ease-in-out infinite;
}
.scroll-fab svg { width: 18px; height: 18px; }
.scroll-fab:hover {
  background: var(--accent-cyan);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 10px 26px var(--accent-cyan-glow);
}
.scroll-fab.show {
  opacity: 1; pointer-events: auto;
  transform: translateY(0) scale(1);
}
@keyframes fabBob {
  0%, 100% { transform: translateY(0) scale(1); }
  50%      { transform: translateY(-3px) scale(1); }
}
.scroll-fab .badge {
  position: absolute;
  top: -3px; right: -3px;
  min-width: 18px; height: 18px;
  border-radius: 9px;
  background: var(--accent-rose);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  display: grid; place-items: center;
  padding: 0 5px;
  box-shadow: 0 0 0 2px var(--surface-canvas);
}

/* ── Date divider ── */
.date-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 880px;
  width: 100%;
  margin: 14px auto 6px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-tertiary);
}
.date-divider::before,
.date-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--hairline-strong), transparent);
}

/* ── SECTION 4: Common Page Overrides (shared across all app pages) ── */
.nav-item.active { color: var(--color-primary-600); background: var(--color-primary-50); }
[data-theme="dark"] .nav-item.active { color: var(--accent-cyan); background: rgba(0,164,210,0.10); }
.mobile-toggle { display: none; }
.greeting .who { font-size: 16px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.greeting .when { font-size: 11px; color: var(--color-text-tertiary); margin-top: 2px; }
.greeting .who .status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent-emerald, #10B981); box-shadow: 0 0 0 0 rgba(16,185,129, 0.5); animation: dotPulse 2.4s ease-in-out infinite; }
.tenant-avatar { width: 30px; height: 30px; border-radius: 8px; background: linear-gradient(135deg, #00A4D2, #6366F1, #D946EF); color: #fff; font-weight: 700; font-size: 13px; display: grid; place-items: center; flex-shrink: 0; transition: transform 220ms ease; box-shadow: 0 4px 14px rgba(99, 102, 241, 0.28); }
.tenant-avatar:hover { transform: scale(1.05) rotate(-2deg); }
[data-theme="dark"] .tenant-avatar { box-shadow: 0 0 0 3px rgba(0,164,210,0.18), 0 4px 10px rgba(0,164,210,0.30); }
@keyframes dotPulse { 0%,100% { box-shadow: 0 0 0 0 rgba(16,185,129, 0.5); } 50% { box-shadow: 0 0 0 6px rgba(16,185,129, 0); } }

/* Common page components */
.page-grid { display: grid; gap: 18px; }
.chart-card { background: var(--surface-card); border: 1px solid var(--hairline); border-radius: 16px; padding: 18px 20px; position: relative; overflow: hidden; }
.chart-card .body { height: 280px; position: relative; }
.chart-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px; }
.chart-icon { width: 36px; height: 36px; border-radius: 10px; background: var(--color-primary-50); color: var(--color-primary-400); display: grid; place-items: center; }
[data-theme="dark"] .chart-icon { background: rgba(0,164,210,0.16); }
.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding: 16px 20px; background: var(--surface-card); border: 1px solid var(--hairline); border-radius: 14px; }
.filter-bar input { flex: 1; min-width: 200px; padding: 9px 14px; border-radius: 10px; border: 1px solid var(--hairline); background: var(--surface-page); color: var(--color-text-primary); font-size: 14px; }
.filter-bar input:focus { outline: 2px solid var(--color-primary-300); border-color: transparent; }
.filter-bar .btn { padding: 9px 16px; border-radius: 10px; background: var(--color-primary-500); color: #fff; font-weight: 600; font-size: 13px; cursor: pointer; border: none; }
.filter-bar .btn:hover { background: var(--color-primary-600); }
.filter-bar .meta { color: var(--color-text-tertiary); font-size: 13px; padding: 0 6px; }
.invoice-table { background: var(--surface-card); border: 1px solid var(--hairline); border-radius: 14px; padding: 18px 20px; }
.invoice-table table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.invoice-table th { text-align: left; font-weight: 600; color: var(--color-text-tertiary); text-transform: uppercase; font-size: 11px; letter-spacing: 0.06em; padding: 10px 12px; border-bottom: 1px solid var(--hairline); }
.invoice-table td { padding: 12px; border-bottom: 1px solid var(--hairline); color: var(--color-text-primary); }
.invoice-table tr:hover td { background: var(--color-primary-50); }
[data-theme="dark"] .invoice-table tr:hover td { background: rgba(0,164,210,0.06); }
.invoice-table td.num { text-align: right; font-family: var(--font-mono); font-weight: 600; }
.pager { display: flex; gap: 10px; justify-content: flex-end; align-items: center; padding-top: 14px; }
.pager button { padding: 7px 14px; border-radius: 8px; border: 1px solid var(--hairline); background: var(--surface-card); color: var(--color-text-primary); cursor: pointer; font-size: 13px; }
.pager button:disabled { opacity: 0.4; cursor: not-allowed; }
.pager button:hover:not(:disabled) { background: var(--color-primary-50); }
[data-theme="dark"] .pager button:hover:not(:disabled) { background: rgba(0,164,210,0.08); }
.pager .info { color: var(--color-text-tertiary); font-size: 13px; margin-right: auto; }
.empty-state { text-align: center; padding: 60px 20px; color: var(--color-text-tertiary); }
.empty-state .ic { font-size: 48px; margin-bottom: 12px; }

@media (max-width: 760px) {
  .mobile-toggle { display: block; }
}

/* ═══════════════════════════════════════════════════════════════════
   SECTION 5: Page-Specific Styles
   (moved from inline <style> blocks in Blade views)
═══════════════════════════════════════════════════════════════════ */


/* ── PAGE: sales ── */
  /* Page-local layout — mirrors dashboard's grid + chart-card patterns */
  .page-grid { display: grid; gap: 18px; }
  .kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
  .charts-row { display: grid; grid-template-columns: 2fr 1fr; gap: 14px; }
  .charts-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
  @media (max-width: 1100px) {
    .kpi-row { grid-template-columns: repeat(2, 1fr); }
    .charts-row, .charts-row-2 { grid-template-columns: 1fr; }
  }
  .chart-card { background: var(--surface-card); border: 1px solid var(--hairline); border-radius: 16px; padding: 18px 20px; position: relative; overflow: hidden; }
  .chart-card .body { height: 280px; position: relative; }
  .chart-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px; }
  .chart-icon { width: 36px; height: 36px; border-radius: 10px; background: var(--color-primary-50); color: var(--color-primary-400); display: grid; place-items: center; }
  [data-theme="dark"] .chart-icon { background: rgba(0,164,210,0.16); }
  .filter-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding: 16px 20px; background: var(--surface-card); border: 1px solid var(--hairline); border-radius: 14px; }
  .filter-bar input { flex: 1; min-width: 200px; padding: 9px 14px; border-radius: 10px; border: 1px solid var(--hairline); background: var(--surface-page); color: var(--color-text-primary); font-size: 14px; }
  .filter-bar input:focus { outline: 2px solid var(--color-primary-300); border-color: transparent; }
  .filter-bar .btn { padding: 9px 16px; border-radius: 10px; background: var(--color-primary-500); color: #fff; font-weight: 600; font-size: 13px; cursor: pointer; border: none; }
  .filter-bar .btn:hover { background: var(--color-primary-600); }
  .filter-bar .meta { color: var(--color-text-tertiary); font-size: 13px; padding: 0 6px; }
  .invoice-table { background: var(--surface-card); border: 1px solid var(--hairline); border-radius: 14px; padding: 18px 20px; }
  .invoice-table table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
  .invoice-table th { text-align: left; font-weight: 600; color: var(--color-text-tertiary); text-transform: uppercase; font-size: 11px; letter-spacing: 0.06em; padding: 10px 12px; border-bottom: 1px solid var(--hairline); }
  .invoice-table td { padding: 12px; border-bottom: 1px solid var(--hairline); color: var(--color-text-primary); }
  .invoice-table tr:hover td { background: var(--color-primary-50); }
  [data-theme="dark"] .invoice-table tr:hover td { background: rgba(0,164,210,0.06); }
  .invoice-table td.num { text-align: right; font-family: var(--font-mono); font-weight: 600; }
  .pager { display: flex; gap: 10px; justify-content: flex-end; align-items: center; padding-top: 14px; }
  .pager button { padding: 7px 14px; border-radius: 8px; border: 1px solid var(--hairline); background: var(--surface-card); color: var(--color-text-primary); cursor: pointer; font-size: 13px; }
  .pager button:disabled { opacity: 0.4; cursor: not-allowed; }
  .pager button:hover:not(:disabled) { background: var(--color-primary-50); }
  [data-theme="dark"] .pager button:hover:not(:disabled) { background: rgba(0,164,210,0.08); }
  .pager .info { color: var(--color-text-tertiary); font-size: 13px; margin-right: auto; }
  .empty-state { text-align: center; padding: 60px 20px; color: var(--color-text-tertiary); }
  .empty-state .ic { font-size: 48px; margin-bottom: 12px; }

/* ── PAGE: outstanding ── */
  .page-grid { display: grid; gap: 18px; }
  .kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
  .charts-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
  @media (max-width: 1100px) { .kpi-row { grid-template-columns: repeat(2, 1fr); } .charts-row { grid-template-columns: 1fr; } }
  .chart-card { background: var(--surface-card); border: 1px solid var(--hairline); border-radius: 16px; padding: 18px 20px; position: relative; overflow: hidden; }
  .chart-card .body { height: 280px; position: relative; }
  .chart-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px; }
  .chart-icon { width: 36px; height: 36px; border-radius: 10px; background: rgba(244,63,94,0.10); color: var(--accent-rose, #F43F5E); display: grid; place-items: center; }
  [data-theme="dark"] .chart-icon { background: rgba(244,63,94,0.18); }
  .defaulters { background: var(--surface-card); border: 1px solid var(--hairline); border-radius: 14px; padding: 18px 20px; }
  .defaulters table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
  .defaulters th { text-align: left; font-weight: 600; color: var(--color-text-tertiary); text-transform: uppercase; font-size: 11px; letter-spacing: 0.06em; padding: 10px 12px; border-bottom: 1px solid var(--hairline); }
  .defaulters td { padding: 12px; border-bottom: 1px solid var(--hairline); color: var(--color-text-primary); }
  .defaulters tr:hover td { background: rgba(244,63,94,0.04); }
  [data-theme="dark"] .defaulters tr:hover td { background: rgba(244,63,94,0.08); }
  .defaulters td.num { text-align: right; font-family: var(--font-mono); font-weight: 600; }
  .age-pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 600; font-family: var(--font-mono); }
  .age-pill.bg-30 { background: rgba(16,185,129,0.12); color: #10B981; }
  .age-pill.bg-60 { background: rgba(245,158,11,0.12); color: #F59E0B; }
  .age-pill.bg-90 { background: rgba(244,63,94,0.12); color: #F43F5E; }
  .age-pill.bg-99 { background: rgba(217,70,239,0.16); color: #D946EF; }
  .empty-state { text-align: center; padding: 60px 20px; color: var(--color-text-tertiary); grid-column: 1 / -1; }
  .empty-state .ic { font-size: 48px; margin-bottom: 12px; }

/* ── PAGE: stock ── */
  .page-grid { display: grid; gap: 18px; }
  .kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
  .charts-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
  @media (max-width: 1100px) { .kpi-row { grid-template-columns: repeat(2, 1fr); } .charts-row { grid-template-columns: 1fr; } }
  .chart-card { background: var(--surface-card); border: 1px solid var(--hairline); border-radius: 16px; padding: 18px 20px; position: relative; overflow: hidden; }
  .chart-card .body { height: 320px; position: relative; }
  .chart-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px; }
  .chart-icon { width: 36px; height: 36px; border-radius: 10px; background: rgba(99,102,241,0.12); color: #6366F1; display: grid; place-items: center; }
  [data-theme="dark"] .chart-icon { background: rgba(99,102,241,0.20); }
  .stock-table { background: var(--surface-card); border: 1px solid var(--hairline); border-radius: 14px; padding: 18px 20px; }
  .stock-table table { width: 100%; border-collapse: collapse; font-size: 13px; }
  .stock-table th { text-align: left; font-weight: 600; color: var(--color-text-tertiary); text-transform: uppercase; font-size: 11px; letter-spacing: 0.06em; padding: 10px 12px; border-bottom: 1px solid var(--hairline); }
  .stock-table td { padding: 10px 12px; border-bottom: 1px solid var(--hairline); color: var(--color-text-primary); }
  .stock-table tr:hover td { background: rgba(99,102,241,0.04); }
  [data-theme="dark"] .stock-table tr:hover td { background: rgba(99,102,241,0.08); }
  .stock-table td.num { text-align: right; font-family: var(--font-mono); font-weight: 600; }
  .badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 600; }
  .badge.low { background: rgba(244,63,94,0.12); color: #F43F5E; }
  .badge.slow { background: rgba(245,158,11,0.12); color: #F59E0B; }
  .badge.healthy { background: rgba(16,185,129,0.12); color: #10B981; }
  .empty-state { text-align: center; padding: 60px 20px; color: var(--color-text-tertiary); grid-column: 1 / -1; }
  .empty-state .ic { font-size: 48px; margin-bottom: 12px; }

/* ── PAGE: ledger ── */
  .page-grid { display: grid; gap: 18px; }
  .filter-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding: 16px 20px; background: var(--surface-card); border: 1px solid var(--hairline); border-radius: 14px; }
  .filter-bar input { flex: 1; min-width: 240px; padding: 9px 14px; border-radius: 10px; border: 1px solid var(--hairline); background: var(--surface-page); color: var(--color-text-primary); font-size: 14px; }
  .filter-bar input:focus { outline: 2px solid var(--color-primary-300); border-color: transparent; }
  .filter-bar .btn { padding: 9px 18px; border-radius: 10px; background: var(--color-primary-500); color: #fff; font-weight: 600; font-size: 13px; cursor: pointer; border: none; }
  .filter-bar .btn:hover { background: var(--color-primary-600); }
  .balance-card { background: var(--surface-card); border: 1px solid var(--hairline); border-radius: 16px; padding: 22px 24px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; align-items: center; }
  .balance-card.empty { grid-template-columns: 1fr; text-align: center; padding: 60px 20px; color: var(--color-text-tertiary); }
  .balance-stat { padding: 4px 0; }
  .balance-stat .lbl { font-size: 11px; color: var(--color-text-tertiary); text-transform: uppercase; letter-spacing: 0.06em; }
  .balance-stat .val { font-family: var(--font-mono); font-size: 22px; font-weight: 700; margin-top: 4px; }
  .balance-stat.party .val { font-family: inherit; font-size: 17px; line-height: 1.3; }
  .balance-stat.net .val.positive { color: #10B981; }
  .balance-stat.net .val.negative { color: #F43F5E; }
  .timeline { background: var(--surface-card); border: 1px solid var(--hairline); border-radius: 14px; padding: 18px 20px; }
  .timeline table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
  .timeline th { text-align: left; font-weight: 600; color: var(--color-text-tertiary); text-transform: uppercase; font-size: 11px; letter-spacing: 0.06em; padding: 10px 12px; border-bottom: 1px solid var(--hairline); }
  .timeline td { padding: 11px 12px; border-bottom: 1px solid var(--hairline); color: var(--color-text-primary); }
  .timeline tr:hover td { background: var(--color-primary-50); }
  [data-theme="dark"] .timeline tr:hover td { background: rgba(0,164,210,0.06); }
  .timeline td.num { text-align: right; font-family: var(--font-mono); font-weight: 600; }
  .kind-pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 600; }
  .kind-pill.sale { background: rgba(16,185,129,0.12); color: #10B981; }
  .kind-pill.purchase { background: rgba(245,158,11,0.12); color: #F59E0B; }
  .summary-table .timeline { padding: 18px 20px; }
  .empty-state { text-align: center; padding: 60px 20px; color: var(--color-text-tertiary); }
  .empty-state .ic { font-size: 48px; margin-bottom: 12px; }
  @media (max-width: 1100px) { .balance-card { grid-template-columns: 1fr 1fr; } }

/* ── PAGE: admin ── */
    .admin-tabs { display: flex; gap: 0; border-bottom: 1px solid var(--hairline); margin-bottom: 24px; }
    .admin-tab { padding: 12px 24px; font-weight: 600; font-size: 14px; cursor: pointer; border-bottom: 2px solid transparent; color: var(--color-text-secondary); transition: all .2s; }
    .admin-tab.active { color: var(--accent-cyan); border-bottom-color: var(--accent-cyan); }
    .admin-tab:hover { color: var(--accent-cyan); }
    .stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
    .stat-card { background: var(--surface-card); border: 1px solid var(--hairline); border-radius: 14px; padding: 18px; }
    .stat-card .label { font-size: 12px; color: var(--color-text-tertiary); margin-bottom: 6px; }
    .stat-card .value { font-size: 24px; font-weight: 700; font-family: var(--font-mono); }
    .data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
    .data-table th { text-align: left; padding: 10px 14px; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--color-text-tertiary); border-bottom: 1px solid var(--hairline); }
    .data-table td { padding: 12px 14px; border-bottom: 1px solid var(--hairline); }
    .data-table tr:hover td { background: var(--accent-cyan-soft); }
    .badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; }
    .badge-green { background: rgba(16,185,129,.1); color: #10b981; }
    .badge-yellow { background: rgba(245,158,11,.1); color: #f59e0b; }
    .badge-red { background: rgba(239,68,68,.1); color: #ef4444; }
    .badge-blue { background: rgba(59,130,246,.1); color: #3b82f6; }
    .card { background: var(--surface-card); border: 1px solid var(--hairline); border-radius: 16px; padding: 24px; margin-bottom: 20px; }
    .card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
    .card-header h3 { font-size: 16px; font-weight: 700; }
    .btn-primary { background: var(--accent-cyan); color: white; border: none; padding: 8px 18px; border-radius: 8px; font-weight: 600; font-size: 13px; cursor: pointer; }
    .btn-primary:hover { opacity: .9; }
    .btn-sm { padding: 5px 12px; font-size: 12px; border-radius: 6px; border: 1px solid var(--hairline); background: var(--surface-card); cursor: pointer; }
    .btn-sm:hover { border-color: var(--accent-cyan); color: var(--accent-cyan); }
    .btn-danger-sm { padding: 5px 12px; font-size: 12px; border-radius: 6px; border: 1px solid rgba(239,68,68,.3); background: transparent; color: #ef4444; cursor: pointer; }
    .modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 1000; place-items: center; }
    .modal-overlay.show { display: grid; }
    .modal { background: var(--surface-card); border-radius: 16px; padding: 28px; width: 90%; max-width: 440px; }
    .modal h3 { margin-bottom: 18px; font-size: 18px; }
    .modal .form-group { margin-bottom: 14px; }
    .modal .form-group label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 5px; color: var(--color-text-secondary); }
    .modal .form-group input, .modal .form-group select { width: 100%; padding: 9px 12px; border: 1px solid var(--hairline); border-radius: 8px; font-size: 14px; background: var(--surface-bg); color: var(--color-text-primary); }
    .modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }
    .perm-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
    .perm-grid label { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
    .perm-grid input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent-cyan); }
    .actions-cell { display: flex; gap: 6px; }
    .empty-state { text-align: center; padding: 40px 20px; color: var(--color-text-tertiary); }
    .tab-panel { display: none; }
    .tab-panel.active { display: block; }

/* ── PAGE: calendar ── */
    .mobile-toggle { display: none; }
    @media (max-width: 760px) { .mobile-toggle { display: inline-grid; } }

    .cal-toolbar {
      display: flex; align-items: center; justify-content: space-between;
      gap: 12px; flex-wrap: wrap;
      padding: 14px 18px;
      background: var(--surface-card);
      border: 1px solid var(--hairline);
      border-radius: 14px;
      margin-bottom: 16px;
    }
    .cal-nav { display: flex; align-items: center; gap: 10px; }
    .cal-nav .month-label {
      font-size: 17px; font-weight: 700;
      letter-spacing: -0.01em;
      white-space: nowrap;
    }
    .cal-nav button {
      width: 32px; height: 32px; flex-shrink: 0;
      border-radius: 8px;
      border: 1px solid var(--hairline);
      background: transparent;
      cursor: pointer;
      display: grid; place-items: center;
      color: var(--color-text-secondary);
      transition: all 180ms ease;
    }
    .cal-nav #todayBtn { width: auto; padding: 0 12px; font-size: 13px; font-weight: 600; }
    .cal-nav button:hover { border-color: var(--accent-cyan); color: var(--accent-cyan); }
    .cal-nav button svg { width: 16px; height: 16px; }

    .btn-primary {
      font: inherit; font-size: 13px; font-weight: 600;
      padding: 9px 16px;
      border: none; cursor: pointer;
      border-radius: 9px;
      background: linear-gradient(135deg, var(--accent-cyan), var(--accent-violet));
      color: white;
      display: inline-flex; align-items: center; gap: 6px;
      transition: transform 180ms ease, box-shadow 180ms ease;
      box-shadow: 0 2px 6px rgba(0, 164, 210, 0.2);
    }
    .btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0, 164, 210, 0.3); }
    .btn-primary:disabled { opacity: 0.5; cursor: wait; }
    .btn-primary svg { width: 14px; height: 14px; }

    .btn-secondary {
      font: inherit; font-size: 13px;
      padding: 8px 14px;
      border: 1px solid var(--hairline); cursor: pointer;
      border-radius: 9px;
      background: transparent;
      color: var(--color-text-secondary);
    }
    .btn-secondary:hover { border-color: var(--accent-cyan); color: var(--accent-cyan); }

    .btn-danger {
      font: inherit; font-size: 13px;
      padding: 8px 14px;
      border: 1px solid rgba(239, 68, 68, 0.35); cursor: pointer;
      border-radius: 9px;
      background: rgba(239, 68, 68, 0.06);
      color: rgb(239, 68, 68);
    }
    .btn-danger:hover { background: rgba(239, 68, 68, 0.16); }

    /* Month grid */
    .cal-grid {
      display: grid;
      grid-template-columns: repeat(7, 1fr);
      gap: 1px;
      background: var(--hairline);
      border: 1px solid var(--hairline);
      border-radius: 14px;
      overflow: hidden;
    }
    .cal-day-head {
      background: var(--surface-card);
      padding: 10px 12px;
      font-size: 11px; font-weight: 600;
      text-transform: uppercase;
      letter-spacing: 0.06em;
      color: var(--color-text-tertiary);
      text-align: center;
    }
    .cal-cell {
      background: var(--surface-card);
      min-height: 110px;
      padding: 8px;
      position: relative;
      cursor: pointer;
      transition: background 180ms ease;
      display: flex; flex-direction: column; gap: 4px;
    }
    .cal-cell:hover { background: var(--accent-cyan-soft); }
    .cal-cell.other-month { opacity: 0.4; }
    .cal-cell.today { background: var(--accent-cyan-soft); }
    .cal-cell .date {
      font-size: 13px; font-weight: 600;
      width: 24px; height: 24px;
      display: grid; place-items: center;
      border-radius: 50%;
    }
    .cal-cell.today .date {
      background: var(--accent-cyan);
      color: white;
    }
    .cal-cell .events {
      display: flex; flex-direction: column; gap: 3px;
      overflow: hidden;
    }
    .cal-event {
      font-size: 11.5px;
      padding: 3px 7px;
      border-radius: 5px;
      background: linear-gradient(135deg, rgba(0,164,210,0.18), rgba(139,92,246,0.14));
      border-left: 3px solid var(--accent-cyan);
      color: var(--color-text-primary);
      white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
      cursor: pointer;
      transition: transform 140ms ease;
    }
    .cal-event:hover { transform: translateX(2px); }
    .cal-event .t-time { color: var(--color-text-tertiary); font-family: var(--font-mono); font-size: 10.5px; margin-right: 4px; }
    .cal-event-more {
      font-size: 11px; color: var(--color-text-tertiary);
      padding: 2px 6px;
      cursor: pointer;
    }

    /* Modals */
    .modal-backdrop {
      position: fixed; inset: 0;
      background: rgba(0, 0, 0, 0.55);
      backdrop-filter: blur(6px);
      display: none; place-items: center;
      z-index: 9000;
    }
    .modal-backdrop.open { display: grid; }
    .modal-card {
      background: var(--surface-card);
      border: 1px solid var(--hairline);
      border-radius: 18px;
      padding: 24px;
      width: 92%; max-width: 480px;
      box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
      max-height: 90vh; overflow-y: auto;
    }
    .modal-title { font-size: 17px; font-weight: 700; margin-bottom: 16px; }
    .modal-row { margin-bottom: 12px; }
    .modal-row label { display: block; font-size: 12px; color: var(--color-text-secondary); margin-bottom: 4px; }
    .modal-row input,
    .modal-row textarea {
      width: 100%;
      font: inherit; font-size: 13.5px;
      padding: 8px 12px;
      border: 1px solid var(--hairline);
      border-radius: 8px;
      background: var(--surface-input, transparent);
      color: var(--color-text-primary);
    }
    .modal-row input:focus, .modal-row textarea:focus {
      outline: none; border-color: var(--accent-cyan);
      box-shadow: 0 0 0 3px rgba(0, 164, 210, 0.12);
    }
    .modal-row textarea { resize: vertical; min-height: 60px; }
    .modal-actions {
      display: flex; gap: 10px; justify-content: flex-end;
      margin-top: 18px;
    }

    .empty-state {
      text-align: center;
      padding: 60px 20px;
      color: var(--color-text-tertiary);
    }
    .empty-state .ic {
      font-size: 36px; margin-bottom: 14px;
      opacity: 0.6;
    }

    .toast {
      position: fixed; bottom: 24px; right: 24px;
      padding: 12px 18px;
      background: rgba(20, 20, 22, 0.95);
      color: white; border-radius: 10px;
      font-size: 13px;
      box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
      opacity: 0; transform: translateY(8px);
      pointer-events: none;
      transition: all 240ms ease;
      z-index: 9999;
    }
    .toast.show { opacity: 1; transform: translateY(0); }
    .toast.err  { background: rgba(239, 68, 68, 0.95); }
    .toast.ok   { background: rgba(34, 197, 94, 0.95); }

    .conflict-list {
      background: rgba(245, 158, 11, 0.12);
      border: 1px solid rgba(245, 158, 11, 0.35);
      border-radius: 8px;
      padding: 10px 12px;
      margin-bottom: 12px;
      font-size: 12.5px;
    }
    .conflict-list ul { margin: 6px 0 0; padding-left: 18px; }

    .event-detail-row {
      display: grid;
      grid-template-columns: 80px 1fr;
      gap: 8px;
      font-size: 13px;
      padding: 8px 0;
      border-bottom: 1px solid var(--hairline);
    }
    .event-detail-row:last-child { border-bottom: none; }
    .event-detail-row .lab { color: var(--color-text-tertiary); font-size: 12px; }

    /* Topbar avatar + status dot — calendar theme: emerald → teal → cyan */
    .tenant-avatar { width: 30px; height: 30px; border-radius: 8px; background: linear-gradient(135deg, #10B981, #14B8A6, #00A4D2); color: #fff; font-weight: 700; font-size: 13px; display: grid; place-items: center; flex-shrink: 0; box-shadow: 0 4px 14px rgba(20,184,166,0.28); }
    [data-theme="dark"] .tenant-avatar { box-shadow: 0 4px 14px rgba(20,184,166,0.18); }
    .status-dot { width: 8px; height: 8px; border-radius: 50%; background: #10B981; box-shadow: 0 0 0 0 rgba(16,185,129,0.5); animation: dotPulse 2.4s ease-in-out infinite; display: inline-block; vertical-align: middle; margin-left: 6px; }
    @keyframes dotPulse { 0%,100% { box-shadow: 0 0 0 0 rgba(16,185,129,0.5); } 50% { box-shadow: 0 0 0 6px rgba(16,185,129,0); } }

/* ── PAGE: reports ── */
    .mobile-toggle { display: none; }
    @media (max-width: 760px) { .mobile-toggle { display: inline-grid; } }

    .report-grid {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
      gap: 16px;
    }
    .report-card {
      background: var(--surface-card);
      border: 1px solid var(--hairline);
      border-radius: 16px;
      padding: 22px;
      box-shadow: var(--shadow-card);
      transition: all 320ms cubic-bezier(0.22, 1, 0.36, 1);
      cursor: pointer;
    }
    .report-card:hover {
      box-shadow: var(--shadow-card-hover);
      transform: translateY(-2px);
      border-color: var(--accent-cyan);
    }
    .report-card .head {
      display: flex; align-items: center; gap: 12px;
      margin-bottom: 12px;
    }
    .report-card .ic {
      width: 40px; height: 40px;
      border-radius: 11px;
      display: grid; place-items: center;
      background: linear-gradient(135deg, var(--accent-cyan-soft), rgba(139,92,246,0.1));
      color: var(--accent-cyan);
    }
    .report-card .ic svg { width: 20px; height: 20px; }
    .report-card .t { font-size: 15px; font-weight: 600; }
    .report-card .desc {
      font-size: 12.5px;
      color: var(--color-text-tertiary);
      margin-bottom: 14px;
      line-height: 1.5;
    }
    .report-card .formats {
      display: flex; gap: 8px;
      flex-wrap: wrap;
    }
    .format-pill {
      font-size: 11px; font-weight: 600;
      padding: 4px 9px;
      border-radius: 999px;
      background: var(--hairline);
      color: var(--color-text-secondary);
      letter-spacing: 0.04em;
      text-transform: uppercase;
    }

    /* Filter bar */
    .filter-bar {
      display: flex; align-items: center; gap: 12px;
      flex-wrap: wrap;
      padding: 14px 18px;
      background: var(--surface-card);
      border: 1px solid var(--hairline);
      border-radius: 14px;
      margin-bottom: 20px;
    }
    .filter-bar label {
      display: flex; align-items: center; gap: 8px;
      font-size: 12.5px;
      color: var(--color-text-secondary);
    }
    .filter-bar input[type="date"], .filter-bar select {
      font: inherit; font-size: 13px;
      padding: 7px 10px;
      border: 1px solid var(--hairline);
      border-radius: 7px;
      background: var(--surface-input, transparent);
      color: var(--color-text-primary);
    }

    /* Modal for picking format */
    .modal-backdrop {
      position: fixed; inset: 0;
      background: rgba(0, 0, 0, 0.55);
      backdrop-filter: blur(6px);
      display: none; place-items: center;
      z-index: 9000;
    }
    .modal-backdrop.open { display: grid; }
    .modal-card {
      background: var(--surface-card);
      border: 1px solid var(--hairline);
      border-radius: 18px;
      padding: 24px;
      width: 92%; max-width: 460px;
      box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    }
    .modal-title { font-size: 17px; font-weight: 700; margin-bottom: 14px; }
    .modal-options {
      display: flex; gap: 12px;
      margin: 18px 0;
    }
    .format-btn {
      flex: 1;
      padding: 14px;
      border: 1.5px solid var(--hairline);
      background: transparent;
      border-radius: 11px;
      cursor: pointer;
      text-align: center;
      transition: all 220ms ease;
      font: inherit;
    }
    .format-btn:hover { border-color: var(--accent-cyan); transform: translateY(-1px); }
    .format-btn.selected { border-color: var(--accent-cyan); background: var(--accent-cyan-soft); }
    .format-btn .icon { font-size: 24px; margin-bottom: 6px; }
    .format-btn .label { font-size: 13px; font-weight: 600; }
    .format-btn .sub { font-size: 11px; color: var(--color-text-tertiary); margin-top: 2px; }

    .modal-actions {
      display: flex; gap: 10px; justify-content: flex-end;
    }
    .btn-primary {
      font: inherit; font-size: 13px; font-weight: 600;
      padding: 9px 18px;
      border: none; cursor: pointer;
      border-radius: 9px;
      background: linear-gradient(135deg, var(--accent-cyan), var(--accent-violet));
      color: white;
    }
    .btn-primary:disabled { opacity: 0.5; cursor: wait; }
    .btn-secondary {
      font: inherit; font-size: 13px;
      padding: 9px 14px;
      border: 1px solid var(--hairline); cursor: pointer;
      border-radius: 9px;
      background: transparent;
      color: var(--color-text-secondary);
    }

    .toast {
      position: fixed; bottom: 24px; right: 24px;
      padding: 12px 18px;
      background: rgba(20, 20, 22, 0.95);
      color: white; border-radius: 10px;
      font-size: 13px;
      box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
      opacity: 0; transform: translateY(8px);
      pointer-events: none;
      transition: all 240ms ease;
      z-index: 9999;
    }
    .toast.show { opacity: 1; transform: translateY(0); }
    .toast.err  { background: rgba(239, 68, 68, 0.95); }
    .toast.ok   { background: rgba(34, 197, 94, 0.95); }

    /* Print-only report layout */
    .print-only { display: none; }
    @media print {
      body * { visibility: hidden; }
      .print-only, .print-only * { visibility: visible; }
      .print-only {
        display: block !important;
        position: absolute; top: 0; left: 0;
        width: 100%; padding: 24px;
        font-family: 'Inter', system-ui, sans-serif;
        color: #000;
        background: white;
      }
      .print-only h1 { font-size: 20px; margin: 0 0 4px; }
      .print-only h2 { font-size: 14px; margin: 14px 0 8px; color: #333; }
      .print-only .meta { font-size: 11px; color: #666; margin-bottom: 14px; }
      .print-only table { width: 100%; border-collapse: collapse; font-size: 11px; }
      .print-only th, .print-only td { padding: 6px 8px; border-bottom: 1px solid #ddd; text-align: left; }
      .print-only th { background: #f5f5f5; font-weight: 600; }
      .print-only .num { text-align: right; font-family: 'JetBrains Mono', monospace; }
      .print-only .summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
      .print-only .stat {
        padding: 10px;
        border: 1px solid #ddd;
        border-radius: 6px;
      }
      .print-only .stat .lbl { font-size: 10px; text-transform: uppercase; color: #888; }
      .print-only .stat .val { font-size: 16px; font-weight: 700; margin-top: 2px; font-family: 'JetBrains Mono', monospace; }
    }

    /* Topbar avatar + status dot — reports theme: amber → rose → indigo */
    .tenant-avatar { width: 30px; height: 30px; border-radius: 8px; background: linear-gradient(135deg, #F59E0B, #F43F5E, #6366F1); color: #fff; font-weight: 700; font-size: 13px; display: grid; place-items: center; flex-shrink: 0; box-shadow: 0 4px 14px rgba(244,63,94,0.28); }
    [data-theme="dark"] .tenant-avatar { box-shadow: 0 4px 14px rgba(244,63,94,0.18); }
    .status-dot { width: 8px; height: 8px; border-radius: 50%; background: #10B981; box-shadow: 0 0 0 0 rgba(16,185,129,0.5); animation: dotPulse 2.4s ease-in-out infinite; display: inline-block; vertical-align: middle; margin-left: 6px; }
    @keyframes dotPulse { 0%,100% { box-shadow: 0 0 0 0 rgba(16,185,129,0.5); } 50% { box-shadow: 0 0 0 6px rgba(16,185,129,0); } }

/* ── PAGE: settings ── */
    .mobile-toggle { display: none; }
    @media (max-width: 760px) { .mobile-toggle { display: inline-grid; } }

    /* Settings page layout */
    .settings-grid { display: grid; gap: 16px; max-width: 880px; }

    .settings-card {
      background: var(--surface-card);
      border: 1px solid var(--hairline);
      border-radius: 16px;
      padding: 22px;
      box-shadow: var(--shadow-card);
      transition: box-shadow 320ms cubic-bezier(0.22, 1, 0.36, 1);
    }
    .settings-card:hover { box-shadow: var(--shadow-card-hover); }

    .settings-card-header {
      display: flex; align-items: center; gap: 12px;
      margin-bottom: 16px;
      padding-bottom: 14px;
      border-bottom: 1px solid var(--hairline);
    }
    .settings-card-header .ic {
      width: 36px; height: 36px;
      border-radius: 10px;
      display: grid; place-items: center;
      background: var(--accent-cyan-soft);
      color: var(--accent-cyan);
    }
    .settings-card-header .ic svg { width: 18px; height: 18px; }
    .settings-card-header .titles {
      display: flex; flex-direction: column; gap: 2px;
    }
    .settings-card-header .t { font-size: 15px; font-weight: 600; }
    .settings-card-header .sub { font-size: 12px; color: var(--color-text-tertiary); }

    .form-row { display: grid; grid-template-columns: 130px 1fr; gap: 14px; align-items: center; margin-bottom: 12px; }
    .form-row label { font-size: 13px; color: var(--color-text-secondary); }
    .form-row input[type="text"],
    .form-row input[type="email"],
    .form-row input[type="tel"] {
      font: inherit; font-size: 13.5px;
      padding: 9px 12px;
      border: 1px solid var(--hairline);
      border-radius: 9px;
      background: var(--surface-input, transparent);
      color: var(--color-text-primary);
      transition: border-color 180ms ease, box-shadow 180ms ease;
    }
    .form-row input:focus {
      outline: none;
      border-color: var(--accent-cyan);
      box-shadow: 0 0 0 3px rgba(0, 164, 210, 0.12);
    }
    .form-row input:disabled { opacity: 0.6; cursor: not-allowed; }

    .form-actions {
      margin-top: 16px;
      display: flex; gap: 10px; align-items: center;
    }
    .btn-primary {
      font: inherit; font-size: 13px; font-weight: 600;
      padding: 9px 18px;
      border: none; cursor: pointer;
      border-radius: 9px;
      background: linear-gradient(135deg, var(--accent-cyan) 0%, var(--accent-violet) 100%);
      color: white;
      transition: transform 180ms ease, box-shadow 180ms ease, opacity 180ms ease;
      box-shadow: 0 2px 6px rgba(0, 164, 210, 0.2);
    }
    .btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0, 164, 210, 0.3); }
    .btn-primary:disabled { opacity: 0.5; cursor: wait; }
    .btn-danger {
      font: inherit; font-size: 13px; font-weight: 600;
      padding: 9px 18px;
      border: 1px solid rgba(239, 68, 68, 0.35); cursor: pointer;
      border-radius: 9px;
      background: rgba(239, 68, 68, 0.08);
      color: rgb(239, 68, 68);
      transition: all 180ms ease;
    }
    .btn-danger:hover { background: rgba(239, 68, 68, 0.18); }
    .btn-secondary {
      font: inherit; font-size: 13px; font-weight: 500;
      padding: 9px 14px;
      border: 1px solid var(--hairline); cursor: pointer;
      border-radius: 9px;
      background: transparent;
      color: var(--color-text-secondary);
    }
    .btn-secondary:hover { border-color: var(--accent-cyan); color: var(--accent-cyan); }

    .status-line { font-size: 12.5px; color: var(--color-text-tertiary); }
    .status-line .badge {
      display: inline-block;
      padding: 2px 8px;
      border-radius: 999px;
      font-size: 11px; font-weight: 600;
      letter-spacing: 0.02em;
    }
    .status-line .badge.ok    { background: rgba(34, 197, 94, 0.12); color: rgb(34, 197, 94); }
    .status-line .badge.off   { background: rgba(148, 163, 184, 0.18); color: rgb(100, 116, 139); }
    .status-line .badge.warn  { background: rgba(245, 158, 11, 0.15); color: rgb(217, 119, 6); }

    .db-list { display: flex; flex-direction: column; gap: 10px; }
    .db-row {
      display: flex; align-items: center; justify-content: space-between;
      padding: 12px 14px;
      border: 1px solid var(--hairline);
      border-radius: 10px;
      transition: border-color 180ms ease;
    }
    .db-row.active { border-color: var(--accent-cyan); background: var(--accent-cyan-soft); }
    .db-row .name  { font-size: 13.5px; font-weight: 500; }
    .db-row .meta  { font-size: 11.5px; color: var(--color-text-tertiary); margin-top: 2px; }

    .toast {
      position: fixed; bottom: 24px; right: 24px;
      padding: 12px 18px;
      background: rgba(20, 20, 22, 0.95);
      color: white;
      border-radius: 10px;
      font-size: 13px;
      box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
      opacity: 0; transform: translateY(8px);
      pointer-events: none;
      transition: opacity 240ms ease, transform 240ms ease;
      z-index: 9999;
    }
    .toast.show { opacity: 1; transform: translateY(0); }
    .toast.err  { background: rgba(239, 68, 68, 0.95); }
    .toast.ok   { background: rgba(34, 197, 94, 0.95); }

    .empty-msg {
      padding: 16px; text-align: center;
      color: var(--color-text-tertiary);
      font-size: 13px;
    }

    /* Topbar avatar + status dot — settings theme: slate → indigo → cyan */
    .tenant-avatar { width: 30px; height: 30px; border-radius: 8px; background: linear-gradient(135deg, #475569, #6366F1, #00A4D2); color: #fff; font-weight: 700; font-size: 13px; display: grid; place-items: center; flex-shrink: 0; box-shadow: 0 4px 14px rgba(99,102,241,0.28); }
    [data-theme="dark"] .tenant-avatar { box-shadow: 0 4px 14px rgba(99,102,241,0.18); }
    .status-dot { width: 8px; height: 8px; border-radius: 50%; background: #10B981; box-shadow: 0 0 0 0 rgba(16,185,129,0.5); animation: dotPulse 2.4s ease-in-out infinite; display: inline-block; vertical-align: middle; margin-left: 6px; }
    @keyframes dotPulse { 0%,100% { box-shadow: 0 0 0 0 rgba(16,185,129,0.5); } 50% { box-shadow: 0 0 0 6px rgba(16,185,129,0); } }

/* ── PAGE: dashboard ── */
    /* Page-local refinements */
    .table-widget {
      background: var(--surface-card);
      border: 1px solid var(--hairline);
      border-radius: 16px;
      padding: 18px 0 0;
      box-shadow: var(--shadow-card);
      transition: box-shadow 320ms cubic-bezier(0.22, 1, 0.36, 1),
                  transform 380ms cubic-bezier(0.22, 1, 0.36, 1);
    }
    .table-widget:hover { box-shadow: var(--shadow-card-hover); transform: translateY(-2px); }
    .table-widget .head {
      display: flex; justify-content: space-between; align-items: center;
      padding: 0 22px 14px;
      border-bottom: 1px solid var(--hairline);
    }
    .table-widget .row {
      display: grid;
      grid-template-columns: 24px 1fr auto auto;
      gap: 12px; align-items: center;
      padding: 12px 22px;
      border-bottom: 1px solid var(--hairline);
      font-size: 13.5px;
      transition: background 180ms ease;
    }
    .table-widget .row:hover { background: var(--accent-cyan-soft); }
    .table-widget .row:last-child { border-bottom: none; }
    .table-widget .row .rank {
      width: 22px; height: 22px;
      border-radius: 6px;
      display: grid; place-items: center;
      font-size: 11px; font-weight: 700;
      color: white;
    }
    .table-widget .row[data-rank="1"] .rank { background: linear-gradient(135deg, #F59E0B, #F97316); }
    .table-widget .row[data-rank="2"] .rank { background: linear-gradient(135deg, #94A3B8, #64748B); }
    .table-widget .row[data-rank="3"] .rank { background: linear-gradient(135deg, #B45309, #92400E); }
    .table-widget .row[data-rank="4"] .rank,
    .table-widget .row[data-rank="5"] .rank,
    .table-widget .row[data-rank="6"] .rank,
    .table-widget .row[data-rank="7"] .rank,
    .table-widget .row[data-rank="8"] .rank { background: var(--color-gray-200); color: var(--color-text-secondary); }
    [data-theme="dark"] .table-widget .row[data-rank="4"] .rank,
    [data-theme="dark"] .table-widget .row[data-rank="5"] .rank,
    [data-theme="dark"] .table-widget .row[data-rank="6"] .rank,
    [data-theme="dark"] .table-widget .row[data-rank="7"] .rank,
    [data-theme="dark"] .table-widget .row[data-rank="8"] .rank { background: rgba(255,255,255,0.08); color: var(--color-text-secondary); }
    .table-widget .row .name { font-weight: 500; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .table-widget .row .meta { color: var(--color-text-tertiary); font-size: 12.5px; white-space: nowrap; }
    .table-widget .row .val  { font-family: var(--font-mono); font-weight: 600; font-size: 13px; white-space: nowrap; }

    .chart-card {
      background: linear-gradient(145deg, rgba(255,255,255,0.92) 0%, rgba(240,248,255,0.85) 100%);
      backdrop-filter: blur(20px) saturate(140%);
      -webkit-backdrop-filter: blur(20px) saturate(140%);
      border: 1px solid rgba(0,164,210,0.15);
      border-radius: 22px;
      padding: 24px 24px 20px;
      box-shadow:
        0 8px 32px rgba(0,164,210,0.08),
        0 2px 8px rgba(0,0,0,0.04),
        inset 0 1px 0 rgba(255,255,255,0.8);
      display: flex; flex-direction: column;
      position: relative;
      overflow: hidden;
      transition: all 420ms cubic-bezier(0.22, 1, 0.36, 1);
    }
    [data-theme="dark"] .chart-card {
      background: linear-gradient(145deg, rgba(28,28,30,0.88) 0%, rgba(20,20,35,0.92) 100%);
      border-color: rgba(0,164,210,0.2);
      box-shadow:
        0 8px 32px rgba(0,0,0,0.3),
        0 0 1px rgba(0,164,210,0.3),
        inset 0 1px 0 rgba(255,255,255,0.05);
    }
    /* Animated neon border glow */
    .chart-card::before {
      content: "";
      position: absolute;
      inset: -1px;
      border-radius: 23px;
      padding: 1.5px;
      background: linear-gradient(135deg, rgba(0,164,210,0.4), rgba(139,92,246,0.3) 50%, rgba(236,72,153,0.3));
      -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
      -webkit-mask-composite: xor;
      mask-composite: exclude;
      opacity: 0;
      transition: opacity 480ms ease;
      pointer-events: none;
      z-index: 0;
    }
    /* Aurora ambient glow */
    .chart-card::after {
      content: "";
      position: absolute;
      inset: 0;
      border-radius: 22px;
      background:
        radial-gradient(ellipse 60% 50% at 90% -5%, rgba(0,164,210,0.12) 0%, transparent 60%),
        radial-gradient(ellipse 50% 40% at -5% 105%, rgba(139,92,246,0.10) 0%, transparent 60%);
      opacity: 0.6;
      pointer-events: none;
      z-index: 0;
    }
    [data-theme="dark"] .chart-card::after {
      background:
        radial-gradient(ellipse 60% 50% at 90% -5%, rgba(0,164,210,0.18) 0%, transparent 60%),
        radial-gradient(ellipse 50% 40% at -5% 105%, rgba(139,92,246,0.15) 0%, transparent 60%);
      opacity: 1;
    }
    .chart-card > * { position: relative; z-index: 1; }
    .chart-card:hover {
      transform: translateY(-4px) scale(1.005);
      border-color: rgba(0,164,210,0.35);
      box-shadow:
        0 20px 50px rgba(0,164,210,0.15),
        0 0 0 1px rgba(0,164,210,0.2) inset,
        0 0 40px rgba(0,164,210,0.06);
    }
    [data-theme="dark"] .chart-card:hover {
      box-shadow:
        0 20px 50px rgba(0,164,210,0.2),
        0 0 0 1px rgba(0,164,210,0.3) inset,
        0 0 60px rgba(0,164,210,0.08);
    }
    .chart-card:hover::before { opacity: 1; }
    .chart-card .chart-header {
      display: flex; align-items: flex-start; justify-content: space-between;
      margin-bottom: 16px;
    }
    .chart-card .chart-header .t-h3 {
      font-size: 15px;
      font-weight: 700;
      letter-spacing: -0.02em;
      background: linear-gradient(135deg, var(--color-text-primary) 60%, var(--accent-cyan));
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
      background-clip: text;
    }
    .chart-card .chart-header .t-meta {
      font-size: 11.5px;
      color: var(--color-text-tertiary);
      margin-top: 2px;
      text-transform: uppercase;
      letter-spacing: 0.04em;
      font-weight: 500;
    }
    .chart-card .chart-icon {
      width: 36px; height: 36px;
      border-radius: 12px;
      display: grid; place-items: center;
      background: linear-gradient(135deg, rgba(0,164,210,0.15), rgba(139,92,246,0.12));
      color: var(--accent-cyan);
      box-shadow:
        0 0 0 1px rgba(0,164,210,0.2),
        0 4px 14px rgba(0,164,210,0.15),
        0 0 20px rgba(0,164,210,0.08);
      transition: all 380ms cubic-bezier(0.34, 1.56, 0.64, 1);
    }
    [data-theme="dark"] .chart-card .chart-icon {
      background: linear-gradient(135deg, rgba(0,164,210,0.2), rgba(139,92,246,0.18));
      box-shadow:
        0 0 0 1px rgba(0,164,210,0.3),
        0 4px 14px rgba(0,164,210,0.2),
        0 0 24px rgba(0,164,210,0.12);
    }
    .chart-card:hover .chart-icon {
      transform: scale(1.12) rotate(-6deg);
      box-shadow:
        0 0 0 1px rgba(0,164,210,0.3),
        0 6px 20px rgba(0,164,210,0.25),
        0 0 30px rgba(0,164,210,0.15);
    }
    .chart-card .chart-icon svg { width: 17px; height: 17px; }
    .chart-card .body {
      flex: 1;
      min-height: 260px;
      position: relative;
    }
    .chart-card canvas { max-width: 100%; }

    .filter-row {
      display: flex; align-items: center; justify-content: space-between;
      gap: 12px; flex-wrap: wrap;
      margin-bottom: var(--gap-section);
    }

    .mobile-toggle { display: none; }
    @media (max-width: 760px) {
      .sidebar.open { display: flex; position: fixed; inset: 0; z-index: 100; }
      .mobile-toggle { display: inline-flex !important; }
    }

    .empty-card {
      grid-column: 1 / -1;
      padding: 48px 24px;
      text-align: center;
      color: var(--color-text-secondary);
      background: var(--surface-card);
      border: 1px dashed var(--hairline-strong);
      border-radius: 16px;
    }
    .empty-card .ic { font-size: 32px; margin-bottom: 8px; opacity: 0.5; }

    .nav-item {
      transition: background 200ms ease, color 200ms ease, transform 220ms cubic-bezier(0.22,1,0.36,1);
    }
    .nav-item:hover { transform: translateX(2px); }
    .nav-item.active {
      background: linear-gradient(135deg, var(--accent-cyan-soft), var(--accent-indigo-soft));
      color: var(--accent-cyan);
    }
    [data-theme="dark"] .nav-item.active { color: var(--accent-cyan); }

    .topbar-actions { gap: 8px; }
    .btn-icon {
      transition: background 220ms ease, transform 200ms ease, color 220ms ease;
    }
    .btn-icon:hover { transform: scale(1.06); }

    /* ── Chat-app-style topbar greeting (matches /chat for consistency) ── */
    .tenant-avatar {
      width: 30px; height: 30px;
      border-radius: 8px;
      background: linear-gradient(135deg, var(--accent-cyan), var(--accent-violet) 65%, var(--accent-fuchsia));
      color: #fff;
      display: grid; place-items: center;
      font-size: 13px;
      font-weight: 700;
      letter-spacing: 0.02em;
      flex-shrink: 0;
      box-shadow:
        0 0 0 3px rgba(0,164,210,0.10),
        0 4px 10px rgba(0,164,210,0.18);
      position: relative;
      transition: transform 320ms cubic-bezier(0.34, 1.56, 0.64, 1);
    }
    .tenant-avatar:hover { transform: scale(1.06) rotate(-2deg); }
    [data-theme="dark"] .tenant-avatar {
      box-shadow:
        0 0 0 3px rgba(0,164,210,0.18),
        0 4px 10px rgba(0,164,210,0.30);
    }

    .topbar .greeting { gap: 2px; }
    .topbar .greeting .who {
      display: flex; align-items: center; gap: 8px;
      font-size: 16px;
      font-weight: 600;
      letter-spacing: -0.01em;
      line-height: 1.2;
    }
    .topbar .greeting .who .status-dot {
      width: 7px; height: 7px;
      border-radius: 50%;
      background: var(--accent-emerald);
      box-shadow: 0 0 0 0 rgba(16,185,129,0.55);
      animation: dotPulse 2.4s ease-out infinite;
    }
    @keyframes dotPulse {
      0%   { box-shadow: 0 0 0 0 rgba(16,185,129,0.45); }
      70%  { box-shadow: 0 0 0 6px rgba(16,185,129,0); }
      100% { box-shadow: 0 0 0 0 rgba(16,185,129,0); }
    }
    .topbar .greeting .when {
      font-size: 11px;
      color: var(--color-text-tertiary);
      font-weight: 500;
      letter-spacing: 0.005em;
      line-height: 1.2;
      margin-top: 1px;
    }

    /* Phase 22 Sprint 3B — anomaly KPI indicators */
    .kpi-anomaly {
      box-shadow:
        var(--shadow-card),
        0 0 0 2px rgba(239, 68, 68, 0.45),
        0 0 24px rgba(239, 68, 68, 0.18);
      animation: anomalyPulse 2.4s ease-in-out infinite;
    }
    [data-theme="dark"] .kpi-anomaly {
      box-shadow:
        var(--shadow-card),
        0 0 0 2px rgba(239, 68, 68, 0.55),
        0 0 28px rgba(239, 68, 68, 0.28);
    }
    @keyframes anomalyPulse {
      0%, 100% { box-shadow: var(--shadow-card), 0 0 0 2px rgba(239, 68, 68, 0.45), 0 0 24px rgba(239, 68, 68, 0.18); }
      50%      { box-shadow: var(--shadow-card), 0 0 0 2px rgba(239, 68, 68, 0.6),  0 0 32px rgba(239, 68, 68, 0.3); }
    }
    .kpi-anomaly-badge {
      width: 22px; height: 22px;
      border-radius: 50%;
      background: linear-gradient(135deg, rgb(239, 68, 68), rgb(220, 38, 38));
      color: white;
      display: grid; place-items: center;
      font-size: 12px; font-weight: 700;
      box-shadow: 0 2px 6px rgba(239, 68, 68, 0.4);
      cursor: help;
    }
    @media (prefers-reduced-motion: reduce) {
      .kpi-anomaly { animation: none; }
    }
  .notif-backdrop {
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(4px);
    opacity: 0; pointer-events: none;
    transition: opacity 220ms ease;
    z-index: 8500;
  }
  .notif-backdrop.open { opacity: 1; pointer-events: auto; }
  .notif-drawer {
    position: fixed; top: 0; right: 0;
    width: min(420px, 92vw); height: 100vh;
    background: var(--surface-card);
    border-left: 1px solid var(--hairline);
    box-shadow: -8px 0 30px rgba(0, 0, 0, 0.18);
    transform: translateX(100%);
    transition: transform 360ms cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 8600;
    display: flex; flex-direction: column;
  }
  .notif-drawer.open { transform: translateX(0); }
  .notif-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 18px 20px;
    border-bottom: 1px solid var(--hairline);
  }
  .notif-head .ttl { font-size: 16px; font-weight: 700; }
  .notif-head .actions { display: flex; gap: 8px; }
  .notif-head button {
    padding: 6px 10px;
    font: inherit; font-size: 12px;
    border: 1px solid var(--hairline);
    border-radius: 7px;
    background: transparent;
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: all 180ms ease;
  }
  .notif-head button:hover { border-color: var(--accent-cyan); color: var(--accent-cyan); }
  .notif-list { flex: 1; overflow-y: auto; padding: 8px 0; }
  .notif-item {
    display: grid;
    grid-template-columns: 36px 1fr;
    gap: 12px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--hairline);
    cursor: pointer;
    transition: background 180ms ease;
  }
  .notif-item:hover { background: var(--accent-cyan-soft); }
  .notif-item.unread { background: rgba(0,164,210,0.04); }
  .notif-item.unread::before {
    content: "";
    position: absolute;
    left: 8px;
    width: 6px; height: 6px;
    margin-top: 8px;
    background: var(--accent-cyan);
    border-radius: 50%;
  }
  .notif-item .ic {
    width: 36px; height: 36px;
    border-radius: 9px;
    display: grid; place-items: center;
    background: var(--accent-cyan-soft);
    color: var(--accent-cyan);
  }
  .notif-item .ic.warning { background: rgba(245,158,11,0.15); color: rgb(217,119,6); }
  .notif-item .ic.error   { background: rgba(239,68,68,0.15);  color: rgb(239,68,68); }
  .notif-item .ic svg { width: 16px; height: 16px; }
  .notif-item .body { min-width: 0; }
  .notif-item .body .t { font-size: 13.5px; font-weight: 600; margin-bottom: 2px; }
  .notif-item .body .m { font-size: 12.5px; color: var(--color-text-secondary); margin-bottom: 4px; line-height: 1.4; }
  .notif-item .body .ts { font-size: 11px; color: var(--color-text-tertiary); }
  .notif-empty {
    padding: 60px 20px;
    text-align: center;
    color: var(--color-text-tertiary);
  }
  .notif-empty .ic { font-size: 36px; opacity: 0.6; margin-bottom: 12px; }

/* ── PAGE: chat ── */
    /* Chat page: sidebar visible (default app.css grid), tables scroll horizontally */
    .bubble.html { overflow-x: auto; max-width: 100%; }

    @media (max-width: 760px) {
      .sidebar.open { display: flex; position: fixed; inset: 0; z-index: 100; }
    }
    .nav-item {
      transition: background 200ms ease, color 200ms ease, transform 220ms cubic-bezier(0.22,1,0.36,1);
    }
    .nav-item:hover { transform: translateX(2px); }
    .nav-item.active {
      background: linear-gradient(135deg, var(--accent-cyan-soft), var(--accent-indigo-soft));
      color: var(--accent-cyan);
    }
    [data-theme="dark"] .nav-item.active { color: var(--accent-cyan); }
    .topbar-actions { gap: 8px; }
    .btn-icon {
      transition: background 220ms ease, transform 200ms ease, color 220ms ease;
    }
    .btn-icon:hover { transform: scale(1.06); }

    /* ── Chat-app-style topbar greeting ── */
    .tenant-avatar {
      width: 30px; height: 30px;
      border-radius: 8px;
      background: linear-gradient(135deg, var(--accent-cyan), var(--accent-violet) 65%, var(--accent-fuchsia));
      color: #fff;
      display: grid; place-items: center;
      font-size: 13px;
      font-weight: 700;
      letter-spacing: 0.02em;
      flex-shrink: 0;
      box-shadow:
        0 0 0 3px rgba(0,164,210,0.10),
        0 4px 10px rgba(0,164,210,0.18);
      position: relative;
      transition: transform 320ms cubic-bezier(0.34, 1.56, 0.64, 1);
    }
    .tenant-avatar:hover { transform: scale(1.06) rotate(-2deg); }

    .topbar .greeting {
      display: flex;
      flex-direction: column;
      gap: 2px;
    }
    .topbar .greeting .who {
      display: flex; align-items: center; gap: 8px;
      font-size: 16px;
      font-weight: 600;
      letter-spacing: -0.01em;
      line-height: 1.2;
      color: var(--color-text-primary);
    }
    .topbar .greeting .who .status-dot {
      width: 7px; height: 7px;
      border-radius: 50%;
      background: var(--accent-emerald);
      box-shadow: 0 0 0 0 rgba(16,185,129,0.55);
      animation: dotPulse 2.4s ease-out infinite;
    }
    @keyframes dotPulse {
      0%   { box-shadow: 0 0 0 0 rgba(16,185,129,0.45); }
      70%  { box-shadow: 0 0 0 6px rgba(16,185,129,0); }
      100% { box-shadow: 0 0 0 0 rgba(16,185,129,0); }
    }
    .topbar .greeting .when {
      font-size: 11px;
      color: var(--color-text-tertiary);
      font-weight: 500;
      letter-spacing: 0.005em;
      line-height: 1.2;
      margin-top: 1px;
    }
    [data-theme="dark"] .tenant-avatar {
      box-shadow:
        0 0 0 3px rgba(0,164,210,0.18),
        0 4px 10px rgba(0,164,210,0.30);
    }
    /* ── Dark mode table overrides ── */
    .bubble.html table { border-collapse: collapse !important; width: 100%; }
    .bubble.html th {
      padding: 7px 10px !important;
      border: 1px solid var(--hairline-strong, #444) !important;
      background: var(--accent-cyan-soft, #1a1a2e) !important;
      color: var(--color-text-primary, #fff) !important;
      font-weight: 600 !important;
      font-size: 12.5px !important;
      white-space: nowrap !important;
    }
    .bubble.html td {
      padding: 6px 10px !important;
      border: 1px solid var(--hairline, #ddd) !important;
      font-size: 12.5px !important;
      white-space: nowrap !important;
      color: var(--color-text-primary, #333) !important;
    }
    .bubble.html tbody tr:nth-child(even) td { background: var(--surface-canvas, #f9f9f9) !important; }
    .bubble.html tbody tr:hover td { background: var(--accent-cyan-soft, #eef4ff) !important; }
    [data-theme="dark"] .bubble.html th { background: rgba(0,164,210,0.15) !important; color: #e0e0e0 !important; border-color: rgba(255,255,255,0.12) !important; }
    [data-theme="dark"] .bubble.html td { color: #d4d4d4 !important; border-color: rgba(255,255,255,0.08) !important; }
    [data-theme="dark"] .bubble.html tbody tr { background: transparent !important; }
    [data-theme="dark"] .bubble.html tbody tr:nth-child(even) { background: rgba(255,255,255,0.03) !important; }
    [data-theme="dark"] .bubble.html tbody tr:hover { background: rgba(0,164,210,0.1) !important; }
    [data-theme="dark"] .bubble.html { background: rgba(255,255,255,0.04); border-color: rgba(255,255,255,0.08); }
    [data-theme="dark"] .bubble.html tbody tr:last-child { background: rgba(255,255,255,0.06) !important; }
    [data-theme="dark"] .bubble.html div[style*="color:#555"] { color: #a1a1a6 !important; }

    /* ── Download buttons ── */
    .download-bar { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
    .dl-btn { display: inline-flex; align-items: center; gap: 5px; padding: 5px 12px; border-radius: 6px; border: none; cursor: pointer; font-size: 11px; font-weight: 600; transition: all 0.15s; }
    .dl-btn.pdf { background: #e53935; color: #fff; }
    .dl-btn.pdf:hover { background: #c62828; }
    .dl-btn.img { background: #1a73e8; color: #fff; }
    .dl-btn.img:hover { background: #1558b0; }
    .dl-btn.csv { background: #2e7d32; color: #fff; }
    .dl-btn.csv:hover { background: #1b5e20; }

    /* ── Chart wrap ── */
    .chart-wrap { margin-top: 12px; padding: 8px 0; }
    .chart-title { font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--color-text-primary); }
