/* ==========================================================================
   نظام إدارة الأعمال والإنتاج - تصميم متطور فائق الجمال (Ultra-Modern UI)
   Pure CSS - RTL Arabic Layout - 100% Offline
   ========================================================================== */

:root {
  /* نظام الألوان المتناسق والفخم */
  --sidebar-bg: #1e293b;
  --sidebar-header: #0f172a;
  --sidebar-hover: #334155;
  --sidebar-active: #2563eb;
  --sidebar-text: #94a3b8;
  --sidebar-text-bright: #ffffff;
  --sidebar-border: rgba(255, 255, 255, 0.07);

  --topbar-bg: #ffffff;
  --topbar-border: #e2e8f0;
  --topbar-text: #0f172a;

  --body-bg: #f1f5f9;
  --card-bg: #ffffff;
  --card-border: #e2e8f0;

  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --primary-glow: rgba(37, 99, 235, 0.25);
  
  --success: #059669;
  --success-hover: #047857;
  --success-light: #ecfdf5;
  
  --warning: #d97706;
  --warning-light: #fffbeb;
  
  --danger: #e11d48;
  --danger-hover: #be123c;
  --danger-light: #ffe4e6;
  
  --info: #0284c7;
  --info-light: #f0f9ff;

  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-full: 9999px;

  --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.04);
  --shadow-sm: 0 2px 4px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 6px 16px -2px rgba(0, 0, 0, 0.06), 0 2px 6px -1px rgba(0, 0, 0, 0.03);
  --shadow-lg: 0 14px 28px -4px rgba(0, 0, 0, 0.09), 0 6px 12px -2px rgba(0, 0, 0, 0.04);

  --sidebar-width: 270px;
  --topbar-height: 70px;
  --transition-fast: 0.18s ease;
  --transition-normal: 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
  font-size: 15px;
  direction: rtl;
  text-align: right;
  scroll-behavior: smooth;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, Tahoma, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background-color: var(--body-bg);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  overflow-x: hidden;
  line-height: 1.6;
}

.app-container {
  display: flex;
  width: 100%;
  min-height: 100vh;
  position: relative;
}

/* ==========================================================================
   الشريط الجانبي (Sidebar)
   ========================================================================== */
.sidebar {
  width: var(--sidebar-width);
  background-color: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  transform: translateX(100%);
  transition: transform var(--transition-normal);
  box-shadow: -6px 0 30px rgba(0, 0, 0, 0.35);
  user-select: none;
}

.sidebar.open {
  transform: translateX(0);
}

.sidebar-header {
  height: var(--topbar-height);
  background-color: var(--sidebar-header);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.35rem;
  border-bottom: 1px solid var(--sidebar-border);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  text-decoration: none;
  color: var(--sidebar-text-bright);
}

.logo-icon-box {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}

.sidebar-logo h1 {
  font-size: 1.12rem;
  font-weight: 800;
  letter-spacing: -0.3px;
  white-space: nowrap;
}

.btn-sidebar-close {
  background: rgba(255, 255, 255, 0.06);
  border: none;
  color: var(--sidebar-text);
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.btn-sidebar-close:hover {
  background-color: rgba(255, 255, 255, 0.15);
  color: var(--sidebar-text-bright);
  transform: scale(1.05);
}

.sidebar-menu {
  list-style: none;
  padding: 1.25rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  overflow-y: auto;
  flex-grow: 1;
}

.menu-item {
  position: relative;
}

.menu-link {
  display: flex;
  align-items: center;
  gap: 0.95rem;
  padding: 0.85rem 1.15rem;
  color: var(--sidebar-text);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.94rem;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

.menu-link .icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform var(--transition-fast);
}

.menu-link:hover {
  background-color: var(--sidebar-hover);
  color: var(--sidebar-text-bright);
  transform: translateX(-3px);
}

.menu-item.active .menu-link {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #ffffff;
  font-weight: 700;
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.35);
}

.sidebar-footer {
  padding: 1.15rem 1.35rem;
  border-top: 1px solid var(--sidebar-border);
  font-size: 0.82rem;
  color: var(--text-light);
  text-align: center;
  background: rgba(0, 0, 0, 0.15);
}

/* ==========================================================================
   الشريط العلوي (Topbar)
   ========================================================================== */
.main-wrapper {
  flex: 1;
  margin-right: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
}

.topbar {
  height: var(--topbar-height);
  background-color: var(--topbar-bg);
  border-bottom: 1px solid var(--topbar-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.75rem;
  position: sticky;
  top: 0;
  z-index: 90;
  box-shadow: var(--shadow-xs);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 1.15rem;
}

.btn-sidebar-toggle {
  background: #f8fafc;
  border: 1px solid var(--card-border);
  color: var(--text-main);
  cursor: pointer;
  padding: 0.55rem;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.btn-sidebar-toggle:hover {
  background-color: #eff6ff;
  border-color: #bfdbfe;
  color: var(--primary);
  transform: scale(1.05);
}

.btn-sidebar-toggle svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  stroke-width: 2.3;
}

.page-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.3px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* بطاقة المستخدم العلوية (مطابقة للصورة بدقة فائقة) */
.user-profile-badge {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  background-color: #ffffff;
  border: 1px solid var(--topbar-border);
  padding: 0.4rem 0.9rem;
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition-fast);
}

.user-profile-badge:hover {
  box-shadow: var(--shadow-md);
}

.user-avatar-circle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #e0e7ff, #c7d2fe);
  color: #3730a3;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
}

.user-info {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.user-name {
  font-size: 0.88rem;
  font-weight: 800;
  color: var(--text-main);
}

.user-role {
  font-size: 0.74rem;
  color: var(--text-muted);
  font-weight: 500;
}

.btn-logout {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background-color: #fff1f2;
  color: #e11d48;
  border: 1px solid rgba(225, 29, 72, 0.25);
  padding: 0.35rem 0.85rem;
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  font-weight: 700;
  text-decoration: none;
  transition: all var(--transition-fast);
}

.btn-logout:hover {
  background-color: #e11d48;
  color: #ffffff;
  box-shadow: 0 4px 10px rgba(225, 29, 72, 0.3);
}

/* ==========================================================================
   زر وخاصية إخفاء الأسعار والخصوصية (Price Privacy Mode)
   ========================================================================== */
.btn-price-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.95rem;
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  font-weight: 800;
  background-color: #ffffff;
  color: var(--text-main);
  border: 1px solid var(--topbar-border);
  box-shadow: var(--shadow-xs);
  cursor: pointer;
  transition: all var(--transition-fast);
  user-select: none;
  text-decoration: none;
}

.btn-price-toggle:hover {
  background-color: #eff6ff;
  border-color: #bfdbfe;
  color: var(--primary);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.btn-price-toggle .price-toggle-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: color var(--transition-fast);
}

.btn-price-toggle:hover .price-toggle-icon {
  color: var(--primary);
}

.btn-price-toggle .price-toggle-badge {
  display: none;
  font-size: 0.68rem;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.25);
  font-weight: 800;
  letter-spacing: -0.2px;
}

/* الحالة النشطة: إخفاء الأسعار مفعل */
html.hide-prices-mode .btn-price-toggle,
body.hide-prices-mode .btn-price-toggle {
  background: linear-gradient(135deg, #4f46e5, #3730a3);
  border-color: #312e81;
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.4);
}

html.hide-prices-mode .btn-price-toggle .price-toggle-icon,
body.hide-prices-mode .btn-price-toggle .price-toggle-icon {
  color: #ffffff;
}

html.hide-prices-mode .btn-price-toggle .icon-eye-open,
body.hide-prices-mode .btn-price-toggle .icon-eye-open {
  display: none !important;
}

html.hide-prices-mode .btn-price-toggle .icon-eye-closed,
body.hide-prices-mode .btn-price-toggle .icon-eye-closed {
  display: inline-block !important;
}

html.hide-prices-mode .btn-price-toggle .price-toggle-badge,
body.hide-prices-mode .btn-price-toggle .price-toggle-badge {
  display: inline-block;
  background: rgba(255, 255, 255, 0.22);
  color: #ffffff;
}

/* قواعد تمويه وحجب الأسعار والبيانات المالية في كامل النظام */
html.hide-prices-mode .price-sensitive:not(.is-revealed),
html.hide-prices-mode [data-price-val]:not(.is-revealed),
html.hide-prices-mode .stat-value:not(.is-revealed),
html.hide-prices-mode .wo-stat-card .val:not(.is-revealed),
html.hide-prices-mode .card-summary-val:not(.is-revealed),
html.hide-prices-mode .running-balance:not(.is-revealed),
html.hide-prices-mode td.price-cell:not(.is-revealed),
html.hide-prices-mode span.price-cell:not(.is-revealed),
html.hide-prices-mode strong.price-cell:not(.is-revealed),
html.hide-prices-mode input.price-sensitive-input:not(.is-revealed),
html.hide-prices-mode input[name*="price" i]:not(.is-revealed),
html.hide-prices-mode input[name*="amount" i]:not(.is-revealed),
html.hide-prices-mode input[name*="salary" i]:not(.is-revealed),
html.hide-prices-mode input[name*="cost" i]:not(.is-revealed),
html.hide-prices-mode input[name*="total" i]:not(.is-revealed),
html.hide-prices-mode input[name*="paid" i]:not(.is-revealed),
html.hide-prices-mode input[name*="remaining" i]:not(.is-revealed),
html.hide-prices-mode input[name*="rate" i]:not(.is-revealed),
html.hide-prices-mode input[name*="balance" i]:not(.is-revealed),
html.hide-prices-mode input[name*="initial_balance" i]:not(.is-revealed),
html.hide-prices-mode input[name*="advance" i]:not(.is-revealed),
html.hide-prices-mode input[name*="bonus" i]:not(.is-revealed),
html.hide-prices-mode input[name*="deduction" i]:not(.is-revealed),
html.hide-prices-mode input[id*="price" i]:not(.is-revealed),
html.hide-prices-mode input[id*="amount" i]:not(.is-revealed),
html.hide-prices-mode input[id*="total" i]:not(.is-revealed),
html.hide-prices-mode input[id*="salary" i]:not(.is-revealed),
html.hide-prices-mode input[id*="cost" i]:not(.is-revealed),
html.hide-prices-mode input[id*="balance" i]:not(.is-revealed),
html.hide-prices-mode input[id*="paid" i]:not(.is-revealed),
body.hide-prices-mode .price-sensitive:not(.is-revealed),
body.hide-prices-mode [data-price-val]:not(.is-revealed),
body.hide-prices-mode .stat-value:not(.is-revealed),
body.hide-prices-mode .wo-stat-card .val:not(.is-revealed),
body.hide-prices-mode .card-summary-val:not(.is-revealed),
body.hide-prices-mode .running-balance:not(.is-revealed),
body.hide-prices-mode td.price-cell:not(.is-revealed),
body.hide-prices-mode span.price-cell:not(.is-revealed),
body.hide-prices-mode strong.price-cell:not(.is-revealed),
body.hide-prices-mode input.price-sensitive-input:not(.is-revealed),
body.hide-prices-mode input[name*="price" i]:not(.is-revealed),
body.hide-prices-mode input[name*="amount" i]:not(.is-revealed),
body.hide-prices-mode input[name*="salary" i]:not(.is-revealed),
body.hide-prices-mode input[name*="cost" i]:not(.is-revealed),
body.hide-prices-mode input[name*="total" i]:not(.is-revealed),
body.hide-prices-mode input[name*="paid" i]:not(.is-revealed),
body.hide-prices-mode input[name*="remaining" i]:not(.is-revealed),
body.hide-prices-mode input[name*="rate" i]:not(.is-revealed),
body.hide-prices-mode input[name*="balance" i]:not(.is-revealed),
body.hide-prices-mode input[name*="initial_balance" i]:not(.is-revealed),
body.hide-prices-mode input[name*="advance" i]:not(.is-revealed),
body.hide-prices-mode input[name*="bonus" i]:not(.is-revealed),
body.hide-prices-mode input[name*="deduction" i]:not(.is-revealed),
body.hide-prices-mode input[id*="price" i]:not(.is-revealed),
body.hide-prices-mode input[id*="amount" i]:not(.is-revealed),
body.hide-prices-mode input[id*="total" i]:not(.is-revealed),
body.hide-prices-mode input[id*="salary" i]:not(.is-revealed),
body.hide-prices-mode input[id*="cost" i]:not(.is-revealed),
body.hide-prices-mode input[id*="balance" i]:not(.is-revealed),
body.hide-prices-mode input[id*="paid" i]:not(.is-revealed) {
  filter: blur(8px) !important;
  user-select: none !important;
  -webkit-user-select: none !important;
  cursor: pointer !important;
  transition: filter 0.18s ease, opacity 0.18s ease, background-color 0.18s ease;
  opacity: 0.8 !important;
}

/* عند المرور بمؤشر الماوس على عنصر مخفي لإعطاء تلميح تفاعلي */
html.hide-prices-mode .price-sensitive:not(.is-revealed):hover,
html.hide-prices-mode [data-price-val]:not(.is-revealed):hover,
html.hide-prices-mode .stat-value:not(.is-revealed):hover,
html.hide-prices-mode .wo-stat-card .val:not(.is-revealed):hover,
html.hide-prices-mode .card-summary-val:not(.is-revealed):hover,
html.hide-prices-mode .running-balance:not(.is-revealed):hover,
html.hide-prices-mode td.price-cell:not(.is-revealed):hover,
body.hide-prices-mode .price-sensitive:not(.is-revealed):hover,
body.hide-prices-mode [data-price-val]:not(.is-revealed):hover,
body.hide-prices-mode .stat-value:not(.is-revealed):hover {
  filter: blur(5px) !important;
  opacity: 0.95 !important;
  background-color: rgba(59, 130, 246, 0.08) !important;
  border-radius: 4px;
}

/* حالة الإظهار المؤقت بالنقر المباشر على العنصر (is-revealed) */
html.hide-prices-mode .is-revealed,
html.hide-prices-mode .is-revealed *,
html.hide-prices-mode .price-sensitive.is-revealed,
html.hide-prices-mode .price-sensitive.is-revealed *,
html.hide-prices-mode [data-price-val].is-revealed,
html.hide-prices-mode [data-price-val].is-revealed *,
html.hide-prices-mode .stat-value.is-revealed,
html.hide-prices-mode .stat-value.is-revealed *,
html.hide-prices-mode .wo-stat-card .val.is-revealed,
html.hide-prices-mode .wo-stat-card .val.is-revealed *,
html.hide-prices-mode .card-summary-val.is-revealed,
html.hide-prices-mode .card-summary-val.is-revealed *,
html.hide-prices-mode .running-balance.is-revealed,
html.hide-prices-mode .running-balance.is-revealed *,
html.hide-prices-mode td.price-cell.is-revealed,
html.hide-prices-mode td.price-cell.is-revealed *,
html.hide-prices-mode span.price-cell.is-revealed,
html.hide-prices-mode span.price-cell.is-revealed *,
html.hide-prices-mode strong.price-cell.is-revealed,
html.hide-prices-mode strong.price-cell.is-revealed *,
html.hide-prices-mode input.price-sensitive-input.is-revealed,
body.hide-prices-mode .is-revealed,
body.hide-prices-mode .is-revealed *,
body.hide-prices-mode .price-sensitive.is-revealed,
body.hide-prices-mode .price-sensitive.is-revealed * {
  filter: none !important;
  user-select: text !important;
  -webkit-user-select: text !important;
  opacity: 1 !important;
  cursor: pointer !important;
}

/* تحديد وتمييز العنصر المكشوف بلمسة عصرية */
html.hide-prices-mode .price-sensitive.is-revealed,
html.hide-prices-mode [data-price-val].is-revealed,
html.hide-prices-mode td.is-revealed,
html.hide-prices-mode .stat-value.is-revealed,
html.hide-prices-mode .wo-stat-card .val.is-revealed,
html.hide-prices-mode span.price-cell.is-revealed,
html.hide-prices-mode strong.price-cell.is-revealed,
html.hide-prices-mode input.price-sensitive-input.is-revealed,
body.hide-prices-mode .price-sensitive.is-revealed,
body.hide-prices-mode [data-price-val].is-revealed,
body.hide-prices-mode td.is-revealed {
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.35);
  background-color: rgba(37, 99, 235, 0.05) !important;
  border-radius: 4px;
  transition: all 0.2s ease;
}

/* إشعار عائم Toast عند تبديل حالة إخفاء الأسعار */
.price-privacy-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(40px);
  background: #0f172a;
  color: #ffffff;
  padding: 0.75rem 1.4rem;
  border-radius: var(--radius-full);
  font-size: 0.88rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  z-index: 100000;
  opacity: 0;
  pointer-events: none;
  transition: all 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.price-privacy-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* شارة حالة المزامنة السحابية العلوية (Topbar Cloud Sync Badge) */
.sync-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  user-select: none;
  border: 1px solid transparent;
}

.sync-status-badge:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.sync-status-badge.badge-online {
  background-color: #ecfdf5;
  color: #065f46;
  border-color: #a7f3d0;
}

.sync-status-badge.badge-offline {
  background-color: #fff1f2;
  color: #9f1239;
  border-color: #fecdd3;
}

.sync-status-badge.badge-syncing {
  background-color: #fffbeb;
  color: #92400e;
  border-color: #fde68a;
}

.sync-status-badge.badge-idle {
  background-color: #f8fafc;
  color: #475569;
  border-color: #e2e8f0;
}

.sync-badge-count {
  background: #e11d48;
  color: #ffffff;
  padding: 0.1rem 0.45rem;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1;
}

.sync-spinner {
  display: inline-block;
  animation: syncSpin 1s linear infinite;
}

@keyframes syncSpin {
  100% { transform: rotate(360deg); }
}

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

/* شارة تاريخ اليوم في الشريط العلوي (Topbar Date Pill) */
.topbar-date-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  border: 1px solid #e2e8f0;
  padding: 0.38rem 0.85rem;
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  color: #334155;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  transition: all var(--transition-fast);
  white-space: nowrap;
  user-select: none;
}

.topbar-date-pill:hover {
  background: #ffffff;
  border-color: #cbd5e1;
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.topbar-date-pill .date-icon-circle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--primary, #2563eb);
}

.topbar-date-pill .date-label-day {
  font-weight: 800;
  color: var(--primary-dark, #1e40af);
}

.topbar-date-pill .date-separator {
  color: #94a3b8;
  font-weight: 700;
}

.topbar-date-pill .date-label-full {
  font-weight: 600;
  color: #475569;
}

/* ==========================================================================
   منطقة المحتوى (Content Area)
   ========================================================================== */
.content-body {
  padding: 1.75rem;
  flex: 1;
}

/* بطاقة الترحيب المطابقة للصورة */
.welcome-banner {
  background: #ffffff;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 2.25rem;
  margin-bottom: 1.75rem;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.welcome-banner::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 6px;
  background: linear-gradient(180deg, var(--primary), #60a5fa);
}

.welcome-header-flex {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.welcome-date-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  background: linear-gradient(135deg, #f8fafc 0%, #edf4fc 100%);
  border: 1px solid #e2e8f0;
  padding: 0.65rem 1.15rem;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  transition: all var(--transition-fast);
}

.welcome-date-badge:hover {
  background: #ffffff;
  border-color: #bfdbfe;
  box-shadow: var(--shadow-sm);
}

.welcome-date-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary, #2563eb);
  background: #eff6ff;
  padding: 0.5rem;
  border-radius: var(--radius-md);
  border: 1px solid #dbeafe;
}

.welcome-date-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.welcome-day-text {
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--primary-dark, #1e40af);
}

.welcome-full-date {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
}

.welcome-title {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 0.4rem;
  letter-spacing: -0.4px;
}

.welcome-desc {
  color: var(--text-muted);
  font-size: 0.98rem;
}

/* شبكة بطاقات الأقسام الرئيسية */
.sections-nav-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
  gap: 1.35rem;
  margin-top: 1.5rem;
}

.section-nav-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 1.6rem;
  text-decoration: none;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 1.35rem;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-fast);
  position: relative;
}

.section-nav-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
  border-color: #cbd5e1;
}

.section-nav-card .icon-box {
  width: 58px;
  height: 58px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform var(--transition-fast);
}

.section-nav-card:hover .icon-box {
  transform: scale(1.1);
}

.section-nav-card.customers .icon-box { background: #eff6ff; color: #2563eb; }
.section-nav-card.work_orders .icon-box { background: #f3e8ff; color: #7c3aed; }
.section-nav-card.expenses .icon-box { background: #fff1f2; color: #e11d48; }
.section-nav-card.employees .icon-box { background: #ecfdf5; color: #059669; }
.section-nav-card.safes .icon-box { background: #fffbeb; color: #d97706; }
.section-nav-card.reports .icon-box { background: #f0fdfa; color: #0284c7; }

.section-nav-card .card-texts h4 {
  font-size: 1.15rem;
  font-weight: 800;
  margin-bottom: 0.3rem;
  color: var(--text-main);
}

.section-nav-card .card-texts p {
  font-size: 0.86rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.section-nav-card .arrow-icon {
  margin-right: auto;
  color: var(--text-light);
  transition: transform var(--transition-fast), color var(--transition-fast);
}

.section-nav-card:hover .arrow-icon {
  transform: translateX(-6px);
  color: var(--primary);
}

/* بطاقات المؤشرات والإحصائيات */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.75rem;
}

.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 1.35rem;
  display: flex;
  align-items: center;
  gap: 1.15rem;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

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

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

.stat-icon.primary { background: #eff6ff; color: #2563eb; }
.stat-icon.success { background: #ecfdf5; color: #059669; }
.stat-icon.warning { background: #fffbeb; color: #d97706; }
.stat-icon.danger { background: #fff1f2; color: #e11d48; }
.stat-icon.info { background: #f0f9ff; color: #0284c7; }

.stat-info {
  display: flex;
  flex-direction: column;
}

.stat-value {
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.3px;
}

.stat-label {
  font-size: 0.86rem;
  color: var(--text-muted);
  font-weight: 600;
}

/* البطاقات العامة */
.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.75rem;
  overflow: hidden;
}

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

.card-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.card-body {
  padding: 1.5rem;
}

/* شريط الإجراءات والبحث */
.action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

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

.search-box input {
  width: 100%;
  padding: 0.75rem 2.6rem 0.75rem 1.15rem;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  background: #ffffff;
  font-size: 0.92rem;
  outline: none;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-xs);
}

.search-box input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.search-icon {
  position: absolute;
  top: 50%;
  right: 0.9rem;
  transform: translateY(-50%);
  color: var(--text-light);
  pointer-events: none;
  display: flex;
  align-items: center;
}

.btn-group {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

/* الأزرار العصرية */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.7rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.92rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition-fast);
  white-space: nowrap;
  flex-shrink: 0;
  line-height: 1.4;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-primary {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.28);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #1d4ed8, #1e40af);
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.35);
}

.btn-secondary {
  background: #ffffff;
  color: var(--text-main);
  border-color: #cbd5e1;
  box-shadow: var(--shadow-xs);
}

.btn-secondary:hover {
  background: #f8fafc;
  border-color: #94a3b8;
}

.btn-success {
  background: linear-gradient(135deg, #059669, #047857);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(5, 150, 105, 0.25);
}

.btn-success:hover {
  background: linear-gradient(135deg, #047857, #065f46);
  box-shadow: 0 6px 16px rgba(5, 150, 105, 0.35);
}

.btn-danger {
  background: linear-gradient(135deg, #e11d48, #be123c);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(225, 29, 72, 0.25);
}

.btn-danger:hover {
  background: linear-gradient(135deg, #be123c, #9f1239);
}

.btn-sm {
  padding: 0.45rem 0.9rem;
  font-size: 0.84rem;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  flex-shrink: 0;
}

/* الجداول المنظمة والراقية */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 #f8fafc;
}

.table-responsive::-webkit-scrollbar {
  height: 6px;
}

.table-responsive::-webkit-scrollbar-track {
  background: #f8fafc;
}

.table-responsive::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

.custom-table td .form-control {
  min-width: 80px;
}

.custom-table {
  width: 100%;
  border-collapse: collapse;
  text-align: right;
  font-size: 0.94rem;
}

.custom-table th {
  background-color: #f8fafc;
  color: var(--text-muted);
  font-weight: 800;
  padding: 0.95rem 1.15rem;
  border-bottom: 2px solid var(--card-border);
  white-space: nowrap;
}

.custom-table td {
  padding: 1rem 1.15rem;
  border-bottom: 1px solid var(--card-border);
  color: var(--text-main);
  vertical-align: middle;
}

/* ضمان تباين الألوان العالي في صفوف الجداول الداكنة والإجماليات */
.custom-table tr.bg-dark td,
.custom-table tr.table-dark-row td,
.custom-table > tfoot > tr > td,
.custom-table tr[style*="background: #1e293b"] td,
.custom-table tr[style*="background:#1e293b"] td,
.custom-table tr[style*="background: #0f172a"] td,
.custom-table tr[style*="background:#0f172a"] td {
  color: #ffffff !important;
}

/* جدول تفاصيل الأزرار والعراوي المصغر */
.micro-buttons-table {
  width: 100% !important;
  border-collapse: collapse !important;
  margin: 0 !important;
}
.micro-buttons-table th,
.micro-buttons-table td {
  border: 1px solid #cbd5e1 !important;
  padding: 4px 6px !important;
  color: #0f172a !important;
  font-size: 0.8rem !important;
}
.micro-buttons-table tfoot td {
  color: #0f172a !important;
  font-weight: 800 !important;
}
.micro-buttons-table .btn-subtotal-cost {
  color: #15803d !important;
  font-weight: 900 !important;
  background-color: #ecfdf5 !important;
}
.micro-buttons-table .btn-total-qty {
  color: #0284c7 !important;
  font-weight: 900 !important;
}

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

.custom-table tbody tr:hover {
  background-color: #f8fafc;
}

/* الشارات والأوسمة (Badges) */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.75rem;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 700;
}

.badge-primary { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }
.badge-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.badge-warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.badge-danger { background: #ffe4e6; color: #9f1239; border: 1px solid #fecdd3; }
.badge-info { background: #e0f2fe; color: #075985; border: 1px solid #bae6fd; }
.badge-purple { background: #f3e8ff; color: #6b21a8; border: 1px solid #e9d5ff; }
.badge-dark { background: #1e293b; color: #f8fafc; border: 1px solid #334155; }
.badge-secondary { background: #f1f5f9; color: #475569; border: 1px solid #e2e8f0; }

/* تبويبات الفلترة السريعة */
.filter-tabs {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.filter-tab-btn {
  padding: 0.45rem 0.95rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 700;
  border: 1px solid var(--card-border);
  background: #ffffff;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: all var(--transition-fast);
}

.filter-tab-btn:hover {
  background: #f8fafc;
  color: var(--text-main);
}

.filter-tab-btn.active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
  box-shadow: 0 2px 8px var(--primary-glow);
}

.filter-tab-btn .count {
  font-size: 0.72rem;
  background: rgba(0, 0, 0, 0.08);
  padding: 0.1rem 0.45rem;
  border-radius: var(--radius-full);
}

.filter-tab-btn.active .count {
  background: rgba(255, 255, 255, 0.25);
  color: #ffffff;
}

/* النماذج والنوافذ المنبثقة (Modals & Forms) */
.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  font-weight: 700;
  font-size: 0.9rem;
  margin-bottom: 0.45rem;
  color: var(--text-main);
}

.form-control {
  width: 100%;
  padding: 0.75rem 0.95rem;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  background: #ffffff;
  font-size: 0.92rem;
  color: var(--text-main);
  outline: none;
  font-family: inherit;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-xs);
}

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

.form-control[readonly] {
  background: #f8fafc;
  color: var(--text-muted);
  font-weight: 700;
}

.modal-backdrop {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  z-index: 1100;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

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

.modal-box, .modal-dialog {
  background: #ffffff;
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 620px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: modalFadeIn 0.25s ease-out;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 2rem);
  margin: auto;
  position: relative;
}

.modal-box > form, .modal-dialog > form {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  margin: 0;
}

@keyframes modalFadeIn {
  from { opacity: 0; transform: translateY(-15px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  padding: 1.15rem 1.5rem;
  border-bottom: 1px solid var(--card-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f8fafc;
  flex-shrink: 0;
}

.modal-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-main);
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.35rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast);
  line-height: 1;
}

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

.modal-body {
  padding: 1.4rem 1.5rem;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  max-height: none;
  -webkit-overflow-scrolling: touch;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--card-border);
  background: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  flex-shrink: 0;
}

/* طبقة التعتيم للقائمة الجانبية */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(2px);
  z-index: 990;
  opacity: 0;
  transition: opacity var(--transition-normal);
}

.sidebar-overlay.active {
  display: block;
  opacity: 1;
}

/* ==========================================================================
   التوافق مع الشاشات والهواتف (Mobile Responsiveness)
   ========================================================================== */
@media (max-width: 992px) {
  .user-role {
    display: none;
  }
  .topbar-date-pill .date-label-full,
  .topbar-date-pill .date-separator {
    display: none;
  }
}

@media (max-width: 640px) {
  .topbar {
    padding: 0 1rem;
  }

  .topbar-date-pill {
    padding: 0.3rem 0.55rem;
    font-size: 0.78rem;
  }

  .page-title {
    font-size: 1.05rem;
  }

  .btn-price-toggle {
    padding: 0.35rem 0.65rem;
  }

  .btn-price-toggle .price-toggle-text {
    display: none;
  }

  .user-name {
    display: none;
  }

  .user-profile-badge {
    padding: 0.3rem 0.6rem;
  }

  .content-body {
    padding: 1.15rem 0.85rem;
  }

  .card-header {
    padding: 1rem 1.15rem;
    gap: 0.75rem;
  }

  .card-header .btn-sm,
  .card-header .btn-primary,
  .card-header .btn-success {
    width: 100%;
    justify-content: center;
    padding: 0.6rem 1rem;
    font-size: 0.9rem;
  }

  .card-body {
    padding: 1rem;
  }

  .welcome-banner {
    padding: 1.35rem;
  }

  .welcome-title {
    font-size: 1.2rem;
  }

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

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

  .btn-group {
    justify-content: stretch;
  }

  .btn-group .btn {
    flex: 1;
  }
}

/* ==========================================================================
   تنسيقات الطباعة (Print Styles - Matching User PDF)
   ========================================================================== */
@media print {
  @page {
    size: A4 portrait;
    margin: 8mm 6mm 8mm 6mm;
  }

  body {
    background: #ffffff !important;
    color: #000000 !important;
    font-size: 9.5pt !important;
  }

  .sidebar, .topbar, .btn, .btn-group, .action-bar, .modal-backdrop, .no-print {
    display: none !important;
  }

  .main-wrapper, .main-content, .content-body {
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  .card {
    border: 1.5px solid #000000 !important;
    box-shadow: none !important;
    margin-bottom: 12px !important;
    width: 100% !important;
    border-radius: 4px !important;
  }

  .table-responsive {
    overflow: visible !important;
    width: 100% !important;
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .custom-table {
    border: 1.5px solid #000000 !important;
    width: 100% !important;
    max-width: 100% !important;
    table-layout: fixed !important;
    border-collapse: collapse !important;
    margin: 0 !important;
  }

  .custom-table th, .custom-table td {
    border: 1px solid #333333 !important;
    color: #000000 !important;
    padding: 5px 3px !important;
    font-size: 8.5pt !important;
    line-height: 1.2 !important;
    vertical-align: middle !important;
    box-sizing: border-box !important;
  }

  .custom-table th {
    background-color: #f1f5f9 !important;
    font-weight: 900 !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .print-only {
    display: block !important;
  }

  th.print-only, td.print-only {
    display: table-cell !important;
  }

  img {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    image-rendering: -webkit-optimize-contrast !important;
  }

  /* تكبير وتوضيح صور القصات والموديلات في الطباعة بشكل متناسق */
  .story-flex-container {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 6px !important;
    text-align: right !important;
  }

  .story-img-wrap {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
    background: #ffffff !important;
    border: 1px solid #000000 !important;
    border-radius: 4px !important;
    padding: 1px !important;
    width: 44px !important;
    height: 44px !important;
    min-width: 44px !important;
    max-width: 44px !important;
    min-height: 44px !important;
    max-height: 44px !important;
    box-shadow: none !important;
  }

  .story-img-thumb {
    width: 100% !important;
    height: 100% !important;
    min-width: 100% !important;
    max-width: 100% !important;
    min-height: 100% !important;
    max-height: 100% !important;
    object-fit: contain !important;
    border: none !important;
    display: block !important;
    background-color: #ffffff !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    image-rendering: -webkit-optimize-contrast !important;
  }

  .story-name-title {
    font-size: 9pt !important;
    font-weight: 900 !important;
    color: #000000 !important;
    margin-bottom: 2px !important;
    line-height: 1.2 !important;
  }

  .story-badges-wrap {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 3px !important;
    align-items: center !important;
  }

  .col-story-model {
    width: 25% !important;
  }

  .col-job-code {
    width: 11% !important;
  }

  .col-story-count {
    width: 9% !important;
  }

  .col-buttons-count {
    width: 10% !important;
  }

  .col-button-cost {
    width: 9% !important;
  }

  .col-item-cost {
    width: 10% !important;
  }

  .col-total-cost {
    width: 16% !important;
    white-space: nowrap !important;
    font-weight: 900 !important;
    font-size: 9pt !important;
  }

  /* شارات الطباعة */
  .badge {
    border: 1px solid #000000 !important;
    color: #000000 !important;
    background: #f8fafc !important;
    font-size: 7.5pt !important;
    font-weight: 800 !important;
    padding: 1px 4px !important;
    border-radius: 3px !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .badge-info {
    border-color: #0284c7 !important;
    background-color: #e0f2fe !important;
    color: #0369a1 !important;
  }

  .badge-purple {
    border-color: #9333ea !important;
    background-color: #f3e8ff !important;
    color: #7e22ce !important;
  }
}

/* تنسيقات صور القصات والموديلات في الجداول والشاشات */
.story-flex-container {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.story-img-wrap {
  position: relative;
  flex-shrink: 0;
  display: inline-flex;
}

.story-img-thumb {
  width: 65px;
  height: 65px;
  border-radius: 8px;
  object-fit: cover;
  border: 2px solid #cbd5e1;
  background-color: #f8fafc;
  box-shadow: 0 2px 5px rgba(0,0,0,0.08);
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), border-color 0.2s, box-shadow 0.2s;
  display: block;
}

.story-img-thumb:hover {
  transform: scale(1.1);
  border-color: #3b82f6;
  box-shadow: 0 6px 14px rgba(59, 130, 246, 0.25);
}

/* حاوية معاينة الصور في حقول الإدخال والرفع */
.image-upload-preview-box {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  align-items: flex-start;
}

.image-upload-thumb-wrapper {
  position: relative;
  display: inline-block;
  border-radius: 6px;
  overflow: hidden;
  border: 1.5px solid #cbd5e1;
  background: #f8fafc;
  width: 50px;
  height: 50px;
}

.image-upload-thumb-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.image-upload-thumb-wrapper .badge-current {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(15, 23, 42, 0.75);
  color: #fff;
  font-size: 0.6rem;
  text-align: center;
  padding: 1px 0;
  font-weight: 700;
}

/* =========================================================================
   Lightbox متطور واحترافي لعرض صور الموديلات والقصات
   ========================================================================= */
.lightbox-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(10, 15, 30, 0.88);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  z-index: 10000;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  opacity: 0;
  transition: opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.lightbox-backdrop.active {
  display: flex;
  opacity: 1;
}

.lightbox-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 92vw;
  max-height: 94vh;
  width: auto;
  position: relative;
  animation: lightboxPop 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes lightboxPop {
  0% { transform: scale(0.92) translateY(10px); opacity: 0; }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}

.lightbox-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-width: 320px;
  max-width: 750px;
  background: rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 50px;
  padding: 0.5rem 1.25rem;
  margin-bottom: 1.1rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  color: #ffffff;
  gap: 1rem;
}

.lightbox-title {
  font-size: 1.1rem;
  font-weight: 800;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lightbox-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.lightbox-btn {
  background: rgba(255, 255, 255, 0.16);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.25);
  padding: 0.4rem 0.85rem;
  border-radius: 20px;
  font-size: 0.84rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.2s ease;
}

.lightbox-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  color: #ffffff;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(255, 255, 255, 0.15);
}

.lightbox-btn-close {
  background: #ef4444;
  border: 1px solid #f87171;
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  cursor: pointer;
  color: #fff;
  transition: all 0.2s ease;
}

.lightbox-btn-close:hover {
  background: #dc2626;
  transform: scale(1.12);
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.4);
}

.lightbox-image-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 25px 65px -10px rgba(0, 0, 0, 0.75), 0 0 0 1px rgba(255, 255, 255, 0.15);
  background: #0f172a;
  max-height: 75vh;
  cursor: zoom-in;
  transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.lightbox-image-wrapper.zoomed {
  cursor: zoom-out;
  max-height: 85vh;
  max-width: 95vw;
}

.lightbox-img {
  display: block;
  max-width: 80vw;
  max-height: 72vh;
  object-fit: contain;
  border-radius: 12px;
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
}

.lightbox-image-wrapper.zoomed .lightbox-img {
  transform: scale(1.55);
}

.lightbox-hint {
  margin-top: 0.85rem;
  font-size: 0.82rem;
  color: rgba(255, 255, 255, 0.65);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(0, 0, 0, 0.3);
  padding: 0.25rem 0.85rem;
  border-radius: 20px;
}

/* تلميح وتأثير تكبير المصغرات في الجداول */
.story-img-wrap {
  position: relative;
  flex-shrink: 0;
  display: inline-flex;
  border-radius: 10px;
  overflow: hidden;
}

.story-img-wrap::after {
  content: '🔍';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.55);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
  border-radius: 8px;
}

.story-img-wrap:hover::after {
  opacity: 1;
}

/* =========================================================================
   قواعد الطباعة الاحترافية لكافة شاشات النظام
   ========================================================================= */
@media print {
  body {
    background: #ffffff !important;
    color: #000000 !important;
    font-size: 11pt;
    margin: 0;
    padding: 0;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .sidebar,
  .topbar,
  .sidebar-overlay,
  .action-bar,
  .no-print,
  .btn,
  .btn-group,
  .lightbox-backdrop,
  .modal-backdrop {
    display: none !important;
  }

  .main-wrapper,
  .main-content,
  .app-container {
    margin: 0 !important;
    padding: 0 !important;
    max-width: 100% !important;
    width: 100% !important;
  }

  .print-only {
    display: block !important;
  }

  .card {
    box-shadow: none !important;
    border: 1px solid #000 !important;
    margin-bottom: 15px !important;
    page-break-inside: auto !important;
    break-inside: auto !important;
  }

  .custom-table {
    border-collapse: collapse !important;
    width: 100% !important;
    page-break-inside: auto !important;
    break-inside: auto !important;
  }

  .custom-table thead {
    display: table-header-group !important;
  }

  .custom-table tr {
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }

  .custom-table th,
  .custom-table td {
    border: 1px solid #333 !important;
    padding: 6px 8px !important;
    color: #000 !important;
  }

  .custom-table th {
    background-color: #f1f5f9 !important;
    font-weight: 800 !important;
  }

  a {
    text-decoration: none !important;
    color: #000 !important;
  }
}

/* =========================================================================
   تصميم وتبويبات شاشة الإعدادات المتقدمة (Settings UI & Modern Tabs)
   ========================================================================= */
.settings-tabs-wrapper {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: #ffffff;
  padding: 0.5rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--card-border);
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.5rem;
  overflow-x: auto;
  scrollbar-width: thin;
}

.settings-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.65rem 1.15rem;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition-fast);
  text-decoration: none;
  user-select: none;
}

.settings-tab-btn:hover {
  color: var(--primary);
  background: #f8fafc;
}

.settings-tab-btn.active {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.settings-tab-btn .tab-icon {
  font-size: 1.1rem;
}

.settings-tab-btn .tab-badge {
  font-size: 0.72rem;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-full);
  background: rgba(0, 0, 0, 0.08);
}

.settings-tab-btn.active .tab-badge {
  background: rgba(255, 255, 255, 0.25);
  color: #ffffff;
}

.settings-pane {
  display: none;
  animation: settingsFadeIn 0.25s ease;
}

.settings-pane.active {
  display: block;
}

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

/* بطاقات الاختيار التفاعلية (Radio Choice Cards) */
.settings-choice-card {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  padding: 1rem 1.15rem;
  background: #ffffff;
  border: 2px solid var(--card-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
}

.settings-choice-card:hover {
  border-color: #93c5fd;
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.settings-choice-card.selected-green {
  border-color: #16a34a;
  background: #f0fdf4;
  box-shadow: 0 0 0 1px #16a34a;
}

.settings-choice-card.selected-blue {
  border-color: #2563eb;
  background: #eff6ff;
  box-shadow: 0 0 0 1px #2563eb;
}

/* شبكات متجاوبة لحقول الإعدادات تمنع الانضغاط نهائياً */
.settings-grid-responsive {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.settings-grid-2col {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.25rem;
}

.settings-grid-4col {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 1rem;
}

/* شريط الحفظ السفلي العائم */
.settings-sticky-bar {
  position: sticky;
  bottom: 1rem;
  z-index: 80;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 0.9rem 1.5rem;
  box-shadow: var(--shadow-lg);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 1.5rem;
}



