/* ============================================================================
   SMART UNIVERSITY IT HELPDESK — DESIGN SYSTEM
   Hyper-modern cyber-minimalist aesthetic.
   Glassmorphism surfaces · neumorphic depth · dual-theme · micro-interactions.

   CONTENTS
     01. Design tokens (colour, type, space, motion)
     02. Reset & base
     03. Typography
     04. Layout shell (sidebar / navbar / content)
     05. Surfaces — cards, glass panels, stat tiles
     06. Buttons & controls
     07. Forms
     08. Badges, pills & status semantics
     09. Tables (sortable / filterable / paginated)
     10. Ticket components (timeline, thread, SLA meter)
     11. AI layer (insight panel, glow, recommender)
     12. Chatbot widget
     13. Charts
     14. Toasts & notifications
     15. Skeleton loaders (shimmer)
     16. Utilities
     17. Responsive
     18. Motion & accessibility
   ========================================================================= */

/* ============================================================================
   01. DESIGN TOKENS
   ========================================================================= */

:root {
  /* ---- Brand ---- */
  --brand-primary:        #2563eb;   /* Electric cobalt blue */
  --brand-primary-hover:  #1d4ed8;
  --brand-primary-soft:   rgba(37, 99, 235, 0.12);
  --brand-secondary:      #7c3aed;   /* Deep royal purple */
  --brand-secondary-hover:#6d28d9;
  --brand-secondary-soft: rgba(124, 58, 237, 0.12);

  /* ---- AI accent layer (reserved strictly for AI-driven surfaces) ---- */
  --ai-accent:            #06b6d4;   /* Luminous neon cyan */
  --ai-accent-bright:     #22d3ee;
  --ai-accent-soft:       rgba(6, 182, 212, 0.12);
  --ai-glow:              0 0 24px rgba(6, 182, 212, 0.35),
                          0 0 60px rgba(6, 182, 212, 0.12);
  --ai-glow-strong:       0 0 32px rgba(6, 182, 212, 0.55),
                          0 0 80px rgba(6, 182, 212, 0.22);

  /* ---- Status semantics ---- */
  --status-critical:      #ef4444;   /* Vibrant coral crimson */
  --status-high:          #f59e0b;   /* Amber gold */
  --status-medium:        #10b981;   /* Emerald mint */
  --status-low:           #64748b;   /* Cool muted blue */
  --status-info:          #2563eb;
  --status-success:       #10b981;
  --status-warning:       #f59e0b;
  --status-danger:        #ef4444;

  /* ---- Typography scale (10pt body → 22pt dashboard titles) ---- */
  --font-sans: 'Inter', 'Poppins', -apple-system, BlinkMacSystemFont,
               'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', Menlo, Consolas, monospace;

  --fs-2xs:   0.6875rem;  /*  11px — micro labels        */
  --fs-xs:    0.75rem;    /*  12px — meta, captions      */
  --fs-sm:    0.8125rem;  /*  13px — dense UI            */
  --fs-base:  0.875rem;   /*  14px ≈ 10pt — body         */
  --fs-md:    0.9375rem;  /*  15px — comfortable body    */
  --fs-lg:    1.0625rem;  /*  17px — card titles         */
  --fs-xl:    1.25rem;    /*  20px — section headings    */
  --fs-2xl:   1.5rem;     /*  24px — page titles         */
  --fs-3xl:   1.875rem;   /*  30px ≈ 22pt — dashboard    */
  --fs-4xl:   2.5rem;     /*  40px — hero metrics        */

  --fw-normal: 400;
  --fw-medium: 500;
  --fw-semi:   600;
  --fw-bold:   700;
  --fw-black:  800;

  --lh-tight: 1.2;
  --lh-snug:  1.4;
  --lh-base:  1.6;

  /* ---- Spacing (4px base) ---- */
  --sp-1: 0.25rem;  --sp-2: 0.5rem;   --sp-3: 0.75rem;  --sp-4: 1rem;
  --sp-5: 1.25rem;  --sp-6: 1.5rem;   --sp-8: 2rem;     --sp-10: 2.5rem;
  --sp-12: 3rem;    --sp-16: 4rem;    --sp-20: 5rem;

  /* ---- Radius ---- */
  --r-xs: 6px;  --r-sm: 8px;  --r-md: 12px;
  --r-lg: 16px; --r-xl: 20px; --r-2xl: 28px; --r-full: 999px;

  /* ---- Motion ---- */
  --ease-out:   cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out:cubic-bezier(0.65, 0, 0.35, 1);
  --ease-spring:cubic-bezier(0.34, 1.56, 0.64, 1);
  --t-fast:   140ms;
  --t-base:   240ms;
  --t-slow:   400ms;

  /* ---- Layout ---- */
  --sidebar-w:           264px;
  --sidebar-w-collapsed: 76px;
  --navbar-h:            68px;
  --content-max:         1600px;

  --z-base: 1; --z-sticky: 100; --z-sidebar: 200;
  --z-dropdown: 300; --z-modal: 400; --z-toast: 500; --z-chat: 450;
}

/* ---- DARK THEME (default) ---- */
:root,
[data-theme='dark'] {
  color-scheme: dark;

  --bg-base:      #0f172a;   /* Deep premium slate-navy */
  --bg-elevated:  #131f38;
  --bg-sunken:    #0a1120;
  --bg-app:       radial-gradient(1200px 700px at 12% -8%,
                                  rgba(37, 99, 235, 0.16), transparent 60%),
                  radial-gradient(1000px 620px at 92% 8%,
                                  rgba(124, 58, 237, 0.14), transparent 62%),
                  radial-gradient(900px 520px at 50% 104%,
                                  rgba(6, 182, 212, 0.07), transparent 60%),
                  #0f172a;

  /* Glass surfaces */
  --glass-bg:        rgba(30, 41, 59, 0.55);
  --glass-bg-strong: rgba(30, 41, 59, 0.78);
  --glass-bg-subtle: rgba(30, 41, 59, 0.34);
  --glass-border:    rgba(148, 163, 184, 0.14);
  --glass-border-hi: rgba(148, 163, 184, 0.26);
  --glass-blur:      blur(18px) saturate(150%);

  /* Text */
  --text-primary:   #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted:     #94a3b8;
  --text-faint:     #64748b;
  --text-inverse:   #0f172a;

  /* Lines & fields */
  --border:        rgba(148, 163, 184, 0.14);
  --border-strong: rgba(148, 163, 184, 0.28);
  --field-bg:      rgba(15, 23, 42, 0.6);
  --field-border:  rgba(148, 163, 184, 0.2);

  /* Elevation — soft neumorphic depth */
  --sh-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --sh-md: 0 4px 16px rgba(0, 0, 0, 0.34);
  --sh-lg: 0 12px 40px rgba(0, 0, 0, 0.42);
  --sh-xl: 0 24px 70px rgba(0, 0, 0, 0.5);
  --sh-inset: inset 0 1px 0 rgba(255, 255, 255, 0.05);

  --scrim: rgba(2, 6, 23, 0.72);
}

/* ---- LIGHT THEME ---- */
[data-theme='light'] {
  color-scheme: light;

  --bg-base:     #f8fafc;    /* Pristine porcelain off-white */
  --bg-elevated: #ffffff;
  --bg-sunken:   #eef2f7;
  --bg-app:      radial-gradient(1100px 640px at 10% -10%,
                                 rgba(37, 99, 235, 0.09), transparent 60%),
                 radial-gradient(950px 560px at 94% 4%,
                                 rgba(124, 58, 237, 0.08), transparent 62%),
                 radial-gradient(800px 480px at 50% 106%,
                                 rgba(6, 182, 212, 0.06), transparent 60%),
                 #f8fafc;

  --glass-bg:        rgba(255, 255, 255, 0.72);
  --glass-bg-strong: rgba(255, 255, 255, 0.92);
  --glass-bg-subtle: rgba(255, 255, 255, 0.5);
  --glass-border:    rgba(15, 23, 42, 0.08);
  --glass-border-hi: rgba(15, 23, 42, 0.14);
  --glass-blur:      blur(18px) saturate(160%);

  --text-primary:   #0f172a;
  --text-secondary: #334155;
  --text-muted:     #64748b;
  --text-faint:     #94a3b8;
  --text-inverse:   #ffffff;

  --border:        rgba(15, 23, 42, 0.09);
  --border-strong: rgba(15, 23, 42, 0.16);
  --field-bg:      rgba(255, 255, 255, 0.86);
  --field-border:  rgba(15, 23, 42, 0.13);

  --sh-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --sh-md: 0 4px 16px rgba(15, 23, 42, 0.08);
  --sh-lg: 0 12px 36px rgba(15, 23, 42, 0.1);
  --sh-xl: 0 24px 64px rgba(15, 23, 42, 0.12);
  --sh-inset: inset 0 1px 0 rgba(255, 255, 255, 0.9);

  --ai-glow: 0 0 20px rgba(6, 182, 212, 0.22), 0 0 48px rgba(6, 182, 212, 0.08);

  --scrim: rgba(15, 23, 42, 0.42);
}

/* ============================================================================
   02. RESET & BASE
   ========================================================================= */

*, *::before, *::after { box-sizing: border-box; }

* { margin: 0; padding: 0; }

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

body {
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: var(--lh-base);
  color: var(--text-primary);
  background: var(--bg-app);
  background-attachment: fixed;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
  transition: background-color var(--t-slow) var(--ease-out),
              color var(--t-base) var(--ease-out);
}

img, svg, video, canvas { display: block; max-width: 100%; }

a { color: var(--brand-primary); text-decoration: none;
    transition: color var(--t-fast) var(--ease-out); }
a:hover { color: var(--brand-primary-hover); }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }

/* Focus ring — visible for keyboard users only. */
:focus-visible {
  outline: 2px solid var(--brand-primary);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}

/* Scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--r-full);
  border: 2px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); background-clip: content-box; }

::selection { background: var(--brand-primary-soft); color: var(--text-primary); }

/* ============================================================================
   03. TYPOGRAPHY
   ========================================================================= */

h1, h2, h3, h4, h5, h6 {
  font-weight: var(--fw-bold);
  line-height: var(--lh-tight);
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

h1 { font-size: var(--fs-3xl); }
h2 { font-size: var(--fs-2xl); }
h3 { font-size: var(--fs-xl); }
h4 { font-size: var(--fs-lg); }
h5 { font-size: var(--fs-md); }
h6 { font-size: var(--fs-base); }

.page-title {
  font-size: var(--fs-3xl);
  font-weight: var(--fw-black);
  letter-spacing: -0.035em;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.page-subtitle {
  font-size: var(--fs-md);
  color: var(--text-muted);
  font-weight: var(--fw-normal);
  margin-top: var(--sp-2);
}

.section-title {
  font-size: var(--fs-lg);
  font-weight: var(--fw-bold);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.eyebrow {
  font-size: var(--fs-2xs);
  font-weight: var(--fw-bold);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.text-muted   { color: var(--text-muted); }
.text-faint   { color: var(--text-faint); }
.text-mono    { font-family: var(--font-mono); font-size: 0.92em; letter-spacing: -0.02em; }

/* Gradient wordmark used for brand and hero numbers. */
.text-gradient {
  background: linear-gradient(120deg, var(--brand-primary), var(--brand-secondary) 55%,
                              var(--ai-accent));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

/* ============================================================================
   04. LAYOUT SHELL
   ========================================================================= */

.main-wrapper {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: padding-left var(--t-base) var(--ease-out);
}
.main-wrapper.with-sidebar { padding-left: var(--sidebar-w); }
body.sidebar-collapsed .main-wrapper.with-sidebar { padding-left: var(--sidebar-w-collapsed); }

.content-area {
  flex: 1;
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--sp-8) var(--sp-8) var(--sp-12);
}

/* ---- Sidebar ---- */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  z-index: var(--z-sidebar);
  display: flex;
  flex-direction: column;
  background: var(--glass-bg-strong);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-right: 1px solid var(--glass-border);
  transition: width var(--t-base) var(--ease-out),
              transform var(--t-base) var(--ease-out);
  overflow: hidden;
}
body.sidebar-collapsed .sidebar { width: var(--sidebar-w-collapsed); }

.sidebar-header {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-5) var(--sp-5);
  min-height: var(--navbar-h);
  border-bottom: 1px solid var(--glass-border);
  flex-shrink: 0;
}

.sidebar-logo {
  width: 38px; height: 38px;
  flex-shrink: 0;
  border-radius: var(--r-md);
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary));
  color: #fff;
  font-size: var(--fs-lg);
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.4);
}

.sidebar-brand { min-width: 0; }
.sidebar-brand-name {
  font-size: var(--fs-md);
  font-weight: var(--fw-bold);
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.sidebar-brand-sub {
  font-size: var(--fs-2xs);
  color: var(--text-faint);
  white-space: nowrap;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--sp-4) var(--sp-3);
}

.nav-section { margin-bottom: var(--sp-5); }
.nav-section-label {
  font-size: var(--fs-2xs);
  font-weight: var(--fw-bold);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 0 var(--sp-3) var(--sp-2);
  white-space: nowrap;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-3);
  margin-bottom: 2px;
  border-radius: var(--r-md);
  color: var(--text-secondary);
  font-size: var(--fs-base);
  font-weight: var(--fw-medium);
  white-space: nowrap;
  position: relative;
  transition: background var(--t-fast) var(--ease-out),
              color var(--t-fast) var(--ease-out),
              transform var(--t-fast) var(--ease-out);
}
.nav-item:hover {
  background: var(--glass-bg-subtle);
  color: var(--text-primary);
  transform: translateX(2px);
}
.nav-item.active {
  background: linear-gradient(100deg, var(--brand-primary-soft), var(--brand-secondary-soft));
  color: var(--text-primary);
  font-weight: var(--fw-semi);
}
/* Active rail marker. */
.nav-item.active::before {
  content: '';
  position: absolute;
  left: -12px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 22px;
  border-radius: 0 var(--r-full) var(--r-full) 0;
  background: linear-gradient(180deg, var(--brand-primary), var(--brand-secondary));
}

.nav-item i { width: 20px; text-align: center; font-size: var(--fs-md); flex-shrink: 0; }
.nav-item-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }

.nav-badge {
  font-size: var(--fs-2xs);
  font-weight: var(--fw-bold);
  padding: 2px 7px;
  border-radius: var(--r-full);
  background: var(--brand-primary);
  color: #fff;
  min-width: 20px;
  text-align: center;
}
.nav-badge.badge-alert { background: var(--status-critical); }
.nav-badge.badge-ai {
  background: var(--ai-accent);
  color: #04252b;
  box-shadow: var(--ai-glow);
}

.sidebar-footer {
  padding: var(--sp-3);
  border-top: 1px solid var(--glass-border);
  flex-shrink: 0;
}

/* Collapsed state: icons only. */
body.sidebar-collapsed .sidebar-brand,
body.sidebar-collapsed .nav-item-label,
body.sidebar-collapsed .nav-badge,
body.sidebar-collapsed .nav-section-label,
body.sidebar-collapsed .sidebar-user-meta { display: none; }
body.sidebar-collapsed .nav-item { justify-content: center; padding-inline: 0; }
body.sidebar-collapsed .sidebar-header { justify-content: center; padding-inline: 0; }

/* ---- Navbar ---- */
.navbar {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  height: var(--navbar-h);
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: 0 var(--sp-8);
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--glass-border);
}

.navbar-toggle,
.icon-button {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: var(--r-md);
  color: var(--text-secondary);
  font-size: var(--fs-md);
  position: relative;
  transition: background var(--t-fast) var(--ease-out),
              color var(--t-fast) var(--ease-out),
              transform var(--t-fast) var(--ease-spring);
}
.navbar-toggle:hover,
.icon-button:hover {
  background: var(--glass-bg-subtle);
  color: var(--text-primary);
  transform: translateY(-1px);
}

.navbar-search {
  flex: 1;
  max-width: 460px;
  position: relative;
}
.navbar-search i {
  position: absolute;
  left: var(--sp-4); top: 50%;
  transform: translateY(-50%);
  color: var(--text-faint);
  font-size: var(--fs-sm);
  pointer-events: none;
}
.navbar-search input {
  width: 100%;
  height: 42px;
  padding: 0 var(--sp-4) 0 var(--sp-10);
  border-radius: var(--r-full);
  background: var(--field-bg);
  border: 1px solid var(--field-border);
  color: var(--text-primary);
  font-size: var(--fs-base);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.navbar-search input:focus {
  outline: none;
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px var(--brand-primary-soft);
}

.navbar-spacer { flex: 1; }
.navbar-actions { display: flex; align-items: center; gap: var(--sp-2); }

.notification-dot {
  position: absolute;
  top: 7px; right: 7px;
  min-width: 17px; height: 17px;
  padding: 0 4px;
  border-radius: var(--r-full);
  background: var(--status-critical);
  color: #fff;
  font-size: 10px;
  font-weight: var(--fw-bold);
  display: grid; place-items: center;
  border: 2px solid var(--bg-base);
  animation: pop var(--t-base) var(--ease-spring);
}

/* ---- User chip & dropdown ---- */
.user-chip {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-full);
  transition: background var(--t-fast) var(--ease-out);
}
.user-chip:hover { background: var(--glass-bg-subtle); }

.avatar {
  width: 36px; height: 36px;
  flex-shrink: 0;
  border-radius: var(--r-full);
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary));
  color: #fff;
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  letter-spacing: 0.02em;
  overflow: hidden;
}
.avatar-sm { width: 28px; height: 28px; font-size: var(--fs-2xs); }
.avatar-lg { width: 56px; height: 56px; font-size: var(--fs-lg); }
.avatar-xl { width: 88px; height: 88px; font-size: var(--fs-2xl); }
.avatar img { width: 100%; height: 100%; object-fit: cover; }

.user-chip-meta { text-align: left; line-height: 1.25; }
.user-chip-name { font-size: var(--fs-sm); font-weight: var(--fw-semi); }
.user-chip-role { font-size: var(--fs-2xs); color: var(--text-faint); }

.dropdown { position: relative; }
.dropdown-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 300px;
  max-width: 380px;
  padding: var(--sp-2);
  border-radius: var(--r-lg);
  background: var(--glass-bg-strong);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border-hi);
  box-shadow: var(--sh-xl);
  z-index: var(--z-dropdown);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px) scale(0.98);
  transform-origin: top right;
  transition: opacity var(--t-fast) var(--ease-out),
              transform var(--t-fast) var(--ease-out),
              visibility var(--t-fast);
}
.dropdown.open .dropdown-panel {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.dropdown-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-3);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--sp-2);
}
.dropdown-title { font-size: var(--fs-sm); font-weight: var(--fw-bold); }

.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3);
  border-radius: var(--r-md);
  color: var(--text-secondary);
  font-size: var(--fs-sm);
  width: 100%;
  text-align: left;
  transition: background var(--t-fast) var(--ease-out), color var(--t-fast);
}
.dropdown-item:hover { background: var(--glass-bg-subtle); color: var(--text-primary); }
.dropdown-item.danger { color: var(--status-danger); }
.dropdown-item i { width: 18px; text-align: center; }
.dropdown-divider { height: 1px; background: var(--border); margin: var(--sp-2) 0; }

.dropdown-scroll { max-height: 380px; overflow-y: auto; }

.notif-row {
  display: flex;
  gap: var(--sp-3);
  padding: var(--sp-3);
  border-radius: var(--r-md);
  transition: background var(--t-fast);
}
.notif-row:hover { background: var(--glass-bg-subtle); }
.notif-row.unread { background: var(--brand-primary-soft); }
.notif-icon {
  width: 34px; height: 34px;
  flex-shrink: 0;
  border-radius: var(--r-sm);
  display: grid; place-items: center;
  background: var(--glass-bg-subtle);
  color: var(--brand-primary);
  font-size: var(--fs-sm);
}
.notif-body { min-width: 0; flex: 1; }
.notif-text {
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  line-height: var(--lh-snug);
}
.notif-time { font-size: var(--fs-2xs); color: var(--text-faint); margin-top: 2px; }

/* ---- Footer ---- */
.footer {
  padding: var(--sp-6) var(--sp-8);
  border-top: 1px solid var(--border);
  background: var(--glass-bg-subtle);
}
.footer-content {
  max-width: var(--content-max);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  flex-wrap: wrap;
  font-size: var(--fs-xs);
  color: var(--text-faint);
}
.footer-links { display: flex; align-items: center; gap: var(--sp-3); }
.footer-links a { color: var(--text-muted); }
.footer-divider { opacity: 0.4; }

/* ============================================================================
   05. SURFACES
   ========================================================================= */

.card {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-md), var(--sh-inset);
  transition: transform var(--t-base) var(--ease-out),
              box-shadow var(--t-base) var(--ease-out),
              border-color var(--t-base) var(--ease-out);
}
.card-hover:hover {
  transform: translateY(-3px);
  box-shadow: var(--sh-lg), var(--sh-inset);
  border-color: var(--glass-border-hi);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  padding: var(--sp-5) var(--sp-6);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.card-body { padding: var(--sp-6); }
.card-body-tight { padding: var(--sp-4); }
.card-footer {
  padding: var(--sp-4) var(--sp-6);
  border-top: 1px solid var(--border);
  background: var(--glass-bg-subtle);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
}

/* Page header block */
.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--sp-6);
  flex-wrap: wrap;
  margin-bottom: var(--sp-8);
}
.page-header-actions { display: flex; gap: var(--sp-3); flex-wrap: wrap; }

/* ---- Stat tiles ---- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--sp-5);
  margin-bottom: var(--sp-8);
}

.stat-card {
  position: relative;
  overflow: hidden;
  padding: var(--sp-5);
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-md), var(--sh-inset);
  transition: transform var(--t-base) var(--ease-out),
              box-shadow var(--t-base) var(--ease-out);
}
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--sh-lg), var(--sh-inset); }

/* Accent bar keyed to the tile's semantic colour. */
.stat-card::before {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: var(--accent, var(--brand-primary));
  opacity: 0.9;
}

.stat-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
}
.stat-label {
  font-size: var(--fs-2xs);
  font-weight: var(--fw-bold);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.stat-icon {
  width: 42px; height: 42px;
  flex-shrink: 0;
  border-radius: var(--r-md);
  display: grid; place-items: center;
  font-size: var(--fs-md);
  background: color-mix(in srgb, var(--accent, #2563eb) 14%, transparent);
  color: var(--accent, var(--brand-primary));
}
.stat-value {
  font-size: var(--fs-4xl);
  font-weight: var(--fw-black);
  line-height: 1;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}
.stat-meta {
  margin-top: var(--sp-3);
  font-size: var(--fs-xs);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}
.stat-trend { font-weight: var(--fw-semi); display: inline-flex; align-items: center; gap: 4px; }
.stat-trend.up   { color: var(--status-success); }
.stat-trend.down { color: var(--status-danger); }

/* Semantic tile variants */
.stat-card.accent-primary   { --accent: #2563eb; }
.stat-card.accent-secondary { --accent: #7c3aed; }
.stat-card.accent-ai        { --accent: #06b6d4; }
.stat-card.accent-critical  { --accent: #ef4444; }
.stat-card.accent-high      { --accent: #f59e0b; }
.stat-card.accent-medium    { --accent: #10b981; }
.stat-card.accent-low       { --accent: #64748b; }

/* AI-flavoured tiles carry the reserved cyan glow. */
.stat-card.accent-ai {
  border-color: rgba(6, 182, 212, 0.3);
  box-shadow: var(--sh-md), var(--ai-glow);
}

/* ---- Grids ---- */
.grid { display: grid; gap: var(--sp-6); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-sidebar { grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr); }
.grid-sidebar-left { grid-template-columns: minmax(300px, 1fr) minmax(0, 2fr); }

/* Linear progression stack — the brief's preferred layout rhythm. */
.stack { display: flex; flex-direction: column; gap: var(--sp-6); }
.stack-sm { display: flex; flex-direction: column; gap: var(--sp-3); }
.stack-lg { display: flex; flex-direction: column; gap: var(--sp-8); }

.row { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); }
.row-tight { display: flex; align-items: center; gap: var(--sp-2); }

/* ============================================================================
   06. BUTTONS
   ========================================================================= */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  height: 42px;
  padding: 0 var(--sp-5);
  border-radius: var(--r-md);
  font-size: var(--fs-base);
  font-weight: var(--fw-semi);
  letter-spacing: -0.01em;
  white-space: nowrap;
  border: 1px solid transparent;
  position: relative;
  overflow: hidden;
  transition: transform var(--t-fast) var(--ease-spring),
              box-shadow var(--t-fast) var(--ease-out),
              background var(--t-fast) var(--ease-out),
              opacity var(--t-fast);
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; pointer-events: none; }

/* Sheen sweep on hover. */
.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 30%,
              rgba(255, 255, 255, 0.16) 50%, transparent 70%);
  transform: translateX(-120%);
  transition: transform var(--t-slow) var(--ease-out);
}
.btn:hover::after { transform: translateX(120%); }

.btn-primary {
  background: linear-gradient(120deg, var(--brand-primary), var(--brand-secondary));
  color: #fff;
  box-shadow: 0 4px 16px rgba(37, 99, 235, 0.32);
}
.btn-primary:hover { box-shadow: 0 8px 26px rgba(37, 99, 235, 0.42); transform: translateY(-1px); }

.btn-secondary {
  background: var(--glass-bg-strong);
  border-color: var(--glass-border-hi);
  color: var(--text-primary);
  backdrop-filter: var(--glass-blur);
}
.btn-secondary:hover { background: var(--glass-bg); transform: translateY(-1px); }

.btn-ghost { color: var(--text-secondary); }
.btn-ghost:hover { background: var(--glass-bg-subtle); color: var(--text-primary); }

.btn-outline {
  border-color: var(--border-strong);
  color: var(--text-secondary);
}
.btn-outline:hover { border-color: var(--brand-primary); color: var(--brand-primary); }

.btn-ai {
  background: linear-gradient(120deg, var(--ai-accent), var(--brand-primary));
  color: #fff;
  box-shadow: var(--ai-glow);
}
.btn-ai:hover { box-shadow: var(--ai-glow-strong); transform: translateY(-1px); }

.btn-success { background: var(--status-success); color: #fff; }
.btn-warning { background: var(--status-warning); color: #1a1206; }
.btn-danger  { background: var(--status-danger);  color: #fff; }
.btn-success:hover, .btn-warning:hover, .btn-danger:hover {
  transform: translateY(-1px);
  filter: brightness(1.08);
}

.btn-sm  { height: 34px; padding: 0 var(--sp-4); font-size: var(--fs-sm); border-radius: var(--r-sm); }
.btn-xs  { height: 28px; padding: 0 var(--sp-3); font-size: var(--fs-xs); border-radius: var(--r-xs); }
.btn-lg  { height: 50px; padding: 0 var(--sp-8); font-size: var(--fs-md); border-radius: var(--r-lg); }
.btn-block { width: 100%; }
.btn-icon { width: 42px; padding: 0; }
.btn-icon.btn-sm { width: 34px; }

.btn-group { display: inline-flex; gap: var(--sp-2); flex-wrap: wrap; }

/* Segmented control for window/range switches. */
.segmented {
  display: inline-flex;
  padding: 3px;
  border-radius: var(--r-md);
  background: var(--glass-bg-subtle);
  border: 1px solid var(--border);
  gap: 2px;
}
.segmented a, .segmented button {
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--r-sm);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semi);
  color: var(--text-muted);
  transition: background var(--t-fast), color var(--t-fast);
}
.segmented a:hover, .segmented button:hover { color: var(--text-primary); }
.segmented a.active, .segmented button.active {
  background: var(--brand-primary);
  color: #fff;
}

/* ============================================================================
   07. FORMS
   ========================================================================= */

.form-group { margin-bottom: var(--sp-5); }

.form-label {
  display: block;
  font-size: var(--fs-sm);
  font-weight: var(--fw-semi);
  color: var(--text-secondary);
  margin-bottom: var(--sp-2);
}
.form-label .required { color: var(--status-critical); margin-left: 2px; }

.form-control {
  width: 100%;
  min-height: 44px;
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md);
  background: var(--field-bg);
  border: 1px solid var(--field-border);
  color: var(--text-primary);
  font-size: var(--fs-base);
  transition: border-color var(--t-fast) var(--ease-out),
              box-shadow var(--t-fast) var(--ease-out),
              background var(--t-fast);
}
.form-control::placeholder { color: var(--text-faint); }
.form-control:hover { border-color: var(--border-strong); }
.form-control:focus {
  outline: none;
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px var(--brand-primary-soft);
  background: var(--bg-elevated);
}
.form-control:disabled { opacity: 0.55; cursor: not-allowed; }

textarea.form-control { min-height: 110px; resize: vertical; line-height: var(--lh-base); }

select.form-control, .form-select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: var(--sp-10);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2394a3b8' d='M1.4 0 6 4.6 10.6 0 12 1.4 6 7.4 0 1.4z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--sp-4) center;
  cursor: pointer;
}
select.form-control option { background: var(--bg-elevated); color: var(--text-primary); }

.form-hint { font-size: var(--fs-xs); color: var(--text-faint); margin-top: var(--sp-2); }
.form-error {
  font-size: var(--fs-xs);
  color: var(--status-danger);
  margin-top: var(--sp-2);
  display: flex; align-items: center; gap: var(--sp-1);
}
.form-control.is-invalid { border-color: var(--status-danger); }
.form-control.is-invalid:focus { box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.16); }

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--sp-4);
}

/* Checkboxes & radios */
.form-check {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-3);
  border-radius: var(--r-md);
  transition: background var(--t-fast);
}
.form-check:hover { background: var(--glass-bg-subtle); }
.form-check-input {
  width: 18px; height: 18px;
  margin-top: 2px;
  flex-shrink: 0;
  accent-color: var(--brand-primary);
  cursor: pointer;
}
.form-check-label { font-size: var(--fs-sm); color: var(--text-secondary); cursor: pointer; }
.form-check-title { font-weight: var(--fw-semi); color: var(--text-primary); }

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--sp-2);
  list-style: none;
}
.checkbox-grid li label {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: var(--fs-sm);
  cursor: pointer;
  transition: border-color var(--t-fast), background var(--t-fast);
}
.checkbox-grid li label:hover { border-color: var(--brand-primary); background: var(--brand-primary-soft); }

/* File drop zone */
.form-file-input { display: none; }
.file-drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: var(--sp-8);
  border: 2px dashed var(--border-strong);
  border-radius: var(--r-lg);
  background: var(--glass-bg-subtle);
  color: var(--text-muted);
  text-align: center;
  cursor: pointer;
  transition: border-color var(--t-base) var(--ease-out),
              background var(--t-base), transform var(--t-base);
}
.file-drop:hover, .file-drop.dragover {
  border-color: var(--brand-primary);
  background: var(--brand-primary-soft);
  color: var(--brand-primary);
  transform: scale(1.01);
}
.file-drop i { font-size: var(--fs-2xl); }
.file-drop-title { font-size: var(--fs-base); font-weight: var(--fw-semi); color: var(--text-primary); }
.file-drop-hint { font-size: var(--fs-xs); }

.file-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-full);
  background: var(--glass-bg-subtle);
  border: 1px solid var(--border);
  font-size: var(--fs-xs);
}

.form-color-input {
  width: 56px; height: 44px;
  padding: 4px;
  border-radius: var(--r-md);
  border: 1px solid var(--field-border);
  background: var(--field-bg);
  cursor: pointer;
}

/* Star rating */
.star-rating { display: flex; gap: var(--sp-1); flex-direction: row-reverse;
               justify-content: flex-end; }
.star-rating input { display: none; }
.star-rating label {
  font-size: var(--fs-2xl);
  color: var(--text-faint);
  cursor: pointer;
  transition: color var(--t-fast), transform var(--t-fast) var(--ease-spring);
}
.star-rating label:hover,
.star-rating label:hover ~ label,
.star-rating input:checked ~ label { color: var(--status-high); transform: scale(1.1); }

/* Auth pages */
.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--sp-6);
}
.auth-card {
  width: 100%;
  max-width: 460px;
  padding: var(--sp-10);
  background: var(--glass-bg-strong);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border-hi);
  border-radius: var(--r-2xl);
  box-shadow: var(--sh-xl);
  animation: rise var(--t-slow) var(--ease-out);
}
.auth-card-wide { max-width: 620px; }
.auth-logo {
  width: 62px; height: 62px;
  margin: 0 auto var(--sp-5);
  border-radius: var(--r-lg);
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary));
  color: #fff;
  font-size: var(--fs-2xl);
  box-shadow: 0 10px 30px rgba(37, 99, 235, 0.4);
}
.auth-header { text-align: center; margin-bottom: var(--sp-8); }
.auth-footer {
  text-align: center;
  margin-top: var(--sp-6);
  padding-top: var(--sp-5);
  border-top: 1px solid var(--border);
  font-size: var(--fs-sm);
  color: var(--text-muted);
}

/* ============================================================================
   08. BADGES & STATUS SEMANTICS
   ========================================================================= */

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  padding: 3px var(--sp-3);
  border-radius: var(--r-full);
  font-size: var(--fs-2xs);
  font-weight: var(--fw-bold);
  letter-spacing: 0.03em;
  text-transform: uppercase;
  white-space: nowrap;
  border: 1px solid transparent;
}
.badge i { font-size: 0.9em; }
.badge-lg { padding: var(--sp-2) var(--sp-4); font-size: var(--fs-xs); }

/* Priority */
.badge-critical {
  background: rgba(239, 68, 68, 0.16);
  color: var(--status-critical);
  border-color: rgba(239, 68, 68, 0.32);
}
.badge-high {
  background: rgba(245, 158, 11, 0.16);
  color: var(--status-high);
  border-color: rgba(245, 158, 11, 0.32);
}
.badge-medium {
  background: rgba(16, 185, 129, 0.16);
  color: var(--status-medium);
  border-color: rgba(16, 185, 129, 0.32);
}
.badge-low {
  background: rgba(100, 116, 139, 0.16);
  color: var(--status-low);
  border-color: rgba(100, 116, 139, 0.32);
}

/* Critical priority pulses to draw the eye — required by the brief. */
.badge-critical.pulse,
.pulse-critical {
  animation: pulseCritical 1.8s var(--ease-in-out) infinite;
}

@keyframes pulseCritical {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.5); }
  50%      { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
}

/* Status */
.badge-submitted   { background: rgba(100, 116, 139, 0.16); color: #94a3b8;
                     border-color: rgba(100, 116, 139, 0.3); }
.badge-assigned    { background: rgba(124, 58, 237, 0.16); color: #a78bfa;
                     border-color: rgba(124, 58, 237, 0.3); }
.badge-in_progress { background: rgba(37, 99, 235, 0.16); color: #60a5fa;
                     border-color: rgba(37, 99, 235, 0.3); }
.badge-resolved    { background: rgba(16, 185, 129, 0.16); color: #34d399;
                     border-color: rgba(16, 185, 129, 0.3); }
.badge-closed      { background: rgba(71, 85, 105, 0.2); color: #94a3b8;
                     border-color: rgba(71, 85, 105, 0.34); }

[data-theme='light'] .badge-submitted   { color: #475569; }
[data-theme='light'] .badge-assigned    { color: #6d28d9; }
[data-theme='light'] .badge-in_progress { color: #1d4ed8; }
[data-theme='light'] .badge-resolved    { color: #047857; }
[data-theme='light'] .badge-closed      { color: #475569; }

/* Roles */
.badge-role-admin      { background: var(--brand-secondary-soft); color: var(--brand-secondary);
                         border-color: rgba(124, 58, 237, 0.3); }
.badge-role-technician { background: var(--brand-primary-soft); color: var(--brand-primary);
                         border-color: rgba(37, 99, 235, 0.3); }
.badge-role-user       { background: rgba(100, 116, 139, 0.16); color: var(--text-muted);
                         border-color: rgba(100, 116, 139, 0.3); }

/* Sentiment */
.badge-sentiment-calm       { background: rgba(16, 185, 129, 0.14); color: var(--status-medium); }
.badge-sentiment-neutral    { background: rgba(100, 116, 139, 0.14); color: var(--text-muted); }
.badge-sentiment-frustrated { background: rgba(245, 158, 11, 0.16); color: var(--status-high); }
.badge-sentiment-distressed {
  background: rgba(239, 68, 68, 0.18);
  color: var(--status-critical);
  border-color: rgba(239, 68, 68, 0.35);
  animation: pulseCritical 1.8s var(--ease-in-out) infinite;
}

/* AI badge — reserved cyan with outer glow. */
.badge-ai {
  background: var(--ai-accent-soft);
  color: var(--ai-accent-bright);
  border-color: rgba(6, 182, 212, 0.36);
  box-shadow: var(--ai-glow);
}
[data-theme='light'] .badge-ai { color: #0e7490; }

.badge-outline {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border-strong);
}

/* Priority left-edge marker on rows and cards. */
.priority-rail { position: relative; }
.priority-rail::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  border-radius: var(--r-full);
  background: var(--rail, #64748b);
}
.priority-rail.p-critical { --rail: #ef4444; }
.priority-rail.p-high     { --rail: #f59e0b; }
.priority-rail.p-medium   { --rail: #10b981; }
.priority-rail.p-low      { --rail: #64748b; }

/* Online presence dot */
.presence {
  width: 8px; height: 8px;
  border-radius: var(--r-full);
  background: var(--text-faint);
  flex-shrink: 0;
}
.presence.online {
  background: var(--status-success);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

/* ============================================================================
   09. TABLES
   ========================================================================= */

.table-wrap {
  overflow-x: auto;
  border-radius: var(--r-lg);
  -webkit-overflow-scrolling: touch;
}

.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--fs-sm);
}

.table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: var(--sp-3) var(--sp-4);
  text-align: left;
  font-size: var(--fs-2xs);
  font-weight: var(--fw-bold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
  background: var(--glass-bg-strong);
  backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--border-strong);
  white-space: nowrap;
}

/* Sortable column headers. */
.table thead th[data-sort] {
  cursor: pointer;
  user-select: none;
  transition: color var(--t-fast);
}
.table thead th[data-sort]:hover { color: var(--text-primary); }
.table thead th[data-sort]::after {
  content: '\f0dc';
  font-family: 'Font Awesome 6 Free';
  font-weight: 900;
  margin-left: var(--sp-2);
  opacity: 0.3;
  font-size: 0.85em;
}
.table thead th[data-sort][aria-sort='ascending']::after  { content: '\f0de'; opacity: 1;
                                                            color: var(--brand-primary); }
.table thead th[data-sort][aria-sort='descending']::after { content: '\f0dd'; opacity: 1;
                                                            color: var(--brand-primary); }

.table tbody td {
  padding: var(--sp-4);
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  vertical-align: middle;
}
.table tbody tr { transition: background var(--t-fast) var(--ease-out); }
.table tbody tr:hover { background: var(--glass-bg-subtle); }
.table tbody tr:last-child td { border-bottom: none; }

.table-compact tbody td { padding: var(--sp-3) var(--sp-4); }

.td-strong { color: var(--text-primary); font-weight: var(--fw-semi); }
.td-actions { text-align: right; white-space: nowrap; }

/* Toolbar above a table */
.table-toolbar {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-wrap: wrap;
  padding: var(--sp-4) var(--sp-6);
  border-bottom: 1px solid var(--border);
}
.table-toolbar .form-control { min-height: 38px; }

.filter-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: var(--sp-3);
  align-items: end;
}

/* Empty state */
.empty-state {
  padding: var(--sp-16) var(--sp-6);
  text-align: center;
  color: var(--text-muted);
}
.empty-icon {
  width: 76px; height: 76px;
  margin: 0 auto var(--sp-5);
  border-radius: var(--r-xl);
  display: grid; place-items: center;
  background: var(--glass-bg-subtle);
  border: 1px solid var(--border);
  font-size: var(--fs-2xl);
  color: var(--text-faint);
}
.empty-title { font-size: var(--fs-lg); font-weight: var(--fw-bold);
               color: var(--text-primary); margin-bottom: var(--sp-2); }
.empty-text { max-width: 420px; margin: 0 auto var(--sp-6); font-size: var(--fs-sm); }

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: var(--sp-5);
  flex-wrap: wrap;
}
.page-link {
  min-width: 38px; height: 38px;
  padding: 0 var(--sp-3);
  display: inline-grid;
  place-items: center;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  transition: background var(--t-fast), border-color var(--t-fast),
              color var(--t-fast), transform var(--t-fast) var(--ease-spring);
}
.page-link:hover {
  background: var(--glass-bg-subtle);
  border-color: var(--border-strong);
  color: var(--text-primary);
  transform: translateY(-1px);
}
.page-link.active {
  background: linear-gradient(120deg, var(--brand-primary), var(--brand-secondary));
  border-color: transparent;
  color: #fff;
}
.page-link.disabled { opacity: 0.4; pointer-events: none; }
.page-info { font-size: var(--fs-xs); color: var(--text-faint); margin: 0 var(--sp-3); }

/* ============================================================================
   10. TICKET COMPONENTS
   ========================================================================= */

/* ---- Ticket card (grid view) ---- */
.ticket-card {
  display: block;
  padding: var(--sp-5) var(--sp-5) var(--sp-5) var(--sp-6);
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-sm);
  color: inherit;
  transition: transform var(--t-base) var(--ease-out),
              box-shadow var(--t-base) var(--ease-out),
              border-color var(--t-base);
}
.ticket-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--sh-lg);
  border-color: var(--glass-border-hi);
  color: inherit;
}
/* Escalated tickets glow to fast-track them visually. */
.ticket-card.escalated {
  border-color: rgba(239, 68, 68, 0.4);
  box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.16), 0 0 26px rgba(239, 68, 68, 0.18);
}

.ticket-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-bottom: var(--sp-3);
}
.ticket-id {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  color: var(--brand-primary);
  letter-spacing: -0.02em;
}
.ticket-title {
  font-size: var(--fs-md);
  font-weight: var(--fw-semi);
  color: var(--text-primary);
  line-height: var(--lh-snug);
  margin-bottom: var(--sp-2);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.ticket-excerpt {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  line-height: var(--lh-snug);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: var(--sp-4);
}
.ticket-meta {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  flex-wrap: wrap;
  font-size: var(--fs-xs);
  color: var(--text-faint);
  padding-top: var(--sp-3);
  border-top: 1px solid var(--border);
}
.ticket-meta-item { display: inline-flex; align-items: center; gap: var(--sp-1); }

/* ---- Linear status timeline ---- */
.timeline-track {
  display: flex;
  align-items: flex-start;
  gap: 0;
  padding: var(--sp-6) var(--sp-2);
  overflow-x: auto;
}

.timeline-step {
  flex: 1;
  min-width: 92px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-2);
  position: relative;
  text-align: center;
}

/* Connector line between steps. */
.timeline-step::before {
  content: '';
  position: absolute;
  top: 19px;
  left: -50%;
  width: 100%;
  height: 2px;
  background: var(--border-strong);
  z-index: 0;
}
.timeline-step:first-child::before { display: none; }
.timeline-step.done::before,
.timeline-step.current::before {
  background: linear-gradient(90deg, var(--brand-primary), var(--brand-secondary));
}

.timeline-dot {
  width: 40px; height: 40px;
  border-radius: var(--r-full);
  display: grid; place-items: center;
  background: var(--bg-elevated);
  border: 2px solid var(--border-strong);
  color: var(--text-faint);
  font-size: var(--fs-sm);
  position: relative;
  z-index: 1;
  transition: all var(--t-base) var(--ease-spring);
}
.timeline-step.done .timeline-dot {
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary));
  border-color: transparent;
  color: #fff;
}
.timeline-step.current .timeline-dot {
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary));
  border-color: transparent;
  color: #fff;
  transform: scale(1.14);
  box-shadow: 0 0 0 6px var(--brand-primary-soft);
}
.timeline-label {
  font-size: var(--fs-xs);
  font-weight: var(--fw-semi);
  color: var(--text-faint);
  white-space: nowrap;
}
.timeline-step.done .timeline-label,
.timeline-step.current .timeline-label { color: var(--text-primary); }

/* ---- Activity feed (vertical) ---- */
.activity-feed { position: relative; padding-left: var(--sp-8); }
.activity-feed::before {
  content: '';
  position: absolute;
  left: 15px; top: 8px; bottom: 8px;
  width: 2px;
  background: var(--border);
}
.activity-item { position: relative; padding-bottom: var(--sp-5); }
.activity-item:last-child { padding-bottom: 0; }
.activity-marker {
  position: absolute;
  left: -28px;
  top: 2px;
  width: 24px; height: 24px;
  border-radius: var(--r-full);
  display: grid; place-items: center;
  background: var(--bg-elevated);
  border: 2px solid var(--border-strong);
  color: var(--text-muted);
  font-size: 10px;
}
.activity-item.highlight .activity-marker {
  background: var(--brand-primary);
  border-color: transparent;
  color: #fff;
}
.activity-item.ai .activity-marker {
  background: var(--ai-accent);
  border-color: transparent;
  color: #04252b;
  box-shadow: var(--ai-glow);
}
.activity-text { font-size: var(--fs-sm); color: var(--text-secondary); line-height: var(--lh-snug); }
.activity-time { font-size: var(--fs-2xs); color: var(--text-faint); margin-top: 2px; }

/* ---- Comment thread ---- */
.thread { display: flex; flex-direction: column; gap: var(--sp-4); }

.comment { display: flex; gap: var(--sp-3); }
.comment-body {
  flex: 1;
  min-width: 0;
  padding: var(--sp-4);
  border-radius: var(--r-md);
  background: var(--glass-bg-subtle);
  border: 1px solid var(--border);
}
.comment-head {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
  margin-bottom: var(--sp-2);
}
.comment-author { font-size: var(--fs-sm); font-weight: var(--fw-semi); color: var(--text-primary); }
.comment-time { font-size: var(--fs-2xs); color: var(--text-faint); }
.comment-content {
  font-size: var(--fs-base);
  color: var(--text-secondary);
  line-height: var(--lh-base);
  white-space: pre-wrap;
  word-break: break-word;
}

/* Internal notes get a distinct visual wrapper — never shown to end-users. */
.comment.internal .comment-body {
  background: rgba(245, 158, 11, 0.07);
  border-color: rgba(245, 158, 11, 0.3);
  border-left: 3px solid var(--status-high);
}
.internal-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: var(--fs-2xs);
  font-weight: var(--fw-bold);
  letter-spacing: 0.1em;
  color: var(--status-high);
  margin-bottom: var(--sp-2);
}

.comment.system .comment-body {
  background: var(--brand-primary-soft);
  border-color: rgba(37, 99, 235, 0.26);
  border-left: 3px solid var(--brand-primary);
}

/* ---- SLA meter ---- */
.sla-meter { margin-top: var(--sp-3); }
.sla-head {
  display: flex;
  justify-content: space-between;
  font-size: var(--fs-2xs);
  color: var(--text-faint);
  margin-bottom: var(--sp-2);
  font-weight: var(--fw-semi);
}
.meter {
  height: 6px;
  border-radius: var(--r-full);
  background: var(--bg-sunken);
  overflow: hidden;
}
.meter-fill {
  height: 100%;
  border-radius: var(--r-full);
  background: linear-gradient(90deg, var(--status-medium), var(--status-high));
  transition: width var(--t-slow) var(--ease-out);
}
.meter-fill.warn   { background: linear-gradient(90deg, var(--status-high), #fb923c); }
.meter-fill.danger { background: linear-gradient(90deg, #fb923c, var(--status-critical)); }
.meter-fill.ok     { background: linear-gradient(90deg, var(--status-medium), #34d399); }

/* Attachment tiles */
.attachment-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: var(--sp-3);
}
.attachment-tile {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3);
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--glass-bg-subtle);
  transition: border-color var(--t-fast), transform var(--t-fast);
}
.attachment-tile:hover { border-color: var(--brand-primary); transform: translateY(-2px); }
.attachment-icon {
  width: 36px; height: 36px;
  flex-shrink: 0;
  border-radius: var(--r-sm);
  display: grid; place-items: center;
  background: var(--brand-primary-soft);
  color: var(--brand-primary);
}
.attachment-name {
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.attachment-size { font-size: var(--fs-2xs); color: var(--text-faint); }

/* Definition list for ticket properties */
.prop-list { display: flex; flex-direction: column; gap: var(--sp-4); }
.prop {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  font-size: var(--fs-sm);
}
.prop-key { color: var(--text-faint); font-weight: var(--fw-medium); }
.prop-val { color: var(--text-primary); font-weight: var(--fw-semi); text-align: right; }

/* ============================================================================
   11. AI COGNITIVE LAYER
   ========================================================================= */

/* The AI panel is the only surface allowed the cyan glow treatment. */
.ai-panel {
  position: relative;
  padding: var(--sp-5);
  border-radius: var(--r-lg);
  background: linear-gradient(150deg,
              rgba(6, 182, 212, 0.09), rgba(37, 99, 235, 0.06));
  border: 1px solid rgba(6, 182, 212, 0.28);
  box-shadow: var(--ai-glow);
  overflow: hidden;
}
.ai-panel::before {
  content: '';
  position: absolute;
  inset: -50% auto auto -20%;
  width: 300px; height: 300px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(6, 182, 212, 0.16), transparent 70%);
  pointer-events: none;
}

.ai-panel-head {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
  position: relative;
}
.ai-mark {
  width: 34px; height: 34px;
  flex-shrink: 0;
  border-radius: var(--r-md);
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--ai-accent), var(--brand-primary));
  color: #fff;
  font-size: var(--fs-sm);
  box-shadow: var(--ai-glow);
}
.ai-title {
  font-size: var(--fs-sm);
  font-weight: var(--fw-bold);
  color: var(--ai-accent-bright);
  letter-spacing: 0.02em;
}
[data-theme='light'] .ai-title { color: #0e7490; }
.ai-sub { font-size: var(--fs-2xs); color: var(--text-muted); }

.ai-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--sp-3);
  position: relative;
}
.ai-cell {
  padding: var(--sp-3);
  border-radius: var(--r-md);
  background: var(--glass-bg-subtle);
  border: 1px solid var(--border);
}
.ai-cell-label {
  font-size: var(--fs-2xs);
  font-weight: var(--fw-bold);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: var(--sp-2);
}
.ai-cell-value {
  font-size: var(--fs-md);
  font-weight: var(--fw-bold);
  color: var(--text-primary);
  display: flex; align-items: center; gap: var(--sp-2);
}

/* Confidence meter */
.confidence { margin-top: var(--sp-2); }
.confidence-bar {
  height: 4px;
  border-radius: var(--r-full);
  background: var(--bg-sunken);
  overflow: hidden;
}
.confidence-fill {
  height: 100%;
  border-radius: var(--r-full);
  background: linear-gradient(90deg, var(--ai-accent), var(--brand-primary));
  transition: width var(--t-slow) var(--ease-out);
}
.confidence-text { font-size: var(--fs-2xs); color: var(--text-faint); margin-top: 4px; }

/* Escalation banner */
.ai-alert {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-4);
  border-radius: var(--r-md);
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.32);
  box-shadow: 0 0 22px rgba(239, 68, 68, 0.18);
  animation: pulseCritical 2.4s var(--ease-in-out) infinite;
}
.ai-alert i { color: var(--status-critical); font-size: var(--fs-lg); margin-top: 2px; }
.ai-alert-title { font-size: var(--fs-sm); font-weight: var(--fw-bold);
                  color: var(--status-critical); }
.ai-alert-text { font-size: var(--fs-xs); color: var(--text-secondary); }

/* Knowledge recommendation cards */
.kb-suggestion {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-4);
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--glass-bg-subtle);
  color: inherit;
  transition: border-color var(--t-fast), transform var(--t-fast),
              box-shadow var(--t-fast);
}
.kb-suggestion:hover {
  border-color: var(--ai-accent);
  transform: translateX(3px);
  box-shadow: var(--ai-glow);
  color: inherit;
}
.kb-match {
  flex-shrink: 0;
  padding: 2px var(--sp-2);
  border-radius: var(--r-full);
  background: var(--ai-accent-soft);
  color: var(--ai-accent-bright);
  font-size: var(--fs-2xs);
  font-weight: var(--fw-bold);
  font-variant-numeric: tabular-nums;
}
[data-theme='light'] .kb-match { color: #0e7490; }
.kb-suggestion-title { font-size: var(--fs-sm); font-weight: var(--fw-semi);
                       color: var(--text-primary); }
.kb-suggestion-text { font-size: var(--fs-xs); color: var(--text-muted); margin-top: 2px; }

/* Typing indicator for live analysis */
.ai-thinking {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-xs);
  color: var(--ai-accent-bright);
}
.ai-dots { display: inline-flex; gap: 3px; }
.ai-dots span {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: currentColor;
  animation: bounceDot 1.2s var(--ease-in-out) infinite;
}
.ai-dots span:nth-child(2) { animation-delay: 0.15s; }
.ai-dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes bounceDot {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30%           { transform: translateY(-5px); opacity: 1; }
}

/* ============================================================================
   12. CHATBOT WIDGET
   ========================================================================= */

.chat-launcher {
  position: fixed;
  bottom: var(--sp-6);
  right: var(--sp-6);
  z-index: var(--z-chat);
  width: 58px; height: 58px;
  border-radius: var(--r-full);
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--ai-accent), var(--brand-primary));
  color: #fff;
  font-size: var(--fs-xl);
  box-shadow: var(--ai-glow-strong), var(--sh-lg);
  transition: transform var(--t-base) var(--ease-spring),
              box-shadow var(--t-base), opacity var(--t-base);
}
.chat-launcher:hover { transform: scale(1.08) rotate(-6deg); }
.chat-launcher.hidden { transform: scale(0); opacity: 0; pointer-events: none; }

.chat-window {
  position: fixed;
  bottom: var(--sp-6);
  right: var(--sp-6);
  z-index: var(--z-chat);
  width: min(400px, calc(100vw - 2 * var(--sp-6)));
  height: min(600px, calc(100vh - 2 * var(--sp-6)));
  display: flex;
  flex-direction: column;
  border-radius: var(--r-xl);
  background: var(--glass-bg-strong);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid rgba(6, 182, 212, 0.3);
  box-shadow: var(--sh-xl), var(--ai-glow);
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(16px) scale(0.96);
  transform-origin: bottom right;
  transition: opacity var(--t-base) var(--ease-out),
              transform var(--t-base) var(--ease-spring),
              visibility var(--t-base);
}
.chat-window.open { opacity: 1; visibility: visible; transform: translateY(0) scale(1); }

.chat-header {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--glass-border);
  background: linear-gradient(120deg, rgba(6, 182, 212, 0.12), rgba(37, 99, 235, 0.08));
  flex-shrink: 0;
}
.chat-title { font-size: var(--fs-sm); font-weight: var(--fw-bold); }
.chat-status { font-size: var(--fs-2xs); color: var(--status-success);
               display: flex; align-items: center; gap: 5px; }

.chat-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-5);
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.chat-msg { display: flex; gap: var(--sp-2); max-width: 88%; }
.chat-msg.user { align-self: flex-end; flex-direction: row-reverse; }
.chat-bubble {
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-lg);
  font-size: var(--fs-sm);
  line-height: var(--lh-snug);
  white-space: pre-wrap;
  word-break: break-word;
}
.chat-msg.bot .chat-bubble {
  background: var(--glass-bg-subtle);
  border: 1px solid var(--border);
  border-bottom-left-radius: var(--r-xs);
}
.chat-msg.user .chat-bubble {
  background: linear-gradient(120deg, var(--brand-primary), var(--brand-secondary));
  color: #fff;
  border-bottom-right-radius: var(--r-xs);
}
.chat-avatar {
  width: 30px; height: 30px;
  flex-shrink: 0;
  border-radius: var(--r-full);
  display: grid; place-items: center;
  font-size: var(--fs-xs);
  background: linear-gradient(135deg, var(--ai-accent), var(--brand-primary));
  color: #fff;
}
.chat-msg.user .chat-avatar {
  background: var(--glass-bg-subtle);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.chat-actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; padding-left: 38px; }

.chat-footer {
  padding: var(--sp-3) var(--sp-4);
  border-top: 1px solid var(--glass-border);
  display: flex;
  gap: var(--sp-2);
  align-items: flex-end;
  flex-shrink: 0;
}
.chat-input {
  flex: 1;
  min-height: 42px;
  max-height: 120px;
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-lg);
  background: var(--field-bg);
  border: 1px solid var(--field-border);
  font-size: var(--fs-sm);
  resize: none;
  line-height: var(--lh-snug);
}
.chat-input:focus {
  outline: none;
  border-color: var(--ai-accent);
  box-shadow: 0 0 0 3px var(--ai-accent-soft);
}
.chat-send {
  width: 42px; height: 42px;
  flex-shrink: 0;
  border-radius: var(--r-lg);
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--ai-accent), var(--brand-primary));
  color: #fff;
  transition: transform var(--t-fast) var(--ease-spring), opacity var(--t-fast);
}
.chat-send:hover { transform: scale(1.06); }
.chat-send:disabled { opacity: 0.45; pointer-events: none; }

/* ============================================================================
   13. CHARTS
   ========================================================================= */

.chart-card { display: flex; flex-direction: column; }
.chart-box { position: relative; padding: var(--sp-5) var(--sp-6) var(--sp-6); }
.chart-canvas-wrap { position: relative; height: 300px; }
.chart-canvas-wrap.tall { height: 380px; }
.chart-canvas-wrap.short { height: 220px; }

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-6);
  border-top: 1px solid var(--border);
  font-size: var(--fs-xs);
  color: var(--text-muted);
}
.legend-item { display: inline-flex; align-items: center; gap: var(--sp-2); }
.legend-swatch { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }

/* Horizontal workload bars */
.workload-row {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) 2fr auto;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-3) 0;
  border-bottom: 1px solid var(--border);
  font-size: var(--fs-sm);
}
.workload-row:last-child { border-bottom: none; }
.workload-name { display: flex; align-items: center; gap: var(--sp-2);
                 font-weight: var(--fw-medium); color: var(--text-primary); }
.workload-bar {
  height: 8px;
  border-radius: var(--r-full);
  background: var(--bg-sunken);
  overflow: hidden;
}
.workload-fill {
  height: 100%;
  border-radius: var(--r-full);
  background: linear-gradient(90deg, var(--brand-primary), var(--brand-secondary));
  transition: width var(--t-slow) var(--ease-out);
}
/* Agents past 80% capacity are flagged for burnout risk. */
.workload-fill.at-risk {
  background: linear-gradient(90deg, var(--status-high), var(--status-critical));
}
.workload-count {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Category share list */
.share-row { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) 0; }
.share-dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.share-name { flex: 1; font-size: var(--fs-sm); color: var(--text-secondary); }
.share-value { font-size: var(--fs-sm); font-weight: var(--fw-bold);
               color: var(--text-primary); font-variant-numeric: tabular-nums; }

/* ============================================================================
   14. TOASTS & ALERTS
   ========================================================================= */

.toast-container {
  position: fixed;
  top: calc(var(--navbar-h) + var(--sp-4));
  right: var(--sp-6);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  max-width: 400px;
  pointer-events: none;
}

.toast-message {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-4);
  border-radius: var(--r-md);
  background: var(--glass-bg-strong);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border-hi);
  border-left: 3px solid var(--brand-primary);
  box-shadow: var(--sh-lg);
  pointer-events: auto;
  animation: slideInRight var(--t-base) var(--ease-out);
}
.toast-success { border-left-color: var(--status-success); }
.toast-error   { border-left-color: var(--status-danger); }
.toast-warning { border-left-color: var(--status-warning); }
.toast-info    { border-left-color: var(--status-info); }

.toast-icon { font-size: var(--fs-md); margin-top: 1px; flex-shrink: 0; }
.toast-success .toast-icon { color: var(--status-success); }
.toast-error   .toast-icon { color: var(--status-danger); }
.toast-warning .toast-icon { color: var(--status-warning); }
.toast-info    .toast-icon { color: var(--status-info); }

.toast-body { flex: 1; min-width: 0; }
.toast-text { font-size: var(--fs-sm); color: var(--text-primary); line-height: var(--lh-snug); }
.toast-close {
  color: var(--text-faint);
  font-size: var(--fs-xs);
  padding: var(--sp-1);
  transition: color var(--t-fast);
}
.toast-close:hover { color: var(--text-primary); }

/* Inline alerts */
.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-4);
  border-radius: var(--r-md);
  font-size: var(--fs-sm);
  border: 1px solid transparent;
}
.alert i { margin-top: 2px; flex-shrink: 0; }
.alert-info    { background: var(--brand-primary-soft); color: var(--text-secondary);
                 border-color: rgba(37, 99, 235, 0.28); }
.alert-success { background: rgba(16, 185, 129, 0.1); color: var(--text-secondary);
                 border-color: rgba(16, 185, 129, 0.28); }
.alert-warning { background: rgba(245, 158, 11, 0.1); color: var(--text-secondary);
                 border-color: rgba(245, 158, 11, 0.28); }
.alert-danger  { background: rgba(239, 68, 68, 0.1); color: var(--text-secondary);
                 border-color: rgba(239, 68, 68, 0.28); }
.alert-ai {
  background: var(--ai-accent-soft);
  border-color: rgba(6, 182, 212, 0.3);
  box-shadow: var(--ai-glow);
  color: var(--text-secondary);
}
.alert-title { font-weight: var(--fw-bold); color: var(--text-primary); margin-bottom: 2px; }

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  background: var(--scrim);
  backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  padding: var(--sp-6);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--t-base) var(--ease-out), visibility var(--t-base);
}
.modal-backdrop.open { opacity: 1; visibility: visible; }
.modal {
  width: 100%;
  max-width: 540px;
  max-height: 88vh;
  overflow-y: auto;
  border-radius: var(--r-xl);
  background: var(--glass-bg-strong);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border-hi);
  box-shadow: var(--sh-xl);
  transform: scale(0.94) translateY(10px);
  transition: transform var(--t-base) var(--ease-spring);
}
.modal-backdrop.open .modal { transform: scale(1) translateY(0); }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-4);
  padding: var(--sp-5) var(--sp-6);
  border-bottom: 1px solid var(--border);
}
.modal-body { padding: var(--sp-6); }
.modal-footer {
  display: flex; justify-content: flex-end; gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-6);
  border-top: 1px solid var(--border);
}

/* ============================================================================
   15. SKELETON LOADERS
   ========================================================================= */

.skeleton {
  position: relative;
  overflow: hidden;
  background: var(--glass-bg-subtle);
  border-radius: var(--r-sm);
}
/* Shimmer sweep shown during async DB queries and AI requests. */
.skeleton::after {
  content: '';
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent,
              rgba(148, 163, 184, 0.14) 50%, transparent);
  animation: shimmer 1.5s infinite;
}
[data-theme='light'] .skeleton::after {
  background: linear-gradient(90deg, transparent,
              rgba(15, 23, 42, 0.06) 50%, transparent);
}

@keyframes shimmer { 100% { transform: translateX(100%); } }

.skeleton-text   { height: 12px; margin-bottom: var(--sp-2); border-radius: var(--r-xs); }
.skeleton-text.w-90 { width: 90%; }
.skeleton-text.w-70 { width: 70%; }
.skeleton-text.w-50 { width: 50%; }
.skeleton-title  { height: 20px; width: 55%; margin-bottom: var(--sp-3); }
.skeleton-circle { width: 40px; height: 40px; border-radius: var(--r-full); }
.skeleton-card   { height: 128px; border-radius: var(--r-lg); }
.skeleton-chart  { height: 300px; border-radius: var(--r-md); }
.skeleton-row    { height: 52px; margin-bottom: var(--sp-2); border-radius: var(--r-sm); }

.is-loading { pointer-events: none; opacity: 0.6; }

/* Inline spinner */
.spinner {
  width: 16px; height: 16px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  display: inline-block;
  animation: spin 0.7s linear infinite;
}
.spinner-lg { width: 28px; height: 28px; border-width: 3px; }

@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================================
   16. UTILITIES
   ========================================================================= */

.mt-0{margin-top:0}      .mt-2{margin-top:var(--sp-2)}   .mt-3{margin-top:var(--sp-3)}
.mt-4{margin-top:var(--sp-4)}  .mt-5{margin-top:var(--sp-5)}  .mt-6{margin-top:var(--sp-6)}
.mt-8{margin-top:var(--sp-8)}
.mb-0{margin-bottom:0}   .mb-2{margin-bottom:var(--sp-2)} .mb-3{margin-bottom:var(--sp-3)}
.mb-4{margin-bottom:var(--sp-4)} .mb-5{margin-bottom:var(--sp-5)} .mb-6{margin-bottom:var(--sp-6)}
.mb-8{margin-bottom:var(--sp-8)}
.p-0{padding:0} .p-4{padding:var(--sp-4)} .p-5{padding:var(--sp-5)} .p-6{padding:var(--sp-6)}

.flex{display:flex} .block{display:block}
.hidden{display:none !important}
.items-center{align-items:center} .items-start{align-items:flex-start}
.items-end{align-items:flex-end}
.justify-between{justify-content:space-between} .justify-center{justify-content:center}
.justify-end{justify-content:flex-end}
.flex-col{flex-direction:column} .flex-wrap{flex-wrap:wrap}
.flex-1{flex:1} .shrink-0{flex-shrink:0}
.gap-1{gap:var(--sp-1)} .gap-2{gap:var(--sp-2)} .gap-3{gap:var(--sp-3)}
.gap-4{gap:var(--sp-4)} .gap-5{gap:var(--sp-5)} .gap-6{gap:var(--sp-6)}

.w-full{width:100%} .h-full{height:100%}
.text-center{text-align:center} .text-right{text-align:right} .text-left{text-align:left}
.text-xs{font-size:var(--fs-xs)} .text-sm{font-size:var(--fs-sm)}
.text-lg{font-size:var(--fs-lg)} .text-xl{font-size:var(--fs-xl)}
.font-medium{font-weight:var(--fw-medium)} .font-semi{font-weight:var(--fw-semi)}
.font-bold{font-weight:var(--fw-bold)}
.uppercase{text-transform:uppercase} .tabular{font-variant-numeric:tabular-nums}
.truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.break-word{word-break:break-word}
.relative{position:relative}
.rounded{border-radius:var(--r-md)} .rounded-full{border-radius:var(--r-full)}
.border-t{border-top:1px solid var(--border)}
.border-b{border-bottom:1px solid var(--border)}

.c-critical{color:var(--status-critical)} .c-high{color:var(--status-high)}
.c-medium{color:var(--status-medium)}     .c-low{color:var(--status-low)}
.c-success{color:var(--status-success)}   .c-danger{color:var(--status-danger)}
.c-ai{color:var(--ai-accent-bright)}      .c-primary{color:var(--brand-primary)}

.divider { height: 1px; background: var(--border); margin: var(--sp-5) 0; }

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ============================================================================
   17. RESPONSIVE
   ========================================================================= */

@media (max-width: 1280px) {
  .grid-sidebar, .grid-sidebar-left { grid-template-columns: 1fr; }
}

@media (max-width: 1024px) {
  :root { --sidebar-w: 240px; }
  .content-area { padding: var(--sp-6); }
  .navbar { padding: 0 var(--sp-5); }
  .stat-grid { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
}

@media (max-width: 860px) {
  /* Sidebar becomes an overlay drawer. */
  .sidebar {
    transform: translateX(-100%);
    box-shadow: var(--sh-xl);
    width: var(--sidebar-w);
  }
  body.sidebar-open .sidebar { transform: translateX(0); }
  body.sidebar-collapsed .sidebar { width: var(--sidebar-w); }
  .main-wrapper.with-sidebar,
  body.sidebar-collapsed .main-wrapper.with-sidebar { padding-left: 0; }

  body.sidebar-open::after {
    content: '';
    position: fixed;
    inset: 0;
    z-index: calc(var(--z-sidebar) - 1);
    background: var(--scrim);
    backdrop-filter: blur(3px);
  }

  body.sidebar-collapsed .sidebar-brand,
  body.sidebar-collapsed .nav-item-label,
  body.sidebar-collapsed .nav-badge,
  body.sidebar-collapsed .nav-section-label { display: revert; }
  body.sidebar-collapsed .nav-item { justify-content: flex-start; padding-inline: var(--sp-3); }
  body.sidebar-collapsed .sidebar-header { justify-content: flex-start; padding-inline: var(--sp-5); }

  .navbar-search { display: none; }
  .user-chip-meta { display: none; }
  .page-header { flex-direction: column; align-items: stretch; }
  .toast-container { left: var(--sp-4); right: var(--sp-4); max-width: none; }
}

@media (max-width: 600px) {
  :root { --fs-3xl: 1.5rem; --fs-4xl: 2rem; }
  .content-area { padding: var(--sp-4); }
  .navbar { padding: 0 var(--sp-4); }
  .card-body, .chart-box { padding: var(--sp-4); }
  .card-header { padding: var(--sp-4); }
  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: var(--sp-3); }
  .stat-card { padding: var(--sp-4); }
  .auth-card { padding: var(--sp-6); }
  .chat-window {
    inset: 0;
    width: 100%; height: 100%;
    border-radius: 0;
  }
  .chat-launcher { bottom: var(--sp-4); right: var(--sp-4); }
  .workload-row { grid-template-columns: 1fr; gap: var(--sp-2); }
  .timeline-track { padding: var(--sp-4) 0; }
  .timeline-label { font-size: 10px; }

  /* Tables reflow into stacked cards. */
  .table thead { display: none; }
  .table tbody td {
    display: flex;
    justify-content: space-between;
    gap: var(--sp-4);
    padding: var(--sp-2) var(--sp-4);
    border: none;
  }
  .table tbody td::before {
    content: attr(data-label);
    font-weight: var(--fw-bold);
    font-size: var(--fs-2xs);
    text-transform: uppercase;
    color: var(--text-faint);
  }
  .table tbody tr {
    display: block;
    margin-bottom: var(--sp-3);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: var(--sp-2) 0;
  }
}

@media print {
  .sidebar, .navbar, .footer, .chat-launcher, .chat-window,
  .toast-container, .page-header-actions, .table-toolbar { display: none !important; }
  .main-wrapper.with-sidebar { padding-left: 0; }
  body { background: #fff; color: #000; }
  .card { break-inside: avoid; border: 1px solid #ddd; box-shadow: none; }
}

/* ============================================================================
   18. MOTION & ACCESSIBILITY
   ========================================================================= */

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes pop {
  from { transform: scale(0.4); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}
@keyframes slideInRight {
  from { opacity: 0; transform: translateX(100%); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes slideOutRight {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(110%); }
}

.animate-rise { animation: rise var(--t-slow) var(--ease-out) both; }
.delay-1 { animation-delay: 60ms; }
.delay-2 { animation-delay: 120ms; }
.delay-3 { animation-delay: 180ms; }
.delay-4 { animation-delay: 240ms; }

/* Respect the user's motion preference — animations become instant. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

@media (prefers-contrast: more) {
  :root { --border: rgba(148, 163, 184, 0.4); --border-strong: rgba(148, 163, 184, 0.6); }
  .badge { border-width: 2px; }
}
