/* ============================================================================
   SpaceX — Workspace OS  |  نظام التصميم
   مبني على دليل الهوية البصرية v1.0 — DEVX SYSTEMS
   RTL أصيل: يعتمد الخصائص المنطقية (inline-start/end) لا left/right
   ============================================================================ */

/* ============================================================================
   1. الرموز (Design Tokens)
   ============================================================================ */
:root {
  /* الألوان الأساسية — من دليل الهوية */
  --sx-violet:        #5B34EF;   /* Orbit Violet  — الأساسي */
  --sx-amber:         #FFB020;   /* Solar Amber   — العدّادات الحية */
  --sx-ink:           #14121F;   /* Space Ink     — النصوص والداكن */
  --sx-indigo:        #7C5CFF;   /* Plasma Indigo */
  --sx-emerald:       #00B368;   /* Emerald       — نجاح */
  --sx-coral:         #FF4D3D;   /* Nebula Coral  — خطر */
  --sx-mist:          #EDEAF7;   /* Nebula Mist   — حدود */
  --sx-star:          #F6F5FB;   /* Star White    — خلفية */

  /* الأساسي — تُعاد كتابته في ملفات theme-*.css */
  --sx-primary:       var(--sx-violet);
  --sx-primary-dark:  #3D1FB0;
  --sx-primary-glow:  rgba(91, 52, 239, .15);
  --sx-primary-bg:    rgba(91, 52, 239, .09);

  /* الأسطح والنصوص */
  --sx-bg:            #F6F5FB;
  --sx-surface:       #FFFFFF;
  --sx-surface-2:     #FBFAFE;
  --sx-text:          #14121F;
  --sx-text-muted:    #6A6580;
  --sx-text-soft:     #9E98B8;
  --sx-border:        rgba(20, 18, 31, .09);
  --sx-border-strong: rgba(20, 18, 31, .16);

  /* الحالات + تدرّجاتها */
  --sx-success:       #00B368;  --sx-success-bg: rgba(0, 179, 104, .12);
  --sx-danger:        #FF4D3D;  --sx-danger-bg:  rgba(255, 77, 61, .12);
  --sx-warning:       #D98A00;  --sx-warning-bg: rgba(255, 176, 32, .16);
  --sx-info:          #7C5CFF;  --sx-info-bg:    rgba(124, 92, 255, .12);

  /* الخطوط — لكل خط وظيفة محددة في الهوية */
  --sx-font-display:  'Orbitron', sans-serif;
  --sx-font-head:     'Cairo', 'Tajawal', sans-serif;
  --sx-font-body:     'Tajawal', system-ui, sans-serif;
  --sx-font-mono:     'Roboto Mono', ui-monospace, monospace;

  /* الأنصاف والظلال */
  --r-xs: 8px;  --r-sm: 12px;  --r-md: 14px;  --r-lg: 18px;  --r-xl: 24px;
  --sh-xs: 0 1px 2px rgba(20, 18, 31, .05);
  --sh-sm: 0 1px 3px rgba(20, 18, 31, .07);
  --sh-md: 0 4px 16px rgba(20, 18, 31, .08);
  --sh-lg: 0 12px 32px rgba(20, 18, 31, .12);
  --sh-primary: 0 6px 20px var(--sx-primary-glow);

  /* التخطيط */
  --sidebar-width: 268px;
  --sidebar-gap: 16px;
  --header-h: 64px;
}

/* ============================================================================
   2. إعادة الضبط والأساسيات
   ============================================================================ */
*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--sx-bg);
  color: var(--sx-text);
  font-family: var(--sx-font-body);
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5 {
  font-family: var(--sx-font-head);
  font-weight: 800;
  line-height: 1.3;
  margin: 0 0 12px;
  color: var(--sx-text);
}
h1 { font-size: 27px; }
h2 { font-size: 20px; font-weight: 700; }
h3 { font-size: 17px; font-weight: 700; }

p { margin: 0 0 12px; }

a { color: var(--sx-primary); text-decoration: none; transition: color .15s; }
a:hover { color: var(--sx-primary-dark); }

img, svg { max-width: 100%; }

::selection { background: var(--sx-primary-bg); color: var(--sx-primary-dark); }

:focus-visible {
  outline: 2px solid var(--sx-primary);
  outline-offset: 2px;
  border-radius: 4px;
}

/* أنماط الأرقام — قاعدة الهوية: الأرقام دائماً LTR وجدولية */
.mono, .sx-money {
  font-family: var(--sx-font-mono);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  direction: ltr;
  unicode-bidi: isolate;
  display: inline-block;
}
.counter {
  font-family: var(--sx-font-display);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  direction: ltr;
  unicode-bidi: isolate;
  letter-spacing: 1px;
  color: var(--sx-primary);
  display: inline-block;
}
.counter-live { color: var(--sx-amber); }

/* ============================================================================
   3. التخطيط — الشريط الجانبي والمحتوى
   ============================================================================ */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-width);
  flex: 0 0 var(--sidebar-width);
  background: var(--sx-ink);
  color: rgba(246, 245, 251, .82);
  display: flex;
  flex-direction: column;
  position: fixed;
  inset-block: 0;
  inset-inline-start: 0;
  z-index: 60;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.14); border-radius: 3px; }

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 20px 20px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
  position: relative;
}
.sidebar-brand-text { line-height: 1.15; }
.sidebar-brand-name {
  font-family: var(--sx-font-display);
  font-weight: 800;
  font-size: 18px;
  letter-spacing: 1px;
  color: #fff;
}
.sidebar-brand-name span { color: var(--sx-amber); }
.sidebar-brand-sub {
  font-size: 10.5px;
  letter-spacing: 2px;
  color: rgba(246, 245, 251, .48);
  text-transform: uppercase;
  margin-top: 2px;
}

/* مبدّل المساحة */
.space-switcher { padding: 14px 16px; border-bottom: 1px solid rgba(255,255,255,.08); }
.space-switcher select {
  width: 100%;
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .12);
  color: #fff;
  font-family: var(--sx-font-body);
  font-size: 13.5px;
  padding: 9px 12px;
  border-radius: var(--r-sm);
  cursor: pointer;
}
.space-switcher select option { background: var(--sx-ink); color: #fff; }

.sidebar-nav { padding: 14px 12px 24px; flex: 1; }

.nav-section {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: rgba(246, 245, 251, .38);
  padding: 16px 10px 7px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9.5px 12px;
  border-radius: var(--r-sm);
  color: rgba(246, 245, 251, .78);
  font-size: 14.5px;
  font-weight: 500;
  margin-bottom: 2px;
  transition: background .14s, color .14s;
  position: relative;
}
.nav-link:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.nav-link.active {
  background: var(--sx-primary);
  color: #fff;
  font-weight: 700;
  box-shadow: var(--sh-primary);
}
.nav-link i, .nav-link svg { width: 18px; height: 18px; flex: 0 0 18px; }
.nav-link .nav-badge {
  margin-inline-start: auto;
  background: var(--sx-amber);
  color: var(--sx-ink);
  font-size: 11px;
  font-weight: 800;
  padding: 1px 7px;
  border-radius: 999px;
}

.main-wrapper {
  flex: 1;
  margin-inline-start: var(--sidebar-width);
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.content { padding: 26px 30px 60px; flex: 1; }

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}
.page-head h1 { margin: 0; }
.page-subtitle { color: var(--sx-text-muted); font-size: 14px; margin: 4px 0 0; }
.page-actions { display: flex; gap: 9px; flex-wrap: wrap; }

/* ============================================================================
   4. البطاقات
   ============================================================================ */
.card {
  background: var(--sx-surface);
  border: 1px solid var(--sx-border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-xs);
  margin-bottom: 18px;
  overflow: hidden;
}
.card-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--sx-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-head h2, .card-head h3 { margin: 0; font-size: 16px; }
.card-body { padding: 20px; }
.card-dark { background: var(--sx-ink); color: var(--sx-star); border-color: transparent; }
.card-dark h1, .card-dark h2, .card-dark h3 { color: #fff; }

/* شبكة الإحصائيات */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.stat {
  background: var(--sx-surface);
  border: 1px solid var(--sx-border);
  border-radius: var(--r-lg);
  padding: 18px 20px;
  box-shadow: var(--sh-xs);
  position: relative;
  overflow: hidden;
}
.stat-label {
  font-size: 12.5px;
  color: var(--sx-text-muted);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 8px;
}
.stat-label i, .stat-label svg { width: 15px; height: 15px; color: var(--sx-primary); }
.stat-value {
  font-family: var(--sx-font-mono);
  font-size: 25px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  direction: ltr;
  unicode-bidi: isolate;
  line-height: 1.2;
}
.stat-hint { font-size: 12px; color: var(--sx-text-soft); margin-top: 5px; }
.stat-accent-violet  { border-inline-start: 3px solid var(--sx-violet); }
.stat-accent-amber   { border-inline-start: 3px solid var(--sx-amber); }
.stat-accent-emerald { border-inline-start: 3px solid var(--sx-emerald); }
.stat-accent-coral   { border-inline-start: 3px solid var(--sx-coral); }

/* ============================================================================
   5. الأزرار
   ============================================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-family: var(--sx-font-body);
  font-size: 14px;
  font-weight: 700;
  padding: 9.5px 18px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: var(--sx-surface);
  color: var(--sx-text);
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .08s, box-shadow .15s;
  white-space: nowrap;
  text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn.disabled { opacity: .55; cursor: not-allowed; }
.btn i, .btn svg { width: 16px; height: 16px; }

.btn-primary { background: var(--sx-primary); color: #fff; box-shadow: var(--sh-primary); }
.btn-primary:hover { background: var(--sx-primary-dark); color: #fff; }

.btn-outline { background: transparent; border-color: var(--sx-border-strong); color: var(--sx-text); }
.btn-outline:hover { background: var(--sx-surface-2); border-color: var(--sx-primary); color: var(--sx-primary); }

.btn-ghost { background: transparent; color: var(--sx-primary); }
.btn-ghost:hover { background: var(--sx-primary-bg); }

.btn-danger  { background: var(--sx-danger);  color: #fff; }
.btn-danger:hover  { background: #E03626; color: #fff; }
.btn-success { background: var(--sx-success); color: #fff; }
.btn-success:hover { background: #009655; color: #fff; }
.btn-amber   { background: var(--sx-amber); color: var(--sx-ink); }
.btn-amber:hover { background: #F0A310; color: var(--sx-ink); }

.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-lg { padding: 13px 26px; font-size: 15.5px; }
.btn-block { width: 100%; }

/* ============================================================================
   6. الشارات
   ============================================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 700;
  padding: 4px 11px;
  border-radius: 999px;
  background: var(--sx-mist);
  color: var(--sx-text-muted);
  white-space: nowrap;
}
.badge-success { background: var(--sx-success-bg); color: var(--sx-success); }
.badge-danger  { background: var(--sx-danger-bg);  color: var(--sx-danger); }
.badge-warning { background: var(--sx-warning-bg); color: var(--sx-warning); }
.badge-info    { background: var(--sx-info-bg);    color: var(--sx-info); }
.badge-primary { background: var(--sx-primary-bg); color: var(--sx-primary); }

/* نقطة النبض — للجلسات النشطة */
.dot-live {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: currentColor;
  animation: sx-pulse 1.6s ease-in-out infinite;
}
@keyframes sx-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

/* ============================================================================
   7. النماذج
   ============================================================================ */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--sx-text);
  margin-bottom: 6px;
}
.form-label .req { color: var(--sx-danger); }
.form-hint { font-size: 12px; color: var(--sx-text-soft); margin-top: 5px; }

.form-control,
input[type="text"], input[type="password"], input[type="number"],
input[type="tel"], input[type="email"], input[type="date"],
input[type="time"], input[type="datetime-local"], select, textarea {
  width: 100%;
  font-family: var(--sx-font-body);
  font-size: 14.5px;
  padding: 10px 13px;
  background: var(--sx-surface);
  border: 1px solid var(--sx-mist);
  border-radius: var(--r-sm);
  color: var(--sx-text);
  transition: border-color .15s, box-shadow .15s;
}
.form-control:focus, input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--sx-primary);
  box-shadow: 0 0 0 3px var(--sx-primary-glow);
}
input[type="number"], .input-money {
  font-family: var(--sx-font-mono);
  font-variant-numeric: tabular-nums;
  direction: ltr;
}
textarea { min-height: 90px; resize: vertical; }

.form-check { display: flex; align-items: center; gap: 9px; }
.form-check input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--sx-primary); cursor: pointer; }
.form-check label { font-size: 14px; cursor: pointer; margin: 0; }

/* ============================================================================
   8. الجداول
   ============================================================================ */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th {
  font-family: var(--sx-font-head);
  font-weight: 700;
  font-size: 13px;
  color: var(--sx-text-muted);
  text-align: start;
  padding: 12px 14px;
  background: var(--sx-surface-2);
  border-bottom: 1px solid var(--sx-mist);
  white-space: nowrap;
}
.table td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--sx-border);
  font-size: 14px;
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: var(--sx-surface-2); }
.table .num {
  font-family: var(--sx-font-mono);
  font-variant-numeric: tabular-nums;
  direction: ltr;
  unicode-bidi: isolate;
}
.table .row-actions { display: flex; gap: 6px; }

/* ============================================================================
   9. التنبيهات والحالة الفارغة
   ============================================================================ */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 13px 16px;
  border-radius: var(--r-md);
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 16px;
  border: 1px solid transparent;
}
.alert i, .alert svg { width: 18px; height: 18px; flex: 0 0 18px; margin-top: 2px; }
.alert-success { background: var(--sx-success-bg); color: #007a47; border-color: rgba(0,179,104,.24); }
.alert-danger  { background: var(--sx-danger-bg);  color: #C22E20; border-color: rgba(255,77,61,.24); }
.alert-warning { background: var(--sx-warning-bg); color: #9A6200; border-color: rgba(255,176,32,.3); }
.alert-info    { background: var(--sx-info-bg);    color: #5B34EF; border-color: rgba(124,92,255,.24); }

.empty-state { text-align: center; padding: 52px 20px; color: var(--sx-text-muted); }
.empty-state .empty-icon {
  width: 58px; height: 58px;
  margin: 0 auto 14px;
  border-radius: 50%;
  background: var(--sx-primary-bg);
  display: flex; align-items: center; justify-content: center;
}
.empty-state .empty-icon i, .empty-state .empty-icon svg { width: 26px; height: 26px; color: var(--sx-primary); }
.empty-state h3 { color: var(--sx-text); margin-bottom: 6px; }
.empty-state p { font-size: 14px; margin: 0; }

/* حاوية التنبيهات العائمة */
.toast-container {
  position: fixed;
  inset-block-start: 20px;
  inset-inline-end: 20px;
  z-index: 900;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 380px;
}
.toast {
  background: var(--sx-surface);
  border: 1px solid var(--sx-border);
  border-radius: var(--r-md);
  box-shadow: var(--sh-lg);
  padding: 13px 16px;
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  animation: sx-slide-in .22s ease-out;
}
@keyframes sx-slide-in { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }
.toast-success { border-inline-start: 3px solid var(--sx-success); }
.toast-danger  { border-inline-start: 3px solid var(--sx-danger); }
.toast-warning { border-inline-start: 3px solid var(--sx-amber); }
.toast-info    { border-inline-start: 3px solid var(--sx-info); }

/* ============================================================================
   10. العنصر التوقيعي — المدار
   ============================================================================ */
.orbit-bg { position: relative; overflow: hidden; }
.orbit-bg > * { position: relative; z-index: 1; }
.orbit-bg::before {
  content: '';
  position: absolute;
  inset: -50% -25%;
  z-index: 0;
  background:
    radial-gradient(circle at 78% 16%, rgba(255, 176, 32, .12), transparent 40%),
    radial-gradient(circle at 14% 84%, rgba(91, 52, 239, .12), transparent 44%);
  pointer-events: none;
}

/* شريط انتحال الشخصية */
.impersonation-bar {
  background: var(--sx-amber);
  color: var(--sx-ink);
  padding: 9px 20px;
  font-size: 13.5px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.impersonation-bar a { color: var(--sx-ink); text-decoration: underline; }

/* شريط تحذير الاشتراك */
.sub-warning-bar {
  background: var(--sx-danger-bg);
  color: #C22E20;
  border-bottom: 1px solid rgba(255, 77, 61, .2);
  padding: 10px 20px;
  font-size: 13.5px;
  font-weight: 600;
  text-align: center;
}

/* ============================================================================
   11. أدوات مساعدة
   ============================================================================ */
.flex     { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 4px; }  .gap-2 { gap: 8px; }  .gap-3 { gap: 12px; }  .gap-4 { gap: 16px; }
.wrap { flex-wrap: wrap; }
.mt-0 { margin-top: 0; }  .mb-0 { margin-bottom: 0; }
.mb-2 { margin-bottom: 8px; }  .mb-3 { margin-bottom: 12px; }  .mb-4 { margin-bottom: 16px; }
.text-muted { color: var(--sx-text-muted); }
.text-soft  { color: var(--sx-text-soft); }
.text-danger  { color: var(--sx-danger); }
.text-success { color: var(--sx-success); }
.text-primary { color: var(--sx-primary); }
.text-center { text-align: center; }
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }
.fw-700 { font-weight: 700; }
.hidden { display: none !important; }

/* زر القائمة للجوال */
.mobile-menu-fab {
  display: none;
  position: fixed;
  inset-block-end: 22px;
  inset-inline-end: 22px;
  width: 52px; height: 52px;
  border-radius: 50%;
  background: var(--sx-primary);
  color: #fff;
  border: none;
  box-shadow: var(--sh-lg);
  z-index: 70;
  cursor: pointer;
  align-items: center;
  justify-content: center;
}
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(20, 18, 31, .5);
  z-index: 55;
}
.sidebar-backdrop.show { display: block; }

/* ============================================================================
   11a. حقل البحث والاختيار (Combobox)
   ============================================================================ */
.sx-combo { position: relative; }

.sx-combo-field { position: relative; }
.sx-combo-field .sx-combo-icon {
  position: absolute;
  inset-inline-start: 12px;
  inset-block-start: 50%;
  transform: translateY(-50%);
  color: var(--sx-text-soft);
  pointer-events: none;
  display: flex;
}
.sx-combo-field .sx-combo-icon i,
.sx-combo-field .sx-combo-icon svg { width: 16px; height: 16px; }
.sx-combo-field input { padding-inline-start: 36px; }

.sx-combo-clear {
  position: absolute;
  inset-inline-end: 8px;
  inset-block-start: 50%;
  transform: translateY(-50%);
  width: 26px; height: 26px;
  border: none;
  background: var(--sx-mist);
  color: var(--sx-text-muted);
  border-radius: 50%;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
}
.sx-combo-clear i, .sx-combo-clear svg { width: 13px; height: 13px; }
.sx-combo.has-value .sx-combo-clear { display: flex; }

.sx-combo-list {
  position: absolute;
  inset-inline: 0;
  inset-block-start: calc(100% + 6px);
  z-index: 150;
  background: var(--sx-surface);
  border: 1px solid var(--sx-mist);
  border-radius: var(--r-md);
  box-shadow: var(--sh-lg);
  max-height: 302px;
  overflow-y: auto;
  display: none;
  padding: 5px;
}
.sx-combo.open .sx-combo-list { display: block; }

.sx-combo-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  cursor: pointer;
  font-size: 14px;
  line-height: 1.4;
}
.sx-combo-item:hover,
.sx-combo-item.active { background: var(--sx-primary-bg); }
.sx-combo-item[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }

.sx-combo-item-main { min-width: 0; }
.sx-combo-item-name {
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sx-combo-item-sub {
  font-size: 12px;
  color: var(--sx-text-muted);
  font-family: var(--sx-font-mono);
  direction: ltr;
  unicode-bidi: isolate;
}
.sx-combo-item-side {
  flex: 0 0 auto;
  font-family: var(--sx-font-mono);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  direction: ltr;
  unicode-bidi: isolate;
  color: var(--sx-text-muted);
}

.sx-combo-empty,
.sx-combo-loading {
  padding: 16px 12px;
  text-align: center;
  font-size: 13.5px;
  color: var(--sx-text-muted);
}
.sx-combo-more {
  padding: 8px 12px;
  text-align: center;
  font-size: 12px;
  color: var(--sx-text-soft);
  border-top: 1px solid var(--sx-border);
  margin-top: 4px;
}

/* ============================================================================
   11b. شبكة بطاقات الجلسات
   ============================================================================ */
.session-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(272px, 1fr));
  gap: 14px;
}

.session-card {
  background: var(--sx-surface);
  border: 1px solid var(--sx-border);
  border-inline-start: 3px solid var(--sx-emerald);
  border-radius: var(--r-lg);
  padding: 16px 18px;
  box-shadow: var(--sh-xs);
  cursor: pointer;
  transition: transform .12s, box-shadow .15s, border-color .15s;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.session-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--sh-md);
  border-color: var(--sx-primary);
}
.session-card:focus-visible { outline: 2px solid var(--sx-primary); outline-offset: 2px; }
.session-card--charging { border-inline-start-color: var(--sx-amber); }
.session-card--debt     { border-inline-start-color: var(--sx-coral); }

.session-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.session-card-name {
  font-family: var(--sx-font-head);
  font-weight: 700;
  font-size: 15.5px;
  line-height: 1.35;
}
.session-card-meta { font-size: 12px; color: var(--sx-text-muted); margin-top: 3px; }
.session-card-id {
  font-family: var(--sx-font-mono);
  font-size: 11px;
  color: var(--sx-text-soft);
}

.session-card-timer {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 0;
  border-block: 1px solid var(--sx-border);
}
.session-card-timer .counter { font-size: 21px; }
.session-card-total {
  font-family: var(--sx-font-mono);
  font-weight: 700;
  font-size: 17px;
  font-variant-numeric: tabular-nums;
  direction: ltr;
  unicode-bidi: isolate;
  color: var(--sx-primary);
}

.session-card-foot { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

/* ============================================================================
   11c. النافذة المنبثقة
   ============================================================================ */
.sx-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: none;
  background: rgba(20, 18, 31, .62);
  backdrop-filter: blur(3px);
  padding: 24px;
  overflow-y: auto;
}
.sx-modal.open { display: flex; align-items: flex-start; justify-content: center; }

.sx-modal-dialog {
  background: var(--sx-bg);
  border-radius: var(--r-xl);
  box-shadow: 0 24px 70px rgba(0, 0, 0, .42);
  width: 100%;
  max-width: 1080px;
  margin: auto;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 48px);
  animation: sx-modal-in .18s ease-out;
  overflow: hidden;
}
@keyframes sx-modal-in {
  from { opacity: 0; transform: translateY(14px) scale(.985); }
  to   { opacity: 1; transform: none; }
}

.sx-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 22px;
  background: var(--sx-ink);
  color: var(--sx-star);
  flex: 0 0 auto;
}
.sx-modal-head h2 { margin: 0; color: #fff; font-size: 17px; }
.sx-modal-head .sub { font-size: 12.5px; color: rgba(246,245,251,.62); margin-top: 2px; }

.sx-modal-close {
  background: rgba(255,255,255,.09);
  border: none;
  color: #fff;
  width: 34px; height: 34px;
  border-radius: 50%;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex: 0 0 auto;
  transition: background .15s;
}
.sx-modal-close:hover { background: rgba(255,255,255,.2); }

.sx-modal-body { padding: 20px 22px; overflow-y: auto; flex: 1 1 auto; }
.sx-modal-foot {
  padding: 14px 22px;
  border-top: 1px solid var(--sx-border);
  background: var(--sx-surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  flex: 0 0 auto;
}

/* ألسنة داخل النافذة */
.sx-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--sx-border);
  margin-bottom: 18px;
  overflow-x: auto;
}
.sx-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 10px 16px;
  font-family: var(--sx-font-body);
  font-size: 14px;
  font-weight: 700;
  color: var(--sx-text-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: color .15s, border-color .15s;
}
.sx-tab:hover { color: var(--sx-text); }
.sx-tab.active { color: var(--sx-primary); border-bottom-color: var(--sx-primary); }
.sx-tab-panel { display: none; }
.sx-tab-panel.active { display: block; }

/* حالة التحميل */
.sx-loading {
  display: flex; align-items: center; justify-content: center;
  gap: 10px; padding: 40px; color: var(--sx-text-muted); font-size: 14px;
}
.sx-spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--sx-mist);
  border-top-color: var(--sx-primary);
  border-radius: 50%;
  animation: sx-spin .7s linear infinite;
}
@keyframes sx-spin { to { transform: rotate(360deg); } }

/* مؤشّر التحديث الحيّ */
.sx-live-dot {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--sx-text-muted);
}
.sx-live-dot::before {
  content: ''; width: 7px; height: 7px; border-radius: 50%;
  background: var(--sx-emerald); animation: sx-pulse 1.8s ease-in-out infinite;
}
.sx-refreshing .sx-live-dot::before { background: var(--sx-amber); }

/* ============================================================================
   12. الاستجابة
   ============================================================================ */
@media (max-width: 992px) {
  /* الشريط يبقى على inset-inline-start (اليمين في RTL) وينزلق خارج الشاشة يميناً.
     نقله إلى inset-inline-end يضعه على اليسار فيدفعه translateX إلى داخل الشاشة. */
  .sidebar {
    transform: translateX(100%);
    transition: transform .22s ease;
  }
  .sidebar.open { transform: none; }
  .main-wrapper { margin-inline-start: 0; }
  .content { padding: 18px 16px 90px; }
  .mobile-menu-fab { display: flex; }
  .page-head { flex-direction: column; align-items: stretch; }
}

@media (max-width: 768px) {
  /* النافذة تملأ الشاشة على الجوال — لا هوامش ضائعة */
  .sx-modal { padding: 0; }
  .sx-modal-dialog {
    max-width: none;
    max-height: 100vh;
    min-height: 100vh;
    border-radius: 0;
    margin: 0;
  }
  .sx-modal-head { padding: 14px 16px; }
  .sx-modal-body { padding: 16px; }
  .sx-modal-foot { padding: 12px 16px; }
  .sx-modal-foot .btn { flex: 1 1 auto; justify-content: center; }
}

@media (max-width: 560px) {
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat { padding: 14px; }
  .stat-value { font-size: 20px; }
  .table th, .table td { padding: 10px; font-size: 13px; }
  .toast-container { inset-inline: 12px; max-width: none; }
  .session-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ============================================================================
   13. الطباعة
   ============================================================================ */
@media print {
  .sidebar, .mobile-menu-fab, .page-actions, .toast-container,
  .impersonation-bar, .row-actions { display: none !important; }
  .main-wrapper { margin: 0; }
  .card { box-shadow: none; border-color: #ccc; break-inside: avoid; }
  body { background: #fff; }
}
