/* Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  /* ==========================================================================
     DESIGN SYSTEM TOKENS
     Based on the Updated Design Guide
     ========================================================================== */

  /* Brand Colors (Primary Accent) - Teal */
  --primary: #0D9488;           /* Primary / 1 - Default accent */
  --primary-hover: #14B8A6;     /* Primary / 2 - Hover states */
  --primary-active: #2DD4BF;    /* Primary / 3 - Active/pressed */
  --primary-disabled: #CCFBF1;  /* Primary / 4 - Disabled */
  --primary-light: #14B8A6;     /* Alias for compatibility */
  --primary-dark: #0F766E;      /* Darker shade */
  --primary-lighter: #F0FDFA;   /* Ultra-light background */

  /* RGB values for rgba() usage */
  --primary-rgb: 13, 148, 136;
  --primary-hover-rgb: 20, 184, 166;
  --primary-active-rgb: 45, 212, 191;

  /* Text Colors */
  --text-header: #1B1C20;       /* Header - Main headings */
  --text-body: #383A47;         /* Body - Primary paragraph text */
  --text-muted: #70727F;        /* Body 2 - Secondary/subtitles */
  --text-tertiary: #CDCED8;     /* Body 3 - Hints/placeholders/disabled */
  --text-on-color: #FFFFFF;     /* Text on dark backgrounds */

  /* Compatibility aliases */
  --text: var(--text-body);
  --text-primary: var(--text-header);
  --text-secondary: var(--text-muted);
  --dark: var(--text-header);
  --dark-light: var(--text-body);

  /* Background Colors */
  --bg-dark: #474958;           /* Background / 1 - Cards, sidebars, dark sections */
  --bg-light: #E8E9ED;          /* Background / 2 - Containers, forms, panels */
  --bg-ultra-light: #F8F8FA;    /* Background / 3 - Page background */
  --white: #FFFFFF;
  --light: var(--bg-ultra-light);

  /* Compatibility aliases */
  --bg-primary: var(--white);
  --bg-secondary: var(--bg-ultra-light);

  /* Border Colors */
  --border: #CDCED8;            /* Light borders */
  --border-light: #E8E9ED;      /* Ultra-light borders */
  --border-dark: #70727F;       /* Dark borders */
  --border-color: var(--border);

  /* Semantic Colors */
  --secondary: #70727F;
  --success: #10b981;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --warning: #f59e0b;

  /* Secondary Accent (use sparingly) */
  --accent-pink: #DF678C;
  --accent-pink-hover: #D84773;

  /* ==========================================================================
     STANDARDIZED SCALES
     ========================================================================== */

  /* Border Radius Scale */
  --radius-2xs: 4px;            /* Very small elements, tags */
  --radius-xs: 6px;             /* Small buttons, inputs */
  --radius-sm: 8px;             /* Inputs, badges, small elements */
  --radius-md: 10px;            /* Medium elements */
  --radius-lg: 12px;            /* Buttons, cards */
  --radius-xl: 14px;            /* Large elements */
  --radius-2xl: 16px;           /* Modals, panels */
  --radius-3xl: 20px;           /* Extra large elements */
  --radius-full: 999px;         /* Pills, avatars */

  /* Z-index Scale */
  --z-base: 1;
  --z-dropdown: 1000;
  --z-sticky: 1100;
  --z-modal-backdrop: 2000;
  --z-modal: 2001;
  --z-toast: 3000;
  --z-tooltip: 4000;

  /* Font Size Scale - Complete */
  --text-2xs: 10px;    /* Tiny labels, badges */
  --text-xs: 11px;     /* Small badges, hints */
  --text-sm: 12px;     /* Small text, captions */
  --text-md: 13px;     /* Secondary body text */
  --text-base: 14px;   /* Primary body text */
  --text-lg: 15px;     /* Emphasized body */
  --text-xl: 16px;     /* Subheadings */
  --text-2xl: 18px;    /* Section headings */
  --text-3xl: 20px;    /* Page subheadings */
  --text-4xl: 24px;    /* Page headings */
  --text-5xl: 28px;    /* Large headings */
  --text-6xl: 32px;    /* Hero text */
  --text-7xl: 48px;    /* Display text */

  /* Spacing Scale - Complete */
  --space-0: 0px;
  --space-px: 1px;
  --space-0-5: 2px;
  --space-1: 4px;
  --space-1-5: 6px;
  --space-2: 8px;
  --space-2-5: 10px;
  --space-3: 12px;
  --space-3-5: 14px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;

  /* Layout */
  --sidebar-width: 260px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--light);
  color: var(--text);
  line-height: 1.6;
}

/* Login Page Styles */
.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  padding: var(--space-5);
}

.login-box {
  background: white;
  border-radius: var(--radius-lg);
  padding: var(--space-12) var(--space-10);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  width: 100%;
  max-width: 420px;
}

.login-header {
  text-align: center;
  margin-bottom: var(--space-8);
}

.login-header h1 {
  font-size: var(--text-5xl);
  color: var(--dark);
  margin-bottom: var(--space-2);
}

.login-header p {
  color: var(--text-muted);
  font-size: var(--text-base);
}

.form-group {
  margin-bottom: var(--space-6);
}

.form-group label {
  display: block;
  margin-bottom: var(--space-2);
  font-weight: 500;
  font-size: var(--text-base);
  color: var(--dark);
}

.form-control {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-lg);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  transition: all 0.3s ease;
  font-family: inherit;
  background: var(--white);
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb, 109, 38, 171), 0.1);
  background: var(--white);
}

.form-control:hover {
  border-color: var(--primary-light);
}

.btn {
  display: inline-block;
  padding: var(--space-3) var(--space-6);
  font-size: var(--text-sm);
  font-weight: 600;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
  font-family: inherit;
}

.btn-primary {
  background: var(--primary);
  color: var(--text-on-color);
  width: 100%;
  box-shadow: 0 4px 12px rgba(var(--primary-rgb), 0.2);
}

.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(var(--primary-rgb), 0.3);
}

.btn-primary:active {
  background: var(--primary-active);
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(var(--primary-rgb), 0.2);
}

.btn-primary:disabled {
  background: var(--primary-disabled);
  color: var(--text-tertiary);
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-secondary {
  background: var(--white);
  color: var(--primary);
  border: 2px solid var(--primary);
}

.btn-secondary:hover {
  background: var(--bg-ultra-light);
  border-color: var(--primary-hover);
}

.btn-danger {
  background: var(--danger);
  color: var(--text-on-color);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.2);
}

.btn-danger:hover {
  background: var(--danger-hover);
  box-shadow: 0 6px 20px rgba(239, 68, 68, 0.3);
}

.btn-sm {
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
}

.btn-xs {
  padding: var(--space-1-5) var(--space-3);
  font-size: var(--text-md);
  font-weight: 500;
}

.alert {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-5);
  font-size: var(--text-sm);
  position: relative;
  z-index: var(--z-toast);
  white-space: pre-line;
}

.alert-error {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.alert-success {
  background: #d1fae5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.alert-info {
  background: #dbeafe;
  color: #1e40af;
  border: 1px solid #bfdbfe;
}

/* Toast Notifications - floating, compact alerts */
.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 100000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--background);
  border-radius: var(--radius);
  padding: 12px 16px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 320px;
  min-width: 200px;
  pointer-events: auto;
  animation: toast-slide-in 0.3s ease;
  border-left: 4px solid var(--text-muted);
}

.toast.toast-success {
  border-left-color: var(--success);
  background: #f0fdf4;
}

.toast.toast-error {
  border-left-color: var(--danger);
  background: #fef2f2;
}

.toast.toast-info {
  border-left-color: var(--primary);
  background: #eff6ff;
}

.toast-icon {
  font-size: 16px;
  flex-shrink: 0;
}

.toast-message {
  flex: 1;
  font-size: 14px;
  line-height: 1.4;
  color: #1f2937 !important;
}

.toast-icon {
  color: #1f2937 !important;
}

.toast.toast-success .toast-icon {
  color: #059669 !important;
}

.toast.toast-error .toast-icon {
  color: #dc2626 !important;
}

.toast.toast-info .toast-icon {
  color: #2563eb !important;
}

.toast-close {
  background: none;
  border: none;
  padding: 4px;
  cursor: pointer;
  color: #6b7280;
  font-size: 16px;
  line-height: 1;
  opacity: 0.6;
  transition: opacity 0.2s;
}

.toast-close:hover {
  opacity: 1;
}

.toast.toast-exit {
  animation: toast-slide-out 0.2s ease forwards;
}

@keyframes toast-slide-in {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes toast-slide-out {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(100%);
    opacity: 0;
  }
}

/* Dark mode toast */
[data-theme="dark"] .toast {
  background: var(--background-secondary);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .toast.toast-success {
  background: #052e16;
}

[data-theme="dark"] .toast.toast-error {
  background: #450a0a;
}

[data-theme="dark"] .toast.toast-info {
  background: #172554;
}

[data-theme="dark"] .toast .toast-message,
[data-theme="dark"] .toast .toast-icon,
html[data-theme="dark"] .toast .toast-message,
html[data-theme="dark"] .toast .toast-icon,
.dark .toast .toast-message,
.dark .toast .toast-icon {
  color: #f3f4f6 !important;
}

[data-theme="dark"] .toast .toast-close,
html[data-theme="dark"] .toast .toast-close,
.dark .toast .toast-close {
  color: #9ca3af !important;
}

/* Form Helper Styles */
.form-text {
  display: block;
  margin-top: var(--space-1);
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.required {
  color: var(--danger);
  font-weight: 600;
}

/* Password Strength Indicator */
.password-strength {
  margin-top: var(--space-2);
}

.strength-bar {
  width: 100%;
  height: 4px;
  background: var(--border-light);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-bottom: var(--space-1);
}

.strength-bar-fill {
  height: 100%;
  width: 0%;
  transition: width 0.3s ease, background-color 0.3s ease;
  border-radius: var(--radius-full);
}

/* Login/Signup Footer */
.login-footer {
  margin-top: var(--space-5);
  text-align: center;
  padding-top: var(--space-4);
  border-top: 1px solid var(--border-light);
}

.login-footer p {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin: 0;
}

.login-footer a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
  transition: color 0.2s ease;
}

.login-footer a:hover {
  color: var(--primary-hover);
  text-decoration: underline;
}

/* Dashboard Layout */
.dashboard {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  background: var(--dark);
  color: white;
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
  left: 0;
  top: 0;
}

.sidebar-header {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

/* ============================================
   APP BRANDING SECTION (Primary - Always Same)
   ============================================ */
.app-branding {
  display: flex;
  align-items: center;  /* Vertically center logo and text */
  gap: 12px;
  padding-bottom: var(--space-3);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.app-logo {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.app-logo svg {
  display: block;  /* Remove inline spacing */
}

.app-title {
  display: flex;
  flex-direction: column;
  justify-content: center;  /* Center text vertically */
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.app-title h2 {
  font-size: 18px;
  font-weight: 700;
  margin: 0;
  padding: 0;
  letter-spacing: -0.4px;
  line-height: 1.3;  /* Better vertical alignment */
  color: #FFFFFF;  /* White text for app name */
}

.app-title p {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.6);  /* Muted white for subtitle */
  margin: 0;
  padding: 0;
  line-height: 1.2;
  font-weight: 500;
}

/* ============================================
   TEAM CONTEXT SECTION (Secondary - Changes)
   ============================================ */
.team-context {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.team-context-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  font-weight: 600;
  opacity: 0.7;
}

.team-selector {
  display: flex !important;
  flex-direction: row !important;  /* Ensure items are in a row */
  align-items: center !important;  /* Vertically center avatar and text */
  gap: 10px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--radius);
  transition: background 0.2s ease;
  cursor: pointer;
  position: relative;
}

.team-selector:hover {
  background: rgba(255, 255, 255, 0.06);
}

/* Team switcher dropdown */
.team-switcher-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: #2a2d3a;
  border: 1px solid rgba(13, 148, 136, 0.2);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  z-index: 1000;
  max-height: 300px;
  overflow-y: auto;
  display: none;
}

.team-switcher-dropdown.show {
  display: block;
}

.team-switcher-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  cursor: pointer;
  transition: background 0.2s ease;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.team-switcher-item:last-child {
  border-bottom: none;
}

.team-switcher-item:hover {
  background: rgba(13, 148, 136, 0.1);
}

.team-switcher-item.active {
  background: rgba(13, 148, 136, 0.15);
}

.team-switcher-item .team-avatar {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}

.team-switcher-item .team-name {
  font-size: 13px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.9);
}

.team-switcher-item.active .team-name {
  color: #0D9488;
  font-weight: 600;
}

.team-switcher-header {
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.5);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

/* Dropdown arrow indicator */
.team-selector::after {
  content: '▼';
  font-size: 10px;
  color: rgba(255, 255, 255, 0.5);
  margin-left: auto;
  transition: transform 0.2s ease;
}

.team-selector.open::after {
  transform: rotate(180deg);
}

.team-avatar {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(13, 148, 136, 0.2), rgba(15, 118, 110, 0.2));
  border-radius: var(--radius);
  border: 1.5px solid rgba(13, 148, 136, 0.3);
  position: relative;  /* For absolute positioning of children */
}

.team-avatar-fallback {
  font-size: 16px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Hide fallback when custom logo is loaded */
.team-avatar img.team-logo-img,
.team-avatar img.team-avatar-img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--radius);
}

.team-info {
  display: flex;
  flex-direction: column;
  justify-content: center;  /* Center text vertically */
  gap: 2px;
  flex: 1 1 auto;  /* Allow shrinking */
  min-width: 0;  /* Allow text truncation */
  max-width: 100%;  /* Don't overflow container */
}

.team-name {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;  /* Better alignment */
  color: #FFFFFF;  /* White text to match */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0;
  padding: 0;
}

/* ============================================
   LEGACY STYLES (Keep for backward compat)
   ============================================ */
.sidebar-header-top {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.sidebar-header-title {
  display: flex;
  flex-direction: column;
  gap: var(--space-px);
  flex: 1;
  min-width: 0;
}

.sidebar-header h2 {
  font-size: var(--text-base);
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.3px;
  line-height: 1;
}

.sidebar-header p {
  font-size: var(--text-2xs);
  color: rgba(255, 255, 255, 0.4);
  margin: 0;
  line-height: 1;
}

/* Team info row - shows team name and status */
.team-info-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.team-badge {
  display: flex;
  align-items: center;
  gap: var(--space-1-5);
  flex: 1;
  min-width: 0;
}

.team-name-badge {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  flex: 1;
  min-width: 0;
  padding: var(--space-1) var(--space-2);
  background: rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-xs);
  transition: background 0.2s;
}

.team-name-badge:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* DEPRECATED: Duplicate .team-name rule - using the one in TEAM CONTEXT SECTION above (line 461) */
/*
.team-name {
  font-size: var(--text-sm);
  font-weight: 500;
  color: rgba(255, 255, 255, 0.9);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
*/

/* Status indicator - shows pending items count */
.header-status-badge {
  font-size: var(--text-xs);
  font-weight: 600;
  background: rgba(239, 68, 68, 0.9);
  color: white;
  padding: var(--space-0-5) var(--space-1-5);
  border-radius: var(--radius-2xs);
  white-space: nowrap;
  flex-shrink: 0;
}

.sidebar-nav {
  flex: 1;
  padding: var(--space-4) 0;
  overflow-y: auto;
}

/* Navigation divider between regular and admin sections */
.nav-divider {
  margin: var(--space-3) var(--space-4);
  height: 1px;
  background: rgba(255, 255, 255, 0.1);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-2-5);
  padding: var(--space-2-5) var(--space-4);
  color: rgba(255, 255, 255, 0.85);
  text-decoration: none;
  transition: all 0.15s ease;
  border-left: 3px solid transparent;
  font-size: var(--text-base);
  font-weight: 500;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin: 0 var(--space-1) var(--space-1) 0;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 1);
  border-left-color: rgba(255, 255, 255, 0.3);
}

.nav-item.active {
  background: rgba(255, 255, 255, 0.15);
  border-left-color: var(--primary);
  color: rgba(255, 255, 255, 1);
  font-weight: 600;
}

.sidebar-footer {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.15);
}

.user-info {
  display: flex;
  align-items: center;
  margin-bottom: var(--space-4);
  padding: var(--space-3);
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-md);
  transition: all 0.2s ease;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.user-info:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.12);
}

.user-avatar {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: var(--text-lg);
  margin-right: var(--space-3);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  flex-shrink: 0;
}

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

.user-details h4 {
  font-size: var(--text-base);
  font-weight: 600;
  margin-bottom: var(--space-0-5);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: rgba(255, 255, 255, 0.95);
  line-height: 1.4;
}

.user-details p {
  font-size: var(--text-sm);
  color: rgba(255, 255, 255, 0.6);
  display: flex;
  align-items: center;
  gap: var(--space-1);
  flex-wrap: wrap;
  line-height: 1.3;
}

/* Sidebar Logout Button - Fixed for visibility */
.sidebar-footer .btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-sm);
  font-size: var(--text-base);
  padding: var(--space-2-5) var(--space-4);
  font-weight: 500;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
}

.sidebar-footer .btn-secondary:hover {
  background: var(--primary) !important;
  border-color: var(--primary) !important;
  color: white !important;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(13, 148, 136, 0.3);
}

.sidebar-footer .btn-secondary:active {
  transform: translateY(0);
  background: rgba(255, 255, 255, 0.12);
}

.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  padding: var(--space-6) var(--space-8);
  width: calc(100% - var(--sidebar-width));
  min-height: 100vh;
  /* Removed max-width constraint - let content flow naturally with consistent padding */
}

.page-header {
  margin-bottom: var(--space-8);
  display: flex;
  align-items: center;
  justify-content: space-between;
  /* Border removed - now handled by .page-header-top-row */
}

.page-header h1 {
  font-size: var(--text-5xl);
  line-height: 1.2;
  color: var(--primary);
  margin-bottom: var(--space-1-5);
  font-weight: 700;
}

.page-header p {
  color: var(--text-muted);
  font-size: var(--text-sm);
  line-height: 1.5;
}

.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: 0 4px 12px rgba(var(--primary-rgb), 0.06);
  margin-bottom: var(--space-6);
  border: 1px solid var(--border);
  transition: all 0.2s ease;
}

.card:hover {
  box-shadow: 0 6px 20px rgba(var(--primary-rgb), 0.1);
}

.card h3 {
  font-size: var(--text-lg);
  line-height: 1.3;
  margin-bottom: var(--space-4);
  color: var(--primary);
  font-weight: 700;
  padding-bottom: var(--space-3);
  border-bottom: 2px solid var(--bg-light);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: var(--space-6);
  margin-bottom: var(--space-8);
}

/* File Upload */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-12) var(--space-6);
  text-align: center;
  transition: all 0.2s;
  cursor: pointer;
}

.upload-zone:hover {
  border-color: var(--primary);
  background: rgba(var(--primary-rgb), 0.02);
}

.upload-zone.drag-over {
  border-color: var(--primary);
  background: rgba(var(--primary-rgb), 0.05);
}

.upload-icon {
  font-size: var(--text-7xl);
  margin-bottom: var(--space-4);
  color: var(--text-muted);
}

.upload-zone h4 {
  font-size: var(--text-lg);
  margin-bottom: var(--space-2);
  color: var(--text-header);
}

.upload-zone p {
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.file-input {
  display: none;
}

.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-top: var(--space-4);
}

.progress-bar-fill {
  height: 100%;
  background: var(--primary);
  transition: width 0.3s;
}

/* Upload Progress Info */
.upload-progress-info {
  margin-bottom: var(--space-2);
}

.upload-filename {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
  margin: 0 0 4px 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.upload-status-text {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin: 0;
}

/* File List */
.file-list {
  list-style: none;
}

.file-item {
  display: flex;
  align-items: center;
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-3);
  transition: all 0.2s;
}

.file-item:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.file-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: var(--bg-ultra-light);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: var(--space-4);
  font-size: var(--text-lg);
}

.file-info {
  flex: 1;
}

.file-name {
  font-weight: 500;
  margin-bottom: var(--space-1);
}

.file-meta {
  font-size: var(--text-base);
  color: var(--text-muted);
}

.file-actions {
  display: flex;
  gap: var(--space-2);
}

.badge {
  display: inline-block;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
  font-weight: 500;
  margin-right: var(--space-2);
}

.badge-pending {
  background: #fef3c7;
  color: #92400e;
}

.badge-processing {
  background: #dbeafe;
  color: #1e40af;
}

.badge-ready {
  background: #d1fae5;
  color: #065f46;
}

.badge-failed {
  background: #fee2e2;
  color: #991b1b;
}

/* Loading Spinner */
.spinner {
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  width: 24px;
  height: 24px;
  animation: spin 0.8s linear infinite;
  display: inline-block;
  margin-right: var(--space-2);
}

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

/* Responsive */
@media (max-width: 768px) {
  .sidebar {
    width: 100%;
    height: auto;
    position: relative;
  }

  .main-content {
    margin-left: 0;
    width: 100%;
    padding: var(--space-4);
    max-width: 100%;
  }

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

  .dashboard {
    flex-direction: column;
  }
}

/* Utilities */
.hidden {
  display: none !important;
}

.text-center {
  text-align: center;
}

.mt-1 { margin-top: var(--space-2); }
.mt-2 { margin-top: var(--space-4); }
.mt-3 { margin-top: var(--space-6); }
.mt-4 { margin-top: var(--space-8); }

.mb-1 { margin-bottom: var(--space-2); }
.mb-2 { margin-bottom: var(--space-4); }
.mb-3 { margin-bottom: var(--space-6); }
.mb-4 { margin-bottom: var(--space-8); }

/* Statistics Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.stat-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: 0 4px 12px rgba(var(--primary-rgb), 0.08);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  border: 1px solid var(--border);
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--primary) 0%, var(--primary-hover) 100%);
}

.stat-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(var(--primary-rgb), 0.15);
}

.stat-card.clickable {
  cursor: pointer;
}

.stat-card.clickable:hover {
  transform: translateY(-4px) scale(1.02);
  box-shadow: 0 8px 24px rgba(var(--primary-rgb), 0.2);
}

.stat-icon {
  font-size: var(--text-2xl);
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-ultra-light);
  border-radius: var(--radius-md);
  color: var(--primary);
}

.stat-content {
  flex: 1;
}

.stat-value {
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--primary);
  margin-bottom: var(--space-1);
}

.stat-label {
  font-size: var(--text-sm);
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* File Type Chart */
.file-type-chart {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.file-type-bar {
  display: flex;
  flex-direction: column;
  gap: var(--space-1-5);
}

.file-type-label {
  display: flex;
  justify-content: space-between;
  font-size: var(--text-base);
  color: var(--text);
}

.file-type-progress {
  width: 100%;
  height: 24px;
  background: var(--light);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.file-type-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary-dark));
  transition: width 0.3s;
}

.chart-loading {
  text-align: center;
  color: var(--text-muted);
  padding: var(--space-5);
}

/* Filters Bar */
.filters-bar {
  display: flex;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
}

.filter-group {
  flex: 1;
  min-width: 200px;
}

/* Bulk Actions */
.bulk-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  background: var(--light);
  border-radius: var(--radius-sm);
  margin-top: var(--space-4);
}

.bulk-actions span {
  font-weight: 500;
  margin-right: auto;
}

/* Files Table */
.files-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: var(--space-4);
}

.files-table thead {
  background: var(--light);
}

.files-table th {
  padding: var(--space-3);
  text-align: left;
  font-weight: 600;
  font-size: var(--text-base);
  color: var(--dark);
  border-bottom: 2px solid var(--border);
}

.files-table td {
  padding: var(--space-3);
  border-bottom: 1px solid var(--border);
  font-size: var(--text-base);
}

.files-table tr:hover {
  background: var(--light);
}

.files-table tr.row-selected {
  background: rgba(37, 99, 235, 0.05);
}

.file-name-cell {
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: inline-block;
}

.table-actions {
  display: flex;
  gap: var(--space-2);
}

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  font-size: var(--text-2xl);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-2xs);
  transition: background 0.2s;
}

.btn-icon:hover {
  background: var(--light);
}

.btn-icon-danger:hover {
  background: #fee2e2;
}

/* Pagination */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4) 0;
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(27, 28, 32, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  /* Keep standard (page-level) modals above custom in-page overlays (e.g. project modals) */
  z-index: calc(var(--z-modal-backdrop) + 10);
  padding: var(--space-5);
  overflow-y: auto;
}

.modal.hidden {
  display: none;
}

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(27, 28, 32, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal-backdrop);
  padding: var(--space-5);
  overflow-y: auto;
}

.modal-content {
  background: var(--white);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 600px;
  max-height: 85vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  position: relative;
  z-index: var(--z-modal);
}

.modal-small {
  max-width: 400px;
}

.modal-large {
  max-width: 900px;
  max-height: 90vh;
}

.modal-header {
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h2,
.modal-header h3 {
  margin: 0;
  font-size: var(--text-lg);
  color: var(--text-header);
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  font-size: var(--text-2xl);
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: background 0.2s;
}

.modal-close:hover {
  background: var(--light);
  color: var(--text);
}

.modal-body p {
  color: var(--text-secondary);
  line-height: 1.6;
  margin: 0;
}

.modal-body {
  padding: var(--space-6);
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
}

/* File Details */
.file-details {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.detail-row {
  display: flex;
  gap: var(--space-3);
}

.detail-label {
  font-weight: 600;
  min-width: 120px;
  color: var(--dark);
}

.detail-value {
  flex: 1;
  color: var(--text);
}

/* Context Items */
.context-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-4);
  margin-bottom: var(--space-4);
}

.context-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-3);
}

.context-content {
  padding: var(--space-3);
  background: var(--light);
  border-radius: var(--radius-xs);
  white-space: pre-wrap;
  word-wrap: break-word;
  font-size: var(--text-base);
  line-height: 1.6;
  max-height: 300px;
  overflow-y: auto;
}

.context-metadata {
  margin-top: var(--space-3);
  padding: var(--space-3);
  background: var(--light);
  border-radius: var(--radius-xs);
  font-size: var(--text-md);
}

.context-metadata pre {
  margin-top: var(--space-2);
  overflow-x: auto;
}

/* Badge Secondary */
.badge-secondary {
  background: var(--light);
  color: var(--dark);
}

/* Permissions Modal */
.permissions-user-info {
  margin-bottom: var(--space-4);
}

.permissions-table-wrapper {
  max-height: 400px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.permissions-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-base);
}

.permissions-table thead {
  position: sticky;
  top: 0;
  background: white;
  z-index: 10;
}

.permissions-table th {
  padding: var(--space-3-5) var(--space-3);
  background: var(--primary);
  border-bottom: 2px solid var(--primary-dark);
  text-align: left;
  font-weight: 600;
  font-size: var(--text-md);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--white);
}

.permissions-table thead {
  background: var(--primary);
}

.permissions-table th:first-child {
  border-radius: var(--radius-sm) 0 0 0;
}

.permissions-table th:last-child {
  border-radius: 0 8px 0 0;
}

.permissions-table td {
  padding: var(--space-3);
  border-bottom: 1px solid var(--border);
}

.permissions-table tbody tr:last-child td {
  border-bottom: none;
}

.permissions-table tbody tr:hover {
  background: var(--light);
  transition: background 0.2s ease;
}

.permissions-table input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--primary);
}

.permissions-table input[type="checkbox"]:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

/* Users Table Styling */
.users-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: var(--space-4);
}

.users-table thead {
  background: var(--primary);
}

.users-table th {
  padding: var(--space-3-5) var(--space-3);
  text-align: left;
  font-weight: 600;
  font-size: var(--text-md);
  color: var(--white);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border: none;
}

.users-table th:first-child {
  border-radius: var(--radius-sm) 0 0 0;
}

.users-table th:last-child {
  border-radius: 0 8px 0 0;
}

.users-table td {
  padding: var(--space-3-5) var(--space-3);
  border-bottom: 1px solid var(--border);
  font-size: var(--text-base);
  vertical-align: middle;
}

.users-table tr:hover {
  background: var(--light);
  transition: background 0.2s ease;
}

.users-table tr:last-child td {
  border-bottom: none;
}

/* User Cell */
.user-cell {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.user-avatar-small {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: var(--white);
  font-size: var(--text-xl);
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(var(--primary-rgb, 109, 38, 171), 0.3);
}

.user-name-cell {
  font-weight: 600;
  color: var(--dark);
  margin-bottom: var(--space-0-5);
}

.user-email-cell {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

/* Role and Status Badges */
.role-badge, .status-badge {
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  display: inline-block;
}

/* Generating status badge with pulse animation */
.status-badge.generating {
  background: #f59e0b;
  color: white;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.6;
  }
}

.role-master {
  background: var(--primary);
  color: var(--white);
  box-shadow: 0 2px 8px rgba(var(--primary-rgb, 109, 38, 171), 0.3);
}

.role-admin {
  background: var(--primary-light);
  color: var(--white);
  box-shadow: 0 2px 8px rgba(var(--primary-light-rgb, 134, 66, 196), 0.3);
}

.role-editor {
  background: var(--success);
  color: var(--white);
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.role-viewer {
  background: var(--warning);
  color: var(--white);
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.3);
}

.status-active {
  background: #d1fae5;
  color: #065f46;
  border: 1px solid #6ee7b7;
}

.status-inactive {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fca5a5;
}

/* Stat Numbers */
.stat-number {
  font-weight: 600;
  color: var(--dark);
  padding: var(--space-1) var(--space-2);
  background: var(--light);
  border-radius: var(--radius-xs);
  display: inline-block;
  min-width: 40px;
  text-align: center;
}

.token-count {
  background: var(--light);
  color: var(--primary);
  font-weight: 700;
  border: 1px solid var(--border);
}

/* Action Buttons */
.action-buttons {
  display: flex;
  gap: var(--space-1-5);
  align-items: center;
}

.action-buttons .btn-icon {
  background: var(--light);
  border-radius: var(--radius-xs);
  padding: var(--space-1-5) var(--space-2-5);
  transition: all 0.2s;
}

.action-buttons .btn-icon:hover {
  background: var(--primary);
  color: var(--white);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(var(--primary-rgb, 109, 38, 171), 0.3);
}

/* Inactive User Row */
.user-row.inactive-user {
  opacity: 0.6;
}

.user-row.inactive-user td {
  color: var(--text-muted);
}

/* Enhanced Card Styling for Team Members */
.card h3 {
  color: var(--primary);
  font-size: var(--text-3xl);
  font-weight: 700;
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-3);
  border-bottom: 3px solid var(--light);
}

/* Filters Section Enhancement */
.filters-row {
  display: flex;
  gap: var(--space-4);
  align-items: flex-end;
  flex-wrap: wrap;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 200px;
}

.filter-group label {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  font-size: var(--text-sm);
}

/* Compact table filters */
.table-filters-compact {
  display: flex;
  gap: var(--space-2);
  align-items: center;
}

.form-control-compact {
  padding: var(--space-1-5) var(--space-2-5);
  font-size: var(--text-md);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  transition: all 0.2s ease;
  font-family: inherit;
  background: var(--white);
  height: 32px;
  box-sizing: border-box;
}

.form-control-compact:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(var(--primary-rgb), 0.1);
}

.form-control-compact:hover {
  border-color: var(--primary-light);
}

/* Responsive: stack filters on smaller screens */
@media (max-width: 768px) {
  .table-filters-compact {
    flex-wrap: wrap;
    margin-top: var(--space-2);
  }
  
  .table-filters-compact .form-control-compact {
    width: 100% !important;
    min-width: 120px;
  }
  
  .card > div:first-child {
    flex-direction: column;
    align-items: flex-start !important;
  }
}

/* =============================================================================
   DARK THEME SUPPORT
   ============================================================================= */

[data-theme="dark"],
html[data-theme="dark"] {
  /* Override CSS variables for dark theme */
  --light: #1e293b;
  --white: #334155;
  --text: #f1f5f9;
  --text-muted: #cbd5e1;
  --border: #475569;
  --dark: #f1f5f9;
  --dark-light: #cbd5e1;
  --bg-muted: #1e293b;
  --secondary: #94a3b8;

  /* Keep alias variables consistent in dark mode */
  --bg-primary: var(--white);
  --bg-secondary: #1e293b;
  --border-color: var(--border);
  --text-primary: var(--text);
  --text-secondary: var(--text-muted);
}

/* Body and main layout */
[data-theme="dark"] body,
html[data-theme="dark"] body {
  background: #0f172a;
  color: var(--text);
}

[data-theme="dark"] .main-content,
html[data-theme="dark"] .main-content {
  background: #0f172a;
}

/* Sidebar - keep it dark but adjust borders */
[data-theme="dark"] .sidebar,
html[data-theme="dark"] .sidebar {
  background: #1e293b;
  border-right: 1px solid var(--border);
}

[data-theme="dark"] .sidebar-header,
html[data-theme="dark"] .sidebar-header {
  border-bottom-color: var(--border);
}

[data-theme="dark"] .sidebar-footer,
html[data-theme="dark"] .sidebar-footer {
  border-top-color: var(--border);
}

/* Cards */
[data-theme="dark"] .card,
html[data-theme="dark"] .card {
  background: var(--white);
  border-color: var(--border);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .card:hover,
html[data-theme="dark"] .card:hover {
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .card h3,
html[data-theme="dark"] .card h3 {
  color: var(--text);
  border-bottom-color: var(--border);
}

/* Page header */
[data-theme="dark"] .page-header,
html[data-theme="dark"] .page-header {
  border-bottom-color: var(--border);
  background: #0f172a;
}

[data-theme="dark"] .page-header h1,
html[data-theme="dark"] .page-header h1 {
  color: var(--primary-light);
}

[data-theme="dark"] .page-header p,
html[data-theme="dark"] .page-header p {
  color: var(--text-muted);
}

/* Form controls */
[data-theme="dark"] .form-control,
html[data-theme="dark"] .form-control {
  background: #1e293b;
  border-color: var(--border);
  color: var(--text);
}

[data-theme="dark"] .form-control:focus,
html[data-theme="dark"] .form-control:focus {
  background: #1e293b;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb, 109, 38, 171), 0.2);
}

[data-theme="dark"] .form-control:hover:not(:disabled),
html[data-theme="dark"] .form-control:hover:not(:disabled) {
  border-color: var(--primary-light);
}

[data-theme="dark"] .form-control:disabled,
html[data-theme="dark"] .form-control:disabled {
  background: #0f172a;
  opacity: 0.5;
}

/* Buttons */
[data-theme="dark"] .btn-secondary,
html[data-theme="dark"] .btn-secondary {
  background: #1e293b;
  border-color: var(--border);
  color: var(--text);
}

[data-theme="dark"] .btn-secondary:hover,
html[data-theme="dark"] .btn-secondary:hover {
  background: #0f172a;
  border-color: var(--primary-light);
}

/* Alerts */
[data-theme="dark"] .alert-error,
html[data-theme="dark"] .alert-error {
  background: #7f1d1d;
  color: #fecaca;
  border-color: #991b1b;
}

[data-theme="dark"] .alert-success,
html[data-theme="dark"] .alert-success {
  background: #064e3b;
  color: #a7f3d0;
  border-color: #065f46;
}

[data-theme="dark"] .alert-info,
html[data-theme="dark"] .alert-info {
  background: #1e3a8a;
  color: #bfdbfe;
  border-color: #1e40af;
}

/* Badges */
[data-theme="dark"] .badge-pending,
html[data-theme="dark"] .badge-pending {
  background: #78350f;
  color: #fde68a;
}

[data-theme="dark"] .badge-processing,
html[data-theme="dark"] .badge-processing {
  background: #1e3a8a;
  color: #93c5fd;
}

[data-theme="dark"] .badge-ready,
html[data-theme="dark"] .badge-ready {
  background: #064e3b;
  color: #6ee7b7;
}

[data-theme="dark"] .badge-failed,
html[data-theme="dark"] .badge-failed {
  background: #7f1d1d;
  color: #fca5a5;
}

/* File items */
[data-theme="dark"] .file-item,
html[data-theme="dark"] .file-item {
  background: var(--white);
  border-color: var(--border);
}

[data-theme="dark"] .file-item:hover,
html[data-theme="dark"] .file-item:hover {
  background: #1e293b;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .file-icon,
html[data-theme="dark"] .file-icon {
  background: #1e293b;
}

/* Upload zone */
[data-theme="dark"] .upload-zone,
html[data-theme="dark"] .upload-zone {
  border-color: var(--border);
  background: #1e293b;
}

[data-theme="dark"] .upload-zone:hover,
html[data-theme="dark"] .upload-zone:hover {
  background: #0f172a;
  border-color: var(--primary-light);
}

[data-theme="dark"] .upload-zone.drag-over,
html[data-theme="dark"] .upload-zone.drag-over {
  background: #1e293b;
  border-color: var(--primary-light);
}

/* Tables */
[data-theme="dark"] table,
html[data-theme="dark"] table {
  color: var(--text);
}

[data-theme="dark"] th,
html[data-theme="dark"] th {
  color: var(--text);
  border-color: var(--border);
}

[data-theme="dark"] td,
html[data-theme="dark"] td {
  border-color: var(--border);
}

/* Text colors */
[data-theme="dark"] .text-muted,
html[data-theme="dark"] .text-muted {
  color: var(--text-muted) !important;
}

/* Login page */
[data-theme="dark"] .login-box,
html[data-theme="dark"] .login-box {
  background: #1e293b;
  color: var(--text);
}

[data-theme="dark"] .login-header h1,
html[data-theme="dark"] .login-header h1 {
  color: var(--text);
}

[data-theme="dark"] .login-header p,
html[data-theme="dark"] .login-header p {
  color: var(--text-muted);
}

/* ==================== FILE PROCESSING PROGRESS ==================== */

.file-progress {
  display: flex;
  flex-direction: column;
  gap: var(--space-1-5);
  min-width: 200px;
}

.progress-bar-container {
  width: 100%;
  height: 12px;
  background: rgba(99, 102, 241, 0.15);
  border-radius: var(--radius-xs);
  overflow: hidden;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.2);
}

.file-progress .progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #6366f1 0%, #8b5cf6 100%);
  transition: width 0.3s ease;
  border-radius: var(--radius-2xs);
  position: relative;
  overflow: hidden;
}

/* Animated shine effect */
.file-progress .progress-bar::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
  animation: shine 2s ease-in-out infinite;
}

@keyframes shine {
  0% { left: -100%; }
  100% { left: 100%; }
}

.progress-message {
  font-size: var(--text-sm);
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
}

/* ==================== END FILE PROCESSING PROGRESS ==================== */

/* Settings Page Styles */
.settings-section {
  margin-bottom: var(--space-8);
  padding-bottom: var(--space-6);
  border-bottom: 1px solid var(--border);
}

.settings-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

.settings-section h4 {
  font-size: var(--text-xl);
  font-weight: 600;
  color: var(--text-header);
  margin-bottom: var(--space-2);
}

.setting-description {
  font-size: var(--text-base);
  color: var(--text-muted);
  margin-bottom: var(--space-4);
}

.model-selector-group {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-5);
}

@media (max-width: 768px) {
  .model-selector-group {
    grid-template-columns: 1fr;
  }
}

.model-info {
  min-height: 60px;
}

.form-hint {
  display: block;
  font-size: var(--text-md);
  color: var(--text-muted);
  margin-top: var(--space-1-5);
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: var(--space-2-5);
  font-size: var(--text-lg);
  color: var(--text-primary);
  cursor: pointer;
  user-select: none;
}

.checkbox-label input[type="checkbox"] {
  width: 20px;
  height: 20px;
  cursor: pointer;
}

.checkbox-label span {
  font-weight: 500;
}

/* ==================== TEAM & PLATFORM ADMIN STYLES ==================== */

/* Platform Admin Badge */
.badge {
  display: inline-block;
  padding: var(--space-0-5) var(--space-2);
  font-size: var(--text-2xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-radius: var(--radius-md);
  margin-left: var(--space-2);
  vertical-align: middle;
}

.badge-platform-admin {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: white;
  box-shadow: 0 1px 3px rgba(245, 158, 11, 0.3);
}

.badge-team-owner {
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
  box-shadow: 0 1px 3px rgba(16, 185, 129, 0.3);
}

/* Team Name in Sidebar Header - DEPRECATED (now using .team-context section above) */
/* Commenting out to prevent conflicts with new team-selector layout */
/*
.sidebar-header .team-info {
  margin-top: var(--space-3-5);
  padding-top: var(--space-3-5);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-header .team-name {
  font-size: var(--text-md);
  color: rgba(255, 255, 255, 0.85);
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: var(--space-1-5);
  padding: var(--space-1-5) var(--space-3);
  background: rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-3xl);
}
*/

/* Removed: icon now shown in team-avatar instead */
/* .sidebar-header .team-name::before {
  content: '🏢';
  font-size: var(--text-sm);
} */

/* Team Branding (Logo or Default Icon) */
.team-branding {
  margin-bottom: var(--space-4);
  display: flex;
  justify-content: center;
}

.team-logo {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-xl);
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.team-default-icon {
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-5xl);
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-radius: var(--radius-xl);
  border: 2px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Platform Admin Navigation Links - No special separator needed with new nav-item margins */
.nav-item.platform-admin-only {
  /* Inherits standard nav-item styles */
}

/* Platform Admin Active State - Orange/Amber Styling */
.nav-item.platform-admin-only.active {
  background: rgba(245, 158, 11, 0.15);
  border-left-color: #f59e0b;
  color: rgba(255, 255, 255, 1);
}

.nav-item.platform-admin-only:hover {
  background: rgba(245, 158, 11, 0.1);
  border-left-color: rgba(245, 158, 11, 0.5);
}

.nav-item.platform-admin-only.active:hover {
  background: rgba(245, 158, 11, 0.2);
}

/* User Info Section Enhancement */
.user-info .user-details p {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1);
}

/* Team Context Banner (optional - for pages that need prominent display) */
.team-context-banner {
  background: var(--primary-lighter);
  border-left: 4px solid var(--primary);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-5);
  border-radius: 0 8px 8px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.team-context-banner .team-label {
  font-size: var(--text-md);
  color: var(--text-muted);
}

.team-context-banner .team-value {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text-primary);
}

/* Platform Admin View Indicator */
.platform-admin-indicator {
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  border: 1px solid #f59e0b;
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  margin-bottom: var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-md);
  color: #92400e;
}

.platform-admin-indicator::before {
  content: '👑';
  font-size: var(--text-xl);
}

/* ==================== END TEAM & PLATFORM ADMIN STYLES ==================== */

/* ==================== FILE TAGGING & TOPICS STYLES ==================== */

/* Tags container in file details */
.tags-container {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin: var(--space-2) 0;
  min-height: 32px;
}

.tags-container:empty::before {
  content: 'No topics assigned';
  color: #999;
  font-size: var(--text-md);
  align-self: center;
  font-style: italic;
}

/* Individual tag badge */
.tag-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1-5);
  background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
  border: 1px solid #2196f3;
  border-radius: var(--radius-2xl);
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-md);
  color: #1565c0;
  font-weight: 500;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  transition: all 0.2s ease;
}

.tag-badge:hover {
  background: linear-gradient(135deg, #bbdefb 0%, #90caf9 100%);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  transform: translateY(-1px);
}

/* Remove tag button */
.tag-remove-btn {
  background: none;
  border: none;
  color: #1565c0;
  cursor: pointer;
  font-size: var(--text-xl);
  padding: 0;
  margin: 0;
  line-height: 1;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s ease;
}

/* Confidence-based tag colors (blue with opacity intensity) */
/* Same blue color (#2196f3) with different opacity levels for intensity */

.tag-badge.tag-confidence-high {
  background: rgba(33, 150, 243, 1);
  border: 1px solid rgba(33, 150, 243, 1);
  color: #ffffff;
}

.tag-badge.tag-confidence-high:hover {
  background: rgba(13, 71, 161, 0.95);
  border-color: rgba(13, 71, 161, 0.95);
  box-shadow: 0 3px 8px rgba(33, 150, 243, 0.4);
}

.tag-badge.tag-confidence-medium {
  background: rgba(33, 150, 243, 0.85);
  border: 1px solid rgba(33, 150, 243, 0.85);
  color: #ffffff;
}

.tag-badge.tag-confidence-medium:hover {
  background: rgba(33, 150, 243, 0.95);
  border-color: rgba(33, 150, 243, 0.95);
  box-shadow: 0 3px 8px rgba(33, 150, 243, 0.4);
}

.tag-badge.tag-confidence-low {
  background: rgba(33, 150, 243, 0.65);
  border: 1px solid rgba(33, 150, 243, 0.65);
  color: #ffffff;
}

.tag-badge.tag-confidence-low:hover {
  background: rgba(33, 150, 243, 0.80);
  border-color: rgba(33, 150, 243, 0.80);
  box-shadow: 0 2px 6px rgba(33, 150, 243, 0.3);
}

.tag-badge.tag-confidence-very-low {
  background: rgba(33, 150, 243, 0.40);
  border: 1px solid rgba(33, 150, 243, 0.40);
  color: rgba(33, 150, 243, 1);
}

.tag-badge.tag-confidence-very-low:hover {
  background: rgba(33, 150, 243, 0.60);
  border-color: rgba(33, 150, 243, 0.60);
  box-shadow: 0 2px 5px rgba(33, 150, 243, 0.3);
}

/* User-added tags (distinct from AI tags) */
.tag-badge.tag-user-added {
  background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
  border: 1px solid #66bb6a;
  color: #2e7d32;
}

.tag-badge.tag-user-added:hover {
  background: linear-gradient(135deg, #c8e6c9 0%, #a5d6a7 100%);
  box-shadow: 0 2px 6px rgba(102, 187, 106, 0.3);
}

/* Confidence score badge inside tag */
.tag-confidence-badge {
  display: inline-block;
  font-size: var(--text-2xs);
  font-weight: 600;
  margin-left: var(--space-1);
  padding: var(--space-px) var(--space-1);
  border-radius: var(--radius-2xs);
  background: rgba(255, 255, 255, 0.3);
}

/* See All button styling */
.btn-see-all-tags {
  background: linear-gradient(135deg, #f5f5f5 0%, #e0e0e0 100%);
  border: 1px solid #bdbdbd;
  border-radius: var(--radius-xs);
  padding: var(--space-1-5) var(--space-3);
  font-size: var(--text-md);
  font-weight: 500;
  color: #424242;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-right: var(--space-2);
}

.btn-see-all-tags:hover {
  background: linear-gradient(135deg, #e0e0e0 0%, #bdbdbd 100%);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
  transform: translateY(-1px);
}

/* Tag actions row adjustment */
.tag-actions {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-2);
  flex-wrap: wrap;
}

.tag-remove-btn:hover {
  background-color: rgba(211, 47, 47, 0.1);
  color: #d32f2f;
}

/* Tag actions (buttons) */
.tag-actions {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

.btn-tag-action {
  padding: var(--space-1-5) var(--space-3);
  font-size: var(--text-sm);
  border: 1px solid #ddd;
  background: white;
  color: #666;
  border-radius: var(--radius-2xs);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-tag-action:hover {
  border-color: #2196f3;
  color: #2196f3;
  background-color: #f5f5f5;
}

.btn-tag-action.primary {
  background: #2196f3;
  color: white;
  border-color: #2196f3;
}

.btn-tag-action.primary:hover {
  background: #1976d2;
  border-color: #1976d2;
}

/* Generate/Regenerate tags button */
.btn-tag-action.btn-generate-tags {
  background: linear-gradient(135deg, #7c3aed 0%, #a855f7 100%);
  color: white;
  border-color: #7c3aed;
  font-weight: 500;
}

.btn-tag-action.btn-generate-tags:hover {
  background: linear-gradient(135deg, #6d28d9 0%, #9333ea 100%);
  border-color: #6d28d9;
}

.btn-tag-action.btn-regenerate-tags {
  background: #f5f3ff;
  color: #7c3aed;
  border-color: #c4b5fd;
}

.btn-tag-action.btn-regenerate-tags:hover {
  background: #ede9fe;
  border-color: #a78bfa;
}

.btn-tag-action:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Small spinner for buttons */
.spinner-small {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
  margin-right: 4px;
}

/* Tag edit modal content */
.tag-edit-container {
  padding: var(--space-4);
}

.tag-edit-container h4 {
  margin: 0 0 12px 0;
  font-size: var(--text-xl);
  font-weight: 600;
  color: #333;
}

/* Tag checkboxes grid */
.tag-checkboxes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-3);
  margin: var(--space-4) 0;
  max-height: 400px;
  overflow-y: auto;
  padding: var(--space-2);
  border: 1px solid #eee;
  border-radius: var(--radius-2xs);
  background-color: #fafafa;
}

/* Individual checkbox */
.tag-checkbox {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
  padding: var(--space-2);
  border-radius: var(--radius-2xs);
  transition: all 0.2s ease;
  user-select: none;
}

.tag-checkbox:hover {
  background-color: #f0f0f0;
}

.tag-checkbox input[type="checkbox"] {
  cursor: pointer;
  margin: 0;
  width: 16px;
  height: 16px;
  accent-color: #2196f3;
}

.tag-checkbox span {
  flex: 1;
  font-size: var(--text-md);
  color: #333;
}

.tag-checkbox small {
  color: #999;
  font-size: var(--text-xs);
  margin-left: auto;
  font-style: italic;
}

/* Modal actions for tag editing */
.tag-modal-actions {
  display: flex;
  gap: var(--space-2);
  justify-content: flex-end;
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid #eee;
}

/* Add new tag input form */
.add-tag-form {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

.add-tag-form input {
  flex: 1;
  padding: var(--space-1-5) var(--space-2);
  border: 1px solid #ddd;
  border-radius: var(--radius-2xs);
  font-size: var(--text-sm);
}

.add-tag-form input:focus {
  outline: none;
  border-color: #2196f3;
  box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.1);
}

.add-tag-form button {
  padding: var(--space-1-5) var(--space-3);
  background: #2196f3;
  color: white;
  border: none;
  border-radius: var(--radius-2xs);
  font-size: var(--text-sm);
  cursor: pointer;
  transition: background 0.2s ease;
}

.add-tag-form button:hover {
  background: #1976d2;
}

/* Tags section in detail row */
.detail-row.tags-row {
  flex-direction: column;
  align-items: flex-start;
}

.detail-row.tags-row strong {
  margin-bottom: var(--space-2);
}

/* ==================== END FILE TAGGING STYLES ==================== */
