/* ============================================
   ODR System v2.4 - Master Stylesheet
   Dark Theme | RTL Arabic | Glassmorphism

   Z-INDEX HIERARCHY:
   1     — Cards, relative elements
   50    — Sidebar
   99    — Filter/Action bars
   1000  — Dock (bottom nav), Topbar
   5000  — Modals, Scanner overlay
   9000  — Toast notifications
   9999  — Tooltips
   99999 — Update banner
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Alexandria:wght@300;400;500;600;700;800;900&display=swap');

/* ---- CSS Variables ---- */
:root {
  --bg-primary: #040306;
  --bg-secondary: #0b0914;
  --bg-card: rgba(15, 15, 20, 0.45);
  --bg-glass: rgba(255, 255, 255, 0.03);
  --bg-hover: rgba(255, 255, 255, 0.08);
  --bg-input: rgba(0, 0, 0, 0.2);
  --bg-modal: rgba(4, 3, 6, 0.85);

  /* Premium horizontal scrollbar (dark default) */
  --scrollbar-track: rgba(255, 255, 255, 0.05);
  --scrollbar-thumb: rgba(150, 150, 150, 0.55);
  --scrollbar-thumb-hover: rgba(180, 180, 180, 0.85);

  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(99, 102, 241, 0.6);

  --text-primary: #ffffff;
  --text-secondary: #a1a1aa;
  --text-muted: #71717a;
  --text-heading: #f4f4f5;

  --accent-primary: #6366f1;
  --accent-primary-hover: #818cf8;
  --accent-secondary: #a855f7;
  --accent-success: #10b981;
  --accent-warning: #f59e0b;
  --accent-danger: #ef4444;
  --accent-info: #0ea5e9;

  --gradient-primary: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
  --gradient-success: linear-gradient(135deg, #10b981 0%, #34d399 100%);
  --gradient-danger: linear-gradient(135deg, #ef4444 0%, #f43f5e 100%);
  --gradient-warning: linear-gradient(135deg, #f59e0b 0%, #fbbf24 100%);
  --gradient-dark: linear-gradient(135deg, #09090b 0%, #18181b 100%);
  --gradient-card: linear-gradient(160deg, rgba(255,255,255,0.03) 0%, rgba(255,255,255,0) 100%);

  --shadow-sm: 0 4px 12px rgba(0,0,0,0.5);
  --shadow-md: 0 12px 32px rgba(0,0,0,0.6);
  --shadow-lg: 0 24px 64px rgba(0,0,0,0.8);
  --shadow-glow: 0 0 40px rgba(99, 102, 241, 0.2);

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --radius-full: 50%;

  --sidebar-width: 280px;
  --topbar-height: 72px;

  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================
   الوضع الفاتح (Light Mode)
   يُفعَّل عبر <html data-color-scheme="light">
   يحافظ على لون الـ accent المختار من السمات (themes)
   ============================================ */
html[data-color-scheme="light"] {
  --bg-primary: #f4f5f7;
  --bg-secondary: #e9ebef;
  --bg-card: rgba(255, 255, 255, 0.92);
  --bg-glass: rgba(0, 0, 0, 0.02);
  --bg-hover: rgba(0, 0, 0, 0.05);
  --bg-input: rgba(0, 0, 0, 0.04);
  /* Premium horizontal scrollbar (light mode) */
  --scrollbar-track: rgba(0, 0, 0, 0.05);
  --scrollbar-thumb: rgba(120, 120, 120, 0.5);
  --scrollbar-thumb-hover: rgba(80, 80, 80, 0.8);
  --bg-modal: rgba(0, 0, 0, 0.45);

  --border-color: rgba(0, 0, 0, 0.12);
  --border-focus: rgba(99, 102, 241, 0.5);

  --text-primary: #1a1a2e;
  --text-secondary: #4b5563;
  --text-muted: #6b7280;
  --text-heading: #111827;

  --gradient-card: linear-gradient(160deg, rgba(255,255,255,0.6) 0%, rgba(255,255,255,0.2) 100%);

  --shadow-sm: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-md: 0 8px 24px rgba(0,0,0,0.12);
  --shadow-lg: 0 16px 48px rgba(0,0,0,0.16);
  --shadow-glow: 0 0 30px rgba(99, 102, 241, 0.15);

  color-scheme: light;
}
/* في الوضع الفاتح: تخفيف خلفية الأورورا المتوهجة */
html[data-color-scheme="light"] body::before,
html[data-color-scheme="light"] body::after {
  opacity: 0.25;
}

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

html {
  font-size: 14px;
  scroll-behavior: smooth;
  color-scheme: dark; /* Forces native dropdowns/selects to use dark theme */
}

body {
  font-family: 'Alexandria', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  direction: rtl;
  line-height: 1.7;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  position: relative;
}

/* Animated Aurora Background */
body::before, body::after {
  content: '';
  position: fixed;
  width: 70vw;
  height: 70vh;
  border-radius: 50%;
  filter: blur(140px);
  z-index: -1;
  opacity: 0.35;
  animation: float-aurora 20s ease-in-out infinite;
  pointer-events: none;
}

body::before {
  background: radial-gradient(circle, rgba(99, 102, 241, 0.4), transparent 60%);
  top: -10%; left: -10%;
}

body::after {
  background: radial-gradient(circle, rgba(168, 85, 247, 0.3), transparent 60%);
  bottom: -10%; right: -10%;
  animation-delay: -10s;
}

@keyframes float-aurora {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(5vw, -5vh) scale(1.1); }
  66% { transform: translate(-3vw, 3vh) scale(0.9); }
}

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

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-secondary); }
::-webkit-scrollbar-thumb { background: rgba(99,102,241,0.3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(99,102,241,0.5); }

/* ============================================
   LOGIN PAGE — Split-screen (شاشة الدخول المقسّمة)
   الجهة اليمنى (بداية RTL): نموذج الدخول على سطح هادئ.
   الجهة اليسرى: لوحة تسويقية بخلفية الهوية + كاروسيل.
   تُطوى اللوحة التسويقية تحت 992px فيبقى النموذج كامل العرض.
   ============================================ */
.login-wrapper {
  display: flex;
  width: 100%;
  /* 100dvh يمنع قفزة شريط عنوان المتصفح على الجوال؛ 100vh احتياط للمتصفحات الأقدم */
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg-primary);
  position: relative;
  overflow: hidden;
}

/* ---- Form pane (يمين) ---- */
.login-pane {
  flex: 0 0 40%;
  max-width: 40%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px clamp(24px, 3vw, 56px);
  background: var(--bg-secondary);
  overflow-y: auto;
  position: relative;
  z-index: 1;
}

.login-card {
  position: relative;
  width: 100%;
  max-width: 400px;
  animation: slideUp 0.6s ease-out;
}

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

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo .logo-icon {
  width: 72px;
  height: 72px;
  margin: 0 auto 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  /* الخلفية المتدرّجة يرسمها الـ SVG نفسه (مستطيل مستدير) — أُزيلت الخلفية المكرّرة والظل النيليّ
     الثابت اللذان كانا يتعارضان مع الثيم النشط. الظل الآن محايد يتبع العمق لا لوناً ثابتاً. */
  filter: drop-shadow(0 8px 22px rgba(0, 0, 0, 0.28));
}
/* تدرّج شعار الدخول مربوط بمتغيّرات الثيم ليتّسق مع باقي الهوية (الاسم النصي والأزرار)
   في كل الثيمات بدل تدرّج نيليّ/بنفسجيّ ثابت يصطدم بلوحة ألوان حمراء/زمرديّة/غيرها. */
.login-logo .logo-icon .hp-stop-a { stop-color: var(--accent-primary); }
.login-logo .logo-icon .hp-stop-b { stop-color: var(--accent-secondary); }

.login-logo h1 {
  font-size: 1.8rem;
  font-weight: 800;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.login-logo p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-top: 4px;
}

/* ============================================
   LOGIN — Marketing pane + carousel (اللوحة التسويقية)
   الخلفية مبنيّة على --gradient-primary فتتبع سمة الهوية المختارة
   بدل تدرّج ثابت، وتعمل في الوضعين الداكن والفاتح.
   ============================================ */
.promo-pane {
  flex: 1 1 60%;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(40px, 5vh, 72px) clamp(40px, 5vw, 96px);
  /* clip بدل hidden: الهالة الزخرفية (::after) تتجاوز حدود اللوحة، ومع hidden تصير اللوحة
     حاوية تمرير — فيُزيح المتصفح المحتوى عند تركيز إحدى نقاط الترقيم (scrollIntoView) ويكسر
     التوسيط. أما clip فلا يُنشئ حاوية تمرير أصلاً. hidden يبقى احتياطاً للمتصفحات الأقدم. */
  overflow: hidden;
  overflow: clip;
  isolation: isolate;
  color: #fff;
  background:
    radial-gradient(115% 85% at 88% 8%, rgba(255,255,255,0.20) 0%, transparent 55%),
    radial-gradient(95% 75% at 8% 100%, rgba(0,0,0,0.32) 0%, transparent 62%),
    var(--gradient-primary);
}

/* شبكة نقطية خفيفة تتلاشى نحو الأسفل — تمنح عمقاً دون ملفات صور */
.promo-pane::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background-image: radial-gradient(rgba(255,255,255,0.20) 1px, transparent 1px);
  background-size: 26px 26px;
  -webkit-mask-image: linear-gradient(to bottom, #000 0%, transparent 78%);
  mask-image: linear-gradient(to bottom, #000 0%, transparent 78%);
  opacity: 0.45;
  pointer-events: none;
}

/* هالة عائمة ناعمة خلف المحتوى */
.promo-pane::after {
  content: '';
  position: absolute;
  z-index: -1;
  width: 46vw;
  height: 46vw;
  bottom: -18vw;
  right: -12vw;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,0.16) 0%, transparent 68%);
  animation: promoOrb 18s ease-in-out infinite;
  pointer-events: none;
}

@keyframes promoOrb {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50%      { transform: translate(-4vw, -5vh) scale(1.12); }
}

.promo-inner {
  position: relative;
  width: 100%;
  max-width: 640px;
  /* يملأ ارتفاع اللوحة ليثبت الشعار أعلى والترقيم أسفل بدل تكتّل كل شيء في المنتصف */
  align-self: stretch;
  display: flex;
  flex-direction: column;
  gap: clamp(28px, 5vh, 52px);
}

.promo-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: 0.5px;
}

.promo-brand svg { flex-shrink: 0; }

.promo-brand span { color: #fff; }

/* الشرائح متراكبة في خلية Grid واحدة: يأخذ المسار ارتفاع أطول شريحة تلقائياً
   فلا يقفز التخطيط عند التبديل ولا نحتاج ارتفاعاً ثابتاً. */
.promo-track {
  display: grid;
  margin: auto 0;   /* يمتصّ الفراغ الحر فيبقى المحتوى موسّطاً بين الشعار والترقيم */
}

.promo-slide {
  grid-area: 1 / 1;
  opacity: 0;
  visibility: hidden;
  transform: translateY(18px);
  transition: opacity 0.6s var(--transition-normal, ease),
              transform 0.6s cubic-bezier(0.16, 1, 0.3, 1),
              visibility 0.6s;
  pointer-events: none;
}

.promo-slide.is-active {
  opacity: 1;
  visibility: visible;
  transform: none;
  pointer-events: auto;
}

.promo-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 58px;
  height: 58px;
  margin-bottom: 24px;
  border-radius: var(--radius-md);
  background: rgba(255,255,255,0.14);
  border: 1px solid rgba(255,255,255,0.22);
  backdrop-filter: blur(6px);
  color: #fff;
}

.promo-title {
  font-size: clamp(1.5rem, 2.4vw, 2.2rem);
  font-weight: 800;
  line-height: 1.45;
  color: #fff;
  margin-bottom: 16px;
  text-wrap: balance;
}

.promo-text {
  font-size: clamp(0.95rem, 1.05vw, 1.08rem);
  line-height: 2;
  color: rgba(255,255,255,0.86);
  max-width: 54ch;
}

/* ---- Pagination dots ---- */
.promo-dots {
  display: flex;
  align-items: center;
  gap: 10px;
}

.promo-dot {
  position: relative;
  width: 10px;
  height: 10px;
  padding: 0;
  border: 0;
  border-radius: 99px;
  background: rgba(255,255,255,0.30);
  cursor: pointer;
  transition: width var(--transition-normal), background var(--transition-normal);
}

/* توسيع مساحة النقر إلى ~34px دون تكبير الشكل المرئي (النقطة نفسها 10px) */
.promo-dot::before {
  content: '';
  position: absolute;
  inset: -12px -5px;
}

.promo-dot:hover { background: rgba(255,255,255,0.55); }

.promo-dot:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
}

.promo-dot.is-active {
  width: 48px;
  background: rgba(255,255,255,0.28);
}

/* شريط التقدّم داخل النقطة النشطة — مدّته مربوطة بمؤقّت الكاروسيل عبر --promo-duration */
.promo-dot-fill {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: #fff;
  transform: scaleX(0);
  transform-origin: right center; /* يمتلئ من اليمين لليسار مسايرةً للـ RTL */
}

.promo-dot.is-active .promo-dot-fill {
  animation: promoDotFill var(--promo-duration, 6000ms) linear forwards;
}

@keyframes promoDotFill {
  from { transform: scaleX(0); }
  to   { transform: scaleX(1); }
}

/* التوقّف عند التحويم أو التركيز — يوقف المؤقّت في JS وشريط التقدّم هنا */
.promo-pane:hover .promo-dot.is-active .promo-dot-fill,
.promo-pane:focus-within .promo-dot.is-active .promo-dot-fill {
  animation-play-state: paused;
}

/* ---- Login split-screen responsive ---- */
@media (max-width: 1280px) {
  .login-pane { flex-basis: 45%; max-width: 45%; }
}

/* دون 992px: تُخفى اللوحة التسويقية ويأخذ النموذج كامل العرض فوراً */
@media (max-width: 991px) {
  .promo-pane { display: none; }

  .login-pane {
    flex: 1 1 100%;
    max-width: 100%;
    background: transparent;
    padding: 32px 20px;
  }

  /* على الجوال يستعيد النموذج هيئة البطاقة الزجاجية المعتمدة في باقي النظام */
  .login-card {
    max-width: 440px;
    padding: 40px 28px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    backdrop-filter: blur(20px);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
  }
}

@media (max-width: 480px) {
  .login-pane { padding: 20px 14px; }
  .login-card { padding: 32px 20px; }
}

@media (prefers-reduced-motion: reduce) {
  .login-card,
  .promo-pane::after { animation: none; }
  .promo-slide { transition-duration: 0.01ms; transform: none; }
  .promo-dot.is-active .promo-dot-fill { animation: none; transform: scaleX(1); }
}

/* ---- Form Elements ---- */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.input-wrapper {
  position: relative;
}

.input-wrapper .input-icon {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.1rem;
  color: var(--text-muted);
  pointer-events: none;
  transition: color var(--transition-fast);
}

.main-content {
  margin-right: 0;
  /* حشوة جانبية مرنة: هامش جمالي صغير يتّسع قليلاً على الشاشات العريضة دون إهدار المساحة */
  padding: 100px clamp(20px, 2vw, 48px) 140px;
  min-height: 100vh;
  transition: padding 0.3s ease;
}

.form-control {
  width: 100%;
  padding: 12px 14px;
  padding-right: 44px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.95rem;
  transition: all var(--transition-normal);
  outline: none;
}

.form-control:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
  background: rgba(255,255,255,0.07);
}

.form-control:focus + .input-icon,
.form-control:focus ~ .input-icon {
  color: var(--accent-primary);
}

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

.form-control-plain {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.95rem;
  transition: all var(--transition-normal);
  outline: none;
}

.form-control-plain:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}

select.form-control-plain {
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='%236366f1' viewBox='0 0 16 16'%3E%3Cpath fill-rule='evenodd' d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 14px center;
  background-size: 14px;
  padding-left: 40px;
}

select.form-control-plain:hover {
  border-color: var(--accent-primary);
  background-color: rgba(99,102,241,0.04);
}

select.form-control-plain:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 4px rgba(99,102,241,0.12);
  background-color: rgba(99,102,241,0.06);
}

select.form-control-plain option {
  background-color: #1a1a2e;
  color: #e4e4e7;
  padding: 12px;
  font-family: inherit;
}

select.form-control-plain option:checked {
  background-color: rgba(99,102,241,0.3);
  color: #fff;
}

select.form-control-plain option:hover {
  background-color: rgba(99,102,241,0.15);
}

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

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-normal);
  outline: none;
  white-space: nowrap;
}

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

.btn-primary {
  background: var(--gradient-primary);
  color: white;
  box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
}
.btn-primary:hover {
  box-shadow: 0 6px 25px rgba(59, 130, 246, 0.5), inset 0 0 0 1px rgba(255,255,255,0.2);
  transform: translateY(-2px);
}

.btn-success {
  background: var(--gradient-success);
  color: white;
  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
}
.btn-success:hover {
  box-shadow: 0 6px 25px rgba(16, 185, 129, 0.5);
  transform: translateY(-2px);
}

.btn-danger {
  background: var(--gradient-danger);
  color: white;
  box-shadow: 0 4px 15px rgba(244, 63, 94, 0.3);
}
.btn-danger:hover {
  box-shadow: 0 6px 25px rgba(244, 63, 94, 0.5);
  transform: translateY(-2px);
}

.btn-warning {
  background: var(--gradient-warning);
  color: #09090b;
  font-weight: 700;
  box-shadow: 0 4px 15px rgba(245, 158, 11, 0.3);
}
.btn-warning:hover {
  box-shadow: 0 6px 25px rgba(245, 158, 11, 0.5);
  transform: translateY(-2px);
}

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

.btn-sm { padding: 8px 16px; font-size: 0.82rem; }
.btn-lg { padding: 14px 32px; font-size: 1rem; }
.btn-block { width: 100%; }
.btn-icon { padding: 10px; border-radius: var(--radius-md); }

/* ---- App Layout ---- */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ---- Floating Dock ---- */
.floating-dock-wrapper {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
}

.floating-dock {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  backdrop-filter: blur(40px) saturate(210%);
  -webkit-backdrop-filter: blur(40px) saturate(210%);
  border: 1px solid var(--border-color);
  padding: 8px 16px;
  border-radius: 50px;
  box-shadow: var(--shadow-lg);
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  max-width: 98vw;
  overflow-x: auto;
  scrollbar-width: none;
}

.dock-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 12px;
  min-width: 70px;
  height: 64px;
  border-radius: 18px;
  background: transparent;
  color: var(--text-secondary);
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  text-decoration: none;
  border: none;
  cursor: pointer;
}

.dock-icon {
  font-size: 1.3rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.dock-icon svg {
  width: 20px;
  height: 20px;
}

.dock-label {
  font-size: 0.65rem;
  font-weight: 600;
  white-space: nowrap;
  opacity: 0.8;
}

.dock-item:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  transform: translateY(-10px) scale(1.05);
  box-shadow: 0 15px 30px rgba(0,0,0,0.4);
}

.dock-item:hover .dock-label { opacity: 1; }

.dock-item.active {
  background: var(--gradient-primary);
  color: white;
  box-shadow: 0 12px 28px rgba(99, 102, 241, 0.4), inset 0 0 0 1px rgba(255,255,255,0.2);
}

.dock-item.active .dock-label { opacity: 1; font-weight: 700; }

.dock-divider {
  width: 1px;
  height: 36px;
  background: var(--border-color);
  margin: 0 6px;
}

/* ---- Dock Brand: شعار Hatpro + اسم متجر المستأجر (مساحة عمل مُعلَّمة) ---- */
.dock-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 6px 0 4px;
}
.dock-logo-link {
  line-height: 0;
  display: block;
  color: var(--accent-primary);
  flex-shrink: 0;
}
.dock-tenant {
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--text-heading);
  letter-spacing: .2px;
  max-width: 150px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* على الشاشات الضيقة نُخفي الاسم النصي ونُبقي الشعار فقط لئلا يتمدّد الشريط */
@media (max-width: 640px) {
  .dock-tenant { display: none; }
}

/* Tooltip for Dock */
.dock-item::after {
  content: attr(data-tooltip);
  position: absolute;
  top: -45px;
  left: 50%;
  transform: translateX(-50%) scale(0.8);
  background: var(--bg-modal);
  color: white;
  padding: 6px 14px;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid rgba(255,255,255,0.1);
}

.dock-item:hover::after {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}

/* ---- Main Content ---- */
/* ---- Main Content ---- */
.main-content {
  flex: 1;
  width: 100%;
  max-width: 100%; /* تخطيط مرن بعرض كامل — أُلغي الحدّ السابق (1440px) لاستغلال الشاشات العريضة */
  margin: 0 auto;
  min-height: 100vh;
  min-width: 0; /* يسمح للعنصر بالانكماش فلا يتمدّد الجدول العريض ويكسر عرض الصفحة */
  display: flex;
  flex-direction: column;
  padding-bottom: 120px; /* Space for the dock */
}

.topbar {
  height: var(--topbar-height);
  margin: 16px 16px 0 0;
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  background: var(--bg-card);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  position: sticky;
  top: 16px;
  z-index: 50;
  box-shadow: var(--shadow-md);
  margin-left: 16px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-title h1 {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-heading);
}

.topbar-title p {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.page-content {
  flex: 1;
  min-width: 0; /* احتواء الجداول العريضة داخل تدفّق العمود دون كسر العرض */
  padding: 28px;
}

/* ---- Bento Grid ---- */
.bento-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  grid-auto-rows: minmax(140px, auto);
  gap: 24px;
  margin-bottom: 32px;
}

.bento-item {
  grid-column: span 3;
}
.bento-item.wide { grid-column: span 6; }
.bento-item.tall { grid-row: span 2; }
.bento-item.full { grid-column: span 12; }

@media (max-width: 1200px) {
  .bento-item { grid-column: span 4; }
  .bento-item.wide { grid-column: span 8; }
}
@media (max-width: 900px) {
  .bento-item, .bento-item.wide { grid-column: span 6; }
}
@media (max-width: 600px) {
  .bento-item, .bento-item.wide, .bento-item.full { grid-column: span 12; }
}

/* ---- Legacy Stats Cards ---- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg-card);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 24px;
  position: relative;
  overflow: hidden;
  transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: var(--shadow-md);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.stat-card:hover {
  transform: translateY(-10px) scale(1.03);
  box-shadow: var(--shadow-lg), 0 0 30px rgba(99, 102, 241, 0.15);
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.05);
}

.stat-card::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 100%;
  height: 3px;
}

.stat-card.purple::after { background: var(--gradient-primary); }
.stat-card.green::after { background: var(--gradient-success); }
.stat-card.orange::after { background: var(--gradient-warning); }
.stat-card.red::after { background: var(--gradient-danger); }

.stat-card .stat-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  margin-bottom: 14px;
}

.stat-card.purple .stat-icon { background: rgba(99,102,241,0.12); color: var(--accent-primary); }
.stat-card.green .stat-icon { background: rgba(16,185,129,0.12); color: var(--accent-success); }
.stat-card.orange .stat-icon { background: rgba(245,158,11,0.12); color: var(--accent-warning); }
.stat-card.red .stat-icon { background: rgba(239,68,68,0.12); color: var(--accent-danger); }

.stat-card .stat-value {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.2;
}

.stat-card .stat-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* ---- Card / Panel ---- */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  overflow: hidden;
  transition: all var(--transition-normal);
  box-shadow: var(--shadow-md);
  margin-bottom: 24px;
}

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

.card-header h2 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-heading);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-body {
  padding: 22px;
}

.card-body.no-pad {
  padding: 0;
}

/* ---- Data Table ---- */
.table-wrapper {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  padding: 0 16px 16px;
  scrollbar-width: thin; /* Firefox */
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

/* Premium horizontal scrollbar — واضح وأنيق وقابل للسحب بسهولة (WebKit/Chromium) */
.table-wrapper::-webkit-scrollbar {
  height: 10px;
}
.table-wrapper::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
  border-radius: 8px;
  margin: 0 16px;
}
.table-wrapper::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 8px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
.table-wrapper::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover);
  background-clip: padding-box;
}

/* Scrollable records/history container — يتيح تمرير مئات السجلات دون كسر التخطيط
   (Web / Mobile / iPad). الرأس يبقى ثابتاً أعلى المنطقة القابلة للتمرير. */
.records-scroll {
  max-height: 60vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.records-scroll .data-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--bg-secondary, #0b0914);
}
@media (max-width: 768px) {
  .records-scroll { max-height: 70vh; }
}

/* صف الإجمالي المنقول لأعلى الجدول (أول صف في tbody) — بارز ليراه المستخدم فوراً دون تمرير.
   يبقى فوق ثيمات مختلفة عبر --accent-primary. لصفوف records-scroll نجعله لاصقاً أسفل الترويسة. */
.data-table tbody tr.totals-row td {
  background: var(--bg-glass);
  font-weight: 800;
  color: var(--text-heading);
  border-top: 2px solid var(--border-color);
  border-bottom: 2px solid var(--accent-primary);
}
.records-scroll .data-table tbody tr.totals-row td {
  position: sticky;
  top: 44px; /* أسفل ترويسة thead اللاصقة مباشرة */
  z-index: 1;
}

.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 8px;
  white-space: nowrap;
}

.data-table th {
  padding: 14px 18px;
  text-align: right;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: transparent;
  border: none;
  white-space: nowrap;       /* لا التفاف في رؤوس الأعمدة */
  vertical-align: middle;
}

.data-table td {
  padding: 14px 18px;        /* مساحة أوسع لتتنفّس البيانات */
  font-size: 0.88rem;
  color: var(--text-primary);
  background: var(--bg-hover);
  border: 1px solid transparent;
  border-top: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
  transition: all var(--transition-normal);
  white-space: nowrap;       /* الشارات والتواريخ والأسعار في سطر واحد نظيف */
  vertical-align: middle;    /* محاذاة مثالية للشارات */
  min-width: 64px;           /* يمنع انكماش الأعمدة القصيرة */
}
/* أعمدة تحتاج عرضاً مريحاً: المصدر/طريقة البيع (قبل الأخير) والإجراءات (الأخير) */
.data-table td:last-child,
.data-table th:last-child {
  min-width: 130px;          /* عمود الإجراءات */
}
.data-table td:nth-last-child(2),
.data-table td:nth-last-child(3) {
  min-width: 120px;          /* طريقة البيع / المصدر */
}
.data-table td:first-child {
  border-right: 1px solid var(--border-color);
  border-radius: 0 12px 12px 0;
}
.data-table td:last-child {
  border-left: 1px solid var(--border-color);
  border-radius: 12px 0 0 12px;
}

.data-table tbody tr {
  transition: all var(--transition-normal);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.data-table tbody tr:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 16px rgba(0,0,0,0.3), var(--shadow-glow);
}
.data-table tbody tr:hover td {
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.15);
}

/* ---- Badges ---- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-success {
  background: rgba(16,185,129,0.12);
  color: var(--accent-success);
}

.badge-warning {
  background: rgba(245,158,11,0.12);
  color: var(--accent-warning);
}

.badge-danger {
  background: rgba(239,68,68,0.12);
  color: var(--accent-danger);
}

.badge-info {
  background: rgba(6,182,212,0.12);
  color: var(--accent-info);
}

.badge-purple {
  background: rgba(99,102,241,0.12);
  color: var(--accent-primary);
}

/* ---- Modal ---- */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  z-index: 5000;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}

.modal-overlay.active {
  display: flex;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modalSlide 0.3s ease;
}

@keyframes modalSlide {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

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

.modal-header h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-heading);
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.3rem;
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.modal-close:hover {
  color: var(--accent-danger);
  background: rgba(239,68,68,0.1);
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
}

/* ---- Form Grid ---- */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-row.three-col {
  grid-template-columns: 1fr 1fr 1fr;
}

.form-group.full-width {
  grid-column: 1 / -1;
}

/* ---- Toolbar ---- */
.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.search-box {
  position: relative;
  flex: 1;
  min-width: 200px;
  max-width: 360px;
}

.search-box input {
  width: 100%;
  padding: 10px 14px;
  padding-right: 40px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.88rem;
  outline: none;
  transition: all var(--transition-normal);
}

.search-box input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}

.search-box .search-icon {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

/* ---- Filter Chips ---- */
.filter-chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.chip {
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
  font-family: inherit;
}

.chip:hover { background: var(--bg-hover); }
.chip.active {
  background: rgba(99,102,241,0.15);
  border-color: var(--accent-primary);
  color: var(--accent-primary-hover);
}

/* ---- Action Buttons in Table ---- */
.action-btns {
  display: flex;
  gap: 6px;
}

.btn-action {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.9rem;
  transition: all var(--transition-fast);
  background: transparent;
}

.btn-action.edit {
  color: var(--accent-info);
}
.btn-action.edit:hover {
  background: rgba(6,182,212,0.12);
}

.btn-action.delete {
  color: var(--accent-danger);
}
.btn-action.delete:hover {
  background: rgba(239,68,68,0.12);
}

.btn-action.view {
  color: var(--accent-primary);
}
.btn-action.view:hover {
  background: rgba(99,102,241,0.12);
}

/* ---- Toast / Notification ---- */
.toast-container {
  position: fixed;
  top: 20px;
  left: 20px;
  z-index: 9000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 14px 20px;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  font-weight: 500;
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toastIn 0.3s ease;
  min-width: 280px;
}

.toast.success { background: rgba(16,185,129,0.15); border: 1px solid rgba(16,185,129,0.3); color: #6ee7b7; }
.toast.error { background: rgba(239,68,68,0.15); border: 1px solid rgba(239,68,68,0.3); color: #fca5a5; }
.toast.warning { background: rgba(245,158,11,0.15); border: 1px solid rgba(245,158,11,0.3); color: #fcd34d; }
.toast.info { background: rgba(6,182,212,0.15); border: 1px solid rgba(6,182,212,0.3); color: #67e8f9; }

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

/* ---- Charts ---- */
.chart-container {
  position: relative;
  height: 280px;
  padding: 10px;
}

.charts-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
  margin-bottom: 28px;
}

/* ---- Scanner ---- */
.scanner-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 5000;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
}

.scanner-overlay.active { display: flex; }

.scanner-viewport {
  width: 320px;
  height: 320px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  position: relative;
  border: 3px solid var(--accent-primary);
  box-shadow: 0 0 60px rgba(99,102,241,0.3);
}

.scanner-viewport video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scanner-line {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--accent-primary);
  box-shadow: 0 0 20px rgba(99,102,241,0.8);
  animation: scanLine 2s ease-in-out infinite;
}

@keyframes scanLine {
  0%, 100% { top: 0; }
  50% { top: calc(100% - 3px); }
}

/* ---- Alerts / Low Stock ---- */
.alert-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.alert-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: rgba(245,158,11,0.06);
  border: 1px solid rgba(245,158,11,0.15);
  border-radius: var(--radius-sm);
}

.alert-item .model-name {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.88rem;
}

.alert-item .stock-count {
  font-size: 0.8rem;
  color: var(--accent-warning);
  font-weight: 700;
}

/* ---- Empty State ---- */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}

.empty-state .empty-icon {
  font-size: 3rem;
  margin-bottom: 12px;
  opacity: 0.4;
}

.empty-state p {
  font-size: 0.92rem;
}

/* ---- Loading Spinner ---- */
.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border-color);
  border-top: 3px solid var(--accent-primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin: 40px auto;
}

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

.topbar {
  position: sticky;
  top: 16px;
  height: var(--topbar-height);
  margin: 16px 16px 0 16px;
  padding: 0 28px;
  background: var(--bg-card);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-md);
  z-index: 50;
  transition: transform 0.38s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
}

/* يختفي بأناقة عند النزول للأسفل، ويعود عند الصعود */
.topbar.topbar--hidden {
  transform: translateY(-160%);
  opacity: 0;
  box-shadow: none;
}

.topbar-title h1 {
  font-size: 1.4rem;
  font-weight: 800;
  margin-bottom: 2px;
}

.topbar-title p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.device-detail-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-color);
}

.device-detail-row:last-child { border-bottom: none; }

.device-detail-row .label {
  color: var(--text-muted);
  font-size: 0.82rem;
}

.device-detail-row .value {
  color: var(--text-primary);
  font-weight: 600;
  font-size: 0.88rem;
}

/* ---- Reports ---- */
.report-filters {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.report-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.report-stat {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  padding: 20px;
  text-align: center;
  transition: all 0.3s ease;
}

.report-stat:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.15);
  transform: scale(1.02);
}

.report-stat .value {
  font-size: 1.5rem;
  font-weight: 800;
  margin-bottom: 4px;
}

.report-stat .label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

.bento-section-title h2 {
  display: flex;
  align-items: center;
  gap: 10px;
}

.bento-section-title h2::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(to left, rgba(255,255,255,0.1), transparent);
}

/* ============================================
   SKELETON LOADERS
   ============================================ */
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.skeleton {
  background: linear-gradient(90deg,
    rgba(255,255,255,0.04) 0%,
    rgba(255,255,255,0.12) 50%,
    rgba(255,255,255,0.04) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease infinite;
  border-radius: 8px;
  display: inline-block;
}

.skeleton-row td {
  background: var(--bg-hover) !important;
  border-color: var(--border-color) !important;
}

/* ============================================
   TOOLTIPS (Global)
   ============================================ */
@keyframes tooltipIn {
  from { opacity: 0; transform: translateX(50%) translateY(4px); }
  to { opacity: 1; transform: translateX(50%) translateY(0); }
}

[data-tooltip] {
  position: relative;
}

[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  right: 50%;
  transform: translateX(50%);
  background: rgba(0,0,0,0.92);
  color: #fff;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 0.73rem;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
  z-index: 9999;
  animation: tooltipIn 0.2s ease;
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}

/* ============================================
   OPTIONAL / REQUIRED FIELD INDICATORS
   ============================================ */
.form-group label .optional-hint {
  font-size: 0.68rem;
  color: var(--text-muted);
  font-weight: 400;
  opacity: 0.6;
  margin-right: 4px;
}

.form-group label .required-dot {
  color: var(--accent-danger);
  margin-left: 2px;
  font-size: 0.7rem;
}

/* ============================================
   COLLAPSIBLE SECTIONS
   ============================================ */
details.collapsible-section {
  margin-top: 14px;
  padding: 14px;
  background: rgba(99,102,241,0.04);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  transition: all 0.3s ease;
}

details.collapsible-section[open] {
  border-color: rgba(99,102,241,0.2);
  background: rgba(99,102,241,0.06);
}

details.collapsible-section summary {
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-heading);
  user-select: none;
  display: flex;
  align-items: center;
  gap: 8px;
  list-style: none;
  padding: 2px 0;
}

details.collapsible-section summary::-webkit-details-marker {
  display: none;
}

details.collapsible-section summary::before {
  content: '▸';
  font-size: 0.85rem;
  transition: transform 0.2s ease;
  color: var(--accent-primary);
}

details.collapsible-section[open] summary::before {
  transform: rotate(90deg);
}

details.collapsible-section .section-content {
  margin-top: 12px;
  animation: fadeSlideDown 0.3s ease;
}

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

/* ============================================
   SKIP CARD (Source Wizard)
   ============================================ */
.sel-card.skip {
  border-style: dashed;
  opacity: 0.7;
}

.sel-card.skip:hover {
  opacity: 1;
  border-color: rgba(99,102,241,0.4);
}

.sel-card.skip.selected {
  opacity: 1;
  border-color: var(--text-muted);
  border-style: solid;
  background: rgba(255,255,255,0.03);
}

/* ============================================
   DRAFT SAVE INDICATOR
   ============================================ */
.draft-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  background: rgba(245,158,11,0.12);
  color: var(--accent-warning);
  border: 1px solid rgba(245,158,11,0.2);
  animation: fadeIn 0.3s ease;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
  /* Table horizontal scroll hint */
  .table-wrapper {
    position: relative;
  }

  .table-wrapper::after {
    content: '← مرّر';
    position: absolute;
    left: 8px;
    top: 8px;
    background: rgba(99,102,241,0.85);
    color: white;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.65rem;
    font-weight: 700;
    pointer-events: none;
    opacity: 0.8;
    z-index: 5;
  }

  /* Modal fixed header on mobile */
  .modal {
    max-height: 95vh;
  }

  .modal-header {
    position: sticky;
    top: 0;
    background: var(--bg-secondary);
    z-index: 10;
  }

  .page-content {
    padding: 16px;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }

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

  .form-row {
    grid-template-columns: 1fr;
  }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .search-box {
    max-width: none;
  }

  .modal {
    max-width: 100%;
    margin: 10px;
  }

  /* استجابة صفحة الدخول تُدار كاملةً في قسم LOGIN PAGE (نقطة الكسر 992px) */

  .scanner-viewport {
    width: 280px;
    height: 280px;
  }
}

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

  .stat-card {
    padding: 16px;
  }

  .stat-card .stat-value {
    font-size: 1.3rem;
  }

  .topbar {
    padding: 0 16px;
  }

  .report-summary-grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* ---- Pulse animation for alerts ---- */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.pulse { animation: pulse 2s ease-in-out infinite; }

/* ---- Print Styles (generic pages) ---- */
@media print {
  .sidebar, .topbar, .toolbar, .btn, .action-btns { display: none !important; }
  .main-content { margin: 0 !important; }
  .page-content { padding: 0 !important; }
  body { background: white; color: black; }
  .card { border: 1px solid #ddd; box-shadow: none; }
}

/* ==================== INVOICE PRINTING (v3.0) ==================== */
/* الحاوية مخفية تماماً على الشاشة — تظهر فقط في وضع الطباعة */
#invoice-container { display: none; }

/* تنسيق الفاتورة — أبيض/أسود نقي للطباعة الحرارية والليزر */
#invoice-container { direction: rtl; color: #000; background: #fff; font-family: 'Alexandria', sans-serif; }
#invoice-container .inv-header { text-align: center; padding-bottom: 6px; }
#invoice-container .inv-logo { max-width: 60%; max-height: 90px; object-fit: contain; margin-bottom: 4px; }
#invoice-container .inv-shop { font-weight: 900; font-size: 1.25em; }
#invoice-container .inv-sub { font-size: .85em; color: #333; }
#invoice-container .inv-divider { border-top: 1px dashed #000; margin: 6px 0; }
#invoice-container .inv-meta div { display: flex; justify-content: space-between; gap: 8px; font-size: .9em; padding: 1px 0; }
#invoice-container .inv-table { width: 100%; border-collapse: collapse; }
#invoice-container .inv-table th { text-align: right; font-size: .85em; border-bottom: 1px solid #000; padding: 3px 2px; }
#invoice-container .inv-table td { padding: 4px 2px; vertical-align: top; font-size: .9em; }
#invoice-container .inv-table td.inv-price { text-align: left; white-space: nowrap; font-weight: 700; }
#invoice-container .inv-item-name { font-weight: 800; }
#invoice-container .inv-item-sub { font-size: .78em; color: #222; }
#invoice-container .inv-totals .inv-total-row { display: flex; justify-content: space-between; font-size: .95em; padding: 1px 0; }
#invoice-container .inv-totals .grand { font-size: 1.1em; font-weight: 900; }
#invoice-container .inv-buyer { font-size: .88em; }
#invoice-container .inv-buyer span { color: #333; }
#invoice-container .inv-policy { margin-top: 6px; padding-top: 6px; border-top: 1px dashed #000; font-size: .75em; color: #222; white-space: pre-wrap; }
#invoice-container .inv-footer { text-align: center; font-weight: 800; margin-top: 8px; font-size: .9em; }
#invoice-container .inv-brand { text-align: center; color: #666; font-size: .62em; margin-top: 4px; letter-spacing: .3px; }

@media print {
  /* عند طباعة فاتورة: أخفِ كل الواجهة وأظهر الفاتورة وحدها */
  body.printing-invoice > *:not(#invoice-container) { display: none !important; }
  /* خلفية الأورورا المتحركة (body::before/::after) تسبّب صفحات فارغة وهدر حبر — تُعطَّل */
  body.printing-invoice::before,
  body.printing-invoice::after { display: none !important; animation: none !important; }
  body.printing-invoice { background: #fff !important; margin: 0 !important; padding: 0 !important; min-height: 0 !important; overflow: visible !important; }

  body.printing-invoice #invoice-container { display: block !important; position: static; z-index: auto; }
  /* منع الصفحات الفارغة الإضافية ومنع قصّ الصفوف بين الصفحات */
  body.printing-invoice #invoice-container { page-break-after: avoid; }
  body.printing-invoice #invoice-container tr,
  body.printing-invoice #invoice-container .inv-totals,
  body.printing-invoice #invoice-container .inv-policy { page-break-inside: avoid; }

  /* حراري 80mm: عرض المنطقة القابلة للطباعة ~76mm بعد هامش 2mm من @page */
  body.printing-invoice #invoice-container.invoice-80mm { width: 76mm; margin: 0; padding: 0; font-size: 12px; }
  /* A4: هامش 10mm من @page — المحتوى في عمود مركزي أنيق */
  body.printing-invoice #invoice-container.invoice-a4 { width: 100%; max-width: 190mm; margin: 0 auto; padding: 0; font-size: 14px; }
  body.printing-invoice #invoice-container.invoice-a4 .inv-logo { max-height: 130px; }
}

/* ══════════════════════════════════════════════════════════════════════════
   MOBILE & TABLET LAYER — سبرنت الاستجابة للجوال واللوحي
   قياسات هذا القسم كلّها مأخوذة من متصفّح حقيقي عند 375×812 لا من التخمين:
   الرصيف (dock) يحجب 106px من أسفل الشاشة، ومذيّل النافذة كان يسقط خارجها
   عند 862px بينما ارتفاع الشاشة 812px، و29–44 حقلاً في الصفحة الواحدة كانت
   بمقاس 13.3px — وهو ما يجعل iOS Safari يُقرّب الشاشة تلقائياً عند اللمس.
   ══════════════════════════════════════════════════════════════════════════ */

/* ── 1) الجداول: حاوية تمرير أفقي ───────────────────────────────────────────
   .table-responsive هو الاسم المعتمد في هذا السبرنت، و.table-wrapper اسمٌ
   قائم يستعمله 21 جدولاً. يشتركان في قاعدة واحدة فلا يُعاد تسمية ما يعمل
   أصلاً، ويصحّ أيّ منهما في الصفحات الجديدة. */
.table-responsive {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;   /* زخم التمرير على iOS */
  overscroll-behavior-x: contain;      /* لا يسحب الصفحة خلفه عند بلوغ الطرف */
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}
.table-wrapper {
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}
/* لا نفرض min-width على الجداول: القياس أثبت أنّها تُمرَّر أصلاً كما ينبغي
   (1214px داخل حاوية 301px)، وفرضُ max-content كان سيُحدث تمريراً أفقياً
   على سطح المكتب حيث لا حاجة إليه. */

/* ── 2) خلوص الرصيف العائم: لا حاجة إليه ───────────────────────────────────
   ظنّ أوّليّ خاطئ صُحّح بالقياس: حشوة .page-content السفلية 16px فبدا أنّ
   الرصيف الثابت (82px ارتفاعاً على بُعد 24px من الأسفل = 106px) يحجب آخر
   المحتوى. لكنّ الحاوية الأمّ .main-content تحمل أصلاً padding-bottom: 140px
   (120px عند الجوال)، والقياس عند 375px أعطى فجوة 78px فوق الرصيف بلا أيّ
   قاعدة إضافية — أي أنّ الخلوص محلول سلفاً. إضافة حشوة ثانية كانت ترفع
   الفراغ الذيلي من 184px إلى 302px بلا فائدة، فأُزيلت. */

/* ── 3) اللمس مقابل المؤشّر ─────────────────────────────────────────────────
   تأثيرات hover على شاشة لمس «تلتصق» بعد النقر فيبقى العنصر مرفوعاً. نقصرها
   على أجهزة تملك مؤشّراً حقيقياً. */
@media (hover: none) {
  .dock-item:hover {
    transform: none;
    box-shadow: none;
    background: transparent;
  }
  .dock-item:hover::after { opacity: 0; }   /* لا تلميحات معلّقة باللمس */
  .dock-item.active:hover { background: var(--gradient-primary); color: #fff; }
}

/* ── 4) الرصيف نفسه: تمرير أفقي سلس ────────────────────────────────────────
   الرصيف يحمل أصلاً max-width:98vw و overflow-x:auto، فبنوده تُمرَّر داخله
   ولا تكسر الصفحة. ما ينقصه زخم iOS وعزل التمرير عن الصفحة. */
.floating-dock {
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
}
.floating-dock .dock-item { scroll-snap-align: center; }

/* ══ الجوال واللوحي (≤1024px): الحقول وأهداف اللمس ════════════════════════ */
@media (max-width: 1024px) {
  /* 16px هو العتبة التي دونها يُقرّب iOS Safari الشاشة عند تركيز الحقل.
     محصورة في مقاسات الجوال واللوحي عمداً: رفعها على سطح المكتب يعيد تصميم
     كل نموذج في النظام بلا داعٍ — العلّة لمسيّة لا عامّة. */
  input, select, textarea,
  .form-input, .form-select, .form-textarea, .search-box input {
    font-size: 16px !important;
  }

  /* أهداف لمس ≥44px (توصية Apple HIG وأدنى حدّ في WCAG 2.5.5) */
  button, .btn, .btn-action, .modal-close, a.btn, input[type="submit"], input[type="button"] {
    min-height: 44px;
  }
  .btn, .btn-sm, .btn-action { padding-top: 8px; padding-bottom: 8px; }
  .btn-action { min-width: 44px; }
  /* الرصيف مستثنى: بنوده 64px أصلاً وله تخطيطه الخاص */
  .dock-item { min-height: 64px; }
}

/* ══ الجوال (≤768px): النوافذ المنبثقة ════════════════════════════════════
   العلّة المقيسة: .modal كان max-height:90vh مع overflow-y:auto، فيُمرَّر
   ككتلة واحدة ويهبط المذيّل (حفظ/إلغاء) خارج الشاشة عند 862px. الحلّ عمودٌ
   مرن: الرأس والمذيّل ثابتان، والجسم وحده يُمرَّر — فيبقى زرّ الحفظ ظاهراً
   مهما طال النموذج أو ارتفعت لوحة المفاتيح. */
@media (max-width: 768px) {
  .modal-overlay { padding: 10px; align-items: flex-start; }

  .modal {
    width: 95%;
    max-width: 100%;
    margin: 10px auto;
    max-height: 90vh;
    max-height: 90dvh;          /* يحسب ارتفاع الشاشة الفعليّ بعد ظهور لوحة المفاتيح */
    display: flex;
    flex-direction: column;
    overflow: hidden;           /* التمرير مسؤولية الجسم وحده */
  }

  .modal-header, .modal-footer { flex: 0 0 auto; }

  .modal-body {
    flex: 1 1 auto;
    max-height: 80vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    padding: 16px;
  }

  .modal-footer {
    position: sticky;
    bottom: 0;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
  }
  /* المذيّل على الجوال: أزرار بعرضٍ متساوٍ يسهل إصابتها بالإبهام */
  .modal-footer .btn { flex: 1; justify-content: center; }
}

/* ══ الجوال الضيّق (≤480px) ═══════════════════════════════════════════════ */
@media (max-width: 480px) {
  .modal { width: 100%; margin: 0 auto; border-radius: var(--radius-lg); }
  .modal-header { padding: 14px 16px; }
  .modal-footer { padding: 12px 16px; }
  .page-content { padding-left: 12px; padding-right: 12px; }
  .table-wrapper, .table-responsive { padding-left: 12px; padding-right: 12px; }
}

/* ── 5) صفّ «عرض المزيد» ────────────────────────────────────────────────────
   ذيل كل شبكة بيانات: زرّ الجلب وعدّاد يقول أين نحن من الإجمالي. الحدّ الثابت
   بلا زرٍّ كان يحبس المستخدم في الصفحة الأولى بلا أيّ أثرٍ يدلّه على الباقي. */
.pager-row td {
  padding: 0;
  background: var(--bg-card);
  border-top: 1px solid var(--border-color);
}
/* الغلاف لاصقٌ عند الحافة المرئية: هذه الجداول تُمرَّر أفقياً، فلولا اللصق لانزاح
   الزرّ مع المحتوى واحتاج المستخدم أن يسحب جانباً ليبلغه. */
.pager-inner {
  position: sticky;
  inset-inline-start: 0;
  width: max-content;
  max-width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 14px 12px;
}
.pager-status, .pager-done {
  font-size: .8rem;
  color: var(--text-muted);
  white-space: nowrap;
}
.pager-done { font-weight: 600; }
@media (max-width: 480px) {
  /* على الجوال: الزرّ سطرٌ كامل والعدّاد تحته، فلا ينضغطان في سطرٍ واحد */
  .pager-inner { flex-direction: column; align-items: stretch; gap: 8px; }
  .pager-remaining { display: none; }
}

/* ══════════════════════════════════════════════════════════════════════════
   iOS / iPadOS POLISH — صقل أجهزة آبل الصغيرة
   ══════════════════════════════════════════════════════════════════════════ */

/* ── 1) منطقة الأمان (iPhone X فما فوق) ────────────────────────────────────
   الرصيف العائم ثابتٌ على بُعد 24px من الأسفل، وهو يقع فوق «شريط المؤشّر المنزلي»
   في الأجهزة ذات الحوّاف المنحنية: يُحجب جزءٌ من البنود ويلتقط النظامُ لمساتِها.
   env() تُضيف ارتفاع المنطقة الآمنة فعلياً، وتساوي صفراً على كل جهازٍ بلا حوّاف
   فلا يتغيّر شيء في غيرها. */
.floating-dock-wrapper {
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
}
@supports (padding: max(0px)) {
  .page-content {
    padding-left: max(var(--page-pad-x, 28px), env(safe-area-inset-left, 0px));
    padding-right: max(var(--page-pad-x, 28px), env(safe-area-inset-right, 0px));
  }
}

/* ── 2) فيض أفقي خارج الجداول ──────────────────────────────────────────────
   body يحمل overflow-x: hidden، لكنه يُخفي العَرَض ولا يمنع سببه — والسبب الغالب هنا
   نصوصٌ طويلة بلا فواصل: أرقام تسلسلية، باركودات، معرّفات أخطاء، بريد إلكتروني.
   داخل خليةٍ ضيّقة تدفع هذه السلاسل الجدولَ فيتجاوز الحاوية. الكسر عند أي محرف
   يحلّ السبب بدل إخفائه. */
.data-table td, .data-table th,
.acct, .stat-card, .bento-card, .modal-body {
  overflow-wrap: anywhere;
}
/* السيريال والباركود يُعرضان بخط أحاديّ المسافة وقد يطولان — نمنعهما من دفع التخطيط */
.data-table td code, .sa-mono, [style*="font-family:monospace"] {
  word-break: break-all;
}

/* ── 3) النوافذ مع لوحة المفاتيح ───────────────────────────────────────────
   85dvh بدل 90: تترك هامشاً للشريط العلوي في سفاري (الذي يظهر ويختفي) فلا يُقصّ
   رأس النافذة لحظة ظهوره. dvh وحدها تتبع لوحة المفاتيح؛ vh الاحتياطية للمتصفّحات
   الأقدم التي لا تعرفها. */
@media (max-width: 1024px) {
  .modal, .sa-modal {
    max-height: 85vh;
    max-height: 85dvh;
  }
  .modal-body, .sa-modal-body {
    max-height: 70dvh;
    /* الزخم داخل الجسم وحده — لا يسحب الصفحة خلفه عند بلوغ الطرف */
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
  }
}

/* ── 4) حقول التاريخ والقوائم على iOS ──────────────────────────────────────
   سفاري يرسم <input type="date"> بعنصره الخاص: يتقلّص إلى ارتفاع النصّ فيصير هدفاً
   صغيراً، ويُحاذي المحتوى إلى اليسار في صفحة RTL. كما أنّ ارتفاعه يتغيّر لحظة فتح
   المنتقي فيقفز التخطيط — تثبيت الارتفاع يمنع القفزة.
   -webkit-appearance: none ممنوعة هنا عمداً: تُعطّل منتقي التاريخ الأصلي على iOS. */
input[type="date"],
input[type="datetime-local"],
input[type="time"] {
  min-height: 44px;
  line-height: 1.2;
  text-align: start;          /* يتبع اتجاه الصفحة بدل التثبيت يساراً */
  -webkit-text-fill-color: currentColor;   /* سفاري يُبهت النصّ في بعض الحالات */
}
/* القوائم المنسدلة: هدف لمس كامل وسهم لا يزحف في RTL */
select, .form-control-plain[multiple] {
  min-height: 44px;
  background-position: left 12px center;
}

/* ── 5) لمسات متفرّقة ──────────────────────────────────────────────────────
   تكبير تلقائي عند التدوير: سفاري يُكبّر النصّ عند الانتقال للوضع الأفقي ما لم يُمنع. */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
/* وميض رمادي عند اللمس على iOS — نستبدله بحالة :active الخاصّة بالتصميم */
a, button, .btn, .sel-card, .chip, .dock-item {
  -webkit-tap-highlight-color: transparent;
}
