/**
 * ╔══════════════════════════════════════════════════════════╗
 * ║         UNIFIED DESIGN SYSTEM — TAPIT PLATFORM          ║
 * ║    Admin Panel · Merchant Panel · Store Front           ║
 * ╚══════════════════════════════════════════════════════════╝
 *
 * Import: Google Fonts (Tajawal for Arabic, Inter for English)
 * Supports: Dark Mode + Light Mode via [data-theme="dark"] attribute
 * RTL Support: Full RTL/LTR via dir="rtl" and IS_RTL
 */

/* ─── Google Fonts ──────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@300;400;500;700;800&family=Inter:wght@300;400;500;600;700&display=swap');

/* ─── Design Tokens (Light Mode) ─────────────────────────────── */
:root {
  /* Brand Colors */
  --brand-primary:       #4F46E5;   /* Indigo 600 */
  --brand-primary-light: #6366F1;   /* Indigo 500 */
  --brand-primary-dark:  #3730A3;   /* Indigo 700 */
  --brand-accent:        #06B6D4;   /* Cyan 500 */
  --brand-success:       #10B981;   /* Emerald 500 */
  --brand-warning:       #F59E0B;   /* Amber 500 */
  --brand-danger:        #EF4444;   /* Red 500 */
  --brand-info:          #3B82F6;   /* Blue 500 */

  /* Neutral Scale */
  --neutral-0:   #FFFFFF;
  --neutral-50:  #F9FAFB;
  --neutral-100: #F3F4F6;
  --neutral-200: #E5E7EB;
  --neutral-300: #D1D5DB;
  --neutral-400: #9CA3AF;
  --neutral-500: #6B7280;
  --neutral-600: #4B5563;
  --neutral-700: #374151;
  --neutral-800: #1F2937;
  --neutral-900: #111827;

  /* Semantic — Light Mode */
  --color-bg:           var(--neutral-50);
  --color-bg-secondary: var(--neutral-100);
  --color-bg-tertiary:  var(--neutral-200);
  --color-surface:      var(--neutral-0);
  --color-surface-raised: var(--neutral-0);
  --color-border:       var(--neutral-200);
  --color-border-strong: var(--neutral-300);
  --color-text:         var(--neutral-900);
  --color-text-secondary: var(--neutral-600);
  --color-text-tertiary: var(--neutral-400);
  --color-text-inverse: var(--neutral-0);
  --color-shadow:       rgba(0,0,0,0.07);
  --color-shadow-lg:    rgba(0,0,0,0.12);
  --color-overlay:      rgba(0,0,0,0.45);

  /* Sidebar — Light Mode */
  --sidebar-bg:       #1E1B4B;   /* deep indigo */
  --sidebar-surface:  #27245A;
  --sidebar-text:     rgba(255,255,255,0.7);
  --sidebar-text-active: #FFFFFF;
  --sidebar-hover:    rgba(255,255,255,0.07);
  --sidebar-active:   rgba(99,102,241,0.35);
  --sidebar-border:   rgba(255,255,255,0.08);
  --sidebar-accent:   #6366F1;

  /* Input */
  --input-bg:        var(--neutral-0);
  --input-border:    var(--neutral-300);
  --input-focus:     var(--brand-primary);
  --input-text:      var(--neutral-900);
  --input-placeholder: var(--neutral-400);

  /* Status Colors */
  --status-success-bg:   #D1FAE5;
  --status-success-text: #065F46;
  --status-warning-bg:   #FEF3C7;
  --status-warning-text: #92400E;
  --status-danger-bg:    #FEE2E2;
  --status-danger-text:  #991B1B;
  --status-info-bg:      #DBEAFE;
  --status-info-text:    #1E40AF;
  --status-gray-bg:      var(--neutral-100);
  --status-gray-text:    var(--neutral-600);

  /* Typography */
  --font-ar:  'Tajawal', 'Tahoma', Arial, sans-serif;
  --font-en:  'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'Courier New', monospace;

  /* Sizing */
  --text-xs:   11px;
  --text-sm:   13px;
  --text-base: 14px;
  --text-md:   15px;
  --text-lg:   17px;
  --text-xl:   20px;
  --text-2xl:  24px;
  --text-3xl:  30px;
  --text-4xl:  36px;

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

  /* Radii */
  --radius-sm:   6px;
  --radius-md:   8px;
  --radius-lg:   12px;
  --radius-xl:   16px;
  --radius-2xl:  24px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-xs: 0 1px 2px var(--color-shadow);
  --shadow-sm: 0 1px 4px var(--color-shadow);
  --shadow-md: 0 4px 12px var(--color-shadow);
  --shadow-lg: 0 8px 24px var(--color-shadow-lg);
  --shadow-xl: 0 16px 48px var(--color-shadow-lg);

  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition:      0.25s ease;
  --transition-slow: 0.4s ease;

  /* Layout */
  --sidebar-width: 260px;
  --header-height: 64px;
  --container-max: 1280px;

  /* z-index scale */
  --z-sidebar:   200;
  --z-header:    100;
  --z-dropdown:  300;
  --z-modal:     500;
  --z-toast:     600;
  --z-overlay:   400;
}

/* ─── Dark Mode Override ─────────────────────────────────────── */
[data-theme="dark"] {
  --color-bg:           #0F172A;
  --color-bg-secondary: #1E293B;
  --color-bg-tertiary:  #334155;
  --color-surface:      #1E293B;
  --color-surface-raised: #263348;
  --color-border:       #334155;
  --color-border-strong: #475569;
  --color-text:         #F1F5F9;
  --color-text-secondary: #94A3B8;
  --color-text-tertiary: #64748B;
  --color-text-inverse: #0F172A;
  --color-shadow:       rgba(0,0,0,0.25);
  --color-shadow-lg:    rgba(0,0,0,0.4);
  --color-overlay:      rgba(0,0,0,0.65);

  /* Sidebar Dark */
  --sidebar-bg:      #0F172A;
  --sidebar-surface: #1E293B;
  --sidebar-text:    rgba(148,163,184,0.9);
  --sidebar-text-active: #F1F5F9;
  --sidebar-hover:   rgba(99,102,241,0.1);
  --sidebar-active:  rgba(99,102,241,0.2);
  --sidebar-border:  rgba(255,255,255,0.06);
  --sidebar-accent:  #818CF8;

  /* Input Dark */
  --input-bg:        #1E293B;
  --input-border:    #334155;
  --input-text:      #F1F5F9;
  --input-placeholder: #64748B;

  /* Status Dark */
  --status-success-bg:   rgba(16,185,129,0.15);
  --status-success-text: #6EE7B7;
  --status-warning-bg:   rgba(245,158,11,0.15);
  --status-warning-text: #FCD34D;
  --status-danger-bg:    rgba(239,68,68,0.15);
  --status-danger-text:  #FCA5A5;
  --status-info-bg:      rgba(59,130,246,0.15);
  --status-info-text:    #93C5FD;
  --status-gray-bg:      rgba(255,255,255,0.06);
  --status-gray-text:    #94A3B8;
}

/* ─── Base Reset ─────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

body {
  font-family: var(--font-ar);
  font-size: var(--text-base);
  line-height: 1.65;
  color: var(--color-text);
  background-color: var(--color-bg);
  transition: background-color var(--transition), color var(--transition);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* RTL/LTR */
[dir="ltr"] body,
body[dir="ltr"] {
  font-family: var(--font-en);
}

h1,h2,h3,h4,h5,h6 {
  font-weight: 700;
  line-height: 1.3;
  color: var(--color-text);
}

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

a:hover { color: var(--brand-primary-dark); }

img { max-width: 100%; height: auto; }
button { font-family: inherit; }
input, textarea, select { font-family: inherit; }

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

.container {
  width: 100%;
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 var(--space-5);
}

.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.justify-end { justify-content: flex-end; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; }
.flex-shrink-0 { flex-shrink: 0; }
.w-full { width: 100%; }
.h-full { height: 100%; }
.min-h-screen { min-height: 100vh; }
.overflow-hidden { overflow: hidden; }
.overflow-x-auto { overflow-x: auto; }
.relative { position: relative; }
.absolute { position: absolute; }
.fixed { position: fixed; }
.sticky { position: sticky; }
.inset-0 { top:0; right:0; bottom:0; left:0; }
.text-center { text-align: center; }
.text-end { text-align: end; }
.text-start { text-align: start; }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.font-medium { font-weight: 500; }
.text-sm { font-size: var(--text-sm); }
.text-xs { font-size: var(--text-xs); }
.text-lg { font-size: var(--text-lg); }
.text-xl { font-size: var(--text-xl); }
.text-2xl { font-size: var(--text-2xl); }
.text-muted { color: var(--color-text-secondary); }
.text-primary { color: var(--brand-primary); }
.text-success { color: var(--brand-success); }
.text-danger { color: var(--brand-danger); }
.text-warning { color: var(--brand-warning); }
.block { display: block; }
.inline-flex { display: inline-flex; }
.hidden { display: none; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: var(--space-1); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.rounded-full { border-radius: var(--radius-full); }
.rounded-lg { border-radius: var(--radius-lg); }
.no-select { user-select: none; }

/* ─── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 9px 18px;
  font-size: var(--text-sm);
  font-weight: 600;
  font-family: inherit;
  border: 1.5px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  text-decoration: none;
  transition: all var(--transition-fast);
  white-space: nowrap;
  line-height: 1;
  position: relative;
  overflow: hidden;
}

.btn:focus-visible {
  outline: 2px solid var(--brand-primary);
  outline-offset: 2px;
}

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

/* Sizes */
.btn-xs  { padding: 5px 10px; font-size: var(--text-xs); border-radius: var(--radius-sm); }
.btn-sm  { padding: 7px 14px; font-size: var(--text-xs); }
.btn-lg  { padding: 12px 28px; font-size: var(--text-md); }
.btn-xl  { padding: 15px 36px; font-size: var(--text-lg); }
.btn-block { width: 100%; }

/* Variants */
.btn-primary {
  background: var(--brand-primary);
  color: #fff;
  border-color: var(--brand-primary);
  box-shadow: 0 1px 3px rgba(79,70,229,0.3);
}
.btn-primary:hover {
  background: var(--brand-primary-dark);
  border-color: var(--brand-primary-dark);
  color: #fff;
  box-shadow: 0 4px 12px rgba(79,70,229,0.4);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border-color: var(--color-border);
  box-shadow: var(--shadow-xs);
}
.btn-secondary:hover {
  background: var(--color-bg-secondary);
  border-color: var(--color-border-strong);
  color: var(--color-text);
}

.btn-success {
  background: var(--brand-success);
  color: #fff;
  border-color: var(--brand-success);
}
.btn-success:hover {
  background: #059669;
  border-color: #059669;
  color: #fff;
  transform: translateY(-1px);
}

.btn-danger {
  background: var(--brand-danger);
  color: #fff;
  border-color: var(--brand-danger);
}
.btn-danger:hover {
  background: #DC2626;
  border-color: #DC2626;
  color: #fff;
  transform: translateY(-1px);
}

.btn-warning {
  background: var(--brand-warning);
  color: #fff;
  border-color: var(--brand-warning);
}
.btn-warning:hover {
  background: #D97706;
  border-color: #D97706;
  color: #fff;
  transform: translateY(-1px);
}

.btn-ghost {
  background: transparent;
  color: var(--color-text-secondary);
  border-color: transparent;
}
.btn-ghost:hover {
  background: var(--color-bg-secondary);
  color: var(--color-text);
  border-color: transparent;
}

.btn-outline {
  background: transparent;
  color: var(--brand-primary);
  border-color: var(--brand-primary);
}
.btn-outline:hover {
  background: var(--brand-primary);
  color: #fff;
}

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

/* ─── Cards ──────────────────────────────────────────────────── */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: box-shadow var(--transition);
}

.card:hover { box-shadow: var(--shadow-md); }

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

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

.card-subtitle {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  margin-top: var(--space-1);
}

.card-body {
  padding: var(--space-6);
}

.card-footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--color-border);
  background: var(--color-bg-secondary);
}

/* Stat Card */
.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
  box-shadow: var(--shadow-sm);
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  inset-inline-start: 0;
  width: 3px;
  height: 100%;
  background: var(--stat-color, var(--brand-primary));
  border-radius: var(--radius-sm);
}

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

.stat-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-lg);
  background: var(--stat-color-bg, rgba(79,70,229,0.1));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: var(--stat-color, var(--brand-primary));
  flex-shrink: 0;
}

.stat-content { flex: 1; }

.stat-label {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  font-weight: 500;
  margin-bottom: var(--space-1);
}

.stat-value {
  font-size: var(--text-3xl);
  font-weight: 800;
  color: var(--color-text);
  line-height: 1.1;
}

.stat-sub {
  font-size: var(--text-xs);
  color: var(--color-text-tertiary);
  margin-top: var(--space-1);
}

.stat-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  margin-top: var(--space-2);
}

.stat-badge.up   { background: var(--status-success-bg); color: var(--status-success-text); }
.stat-badge.down { background: var(--status-danger-bg);  color: var(--status-danger-text);  }

/* ─── Tables ─────────────────────────────────────────────────── */
.table-wrapper {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  padding: 13px var(--space-5);
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--color-text-secondary);
  background: var(--color-bg-secondary);
  border-bottom: 1px solid var(--color-border);
  text-align: inherit;
  white-space: nowrap;
}

.data-table td {
  padding: 14px var(--space-5);
  font-size: var(--text-sm);
  color: var(--color-text);
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
}

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

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

/* ─── Badges ─────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  font-size: var(--text-xs);
  font-weight: 700;
  border-radius: var(--radius-full);
  white-space: nowrap;
  line-height: 1.5;
}

.badge-primary { background: rgba(79,70,229,0.12); color: #4338CA; }
.badge-success { background: var(--status-success-bg); color: var(--status-success-text); }
.badge-warning { background: var(--status-warning-bg); color: var(--status-warning-text); }
.badge-danger  { background: var(--status-danger-bg);  color: var(--status-danger-text);  }
.badge-info    { background: var(--status-info-bg);    color: var(--status-info-text);    }
.badge-gray    { background: var(--status-gray-bg);    color: var(--status-gray-text);    }

[data-theme="dark"] .badge-primary { background: rgba(99,102,241,0.2); color: #A5B4FC; }

/* ─── Form Elements (Unified SaaS Fields) ───────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-5);
}

.form-label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
}

.form-label .required {
  color: var(--brand-danger);
  margin-inline-start: 2px;
}

/* Global inputs to catch everything missing explicit classes */
.form-input,
.form-select,
.form-textarea,
.form-control,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="url"],
input[type="tel"],
textarea,
select {
  width: 100%;
  padding: 12px 16px;
  font-size: var(--text-sm);
  font-family: inherit;
  color: var(--color-text);
  background: var(--input-bg);
  border: 1.5px solid var(--input-border);
  border-radius: var(--radius-md);
  transition: all 0.2s ease;
  outline: none;
  line-height: 1.5;
  box-shadow: 0 1px 2px rgba(0,0,0,0.015);
}

/* Specific heights and fixes */
.form-input,
.form-select,
.form-control,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="url"],
input[type="tel"],
select {
  height: 48px !important;
  padding: 12px 16px !important;
}

textarea.form-control,
.form-textarea,
textarea {
  resize: vertical;
  min-height: 120px !important;
  height: auto !important;
  padding: 14px 16px !important;
}

.form-input::placeholder,
.form-textarea::placeholder,
.form-control::placeholder,
input::placeholder,
textarea::placeholder {
  color: var(--input-placeholder);
  opacity: 0.8;
}

/* Hover State */
.form-input:hover,
.form-select:hover,
.form-textarea:hover,
.form-control:hover,
input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="file"]):hover,
select:hover,
textarea:hover {
  border-color: var(--color-border-strong);
}

/* Focus State */
.form-input:focus,
.form-select:focus,
.form-textarea:focus,
.form-control:focus,
input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="file"]):focus,
select:focus,
textarea:focus {
  border-color: var(--brand-primary);
  background: var(--color-surface);
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.12);
}

/* Dark mode subtle glow adjustment */
[data-theme="dark"] .form-input:focus,
[data-theme="dark"] .form-select:focus,
[data-theme="dark"] .form-textarea:focus,
[data-theme="dark"] .form-control:focus,
[data-theme="dark"] input:focus,
[data-theme="dark"] select:focus,
[data-theme="dark"] textarea:focus {
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.2);
}

/* Disabled State */
.form-input:disabled,
.form-select:disabled,
.form-textarea:disabled,
.form-control:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  background: var(--color-bg-secondary);
  border-color: var(--color-border);
}

/* Error State */
.form-input.error,
.form-control.error,
.has-error .form-control {
  border-color: var(--brand-danger);
  background-color: rgba(239, 68, 68, 0.02);
}

.form-input.error:focus,
.form-control.error:focus,
.has-error .form-control:focus {
  box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.15);
}

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

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

/* Custom Select styling specifically for dropdowns */
.form-select,
select.form-control,
select {
  cursor: pointer;
  appearance: none;
  padding-right: 16px !important;
  padding-left: 40px !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 14px center !important;
  background-size: 16px;
}

/* Mobile Adjustments for fields */
@media (max-width: 768px) {
  .form-input,
  .form-select,
  .form-control,
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="number"],
  input[type="url"],
  input[type="tel"],
  select {
    height: 52px; /* Slightly larger targets for mobile */
    font-size: 16px; /* Prevents auto-zoom on iOS */
  }
}

/* ─── Alerts ─────────────────────────────────────────────────── */
.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font-size: var(--text-sm);
  line-height: 1.6;
}

.alert-icon { font-size: 18px; flex-shrink: 0; margin-top: 1px; }

.alert-success {
  background: var(--status-success-bg);
  color: var(--status-success-text);
  border-color: rgba(16,185,129,0.25);
}
.alert-warning {
  background: var(--status-warning-bg);
  color: var(--status-warning-text);
  border-color: rgba(245,158,11,0.25);
}
.alert-danger {
  background: var(--status-danger-bg);
  color: var(--status-danger-text);
  border-color: rgba(239,68,68,0.25);
}
.alert-info {
  background: var(--status-info-bg);
  color: var(--status-info-text);
  border-color: rgba(59,130,246,0.25);
}

/* ─── Modals ─────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--color-overlay);
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition), visibility var(--transition);
  backdrop-filter: blur(2px);
}

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

.modal {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: scale(0.95) translateY(10px);
  transition: transform var(--transition);
}

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

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

.modal-title {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--color-text);
}

.modal-close {
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--color-text-secondary);
  font-size: 18px;
  transition: all var(--transition-fast);
}
.modal-close:hover { background: var(--color-bg-tertiary); color: var(--color-text); }

.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(--color-border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
  flex-shrink: 0;
}

/* ─── Tabs ───────────────────────────────────────────────────── */
.tabs {
  display: flex;
  align-items: center;
  border-bottom: 2px solid var(--color-border);
  gap: var(--space-1);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab-btn {
  padding: 10px var(--space-4);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text-secondary);
  border: none;
  background: none;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color var(--transition-fast), border-color var(--transition-fast);
  white-space: nowrap;
  font-family: inherit;
}
.tab-btn:hover { color: var(--color-text); }
.tab-btn.active {
  color: var(--brand-primary);
  border-bottom-color: var(--brand-primary);
}

.tab-panel { display: none; padding-top: var(--space-5); }
.tab-panel.active { display: block; }

/* ─── Empty State ────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-16) var(--space-8);
  text-align: center;
  gap: var(--space-4);
  color: var(--color-text-tertiary);
}

.empty-state-icon {
  font-size: 48px;
  opacity: 0.5;
}

.empty-state-title {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--color-text-secondary);
}

.empty-state-text {
  font-size: var(--text-sm);
  max-width: 320px;
  line-height: 1.7;
}

/* ─── Pagination ─────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  flex-wrap: wrap;
}

.page-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text-secondary);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  cursor: pointer;
  text-decoration: none;
  transition: all var(--transition-fast);
}
.page-btn:hover:not(:disabled) {
  background: var(--color-bg-secondary);
  color: var(--brand-primary);
  border-color: var(--brand-primary);
}
.page-btn.active {
  background: var(--brand-primary);
  color: #fff;
  border-color: var(--brand-primary);
}
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ─── Theme Toggle Button ────────────────────────────────────── */
.theme-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 7px 14px;
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  cursor: pointer;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text-secondary);
  transition: all var(--transition-fast);
  font-family: inherit;
}
.theme-toggle-btn:hover {
  background: var(--color-bg-tertiary);
  color: var(--color-text);
}
.theme-icon { font-size: 16px; line-height: 1; }

/* ─── Loading / Skeleton  ────────────────────────────────────── */
@keyframes shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}

.skeleton {
  border-radius: var(--radius-md);
  background: linear-gradient(90deg,
    var(--color-bg-secondary) 25%,
    var(--color-bg-tertiary) 37%,
    var(--color-bg-secondary) 63%
  );
  background-size: 800px 100%;
  animation: shimmer 1.4s infinite linear;
}

/* ─── Dividers ───────────────────────────────────────────────── */
.divider {
  border: 0;
  border-top: 1px solid var(--color-border);
  margin: var(--space-5) 0;
}

/* ─── Avatar ─────────────────────────────────────────────────── */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: var(--brand-primary);
  color: #fff;
  font-weight: 700;
  font-size: var(--text-sm);
  flex-shrink: 0;
}
.avatar-sm { width: 28px; height: 28px; font-size: var(--text-xs); }
.avatar-lg { width: 48px; height: 48px; font-size: var(--text-lg); }

/* ─── Tooltip ────────────────────────────────────────────────── */
[data-tooltip] {
  position: relative;
  cursor: help;
}
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--neutral-800);
  color: #fff;
  font-size: var(--text-xs);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition-fast);
  z-index: var(--z-dropdown);
}
[data-tooltip]:hover::after { opacity: 1; }

/* ─── Scrollbar Styling ──────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--color-border-strong); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: var(--color-text-tertiary); }

/* ─── Responsive Grid ────────────────────────────────────────── */
.grid { display: grid; }
.grid-cols-1 { grid-template-columns: repeat(1, 1fr); }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-5);
}

@media (max-width: 1200px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  .stats-grid { grid-template-columns: repeat(1, 1fr); }
  .grid-cols-2,
  .grid-cols-3,
  .grid-cols-4 { grid-template-columns: repeat(1, 1fr); }
}

/* ─── Micro-animations ───────────────────────────────────────── */
@keyframes fadeIn  { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:none; } }
@keyframes slideIn { from { opacity:0; transform:translateX(20px); } to { opacity:1; transform:none; } }
@keyframes pulse   { 0%,100% { opacity:1; } 50% { opacity:0.5; } }
@keyframes spin    { to { transform: rotate(360deg); } }

.animate-fade-in  { animation: fadeIn  0.3s ease forwards; }
.animate-slide-in { animation: slideIn 0.3s ease forwards; }
.animate-pulse    { animation: pulse   2s ease infinite; }
.animate-spin     { animation: spin    1s linear infinite; }

/* ─── Print ──────────────────────────────────────────────────── */
@media print {
  .sidebar, .header, .no-print { display: none !important; }
  .content { margin: 0 !important; }
}
