/* ============================================
   YourSelfAndMe — Unified Design System
   Dark Premium Theme · Glassmorphism · RTL-Ready
   ============================================ */

/* ── Google Fonts ── loaded via <link> in HTML headers for better performance */

/* ══════════════════════════════════════════════
   1. CSS CUSTOM PROPERTIES (Design Tokens)
   ══════════════════════════════════════════════ */
:root {
  /* Background layers */
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-tertiary: #1a1a2e;
  --bg-elevated: #1e1e32;

  /* Glass surfaces */
  --surface-glass: rgba(255, 255, 255, 0.03);
  --surface-glass-hover: rgba(255, 255, 255, 0.06);
  --surface-glass-active: rgba(255, 255, 255, 0.08);
  --border-glass: rgba(255, 255, 255, 0.08);
  --border-glass-hover: rgba(255, 255, 255, 0.15);

  /* Accent colors */
  --accent-purple: #6C5CE7;
  --accent-purple-light: #a29bfe;
  --accent-purple-dark: #4a3db8;
  --accent-purple-glow: rgba(108, 92, 231, 0.15);
  --accent-gold: #D4AF37;
  --accent-gold-light: #f0d060;
  --accent-gold-glow: rgba(212, 175, 55, 0.15);
  --accent-cyan: #00CEC9;
  --accent-cyan-light: #55eee8;
  --accent-cyan-glow: rgba(0, 206, 201, 0.15);

  /* Text */
  --text-primary: #E8E8ED;
  --text-secondary: #8B8B9E;
  --text-tertiary: #5C5C70;
  --text-inverse: #0a0a0f;

  /* Status */
  --success: #2EA043;
  --success-bg: rgba(46, 160, 67, 0.12);
  --success-border: rgba(46, 160, 67, 0.25);
  --warning: #D29922;
  --warning-bg: rgba(210, 153, 34, 0.12);
  --warning-border: rgba(210, 153, 34, 0.25);
  --danger: #F85149;
  --danger-bg: rgba(248, 81, 73, 0.12);
  --danger-border: rgba(248, 81, 73, 0.25);
  --info: #58A6FF;
  --info-bg: rgba(88, 166, 255, 0.12);
  --info-border: rgba(88, 166, 255, 0.25);

  /* Typography */
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  --font-xs: 0.75rem;
  --font-sm: 0.8125rem;
  --font-base: 0.9375rem;
  --font-md: 1rem;
  --font-lg: 1.125rem;
  --font-xl: 1.25rem;
  --font-2xl: 1.5rem;
  --font-3xl: 1.875rem;
  --font-4xl: 2.25rem;
  --line-height: 1.6;

  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  --space-3xl: 4rem;

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

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.5);
  --shadow-glow-purple: 0 0 20px rgba(108, 92, 231, 0.3);
  --shadow-glow-gold: 0 0 20px rgba(212, 175, 55, 0.3);

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
  --transition-slow: 400ms ease;

  /* Layout */
  --sidebar-width: 260px;
  --sidebar-collapsed: 72px;
  --topbar-height: 64px;
  --content-max-width: 1400px;

  /* Z-index layers */
  --z-dropdown: 100;
  --z-sidebar: 200;
  --z-overlay: 300;
  --z-modal: 400;
  --z-toast: 500;
}

/* ══════════════════════════════════════════════
   2. RESET & BASE
   ══════════════════════════════════════════════ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

body {
  font-family: var(--font-family);
  font-size: var(--font-base);
  line-height: var(--line-height);
  color: var(--text-primary);
  background: var(--bg-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

a {
  color: var(--accent-purple-light);
  text-decoration: none;
  transition: color var(--transition-fast);
}
a:hover { color: var(--accent-purple); }

img { max-width: 100%; height: auto; display: block; }

h1, h2, h3, h4, h5, h6 {
  color: var(--text-primary);
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: var(--space-sm);
}
h1 { font-size: var(--font-3xl); }
h2 { font-size: var(--font-2xl); }
h3 { font-size: var(--font-xl); }
h4 { font-size: var(--font-lg); }

p { margin-bottom: var(--space-md); color: var(--text-secondary); }

::selection {
  background: var(--accent-purple);
  color: white;
}

/* Custom scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-glass);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.15); }

/* ══════════════════════════════════════════════
   3. APP SHELL LAYOUT
   ══════════════════════════════════════════════ */
.app-shell {
  display: flex;
  min-height: 100vh;
  background: var(--bg-primary);
}

/* ── Sidebar ── */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-glass);
  display: flex;
  flex-direction: column;
  z-index: var(--z-sidebar);
  transition: transform var(--transition-base);
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-brand {
  padding: var(--space-lg) var(--space-lg);
  border-bottom: 1px solid var(--border-glass);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-shrink: 0;
}

.sidebar-brand-logo {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-gold));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: var(--font-lg);
  color: white;
}

.sidebar-brand-text {
  font-size: var(--font-md);
  font-weight: 700;
  color: var(--text-primary);
}

.sidebar-brand-text small {
  display: block;
  font-size: var(--font-xs);
  font-weight: 400;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

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

.sidebar-section {
  padding: var(--space-xs) var(--space-lg);
  margin-top: var(--space-md);
}

.sidebar-section:first-child { margin-top: 0; }

.sidebar-section-title {
  font-size: var(--font-xs);
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: var(--space-xs);
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 12px var(--space-lg);
  min-height: 44px;
  color: var(--text-secondary);
  font-size: var(--font-sm);
  font-weight: 500;
  border-radius: 0;
  transition: all var(--transition-fast);
  position: relative;
  text-decoration: none;
}

.sidebar-link:hover {
  color: var(--text-primary);
  background: var(--surface-glass-hover);
}

.sidebar-link.active {
  color: var(--accent-purple-light);
  background: var(--accent-purple-glow);
  border-right: 3px solid var(--accent-purple);
}

.sidebar-link i {
  font-size: 1.25rem;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-badge {
  margin-left: auto;
  background: var(--danger);
  color: white;
  font-size: 0.6875rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  min-width: 20px;
  text-align: center;
  line-height: 1.4;
}

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

/* ── Main Content Area ── */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Topbar ── */
.topbar {
  position: sticky;
  top: 0;
  height: var(--topbar-height);
  background: rgba(10, 10, 15, 0.8);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-glass);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-xl);
  z-index: var(--z-dropdown);
  flex-shrink: 0;
  gap: var(--space-sm);
  min-width: 0;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  min-width: 0;
  flex: 1;
  overflow: hidden;
}

.topbar-title {
  font-size: var(--font-lg);
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-shrink: 0;
}

.topbar-btn {
  position: relative;
  width: 40px;
  height: 40px;
  border: none;
  background: var(--surface-glass);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

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

.topbar-btn .notification-dot {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 8px;
  height: 8px;
  background: var(--danger);
  border-radius: 50%;
  border: 2px solid var(--bg-primary);
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.topbar-user:hover { background: var(--surface-glass); }

.topbar-avatar {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-cyan));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: var(--font-sm);
  color: white;
  flex-shrink: 0;
}

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

.topbar-user-name {
  font-size: var(--font-sm);
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.2;
}

.topbar-user-role {
  font-size: var(--font-xs);
  color: var(--text-tertiary);
}

.mobile-toggle {
  display: none;
  width: 44px;
  height: 44px;
  border: none;
  background: var(--surface-glass);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 1.3rem;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  touch-action: manipulation;
}

/* Sidebar close button (shown only on mobile) */
.sidebar-close {
  display: none;
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border: none;
  background: var(--surface-glass-hover);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 1.1rem;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  z-index: 10;
  touch-action: manipulation;
}

[dir="rtl"] .sidebar-close { right: auto; left: 12px; }

/* ── Page Content ── */
.page-content {
  flex: 1;
  padding: var(--space-xl);
  max-width: var(--content-max-width);
  width: 100%;
  margin: 0 auto;
}

.page-header {
  margin-bottom: var(--space-xl);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-md);
}

.page-header h1 {
  margin-bottom: 0;
}

.page-header-subtitle {
  color: var(--text-secondary);
  font-size: var(--font-sm);
  margin-top: var(--space-xs);
}

/* Sidebar overlay for mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: calc(var(--z-sidebar) - 1);
  backdrop-filter: blur(4px);
}

/* ══════════════════════════════════════════════
   4. CARDS
   ══════════════════════════════════════════════ */
.card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  transition: all var(--transition-base);
}

.glass-card {
  background: var(--surface-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  transition: all var(--transition-base);
}

.glass-card:hover {
  border-color: var(--border-glass-hover);
  background: var(--surface-glass-hover);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-lg);
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--border-glass);
}

.card-title {
  font-size: var(--font-md);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0;
}

/* Stat Cards */
.stat-grid {
  display: grid;
  /* RAM pattern: auto-collapses to 1 column when viewport too narrow for 2×220px */
  grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr));
  gap: var(--space-lg);
  margin-bottom: var(--space-xl);
}

.stat-card {
  background: var(--surface-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  display: flex;
  align-items: flex-start;
  gap: var(--space-md);
  transition: all var(--transition-base);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--stat-accent, var(--accent-purple)), transparent);
  opacity: 0;
  transition: opacity var(--transition-base);
}

.stat-card:hover {
  border-color: var(--border-glass-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-card:hover::before { opacity: 1; }

.stat-card.purple { --stat-accent: var(--accent-purple); }
.stat-card.gold { --stat-accent: var(--accent-gold); }
.stat-card.cyan { --stat-accent: var(--accent-cyan); }
.stat-card.green { --stat-accent: var(--success); }
.stat-card.red { --stat-accent: var(--danger); }

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}

.stat-icon.purple { background: var(--accent-purple-glow); color: var(--accent-purple-light); }
.stat-icon.gold { background: var(--accent-gold-glow); color: var(--accent-gold); }
.stat-icon.cyan { background: var(--accent-cyan-glow); color: var(--accent-cyan); }
.stat-icon.green { background: var(--success-bg); color: var(--success); }
.stat-icon.red { background: var(--danger-bg); color: var(--danger); }

.stat-info { flex: 1; }

.stat-label {
  font-size: var(--font-xs);
  font-weight: 500;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.stat-value {
  font-size: var(--font-2xl);
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.stat-change {
  font-size: var(--font-xs);
  font-weight: 500;
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.stat-change.up { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* ══════════════════════════════════════════════
   5. BUTTONS
   ══════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 10px 20px;
  font-family: var(--font-family);
  font-size: var(--font-sm);
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.4;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-purple-dark));
  color: white;
  border-color: var(--accent-purple);
  box-shadow: 0 2px 8px rgba(108, 92, 231, 0.3);
}
.btn-primary:hover {
  background: linear-gradient(135deg, var(--accent-purple-light), var(--accent-purple));
  box-shadow: var(--shadow-glow-purple);
  color: white;
}

.btn-gold {
  background: linear-gradient(135deg, var(--accent-gold), #c49b2f);
  color: var(--text-inverse);
  border-color: var(--accent-gold);
}
.btn-gold:hover {
  box-shadow: var(--shadow-glow-gold);
  color: var(--text-inverse);
}

.btn-success {
  background: var(--success);
  color: white;
  border-color: var(--success);
}
.btn-success:hover { filter: brightness(1.15); color: white; }

.btn-danger {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
}
.btn-danger:hover { filter: brightness(1.15); color: white; }

.btn-warning {
  background: var(--warning);
  color: var(--text-inverse);
  border-color: var(--warning);
}
.btn-warning:hover { filter: brightness(1.15); color: var(--text-inverse); }

.btn-outline {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border-glass);
}
.btn-outline:hover {
  border-color: var(--accent-purple);
  color: var(--accent-purple-light);
  background: var(--accent-purple-glow);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: none;
  padding: 8px 12px;
}
.btn-ghost:hover {
  color: var(--text-primary);
  background: var(--surface-glass);
}

.btn-sm { padding: 6px 14px; font-size: var(--font-xs); }
.btn-lg { padding: 14px 28px; font-size: var(--font-md); }

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-md);
}

.btn-block { width: 100%; }

.btn:disabled, .btn.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* ══════════════════════════════════════════════
   6. BADGES
   ══════════════════════════════════════════════ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  font-size: var(--font-xs);
  font-weight: 600;
  border-radius: var(--radius-full);
  white-space: nowrap;
  line-height: 1.4;
}

.badge-success { background: var(--success-bg); color: var(--success); border: 1px solid var(--success-border); }
.badge-warning { background: var(--warning-bg); color: var(--warning); border: 1px solid var(--warning-border); }
.badge-danger  { background: var(--danger-bg);  color: var(--danger);  border: 1px solid var(--danger-border);  }
.badge-info    { background: var(--info-bg);    color: var(--info);    border: 1px solid var(--info-border);    }
.badge-purple  { background: var(--accent-purple-glow); color: var(--accent-purple-light); border: 1px solid rgba(108,92,231,0.25); }
.badge-gold    { background: var(--accent-gold-glow); color: var(--accent-gold); border: 1px solid rgba(212,175,55,0.25); }
.badge-neutral {
  background: rgba(255,255,255,0.05);
  color: var(--text-secondary);
  border: 1px solid var(--border-glass);
}

/* ══════════════════════════════════════════════
   7. FORMS
   ══════════════════════════════════════════════ */
.form-group {
  margin-bottom: var(--space-lg);
}

.form-label {
  display: block;
  font-size: var(--font-sm);
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: var(--space-xs);
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  font-family: var(--font-family);
  font-size: var(--font-base);
  color: var(--text-primary);
  background: var(--bg-primary);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  outline: none;
}

.form-control:focus {
  border-color: var(--accent-purple);
  box-shadow: 0 0 0 3px var(--accent-purple-glow);
}

.form-control::placeholder {
  color: var(--text-tertiary);
}

.form-control:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

textarea.form-control {
  min-height: 100px;
  resize: vertical;
}

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%238B8B9E' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

.form-check {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  cursor: pointer;
}

.form-check input[type="checkbox"],
.form-check input[type="radio"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent-purple);
  cursor: pointer;
}

.form-hint {
  font-size: var(--font-xs);
  color: var(--text-tertiary);
  margin-top: 4px;
}

.form-error {
  font-size: var(--font-xs);
  color: var(--danger);
  margin-top: 4px;
}

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

/* ══════════════════════════════════════════════
   8. TABLES
   ══════════════════════════════════════════════ */
.table-container {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-glass);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-sm);
}

.data-table thead {
  background: var(--bg-tertiary);
}

.data-table th {
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  color: var(--text-secondary);
  font-size: var(--font-xs);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
  border-bottom: 1px solid var(--border-glass);
}

.data-table td {
  padding: 12px 16px;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-glass);
  vertical-align: middle;
}

.data-table tbody tr {
  transition: background var(--transition-fast);
}

.data-table tbody tr:hover {
  background: var(--surface-glass-hover);
}

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

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

/* ══════════════════════════════════════════════
   9. ALERTS / FLASH MESSAGES
   ══════════════════════════════════════════════ */
.alert {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-md);
  font-size: var(--font-sm);
  font-weight: 500;
  margin-bottom: var(--space-lg);
  animation: alertSlideIn 0.3s ease;
}

.alert i { font-size: 1.2rem; flex-shrink: 0; }
.alert span { flex: 1; }

.alert-close {
  background: none;
  border: none;
  color: inherit;
  font-size: 1.2rem;
  cursor: pointer;
  opacity: 0.6;
  padding: 0 4px;
  line-height: 1;
}
.alert-close:hover { opacity: 1; }

.alert-success { background: var(--success-bg); color: var(--success); border: 1px solid var(--success-border); }
.alert-error   { background: var(--danger-bg);  color: var(--danger);  border: 1px solid var(--danger-border);  }
.alert-warning { background: var(--warning-bg); color: var(--warning); border: 1px solid var(--warning-border); }
.alert-info    { background: var(--info-bg);    color: var(--info);    border: 1px solid var(--info-border);    }

@keyframes alertSlideIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ══════════════════════════════════════════════
   10. MODALS
   ══════════════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-base);
  padding: var(--space-md);
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(0.95) translateY(10px);
  transition: transform var(--transition-base);
}

.modal-overlay.active .modal {
  transform: scale(1) translateY(0);
}

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

.modal-title {
  font-size: var(--font-lg);
  font-weight: 600;
  margin-bottom: 0;
}

.modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: var(--surface-glass);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.modal-close:hover {
  background: var(--danger-bg);
  color: var(--danger);
}

.modal-body { padding: var(--space-lg); }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid var(--border-glass);
}

/* ══════════════════════════════════════════════
   11. EMPTY / LOADING / ERROR STATES
   ══════════════════════════════════════════════ */
.empty-state {
  text-align: center;
  padding: var(--space-3xl) var(--space-xl);
}

.empty-state-icon {
  font-size: 3rem;
  color: var(--text-tertiary);
  margin-bottom: var(--space-md);
}

.empty-state-title {
  font-size: var(--font-lg);
  font-weight: 600;
  margin-bottom: var(--space-sm);
  color: var(--text-secondary);
}

.empty-state-desc {
  color: var(--text-tertiary);
  margin-bottom: var(--space-lg);
  max-width: 400px;
  margin-inline: auto;
}

/* Loading skeleton */
.skeleton {
  background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--surface-glass-hover) 50%, var(--bg-tertiary) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

.skeleton-text { height: 14px; margin-bottom: 8px; }
.skeleton-title { height: 24px; width: 60%; margin-bottom: 12px; }
.skeleton-avatar { width: 40px; height: 40px; border-radius: 50%; }
.skeleton-card { height: 100px; }

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

/* Spinner */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-glass);
  border-top-color: var(--accent-purple);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* ══════════════════════════════════════════════
   12. PAGINATION
   ══════════════════════════════════════════════ */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  margin-top: var(--space-xl);
}

.pagination a,
.pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  font-size: var(--font-sm);
  font-weight: 500;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  text-decoration: none;
  transition: all var(--transition-fast);
  border: 1px solid transparent;
}

.pagination a:hover {
  background: var(--surface-glass);
  color: var(--text-primary);
  border-color: var(--border-glass);
}

.pagination .active {
  background: var(--accent-purple-glow);
  color: var(--accent-purple-light);
  border-color: var(--accent-purple);
}

.pagination .disabled {
  opacity: 0.3;
  pointer-events: none;
}

/* ══════════════════════════════════════════════
   13. NOTIFICATION ITEMS
   ══════════════════════════════════════════════ */
.notification-item {
  display: flex;
  gap: var(--space-md);
  padding: var(--space-md);
  border-radius: var(--radius-md);
  transition: background var(--transition-fast);
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}

.notification-item:hover {
  background: var(--surface-glass);
  color: inherit;
}

.notification-item.unread {
  background: var(--surface-glass);
  border-left: 3px solid var(--accent-purple);
}

.notification-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.notification-body { flex: 1; min-width: 0; }

.notification-title {
  font-size: var(--font-sm);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.notification-text {
  font-size: var(--font-xs);
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.notification-time {
  font-size: var(--font-xs);
  color: var(--text-tertiary);
  white-space: nowrap;
  flex-shrink: 0;
}

/* ══════════════════════════════════════════════
   14. ACTIVITY FEED
   ══════════════════════════════════════════════ */
.activity-item {
  display: flex;
  gap: var(--space-md);
  padding: var(--space-md) 0;
  border-bottom: 1px solid var(--border-glass);
}

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

.activity-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-top: 6px;
  flex-shrink: 0;
}

.activity-dot.purple { background: var(--accent-purple); }
.activity-dot.gold { background: var(--accent-gold); }
.activity-dot.green { background: var(--success); }
.activity-dot.cyan { background: var(--accent-cyan); }

.activity-content { flex: 1; }

.activity-text {
  font-size: var(--font-sm);
  color: var(--text-primary);
  margin-bottom: 2px;
}

.activity-time {
  font-size: var(--font-xs);
  color: var(--text-tertiary);
}

/* ══════════════════════════════════════════════
   15. DROPDOWN
   ══════════════════════════════════════════════ */
.dropdown {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 200px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: var(--z-dropdown);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: all var(--transition-fast);
  padding: var(--space-xs);
}

.dropdown-menu.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 8px 12px;
  font-size: var(--font-sm);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  text-decoration: none;
}

.dropdown-item:hover {
  background: var(--surface-glass);
  color: var(--text-primary);
}

.dropdown-divider {
  height: 1px;
  background: var(--border-glass);
  margin: var(--space-xs) 0;
}

/* ══════════════════════════════════════════════
   16. TABS
   ══════════════════════════════════════════════ */
.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border-glass);
  margin-bottom: var(--space-lg);
  overflow-x: auto;
}

.tab {
  padding: var(--space-sm) var(--space-lg);
  font-size: var(--font-sm);
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  border: none;
  background: none;
  border-bottom: 2px solid transparent;
  transition: all var(--transition-fast);
  white-space: nowrap;
  text-decoration: none;
}

.tab:hover { color: var(--text-primary); }

.tab.active {
  color: var(--accent-purple-light);
  border-bottom-color: var(--accent-purple);
}

/* ══════════════════════════════════════════════
   17. TOOLTIPS
   ══════════════════════════════════════════════ */
[data-tooltip] {
  position: relative;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-size: var(--font-xs);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-fast);
  pointer-events: none;
  border: 1px solid var(--border-glass);
}

[data-tooltip]:hover::after {
  opacity: 1;
  visibility: visible;
}

/* ══════════════════════════════════════════════
   18. FILE UPLOAD
   ══════════════════════════════════════════════ */
.file-upload {
  border: 2px dashed var(--border-glass);
  border-radius: var(--radius-lg);
  padding: var(--space-2xl);
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-base);
}

.file-upload:hover,
.file-upload.dragover {
  border-color: var(--accent-purple);
  background: var(--accent-purple-glow);
}

.file-upload-icon {
  font-size: 2.5rem;
  color: var(--text-tertiary);
  margin-bottom: var(--space-md);
}

.file-upload-text {
  font-size: var(--font-sm);
  color: var(--text-secondary);
}

.file-upload-text strong {
  color: var(--accent-purple-light);
}

.file-upload-hint {
  font-size: var(--font-xs);
  color: var(--text-tertiary);
  margin-top: var(--space-sm);
}

.file-preview {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  background: var(--surface-glass);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-glass);
  margin-top: var(--space-md);
}

.file-preview img {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: var(--radius-sm);
}

.file-preview-info { flex: 1; }

.file-preview-name {
  font-size: var(--font-sm);
  font-weight: 500;
  color: var(--text-primary);
}

.file-preview-size {
  font-size: var(--font-xs);
  color: var(--text-tertiary);
}

/* ══════════════════════════════════════════════
   19. AUTH PAGES (Login/Register)
   ══════════════════════════════════════════════ */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-xl);
  background: var(--bg-primary);
  position: relative;
  overflow: hidden;
}

.auth-page::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle at 30% 40%, rgba(108, 92, 231, 0.08) 0%, transparent 50%),
              radial-gradient(circle at 70% 60%, rgba(212, 175, 55, 0.05) 0%, transparent 50%),
              radial-gradient(circle at 50% 80%, rgba(0, 206, 201, 0.04) 0%, transparent 50%);
  animation: authBgFloat 20s ease-in-out infinite alternate;
}

@keyframes authBgFloat {
  0% { transform: translate(0, 0) rotate(0deg); }
  100% { transform: translate(-2%, -2%) rotate(3deg); }
}

.auth-card {
  position: relative;
  width: 100%;
  max-width: 440px;
  background: var(--surface-glass);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-xl);
  padding: var(--space-2xl);
  box-shadow: var(--shadow-lg);
}

.auth-logo {
  text-align: center;
  margin-bottom: var(--space-xl);
}

.auth-logo-mark {
  width: 56px;
  height: 56px;
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-gold));
  border-radius: var(--radius-lg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: var(--font-xl);
  color: white;
  margin-bottom: var(--space-md);
}

.auth-title {
  font-size: var(--font-2xl);
  font-weight: 700;
  text-align: center;
  margin-bottom: var(--space-xs);
}

.auth-subtitle {
  font-size: var(--font-sm);
  color: var(--text-secondary);
  text-align: center;
  margin-bottom: var(--space-xl);
}

.auth-footer {
  text-align: center;
  margin-top: var(--space-lg);
  font-size: var(--font-sm);
  color: var(--text-secondary);
}

.auth-footer a {
  color: var(--accent-purple-light);
  font-weight: 600;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin: var(--space-lg) 0;
  color: var(--text-tertiary);
  font-size: var(--font-xs);
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-glass);
}

/* ══════════════════════════════════════════════
   20. LANGUAGE SWITCHER
   ══════════════════════════════════════════════ */
.lang-switcher {
  display: flex;
  gap: 2px;
  background: var(--surface-glass);
  border-radius: var(--radius-md);
  padding: 2px;
  border: 1px solid var(--border-glass);
}

.lang-btn {
  padding: 4px 10px;
  font-size: var(--font-xs);
  font-weight: 600;
  border: none;
  background: none;
  color: var(--text-tertiary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-transform: uppercase;
}

.lang-btn:hover { color: var(--text-primary); }

.lang-btn.active {
  background: var(--accent-purple);
  color: white;
}

/* ══════════════════════════════════════════════
   21. FILTER BAR
   ══════════════════════════════════════════════ */
.filter-bar {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
  flex-wrap: wrap;
}

.filter-search {
  position: relative;
  flex: 1;
  min-width: 200px;
}

.filter-search i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-tertiary);
}

.filter-search input {
  width: 100%;
  padding: 10px 14px 10px 36px;
  font-family: var(--font-family);
  font-size: var(--font-sm);
  color: var(--text-primary);
  background: var(--bg-primary);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  outline: none;
  transition: border-color var(--transition-fast);
}

.filter-search input:focus {
  border-color: var(--accent-purple);
}

.filter-group {
  display: flex;
  gap: 2px;
  background: var(--surface-glass);
  border-radius: var(--radius-md);
  padding: 2px;
  border: 1px solid var(--border-glass);
}

.filter-btn {
  padding: 8px 16px;
  font-size: var(--font-xs);
  font-weight: 600;
  border: none;
  background: none;
  color: var(--text-tertiary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  text-decoration: none;
}

.filter-btn:hover { color: var(--text-primary); }

.filter-btn.active {
  background: var(--accent-purple-glow);
  color: var(--accent-purple-light);
}

/* ══════════════════════════════════════════════
   22. UTILITY CLASSES
   ══════════════════════════════════════════════ */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-primary { color: var(--text-primary) !important; }
.text-secondary { color: var(--text-secondary) !important; }
.text-success { color: var(--success) !important; }
.text-warning { color: var(--warning) !important; }
.text-danger { color: var(--danger) !important; }
.text-purple { color: var(--accent-purple-light) !important; }
.text-gold { color: var(--accent-gold) !important; }
.text-cyan { color: var(--accent-cyan) !important; }

.fw-400 { font-weight: 400; }
.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }

.fs-xs { font-size: var(--font-xs); }
.fs-sm { font-size: var(--font-sm); }
.fs-md { font-size: var(--font-md); }
.fs-lg { font-size: var(--font-lg); }

.mt-0 { margin-top: 0; }
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mt-xl { margin-top: var(--space-xl); }
.mb-0 { margin-bottom: 0 !important; }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.mb-xl { margin-bottom: var(--space-xl); }

.p-0 { padding: 0; }
.p-md { padding: var(--space-md); }
.p-lg { padding: var(--space-lg); }

.d-flex { display: flex; }
.d-grid { display: grid; }
.d-none { display: none; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }
.flex-1 { flex: 1; }
.flex-wrap { flex-wrap: wrap; }

.w-100 { width: 100%; }
.rounded { border-radius: var(--radius-md); }
.overflow-hidden { overflow: hidden; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* Grid helpers */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-lg); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-lg); }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-lg); }

/* ══════════════════════════════════════════════
   23. RTL SUPPORT
   ══════════════════════════════════════════════ */
[dir="rtl"] .sidebar {
  left: auto;
  right: 0;
  border-right: none;
  border-left: 1px solid var(--border-glass);
}

[dir="rtl"] .sidebar-link.active {
  border-right: none;
  border-left: 3px solid var(--accent-purple);
}

[dir="rtl"] .sidebar-badge {
  margin-left: 0;
  margin-right: auto;
}

[dir="rtl"] .main-content {
  margin-left: 0;
  margin-right: var(--sidebar-width);
}

[dir="rtl"] .data-table th,
[dir="rtl"] .data-table td {
  text-align: right;
}

[dir="rtl"] select.form-control {
  background-position: left 14px center;
  padding-right: 14px;
  padding-left: 36px;
}

[dir="rtl"] .filter-search i {
  left: auto;
  right: 12px;
}

[dir="rtl"] .filter-search input {
  padding-left: 14px;
  padding-right: 36px;
}

[dir="rtl"] .notification-item.unread {
  border-left: none;
  border-right: 3px solid var(--accent-purple);
}

/* ══════════════════════════════════════════════
   24. RESPONSIVE BREAKPOINTS
   ══════════════════════════════════════════════ */

/* Large desktop (1920px+) */
@media (min-width: 1920px) {
  :root { --content-max-width: 1600px; }
}

/* Small desktop (1200px) */
@media (max-width: 1200px) {
  .page-content { padding: var(--space-lg); }

  .notification-dropdown {
    width: min(380px, calc(100vw - var(--space-lg) * 2));
  }
}

/* Tablet landscape & small desktop (≤1024px)
   ── This matches the JS handleResize() breakpoint
   ── Sidebar slides off-screen; hamburger becomes visible */
@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }

  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-stats { grid-template-columns: repeat(2, 1fr); }

  /* ── Critical: collapse sidebar & reveal toggle on ALL tablets ── */
  .sidebar {
    transform: translateX(-100%);
    will-change: transform;
  }
  [dir="rtl"] .sidebar { transform: translateX(100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.show { display: block; }
  .sidebar-close { display: flex; }

  /* Main content fills full width when sidebar is off-screen */
  .main-content {
    margin-left: 0 !important;
    margin-right: 0 !important;
  }

  /* Show hamburger toggle on tablets */
  .mobile-toggle { display: flex; }

  /* Topbar slightly tighter on tablet */
  .topbar { padding: 0 var(--space-lg); }

  /* Page content less padding */
  .page-content { padding: var(--space-lg); }
}

/* ══════════════════════════════════════════════
   RESPONSIVE — Tablet portrait (≤768px)
   ══════════════════════════════════════════════ */
@media (max-width: 768px) {
  /* Sidebar already off-screen from the 1024px rule above;
     these rules add the extra phone-specific overrides */

  /* Topbar tighter */
  .topbar { padding: 0 var(--space-md); gap: var(--space-xs); }
  .topbar-right { gap: var(--space-xs); }
  .topbar-user-info { display: none; }

  /* Page layout */
  .page-content { padding: var(--space-md); }
  .page-header { flex-direction: column; align-items: flex-start; gap: var(--space-sm); }
  .page-header h1 { font-size: var(--font-xl); }

  /* Grids → single column */
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: 1fr 1fr; }

  /* Filter bar */
  .filter-bar { flex-direction: column; gap: var(--space-sm); }
  .filter-group, .filter-search { width: 100%; }

  /* Modal: full-width */
  .modal { margin: var(--space-md); max-width: none; }

  /* Responsive tables → card layout */
  .data-table.responsive thead { display: none; }
  .data-table.responsive tbody tr {
    display: block;
    padding: var(--space-md);
    border-bottom: 1px solid var(--border-glass);
    margin-bottom: var(--space-sm);
    border-radius: var(--radius-md);
    background: var(--surface-glass);
  }
  .data-table.responsive td {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 7px 0;
    border-bottom: 1px solid rgba(255,255,255,0.03);
    gap: var(--space-sm);
    flex-wrap: wrap;
  }
  .data-table.responsive td:last-child { border-bottom: none; }
  .data-table.responsive td::before {
    content: attr(data-label);
    font-weight: 600;
    font-size: var(--font-xs);
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    flex-shrink: 0;
  }
  .data-table.responsive td:last-child {
    display: flex;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: var(--space-xs);
  }
  .data-table.responsive td:last-child::before { display: none; }

  /* Lang switcher compact */
  .lang-switcher .lang-btn:not(.active) { display: none; }
  .lang-switcher .lang-btn.active {
    padding-right: 22px;
    position: relative;
  }
  .lang-switcher .lang-btn.active::after {
    content: '▾';
    position: absolute;
    right: 6px;
    font-size: 0.65rem;
    top: 50%;
    transform: translateY(-50%);
  }
  .lang-switcher.open .lang-btn { display: flex; }
  .lang-switcher.open {
    position: absolute;
    right: var(--space-sm);
    top: calc(var(--topbar-height) + 4px);
    background: var(--bg-secondary);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    padding: var(--space-xs);
    flex-direction: column;
    z-index: var(--z-dropdown);
    box-shadow: var(--shadow-lg);
    gap: 2px;
  }

  /* Notification dropdown: full viewport width */
  .notification-dropdown {
    width: min(380px, calc(100vw - var(--space-md) * 2));
    right: 0;
  }

  /* Ensure all non-responsive tables scroll horizontally */
  .data-table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* ══════════════════════════════════════════════
   RESPONSIVE — Large phones ≤576px
   ══════════════════════════════════════════════ */
@media (max-width: 576px) {
  :root {
    --topbar-height: 56px;
  }

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

  /* Full-screen modal on phones */
  .modal {
    margin: 0;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 90dvh;
    max-width: none;
    overflow-y: auto;
    animation: slideUpModal 0.3s ease;
  }

  @keyframes slideUpModal {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
  }

  .modal-backdrop.show .modal {
    transform: translateY(0);
  }

  .page-header h1 { font-size: var(--font-lg); }
  .page-header { gap: var(--space-xs); }

  /* Notification dropdown: full width */
  .notification-dropdown {
    width: calc(100vw - var(--space-md));
    right: calc(-1 * var(--space-xs));
    left: auto;
  }

  /* Topbar: reduce padding more */
  .topbar { padding: 0 var(--space-sm); }
  .page-content { padding: var(--space-sm) var(--space-md); }

  /* Stat cards: tighter */
  .stat-card { padding: var(--space-md); }
  .stat-value { font-size: var(--font-xl); }

  /* Buttons: full-width in stacked layouts */
  .btn-group-mobile { display: flex; flex-direction: column; gap: var(--space-sm); width: 100%; }
  .btn-group-mobile .btn { width: 100%; justify-content: center; }

  /* Tabs: scrollable horizontal */
  .tabs { gap: 0; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .tab { padding: var(--space-sm) var(--space-md); white-space: nowrap; flex-shrink: 0; }
}

/* ══════════════════════════════════════════════
   RESPONSIVE — Standard phones ≤480px
   ══════════════════════════════════════════════ */
@media (max-width: 480px) {
  :root {
    --font-3xl: 1.4rem;
    --font-2xl: 1.2rem;
    --font-xl: 1.1rem;
  }

  .stat-grid { grid-template-columns: 1fr; }
  .card, .glass-card { padding: var(--space-md); }
  .stat-card { flex-direction: row; align-items: center; padding: var(--space-md); }

  .btn { padding: 8px 14px; font-size: var(--font-xs); }
  .btn-lg { padding: 12px 20px; font-size: var(--font-sm); }
  .btn-sm { padding: 5px 10px; }

  /* Topbar: hide non-essential items */
  .topbar-btn { width: 38px; height: 38px; }
  .topbar-avatar { width: 30px; height: 30px; font-size: 0.7rem; }

  /* Sidebar slightly narrower */
  :root { --sidebar-width: 240px; }

  /* Card header wraps */
  .card-header { flex-direction: column; align-items: flex-start; gap: var(--space-sm); }
  .card-header > *:last-child { width: 100%; }
}

/* ══════════════════════════════════════════════
   RESPONSIVE — Small phones ≤360px
   ══════════════════════════════════════════════ */
@media (max-width: 360px) {
  :root { --sidebar-width: 220px; }

  .page-content { padding: var(--space-sm); }
  .card, .glass-card, .stat-card { padding: 12px; }
  .topbar { padding: 0 var(--space-sm); }

  .filter-bar { gap: var(--space-xs); }
  .filter-group { width: 100%; }
  .filter-search { font-size: var(--font-xs); }

  .btn { padding: 7px 12px; }
  .stat-value { font-size: var(--font-lg); }
}

/* ══════════════════════════════════════════════
   RESPONSIVE — iPhone safe-area insets
   ══════════════════════════════════════════════ */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .sidebar {
    padding-bottom: calc(var(--space-md) + env(safe-area-inset-bottom));
  }
  .topbar {
    padding-left: max(var(--space-md), env(safe-area-inset-left));
    padding-right: max(var(--space-md), env(safe-area-inset-right));
  }
  /* Full-screen modals respect home bar */
  @media (max-width: 576px) {
    .modal {
      padding-bottom: env(safe-area-inset-bottom);
    }
  }
}

/* ══════════════════════════════════════════════
   25. PRINT STYLES
   ══════════════════════════════════════════════ */
@media print {
  .sidebar, .topbar, .mobile-toggle, .sidebar-overlay,
  .btn, .filter-bar, .pagination { display: none !important; }

  .main-content { margin-left: 0 !important; }
  .page-content { padding: 0; max-width: none; }

  body {
    color: #000;
    background: #fff;
    font-size: 12pt;
  }

  .card, .glass-card, .stat-card {
    border: 1px solid #ddd;
    background: #fff;
    box-shadow: none;
    backdrop-filter: none;
  }
}

/* ══════════════════════════════════════════════
   26. ANIMATIONS
   ══════════════════════════════════════════════ */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-16px); }
  to { opacity: 1; transform: translateX(0); }
}

.animate-fade-in { animation: fadeIn 0.4s ease; }
.animate-slide-up { animation: slideUp 0.4s ease; }

/* Staggered children */
.stagger > * {
  animation: slideUp 0.4s ease backwards;
}
.stagger > *:nth-child(1) { animation-delay: 0.05s; }
.stagger > *:nth-child(2) { animation-delay: 0.1s; }
.stagger > *:nth-child(3) { animation-delay: 0.15s; }
.stagger > *:nth-child(4) { animation-delay: 0.2s; }
.stagger > *:nth-child(5) { animation-delay: 0.25s; }
.stagger > *:nth-child(6) { animation-delay: 0.3s; }

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ══════════════════════════════════════════════
   27. DROPDOWN MENUS
   ══════════════════════════════════════════════ */
.dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  min-width: 180px;
  z-index: var(--z-dropdown);
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.2s ease;
  overflow: hidden;
}

.dropdown-menu.show {
  display: block;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  color: var(--text-secondary);
  font-size: var(--font-sm);
  text-decoration: none;
  transition: background var(--transition-fast), color var(--transition-fast);
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  font-family: var(--font-family);
}

.dropdown-item:hover {
  background: var(--surface-glass-hover);
  color: var(--text-primary);
}

.dropdown-divider {
  border-top: 1px solid var(--border-glass);
  margin: 4px 0;
}

/* ══════════════════════════════════════════════
   28. LANGUAGE SWITCHER
   ══════════════════════════════════════════════ */
.lang-switcher {
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--surface-glass);
  border-radius: var(--radius-md);
  padding: 2px;
}

.lang-btn {
  padding: 4px 10px;
  border: none;
  background: transparent;
  color: var(--text-tertiary);
  font-family: var(--font-family);
  font-size: var(--font-xs);
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.lang-btn:hover {
  color: var(--text-primary);
}

.lang-btn.active {
  background: var(--accent-purple);
  color: white;
}

/* ══════════════════════════════════════════════
   29. UTILITY CLASSES
   ══════════════════════════════════════════════ */
.fw-600 { font-weight: 600; }
.fs-sm { font-size: var(--font-sm); }
.text-secondary { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }
.p-lg { padding: var(--space-lg); }
.empty-state { text-align: center; }

/* ══════════════════════════════════════════════
   30. ADMIN-SPECIFIC LAYOUT UTILITIES
   ══════════════════════════════════════════════ */

/* Dashboard stats — used on admin payments, email-logs */
.dashboard-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-lg);
  margin-bottom: var(--space-lg);
}

/* Testimonial card grid — used on admin testimonials */
.testimonial-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--space-lg);
}

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