:root {
      /* ===== هوية احترافية - نيلي داكن + زمردي ===== */
      --primary: #1E5E8A;
      --primary-dark: #14436B;
      --primary-light: #E8F0FE;
      --primary-soft: #D0E1F5;
      --gov-gold: #C9A961;
      --gov-gold-light: #F5EFE0;
      --secondary: #1AA37A;
      --success: #16A34A;
      --danger: #DC2626;
      --warning: #D97706;
      --info: #2874A6;
      --bg: #F4F6F9;
      --surface: #ffffff;
      --surface2: #F8FAFC;
      --surface3: #F1F4F8;
      --border: #DFE4EA;
      --border-strong: #C8D0DA;
      --text: #1A232E;
      --text-muted: #6B7A8F;
      --text-light: #94A3B3;

      /* ===== السايدبار - أبيض مع لمسة نيلي ===== */
      --sidebar-bg: #ffffff;
      --sidebar-text: #1A232E;
      --sidebar-active: #1E5E8A;
      --sidebar-header-border: #E2E8ED;
      --sidebar-footer-border: #E2E8ED;
      --sidebar-scrollbar: rgba(30, 94, 138, 0.20);
      --sidebar-section-title: #4B5A6E;
      --sidebar-hover-bg: rgba(30, 94, 138, 0.04);
      --sidebar-hover-color: #1E5E8A;
      --sidebar-active-bg: rgba(30, 94, 138, 0.08);
      --sidebar-active-color: #1E5E8A;
      --sidebar-active-border: #1E5E8A;
      --sidebar-active-glow: rgba(30, 94, 138, .45);
      --sidebar-title-color: #1A232E;
      --sidebar-subtitle-color: #6B7A8F;
      --sidebar-company-color: #C9A961;
      --sidebar-username-color: #1A232E;
      --sidebar-userrole-color: #6B7A8F;
      --sidebar-nav-icon-color: #97A3B5;
      --sidebar-logout-color: #94A3B3;
      --sidebar-tooltip-bg: #1A232E;
      --sidebar-tooltip-color: #ffffff;

      /* ===== ظلال ناعمة ===== */
      --shadow: 0 1px 2px rgba(30, 94, 138, 0.04), 0 2px 8px rgba(26, 35, 46, 0.05);
      --shadow-md: 0 2px 6px rgba(30, 94, 138, 0.06), 0 4px 16px rgba(26, 35, 46, 0.07);
      --shadow-lg: 0 8px 28px rgba(30, 94, 138, 0.10), 0 4px 12px rgba(26, 35, 46, 0.06);
      --shadow-inset: inset 0 1px 0 rgba(255, 255, 255, 0.6);

      /* ===== Radius ===== */
      --radius: 10px;
      --radius-sm: 6px;
      --radius-lg: 14px;
      --font: 'Cairo', 'Tajawal', sans-serif;

      /* ===== كروت الميزانية والخزنة (الوضع الفاتح) ===== */
      --finance-card-grad: linear-gradient(135deg, #ffffff 0%, #F4F8FC 100%);
      --finance-card-border: #C8D6E5;
      --finance-card-shadow: 0 2px 8px rgba(30, 94, 138, 0.06), 0 1px 3px rgba(26, 35, 46, 0.04);
      --finance-card-shadow-hover: 0 8px 24px rgba(30, 94, 138, 0.14), 0 4px 10px rgba(26, 35, 46, 0.06);
      --finance-card-text: #1A232E;
      --finance-card-text-muted: #6B7A8F;
      --finance-card-accent: #1E5E8A;
      --finance-card-item-bg: rgba(30, 94, 138, 0.05);
      --finance-card-item-bg-main: rgba(30, 94, 138, 0.10);
      --finance-card-badge-bg: rgba(30, 94, 138, 0.08);
      --finance-card-badge-text: #1E5E8A;
      --finance-card-text-shadow: none;

      /* ===== لمسة جمالية للخلفية: توهّج لوني ناعم جدًا فى أطراف الشاشة، بيتماشى مع
      لون النظام المختار (بدل خلفية رمادية مسطّحة بالكامل) ===== */
      --bg-glow-1: rgba(30, 94, 138, 0.05);
      --bg-glow-2: rgba(26, 163, 122, 0.045);
    }

    [data-theme="dark"] {
      --bg: #0B141E;
      --surface: #111D2B;
      --surface2: #172639;
      --surface3: #1E3050;
      --border: #253B5E;
      --border-strong: #2E4870;
      --text: #E4E8EE;
      --text-muted: #94A3B8;
      --text-light: #6B7F99;
      --sidebar-bg: #0f172a;
      --sidebar-text: #D4DCE6;
      --sidebar-header-border: rgba(255, 255, 255, 0.06);
      --sidebar-footer-border: rgba(255, 255, 255, 0.06);
      --sidebar-scrollbar: rgba(255, 255, 255, 0.12);
      --sidebar-section-title: rgba(255, 255, 255, 0.62);
      --sidebar-hover-bg: rgba(46, 148, 255, 0.08);
      --sidebar-hover-color: #ffffff;
      --sidebar-active-bg: rgba(46, 148, 255, 0.18);
      --sidebar-active-color: #ffffff;
      --sidebar-active-border: #2E94FF;
      --sidebar-active-glow: rgba(46, 148, 255, .55);
      --sidebar-title-color: #ffffff;
      --sidebar-subtitle-color: rgba(255, 255, 255, 0.55);
      --sidebar-company-color: #E0C27A;
      --sidebar-username-color: #E4E8EE;
      --sidebar-userrole-color: rgba(255, 255, 255, 0.50);
      --sidebar-nav-icon-color: rgba(255, 255, 255, 0.42);
      --sidebar-logout-color: rgba(255, 255, 255, 0.45);
      --sidebar-tooltip-bg: #0B141E;
      --sidebar-tooltip-color: #E4E8EE;
      --primary-light: #1A2D44;
      --primary-soft: #253B5E;
      --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 4px 12px rgba(0, 0, 0, 0.25);
      --shadow-md: 0 2px 6px rgba(0, 0, 0, 0.45), 0 4px 16px rgba(0, 0, 0, 0.30);
      --shadow-lg: 0 8px 28px rgba(0, 0, 0, 0.5), 0 4px 12px rgba(0, 0, 0, 0.3);

      /* ===== كروت الميزانية (داكن) ===== */
      --finance-card-grad: linear-gradient(135deg, #111D2B 0%, #172639 100%);
      --finance-card-border: #253B5E;
      --finance-card-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
      --finance-card-shadow-hover: 0 10px 30px rgba(0, 0, 0, 0.45);
      --finance-card-text: #ffffff;
      --finance-card-text-muted: rgba(255, 255, 255, 0.75);
      --finance-card-accent: #2E94FF;
      --finance-card-item-bg: rgba(255, 255, 255, 0.06);
      --finance-card-item-bg-main: rgba(46, 148, 255, 0.15);
      --finance-card-badge-bg: rgba(46, 148, 255, 0.18);
      --finance-card-badge-text: #2E94FF;
      --finance-card-text-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
      --bg-glow-1: rgba(46, 148, 255, 0.07);
      --bg-glow-2: rgba(46, 148, 255, 0.04);
    }

    [data-color-theme="emerald"] {
      --primary: #0F766E;
      --primary-dark: #0B5750;
      --primary-light: #E6F7F5;
      --primary-soft: #C7EAE6;
      --secondary: #0D9488;
      --sidebar-active: #0F766E;
      --sidebar-scrollbar: rgba(15, 118, 110, 0.20);
      --sidebar-hover-bg: rgba(15, 118, 110, 0.04);
      --sidebar-hover-color: #0F766E;
      --sidebar-active-bg: rgba(15, 118, 110, 0.08);
      --sidebar-active-color: #0F766E;
      --sidebar-active-border: #0F766E;
      --sidebar-active-glow: rgba(15, 118, 110, .45);
      --shadow: 0 1px 2px rgba(15, 118, 110, 0.04), 0 2px 8px rgba(26, 35, 46, 0.05);
      --shadow-md: 0 2px 6px rgba(15, 118, 110, 0.06), 0 4px 16px rgba(26, 35, 46, 0.07);
      --shadow-lg: 0 8px 28px rgba(15, 118, 110, 0.10), 0 4px 12px rgba(26, 35, 46, 0.06);
      --finance-card-accent: #0F766E;
      --finance-card-item-bg: rgba(15, 118, 110, 0.05);
      --finance-card-item-bg-main: rgba(15, 118, 110, 0.10);
      --finance-card-badge-bg: rgba(15, 118, 110, 0.08);
      --finance-card-badge-text: #0F766E;
      --bg-glow-1: rgba(15, 118, 110, 0.05);
      --bg-glow-2: rgba(13, 148, 136, 0.045);
    }
    [data-theme="dark"][data-color-theme="emerald"] {
      --primary-light: #1A2D44;
      --primary-soft: #253B5E;
      --sidebar-hover-bg: rgba(45, 212, 191, 0.08);
      --sidebar-hover-color: #ffffff;
      --sidebar-active-bg: rgba(45, 212, 191, 0.18);
      --sidebar-active-color: #ffffff;
      --sidebar-active-border: #2DD4BF;
      --sidebar-active-glow: rgba(45, 212, 191, .55);
      --finance-card-accent: #2DD4BF;
      --finance-card-item-bg-main: rgba(45, 212, 191, 0.15);
      --finance-card-badge-bg: rgba(45, 212, 191, 0.18);
      --finance-card-badge-text: #2DD4BF;
      --bg-glow-1: rgba(45, 212, 191, 0.07);
      --bg-glow-2: rgba(45, 212, 191, 0.04);
    }

    [data-color-theme="purple"] {
      --primary: #6D28D9;
      --primary-dark: #4C1D95;
      --primary-light: #F1E9FE;
      --primary-soft: #DDD0FB;
      --secondary: #8B5CF6;
      --sidebar-active: #6D28D9;
      --sidebar-scrollbar: rgba(109, 40, 217, 0.20);
      --sidebar-hover-bg: rgba(109, 40, 217, 0.04);
      --sidebar-hover-color: #6D28D9;
      --sidebar-active-bg: rgba(109, 40, 217, 0.08);
      --sidebar-active-color: #6D28D9;
      --sidebar-active-border: #6D28D9;
      --sidebar-active-glow: rgba(109, 40, 217, .45);
      --shadow: 0 1px 2px rgba(109, 40, 217, 0.04), 0 2px 8px rgba(26, 35, 46, 0.05);
      --shadow-md: 0 2px 6px rgba(109, 40, 217, 0.06), 0 4px 16px rgba(26, 35, 46, 0.07);
      --shadow-lg: 0 8px 28px rgba(109, 40, 217, 0.10), 0 4px 12px rgba(26, 35, 46, 0.06);
      --finance-card-accent: #6D28D9;
      --finance-card-item-bg: rgba(109, 40, 217, 0.05);
      --finance-card-item-bg-main: rgba(109, 40, 217, 0.10);
      --finance-card-badge-bg: rgba(109, 40, 217, 0.08);
      --finance-card-badge-text: #6D28D9;
      --bg-glow-1: rgba(109, 40, 217, 0.05);
      --bg-glow-2: rgba(139, 92, 246, 0.045);
    }
    [data-theme="dark"][data-color-theme="purple"] {
      --primary-light: #1A2D44;
      --primary-soft: #253B5E;
      --sidebar-hover-bg: rgba(167, 139, 250, 0.08);
      --sidebar-hover-color: #ffffff;
      --sidebar-active-bg: rgba(167, 139, 250, 0.18);
      --sidebar-active-color: #ffffff;
      --sidebar-active-border: #A78BFA;
      --sidebar-active-glow: rgba(167, 139, 250, .55);
      --finance-card-accent: #A78BFA;
      --finance-card-item-bg-main: rgba(167, 139, 250, 0.15);
      --finance-card-badge-bg: rgba(167, 139, 250, 0.18);
      --finance-card-badge-text: #A78BFA;
      --bg-glow-1: rgba(167, 139, 250, 0.07);
      --bg-glow-2: rgba(167, 139, 250, 0.04);
    }

    [data-color-theme="burgundy"] {
      --primary: #9F1239;
      --primary-dark: #6E0F29;
      --primary-light: #FCE8EE;
      --primary-soft: #F5C7D4;
      --secondary: #BE185D;
      --sidebar-active: #9F1239;
      --sidebar-scrollbar: rgba(159, 18, 57, 0.20);
      --sidebar-hover-bg: rgba(159, 18, 57, 0.04);
      --sidebar-hover-color: #9F1239;
      --sidebar-active-bg: rgba(159, 18, 57, 0.08);
      --sidebar-active-color: #9F1239;
      --sidebar-active-border: #9F1239;
      --sidebar-active-glow: rgba(159, 18, 57, .45);
      --shadow: 0 1px 2px rgba(159, 18, 57, 0.04), 0 2px 8px rgba(26, 35, 46, 0.05);
      --shadow-md: 0 2px 6px rgba(159, 18, 57, 0.06), 0 4px 16px rgba(26, 35, 46, 0.07);
      --shadow-lg: 0 8px 28px rgba(159, 18, 57, 0.10), 0 4px 12px rgba(26, 35, 46, 0.06);
      --finance-card-accent: #9F1239;
      --finance-card-item-bg: rgba(159, 18, 57, 0.05);
      --finance-card-item-bg-main: rgba(159, 18, 57, 0.10);
      --finance-card-badge-bg: rgba(159, 18, 57, 0.08);
      --finance-card-badge-text: #9F1239;
      --bg-glow-1: rgba(159, 18, 57, 0.05);
      --bg-glow-2: rgba(190, 24, 93, 0.045);
    }
    [data-theme="dark"][data-color-theme="burgundy"] {
      --primary-light: #1A2D44;
      --primary-soft: #253B5E;
      --sidebar-hover-bg: rgba(251, 113, 133, 0.08);
      --sidebar-hover-color: #ffffff;
      --sidebar-active-bg: rgba(251, 113, 133, 0.18);
      --sidebar-active-color: #ffffff;
      --sidebar-active-border: #FB7185;
      --sidebar-active-glow: rgba(251, 113, 133, .55);
      --finance-card-accent: #FB7185;
      --finance-card-item-bg-main: rgba(251, 113, 133, 0.15);
      --finance-card-badge-bg: rgba(251, 113, 133, 0.18);
      --finance-card-badge-text: #FB7185;
      --bg-glow-1: rgba(251, 113, 133, 0.07);
      --bg-glow-2: rgba(251, 113, 133, 0.04);
    }

    [data-color-theme="slate"] {
      --primary: #334155;
      --primary-dark: #1E293B;
      --primary-light: #EEF1F5;
      --primary-soft: #D5DCE5;
      --secondary: #475569;
      --sidebar-active: #334155;
      --sidebar-scrollbar: rgba(51, 65, 85, 0.20);
      --sidebar-hover-bg: rgba(51, 65, 85, 0.04);
      --sidebar-hover-color: #334155;
      --sidebar-active-bg: rgba(51, 65, 85, 0.08);
      --sidebar-active-color: #334155;
      --sidebar-active-border: #334155;
      --sidebar-active-glow: rgba(51, 65, 85, .45);
      --shadow: 0 1px 2px rgba(51, 65, 85, 0.04), 0 2px 8px rgba(26, 35, 46, 0.05);
      --shadow-md: 0 2px 6px rgba(51, 65, 85, 0.06), 0 4px 16px rgba(26, 35, 46, 0.07);
      --shadow-lg: 0 8px 28px rgba(51, 65, 85, 0.10), 0 4px 12px rgba(26, 35, 46, 0.06);
      --finance-card-accent: #334155;
      --finance-card-item-bg: rgba(51, 65, 85, 0.05);
      --finance-card-item-bg-main: rgba(51, 65, 85, 0.10);
      --finance-card-badge-bg: rgba(51, 65, 85, 0.08);
      --finance-card-badge-text: #334155;
      --bg-glow-1: rgba(51, 65, 85, 0.05);
      --bg-glow-2: rgba(71, 85, 105, 0.045);
    }
    [data-theme="dark"][data-color-theme="slate"] {
      --primary-light: #1A2D44;
      --primary-soft: #253B5E;
      --sidebar-hover-bg: rgba(148, 163, 184, 0.08);
      --sidebar-hover-color: #ffffff;
      --sidebar-active-bg: rgba(148, 163, 184, 0.18);
      --sidebar-active-color: #ffffff;
      --sidebar-active-border: #94A3B8;
      --sidebar-active-glow: rgba(148, 163, 184, .55);
      --finance-card-accent: #94A3B8;
      --finance-card-item-bg-main: rgba(148, 163, 184, 0.15);
      --finance-card-badge-bg: rgba(148, 163, 184, 0.18);
      --finance-card-badge-text: #94A3B8;
      --bg-glow-1: rgba(148, 163, 184, 0.07);
      --bg-glow-2: rgba(148, 163, 184, 0.04);
    }

    [data-color-theme="amber"] {
      --primary: #B45309;
      --primary-dark: #7C3A05;
      --primary-light: #FEF3E2;
      --primary-soft: #FCE1B8;
      --secondary: #D97706;
      --sidebar-active: #B45309;
      --sidebar-scrollbar: rgba(180, 83, 9, 0.20);
      --sidebar-hover-bg: rgba(180, 83, 9, 0.04);
      --sidebar-hover-color: #B45309;
      --sidebar-active-bg: rgba(180, 83, 9, 0.08);
      --sidebar-active-color: #B45309;
      --sidebar-active-border: #B45309;
      --sidebar-active-glow: rgba(180, 83, 9, .45);
      --shadow: 0 1px 2px rgba(180, 83, 9, 0.04), 0 2px 8px rgba(26, 35, 46, 0.05);
      --shadow-md: 0 2px 6px rgba(180, 83, 9, 0.06), 0 4px 16px rgba(26, 35, 46, 0.07);
      --shadow-lg: 0 8px 28px rgba(180, 83, 9, 0.10), 0 4px 12px rgba(26, 35, 46, 0.06);
      --finance-card-accent: #B45309;
      --finance-card-item-bg: rgba(180, 83, 9, 0.05);
      --finance-card-item-bg-main: rgba(180, 83, 9, 0.10);
      --finance-card-badge-bg: rgba(180, 83, 9, 0.08);
      --finance-card-badge-text: #B45309;
      --bg-glow-1: rgba(180, 83, 9, 0.05);
      --bg-glow-2: rgba(217, 119, 6, 0.045);
    }
    [data-theme="dark"][data-color-theme="amber"] {
      --primary-light: #1A2D44;
      --primary-soft: #253B5E;
      --sidebar-hover-bg: rgba(251, 191, 36, 0.08);
      --sidebar-hover-color: #ffffff;
      --sidebar-active-bg: rgba(251, 191, 36, 0.18);
      --sidebar-active-color: #ffffff;
      --sidebar-active-border: #FBBF24;
      --sidebar-active-glow: rgba(251, 191, 36, .55);
      --finance-card-accent: #FBBF24;
      --finance-card-item-bg-main: rgba(251, 191, 36, 0.15);
      --finance-card-badge-bg: rgba(251, 191, 36, 0.18);
      --finance-card-badge-text: #FBBF24;
      --bg-glow-1: rgba(251, 191, 36, 0.07);
      --bg-glow-2: rgba(251, 191, 36, 0.04);
    }

    [data-theme="dark"] .sidebar {
      box-shadow: -2px 0 20px rgba(0, 0, 0, 0.4);
    }

    [data-theme="dark"] .sidebar-header {
      /* handled by --sidebar-header-border variable */
    }

    [data-theme="dark"] .sidebar-nav::-webkit-scrollbar-thumb {
      /* handled by --sidebar-scrollbar variable */
    }

    [data-theme="dark"] .nav-section-title {
      color: rgba(255, 255, 255, 0.62);
    }

    [data-theme="dark"] .nav-section-title::before {
      background: #2E94FF;
      opacity: 0.8;
    }

    [data-theme="dark"] .nav-section-title::after {
      background: linear-gradient(to left, transparent, rgba(255, 255, 255, 0.10));
    }

    [data-theme="dark"] .nav-item:hover {
      /* handled by --sidebar-hover-bg / --sidebar-hover-color variables */
    }

    [data-theme="dark"] .sidebar-footer {
      /* handled by --sidebar-footer-border variable */
    }

    [data-theme="dark"] .stat-card {
      background: linear-gradient(135deg, #112240 0%, #162d4a 100%);
      border-color: #1e3a5f;
    }

    [data-theme="dark"] .card {
      background: #112240;
      border-color: #1e3a5f;
    }

    [data-theme="dark"] tbody tr:hover {
      background: rgba(30, 58, 95, 0.5);
    }

    [data-theme="dark"] .modal {
      background: #112240;
      border: 1px solid #1e3a5f;
    }

    [data-theme="dark"] .field input,
    [data-theme="dark"] .field select,
    [data-theme="dark"] .field textarea,
    [data-theme="dark"] .date-filter-bar input,
    [data-theme="dark"] .date-filter-bar select,
    [data-theme="dark"] .cust-branch-filter-select,
    [data-theme="dark"] .sup-branch-filter-select {
      background: #0d1b2e;
      border-color: #1e3a5f;
      color: #ccd6f6;
    }

    [data-theme="dark"] .field input:focus,
    [data-theme="dark"] .field select:focus,
    [data-theme="dark"] .field textarea:focus {
      border-color: #1E5E8A;
      box-shadow: 0 0 0 3px rgba(30, 94, 138, 0.2);
    }

    [data-theme="dark"] .date-filter-bar {
      background: #0d1b2e;
      border-color: #1e3a5f;
    }

    /* حالة جاري الحفظ على الأزرار */
    .btn-saving {
      opacity: 0.82;
      pointer-events: none;
      cursor: not-allowed;
    }

    .btn-saving .save-spinner {
      display: inline-block;
      width: 13px;
      height: 13px;
      border: 2px solid rgba(255, 255, 255, 0.4);
      border-top-color: #fff;
      border-radius: 50%;
      animation: btn-spin 0.7s linear infinite;
      vertical-align: middle;
      margin-left: 5px;
    }

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

    /* زر الوضع الداكن: موبايل فقط */
    .mobile-only-theme-btn {
      display: none !important;
    }

    @media (max-width: 900px) {
      .mobile-only-theme-btn {
        display: flex !important;
      }
    }

    /* أزرار تظهر فى الكمبيوتر فقط أو فى الموبايل فقط (نمط عام قابل لإعادة الاستخدام) */
    .desktop-only-btn {
      display: inline-flex !important;
    }

    .mobile-only-btn {
      display: none !important;
    }

    /* نفس الفكرة لكن لعناصر container كاملة (مثل .page-header) اللى شكلها الافتراضى flex مش inline-flex */
    /* ===== إخفاء شريط التمرير بصريًا مع الإبقاء على إمكانية التمرير (سحب/لمس) ===== */
    .no-scrollbar {
      scrollbar-width: none;
      /* Firefox */
      -ms-overflow-style: none;
      /* Edge/IE القديم */
    }

    .no-scrollbar::-webkit-scrollbar {
      display: none;
      /* Chrome/Safari/Edge الحديث */
    }

    .mobile-only-block {
      display: none !important;
    }

    @media (max-width: 768px) {
      .desktop-only-btn {
        display: none !important;
      }

      .mobile-only-btn {
        display: inline-flex !important;
      }

      .mobile-only-block {
        display: flex !important;
      }
    }

    /* toggle switch للإعدادات */
    .theme-toggle-row {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 14px 0;
      border-bottom: 1px solid var(--border);
    }

    .theme-toggle-row:last-child {
      border-bottom: none;
      padding-bottom: 0;
    }

    .theme-toggle-row .toggle-info {
      display: flex;
      flex-direction: column;
      gap: 3px;
    }

    .theme-toggle-row .toggle-info strong {
      font-size: .92rem;
      color: var(--text);
    }

    .theme-toggle-row .toggle-info small {
      font-size: .78rem;
      color: var(--text-muted);
    }

    .toggle-switch {
      position: relative;
      width: 48px;
      height: 26px;
      flex-shrink: 0;
    }

    .toggle-switch input {
      opacity: 0;
      width: 0;
      height: 0;
    }

    .toggle-slider {
      position: absolute;
      inset: 0;
      background: var(--border);
      border-radius: 999px;
      cursor: pointer;
      transition: .3s;
    }

    .toggle-slider::before {
      content: '';
      position: absolute;
      width: 20px;
      height: 20px;
      border-radius: 50%;
      background: #fff;
      left: 3px;
      top: 3px;
      transition: .3s;
      box-shadow: 0 1px 4px rgba(0, 0, 0, .2);
    }

    .toggle-switch input:checked+.toggle-slider {
      background: var(--primary);
    }

    .toggle-switch input:checked+.toggle-slider::before {
      transform: translateX(22px);
    }

    [data-theme="dark"] .btn-outline {
      border-color: #1e3a5f;
      color: #8892b0;
    }

    /* ===== Dashboard Professional Navigation Cards ===== */
    .dashboard-page-cards {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
      gap: 16px;
      width: 100%;
      margin-bottom: 16px;
    }

    @media (max-width: 768px) {
      .dashboard-page-cards {
        /* 2 كروت جنب بعض على الموبايل */
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
      }
    }


    .dashboard-page-card {
      position: relative;
      overflow: hidden;
      min-height: 130px;
      padding: 0;
      border-radius: 18px;
      border: 1px solid rgba(255, 255, 255, 0.08);

      background:
        linear-gradient(135deg,
          rgba(30, 94, 138, 0.95) 0%,
          rgba(30, 94, 138, 0.88) 45%,
          rgba(26, 154, 122, 0.85) 100%);

      box-shadow:
        0 10px 28px rgba(30, 94, 138, 0.28),
        0 4px 12px rgba(0, 0, 0, 0.08);

      cursor: pointer;
      display: flex;
      flex-direction: column;
      justify-content: flex-end;
      transition:
        transform .25s ease,
        box-shadow .25s ease,
        filter .25s ease;
    }

    .dashboard-page-card:hover {
      transform: translateY(-4px) scale(1.02);

      box-shadow:
        0 16px 36px rgba(30, 94, 138, 0.35),
        0 6px 18px rgba(0, 0, 0, 0.12);

      filter: brightness(1.04);
    }

    .dashboard-page-card>div:last-child {
      position: relative;
      z-index: 2;
      padding: 10px 14px 13px;
      background: linear-gradient(to top, rgba(0, 0, 0, 0.45) 0%, rgba(0, 0, 0, 0.1) 70%, transparent 100%);
    }

    .dashboard-page-card .card-title {
      font-size: .92rem;
      font-weight: 700;
      color: #fff;
      margin: 0;
      text-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
    }

    [data-theme="dark"] .dashboard-page-card {
      box-shadow: 0 4px 18px rgba(0, 0, 0, 0.4);
    }

    @media (max-width: 700px) {
      .dashboard-page-cards {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 10px;
      }

      .dashboard-page-card {
        min-height: 110px;
        border-radius: 14px;
        padding: 0 !important;
      }

      .dashboard-page-card .card-title {
        font-size: .82rem;
      }
    }

    @media (max-width: 380px) {
      .dashboard-page-cards {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
      }
    }

    [data-theme="dark"] @media (max-width: 500px) {
      .dashboard-section-intro {
        margin: 16px 0 12px;
        gap: 8px;
      }

    }

    /* ===== تحسين ألوان النصوص داخل كروت لوحة التحكم ===== */

    /* عنوان الكارت */
    .dashboard-page-card .card-title,
    .tsc-title,
    .bsc-title {
      color: rgba(255, 255, 255, 0.96);
      text-shadow: 0 1px 2px rgba(0, 0, 0, 0.18);
      letter-spacing: .2px;
    }

    /* النصوص الثانوية */
    .tsc-item-label,
    .bsc-item-label,
    .tsc-status-badge,
    .bsc-status-badge,
    .tsc-action,
    .bsc-action {
      color: rgba(255, 255, 255, 0.78);
    }

    /* القيم والأرقام */
    .tsc-item-value,
    .bsc-item-value,
    .tsc-main-value {
      color: #f8fafc;
      text-shadow: 0 1px 3px rgba(0, 0, 0, 0.22);
    }

    /* الأيقونات الخلفية */
    .tsc-bg-icon,
    .bsc-bg-icon {
      color: rgba(255, 255, 255, 0.10) !important;
    }

    /* خلفيات العناصر الداخلية */
    .tsc-item,
    .bsc-item {
      background: rgba(255, 255, 255, 0.12);
      border: 1px solid rgba(255, 255, 255, 0.08);
      backdrop-filter: blur(10px);
    }

    /* العنصر الرئيسي */
    .tsc-item-main {
      background: rgba(255, 255, 255, 0.18);
    }

    /* تحسين الـ badges */
    .tsc-status-badge,
    .bsc-status-badge,
    .tsc-action,
    .bsc-action {
      background: rgba(255, 255, 255, 0.14);
      border: 1px solid rgba(255, 255, 255, 0.08);
      backdrop-filter: blur(8px);
    }

    /* Hover احترافي */
    .dashboard-page-card:hover,
    .treasury-status-card:hover,
    .balance-status-card:hover {
      filter: brightness(1.03) saturate(1.05);
    }

    /* ===== ألوان احترافية لإحصائيات الميزانية والخزنة ===== */

    /* الميزانية */
    .bsc-item-value {
      color: #fef3c7 !important;
    }

    #bsc-assets {
      color: #a7f3d0 !important;
    }

    #bsc-liabequity {
      color: #C5E4DA !important;
    }

    #bsc-diff {
      color: #fde68a !important;
    }

    /* الخزنة */
    .tsc-main-value {
      color: #fef9c3 !important;
    }

    #tsc-inflow {
      color: #bbf7d0 !important;
    }

    #tsc-outflow {
      color: #fecaca !important;
    }

    /* labels */
    .tsc-item-label,
    .bsc-item-label {
      color: rgba(255, 255, 255, 0.72) !important;
    }

    /* ===== تصغير عرض صفحة لوحة التحكم ===== */
    #page-dashboard {
      width: 100%;
      max-width: 100%;
      margin: 0;
    }

    /* ===== فصل كروت الميزانية والخزنة (للصفحات الأخرى غير لوحة التحكم) ===== */
    .balance-status-card,
    .treasury-status-card {
      display: block;
      clear: both;
      position: relative;
    }

    /* لوحة التحكم: المسافات يحددها الـ grid */
    .balance-status-card:not(.balance-treasury-grid .balance-status-card) {
      width: 100%;
      margin-bottom: 22px !important;
    }

    .treasury-status-card:not(.balance-treasury-grid .treasury-status-card) {
      width: 100%;
      margin-top: 10px !important;
    }

    /* ===== تأكيد استقلال كروت الميزانية والخزنة داخل لوحة التحكم ===== */
    /* (هذه القواعد لا تطبق داخل .balance-treasury-grid) */
    #page-dashboard #balance-status-card:not(.balance-treasury-grid #balance-status-card),
    #page-dashboard #treasury-status-card:not(.balance-treasury-grid #treasury-status-card) {
      display: block !important;
      width: 100% !important;
      clear: both !important;
      position: relative !important;
      overflow: hidden !important;
    }

    /* ===== كارت الميزانية والخزنة جنب بعض ===== */
    /* الـ wrapper اللي هيجمعهم في شبكة (موجود في HTML) */
    #page-dashboard .balance-treasury-grid {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 18px;
      align-items: stretch;
      margin: 0 0 18px;
    }

    #page-dashboard .balance-treasury-grid #balance-status-card,
    #page-dashboard .balance-treasury-grid #treasury-status-card {
      position: relative !important;
      overflow: hidden !important;
      margin: 0 !important;
      width: auto !important;
      clear: none !important;
      float: none !important;
      display: block !important;
      height: 100%;
    }

    /* الموبايل: فوق بعض (responsive) */
    @media (max-width: 768px) {
      #page-dashboard .balance-treasury-grid {
        grid-template-columns: 1fr;
        gap: 18px;
      }

      #page-dashboard .balance-treasury-grid #balance-status-card,
      #page-dashboard .balance-treasury-grid #treasury-status-card {
        width: 100% !important;
      }
    }

    /* ألوان نتائج كارت الميزانية */
    #page-dashboard #bsc-assets {
      color: #86efac !important;
    }

    #page-dashboard #bsc-liabequity {
      color: #93c5fd !important;
    }

    #page-dashboard #bsc-diff {
      color: #fde68a !important;
    }

    /* ألوان نتائج كارت الخزنة */
    #page-dashboard #tsc-balance {
      color: #fef08a !important;
    }

    #page-dashboard #tsc-inflow {
      color: #93c5fd !important;
    }

    #page-dashboard #tsc-outflow {
      color: #fecaca !important;
    }


    /* ===== Main Page Scrollbar Only ===== */

    /* Chrome / Edge */
    html::-webkit-scrollbar,
    body::-webkit-scrollbar {
      width: 12px;
    }

    html::-webkit-scrollbar-track,
    body::-webkit-scrollbar-track {
      background: transparent;
    }

    html::-webkit-scrollbar-thumb,
    body::-webkit-scrollbar-thumb {
      background: linear-gradient(180deg, #3a3a3a, #555555);
      border-radius: 999px;
      border: 3px solid transparent;
      background-clip: content-box;
    }

    html::-webkit-scrollbar-thumb:hover,
    body::-webkit-scrollbar-thumb:hover {
      background: linear-gradient(180deg, #2b2b2b, #3f3f3f);
      background-clip: content-box;
    }

    /* Firefox */
    html,
    body {
      scrollbar-width: thin;
      scrollbar-color: #444444 transparent;
    }


    * {
      margin: 0;
      padding: 0;
      box-sizing: border-box;
    }

    html {
      font-size: 16px;
    }

    body {
      font-family: var(--font);
      /* ★ لمسة جمالية: توهّج لوني ناعم جدًا فى ركنين من الشاشة، بيتلوّن تلقائيًا مع
      لون النظام المختار (فوق خلفية اللون الأساسي العادي) — مش تغيير جذري، مجرد عمق
      بصري خفيف بدل خلفية مسطّحة تمامًا */
      background-color: var(--bg);
      background-image:
        radial-gradient(circle at 100% 0%, var(--bg-glow-1) 0%, transparent 45%),
        radial-gradient(circle at 0% 100%, var(--bg-glow-2) 0%, transparent 45%);
      background-attachment: fixed;
      color: var(--text);
      transition: background-color 0.3s, color 0.3s;
      min-height: 100vh;
      overflow-x: hidden;
    }

    /* ===== منع تحديد النص في كل أنحاء التطبيق ما عدا حقول الإدخال ===== */
    body {
      -webkit-user-select: none;
      -moz-user-select: none;
      -ms-user-select: none;
      user-select: none;
      -webkit-touch-callout: none;
      /* منع قائمة الـ long-press على iOS */
      -webkit-tap-highlight-color: transparent;
      /* منع وميض اللمس */
    }

    /* السماح بالتحديد والكتابة فقط في حقول الإدخال */
    input,
    textarea,
    select,
    [contenteditable="true"] {
      -webkit-user-select: text !important;
      -moz-user-select: text !important;
      -ms-user-select: text !important;
      user-select: text !important;
      -webkit-touch-callout: default !important;
    }

    /* ===== LOGIN ===== */
    #login-screen {
      min-height: 100vh;
      display: flex;
      align-items: center;
      justify-content: center;
      background: linear-gradient(135deg, #e0e7ff 0%, #c7d2fe 50%, #e0e7ff 100%);
      position: relative;
      overflow: hidden;
    }

    [data-theme="dark"] #login-screen {
      background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 50%, #0f172a 100%);
    }

    #login-screen::before {
      content: '';
      position: absolute;
      width: 600px;
      height: 600px;
      border-radius: 50%;
      background: radial-gradient(circle, rgba(30, 94, 138, 0.18) 0%, transparent 70%);
      top: -200px;
      right: -100px;
      animation: pulse 4s ease-in-out infinite;
    }

    #login-screen::after {
      content: '';
      position: absolute;
      width: 400px;
      height: 400px;
      border-radius: 50%;
      background: radial-gradient(circle, rgba(14, 165, 233, 0.15) 0%, transparent 70%);
      bottom: -100px;
      left: -100px;
      animation: pulse 4s ease-in-out infinite 2s;
    }

    @keyframes pulse {

      0%,
      100% {
        transform: scale(1);
        opacity: 0.8
      }

      50% {
        transform: scale(1.1);
        opacity: 1
      }
    }

    .login-card {
      background: rgba(255, 255, 255, 0.85);
      backdrop-filter: blur(20px);
      border: 1px solid rgba(255, 255, 255, 0.7);
      border-radius: 24px;
      padding: 48px 40px;
      width: 420px;
      max-width: 95vw;
      position: relative;
      z-index: 1;
      box-shadow: 0 25px 50px rgba(15, 23, 42, 0.15);
    }

    [data-theme="dark"] .login-card {
      background: rgba(255, 255, 255, 0.05);
      border: 1px solid rgba(255, 255, 255, 0.1);
      box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
    }

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

    .login-logo .icon {
      width: 72px;
      height: 72px;
      background: linear-gradient(135deg, #1E5E8A, #1AA37A);
      border-radius: 20px;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      font-size: 32px;
      color: white;
      margin-bottom: 16px;
      box-shadow: 0 8px 24px rgba(30, 94, 138, 0.4);
      overflow: hidden;
    }

    .login-logo h1 {
      color: #0f172a;
      font-size: 1.6rem;
      font-weight: 800;
    }

    [data-theme="dark"] .login-logo h1 {
      color: white;
    }

    .login-logo p {
      color: rgba(15, 23, 42, 0.6);
      font-size: 0.9rem;
      margin-top: 4px;
    }

    [data-theme="dark"] .login-logo p {
      color: rgba(255, 255, 255, 0.5);
    }

    .form-group {
      margin-bottom: 20px;
    }

    .form-group label {
      display: block;
      color: rgba(15, 23, 42, 0.75);
      font-size: 0.85rem;
      margin-bottom: 8px;
      font-weight: 500;
    }

    [data-theme="dark"] .form-group label {
      color: rgba(255, 255, 255, 0.7);
    }

    .form-group input {
      width: 100%;
      background: rgba(255, 255, 255, 0.7);
      border: 1px solid rgba(15, 23, 42, 0.12);
      border-radius: 10px;
      padding: 12px 16px;
      color: #0f172a;
      font-family: var(--font);
      font-size: 0.95rem;
      transition: all 0.2s;
      outline: none;
    }

    [data-theme="dark"] .form-group input {
      background: rgba(255, 255, 255, 0.08);
      border: 1px solid rgba(255, 255, 255, 0.15);
      color: white;
    }

    .form-group input:focus {
      border-color: #1E5E8A;
      background: rgba(255, 255, 255, 0.95);
      box-shadow: 0 0 0 3px rgba(30, 94, 138, 0.2);
    }

    [data-theme="dark"] .form-group input:focus {
      background: rgba(30, 94, 138, 0.1);
    }

    .form-group input::placeholder {
      color: rgba(15, 23, 42, 0.35);
    }

    [data-theme="dark"] .form-group input::placeholder {
      color: rgba(255, 255, 255, 0.3);
    }

    .btn-login {
      width: 100%;
      background: linear-gradient(135deg, #1E5E8A, #1AA37A);
      color: white;
      border: none;
      border-radius: 10px;
      padding: 14px;
      font-family: var(--font);
      font-size: 1rem;
      font-weight: 700;
      cursor: pointer;
      transition: all 0.2s;
      margin-top: 8px;
    }

    .btn-login:hover {
      transform: translateY(-1px);
      box-shadow: 0 8px 24px rgba(30, 94, 138, 0.4);
    }

    .login-error {
      color: #ef4444;
      font-size: 0.85rem;
      text-align: center;
      margin-top: 12px;
      min-height: 20px;
    }

    /* ===== MAIN LAYOUT ===== */
    #app {
      display: none;
    }

    #app.visible {
      display: flex;
      min-height: 100vh;
    }

    /* SIDEBAR */
    .sidebar {
      width: 215px;
      background: var(--sidebar-bg);
      border-left: 1px solid var(--sidebar-header-border);
      box-shadow: -2px 0 12px rgba(0, 0, 0, 0.06);
      display: flex;
      flex-direction: column;
      position: fixed;
      top: 30px;
      right: 0;
      bottom: 0;
      z-index: 2147483647;
      transition: width 0.3s cubic-bezier(.4, 0, .2, 1), transform 0.3s cubic-bezier(.4, 0, .2, 1), box-shadow 0.3s;
      overflow: hidden;
    }

    /* Desktop collapsed sidebar */
    .sidebar.collapsed {
      width: 60px;
      box-shadow: -4px 0 20px rgba(0, 0, 0, 0.08);
    }

    .sidebar.collapsed .sidebar-title,
    .sidebar.collapsed .nav-section-title,
    .sidebar.collapsed .sidebar-footer .btn-logout-text {
      opacity: 0;
      pointer-events: none;
      width: 0;
      overflow: hidden;
      white-space: nowrap;
    }

    .sidebar.collapsed .sidebar-header {
      padding: 12px 8px;
    }

    .sidebar.collapsed .sidebar-brand-banner {
      justify-content: center;
      gap: 0;
    }

    .sidebar.collapsed .sidebar-logo {
      margin: 0;
    }

    .sidebar.collapsed .nav-section {
      padding: 10px 0 2px;
      margin-top: 6px;
      border-top: 1px solid var(--sidebar-header-border);
    }

    .sidebar.collapsed .nav-section:first-of-type {
      margin-top: 0;
      border-top: none;
    }

    .sidebar.collapsed .nav-item {
      justify-content: center;
      padding: 12px 0;
      border-right: none;
      border-radius: 0;
      position: relative;
      font-size: 0;
      gap: 0;
      white-space: nowrap;
      overflow: hidden;
    }

    .sidebar.collapsed .nav-item .icon {
      width: 24px;
      font-size: 1.1rem;
    }

    .sidebar.collapsed .nav-item.active {
      border-right: none;
    }

    .sidebar.collapsed .nav-item.active::after {
      content: '';
      position: absolute;
      right: 0;
      top: 50%;
      transform: translateY(-50%);
      width: 3px;
      height: 60%;
      background: linear-gradient(180deg, var(--primary) 0%, var(--gov-gold) 100%);
      border-radius: 3px 0 0 3px;
      box-shadow: 0 0 8px var(--sidebar-active-glow);
    }

    .sidebar.collapsed .sidebar-footer {
      justify-content: center;
      padding: 14px 8px;
      gap: 10px;
    }

    .sidebar.collapsed .btn-logout {
      padding: 10px 0;
      gap: 0;
    }

    /* Tooltip on collapsed nav items */
    .sidebar.collapsed .nav-item[data-label]::before {
      content: attr(data-label);
      position: absolute;
      right: calc(100% + 8px);
      top: 50%;
      transform: translateY(-50%);
      background: var(--sidebar-tooltip-bg);
      color: var(--sidebar-tooltip-color);
      font-size: 0.78rem;
      font-weight: 600;
      padding: 5px 10px;
      border-radius: 8px;
      white-space: nowrap;
      opacity: 0;
      pointer-events: none;
      transition: opacity 0.18s;
      z-index: 9999;
      box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    }

    .sidebar.collapsed .nav-item[data-label]::after {
      content: '';
      position: absolute;
      right: calc(100% + 2px);
      top: 50%;
      transform: translateY(-50%);
      border: 5px solid transparent;
      border-left-color: var(--sidebar-tooltip-bg);
      opacity: 0;
      pointer-events: none;
      transition: opacity 0.18s;
      z-index: 9999;
    }

    .sidebar.collapsed .nav-item[data-label]:hover::before,
    .sidebar.collapsed .nav-item[data-label]:hover::after {
      opacity: 1;
    }

    /* Adjust main margin when collapsed */
    .main.sidebar-collapsed {
      margin-right: 60px;
    }

    .sidebar-header {
      padding: 14px;
      border-bottom: 1px solid var(--sidebar-header-border);
    }

    .sidebar-brand-banner {
      display: flex;
      align-items: center;
      gap: 12px;
      padding: 12px;
      border-radius: 14px;
      background: var(--surface);
      border: 1px solid var(--sidebar-header-border);
      box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
    }

    .sidebar.collapsed .sidebar-brand-banner {
      background: transparent;
      border-color: transparent;
      box-shadow: none;
      padding: 0;
    }

    /* ===== بانر الترحيب بالمستخدم ===== */
    .sidebar-welcome {
      display: flex;
      align-items: center;
      gap: 10px;
      padding: 12px 16px;
      margin: 0;
      border-bottom: 1px solid var(--sidebar-header-border);
      background: linear-gradient(135deg, rgba(220, 38, 38, 0.04) 0%, rgba(239, 68, 68, 0.02) 100%);
      position: relative;
      overflow: hidden;
    }

    [data-theme="dark"] .sidebar-welcome {
      background: linear-gradient(135deg, rgba(220, 38, 38, 0.08) 0%, rgba(239, 68, 68, 0.04) 100%);
    }

    .sidebar-welcome .welcome-avatar {
      width: 36px;
      height: 36px;
      border-radius: 50%;
      background: linear-gradient(135deg, #14436B, #1E5E8A);
      display: flex;
      align-items: center;
      justify-content: center;
      color: #fff;
      font-size: 0.85rem;
      flex-shrink: 0;
      box-shadow: 0 2px 6px rgba(30, 94, 138, 0.30);
    }

    .sidebar-welcome .welcome-text {
      flex: 1;
      min-width: 0;
      overflow: hidden;
    }

    .sidebar-welcome .welcome-greeting {
      font-size: 0.7rem;
      color: var(--text-muted);
      font-weight: 600;
      margin-bottom: 1px;
      line-height: 1;
    }

    .sidebar-welcome .welcome-name {
      font-size: 0.88rem;
      color: var(--sidebar-title-color);
      font-weight: 700;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      line-height: 1.2;
    }

    .sidebar-welcome .welcome-role-badge {
      font-size: 0.62rem;
      padding: 2px 7px;
      border-radius: 8px;
      font-weight: 700;
      flex-shrink: 0;
      letter-spacing: 0;
    }

    .sidebar-welcome .welcome-role-badge.role-admin {
      background: rgba(220, 38, 38, 0.12);
      color: #dc2626;
      border: 1px solid rgba(220, 38, 38, 0.25);
    }

    .sidebar-welcome .welcome-role-badge.role-manager {
      background: rgba(59, 130, 246, 0.12);
      color: #1E5E8A;
      border: 1px solid rgba(59, 130, 246, 0.25);
    }

    .sidebar-welcome .welcome-role-badge.role-supervisor {
      background: rgba(245, 158, 11, 0.12);
      color: #d97706;
      border: 1px solid rgba(245, 158, 11, 0.25);
    }

    .sidebar-welcome .welcome-role-badge.role-cashier {
      background: rgba(16, 185, 129, 0.12);
      color: #059669;
      border: 1px solid rgba(16, 185, 129, 0.25);
    }

    .sidebar-welcome .welcome-role-badge.role-custom {
      background: rgba(107, 122, 143, 0.12);
      color: #6B7A8F;
      border: 1px solid rgba(107, 122, 143, 0.25);
    }

    [data-theme="dark"] .sidebar-welcome .welcome-role-badge.role-admin {
      background: rgba(248, 113, 113, 0.15);
      color: #fca5a5;
      border-color: rgba(248, 113, 113, 0.3);
    }

    [data-theme="dark"] .sidebar-welcome .welcome-role-badge.role-manager {
      background: rgba(96, 165, 250, 0.15);
      color: #93c5fd;
      border-color: rgba(96, 165, 250, 0.3);
    }

    [data-theme="dark"] .sidebar-welcome .welcome-role-badge.role-supervisor {
      background: rgba(251, 191, 36, 0.15);
      color: #fcd34d;
      border-color: rgba(251, 191, 36, 0.3);
    }

    [data-theme="dark"] .sidebar-welcome .welcome-role-badge.role-cashier {
      background: rgba(52, 211, 153, 0.15);
      color: #6ee7b7;
      border-color: rgba(52, 211, 153, 0.3);
    }

    [data-theme="dark"] .sidebar-welcome .welcome-role-badge.role-custom {
      background: rgba(148, 163, 184, 0.15);
      color: #cbd5e1;
      border-color: rgba(148, 163, 184, 0.3);
    }

    /* في الحالة المطوية: نخفي النص والـ badge، تبقى الـ avatar فقط متمركزة */
    .sidebar.collapsed .sidebar-welcome {
      padding: 12px;
      justify-content: center;
    }

    .sidebar.collapsed .sidebar-welcome .welcome-text,
    .sidebar.collapsed .sidebar-welcome .welcome-role-badge {
      display: none;
    }

    .sidebar-logo {
      width: 44px;
      height: 44px;
      background: linear-gradient(135deg, #dc2626, #ef4444);
      border-radius: 12px;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 20px;
      color: white;
      flex-shrink: 0;
    }

    .sidebar-title {
      color: var(--sidebar-title-color);
      font-weight: 800;
      font-size: 1rem;
      line-height: 1.2;
      display: flex;
      flex-direction: column;
      align-items: flex-start;
      flex: 1;
      min-width: 0;
      max-width: 100%;
    }

    .sidebar-title span {
      display: block;
      font-size: 0.75rem;
      color: var(--sidebar-subtitle-color);
      font-weight: 500;
    }

    #sb-company {
      display: block;
      font-size: 1rem;
      font-weight: 800;
      color: var(--sidebar-company-color) !important;
      line-height: 1.2;
      max-width: 100%;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .sidebar-nav {
      flex: 1;
      overflow-y: auto;
      padding: 12px 0;
      /* منع نقل السكرول إلى body عند الوصول لنهاية القائمة (scroll-chaining prevention) */
      overscroll-behavior: contain;
      overscroll-behavior-y: contain;
      /* سكرول بدون ظهور scrollbar */
      scrollbar-width: none;
      -ms-overflow-style: none;
    }

    .sidebar-nav::-webkit-scrollbar {
      display: none;
    }

    .nav-section {
      padding: 18px 16px 5px;
      position: relative;
    }

    .nav-section-title {
      font-size: 0.86rem;
      color: var(--sidebar-section-title);
      font-weight: 800;
      font-family: 'Tajawal', 'Cairo', sans-serif;
      letter-spacing: 0.04em;
      display: flex;
      align-items: center;
      gap: 7px;
      position: relative;
      white-space: nowrap;
      cursor: pointer;
      user-select: none;
    }

    .nav-section-title:hover {
      opacity: .8;
    }

    .nav-section-chevron {
      font-size: .62rem;
      flex-shrink: 0;
      opacity: .55;
      transition: transform .2s ease;
      order: 2;
      margin-inline-start: 4px;
    }

    .nav-section.section-collapsed .nav-section-chevron {
      transform: rotate(-90deg);
    }

    .sidebar:not(.collapsed) .nav-item.nav-item-hidden-by-collapse {
      display: none !important;
    }

    .nav-section-title::before {
      content: '';
      display: inline-block;
      width: 4px;
      height: 13px;
      background: linear-gradient(180deg, var(--primary) 0%, var(--gov-gold) 100%);
      border-radius: 3px;
      opacity: 0.9;
      flex-shrink: 0;
      box-shadow: 0 0 6px var(--sidebar-active-glow);
    }

    .nav-section-title::after {
      content: '';
      display: block;
      flex: 1;
      height: 1px;
      background: linear-gradient(to left, var(--gov-gold) 0%, var(--border) 45%, transparent 100%);
      opacity: .55;
      margin-right: 4px;
      order: 1;
    }

    .nav-item {
      display: flex;
      align-items: center;
      gap: 12px;
      padding: 10px 16px;
      color: var(--sidebar-text);
      cursor: pointer;
      transition: all 0.2s;
      border-right: 3px solid transparent;
      font-size: 0.9rem;
      font-weight: 700;
      user-select: none;
      position: relative;
    }

    .nav-item::before {
      content: '';
      position: absolute;
      right: 0;
      top: 50%;
      width: 3px;
      height: 60%;
      border-radius: 3px 0 0 3px;
      background: linear-gradient(180deg, var(--primary) 0%, var(--gov-gold) 100%);
      transform: translateY(-50%) scaleY(0);
      transform-origin: center;
      transition: transform .25s ease, box-shadow .25s ease;
    }

    .nav-item:hover {
      background: var(--sidebar-hover-bg);
      color: var(--sidebar-hover-color);
    }

    .nav-item:hover::before {
      transform: translateY(-50%) scaleY(.4);
    }

    .nav-item.active {
      background: var(--sidebar-active-bg);
      color: var(--sidebar-active-color);
      border-right-color: transparent;
    }

    .nav-item.active::before {
      transform: translateY(-50%) scaleY(1);
      box-shadow: 0 0 8px var(--sidebar-active-glow);
    }

    .nav-item .icon {
      width: 20px;
      text-align: center;
      font-size: 0.95rem;
      color: var(--sidebar-nav-icon-color);
      transition: color 0.2s;
    }

    .nav-item:hover .icon,
    .nav-item.active .icon {
      color: currentColor;
    }

    .sidebar-footer {
      padding: 14px 16px;
      border-top: 1px solid var(--sidebar-footer-border);
      display: flex;
      flex-direction: column;
      gap: 10px;
    }

    .btn-logout {
      width: 100%;
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 8px;
      padding: 10px 14px;
      border-radius: 10px;
      color: var(--sidebar-logout-color);
      cursor: pointer;
      transition: all 0.2s ease;
      background: rgba(239, 68, 68, 0.06);
      border: 1px solid rgba(239, 68, 68, 0.15);
      font-size: 0.88rem;
      font-weight: 600;
      font-family: var(--font);
    }

    .btn-logout i {
      font-size: 0.95rem;
    }

    .btn-logout:hover {
      color: #ffffff;
      background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
      border-color: transparent;
      box-shadow: 0 4px 12px rgba(239, 68, 68, 0.25);
      transform: translateY(-1px);
    }

    [data-theme="dark"] .btn-logout {
      background: rgba(239, 68, 68, 0.10);
      border-color: rgba(239, 68, 68, 0.22);
    }

    /* MAIN CONTENT */
    .main {
      margin-right: 215px;
      margin-top: 30px;
      flex: 1;
      min-width: 0;
      display: flex;
      flex-direction: column;
      min-height: 100vh;
      transition: margin-right 0.3s cubic-bezier(.4, 0, .2, 1);
    }

    .topbar {
      background: var(--surface);
      border-bottom: 1px solid var(--border);
      box-shadow: 0 1px 6px rgba(0, 0, 0, 0.06);
      padding: 0 20px;
      height: 64px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 16px;
      position: sticky;
      top: 30px;
      z-index: 50;
    }

    /* شريط علوي ثابت بهوية النظام (EasyPOS) — غير قابل للتعديل أو الإخفاء من أي إعدادات */
    .brand-topbar {
      position: fixed;
      top: 0;
      right: 0;
      left: 0;
      height: 30px;
      background: #0a0e1a;
      display: flex;
      align-items: center;
      padding: 0 16px;
      gap: 8px;
      z-index: 2147483647;
      font-family: var(--font);
    }

    .brand-topbar .brand-topbar-icon {
      width: 16px;
      height: 16px;
      border-radius: 4px;
      background: linear-gradient(135deg, var(--primary), var(--secondary));
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: .62rem;
      color: #fff;
    }

    .brand-topbar .brand-topbar-name {
      font-size: .72rem;
      font-weight: 800;
      letter-spacing: .5px;
      color: #fff;
    }

    .brand-topbar .brand-topbar-name b {
      color: #8b9cff;
      font-weight: 800;
    }

    .topbar-title {
      font-size: 1.1rem;
      font-weight: 700;
      color: #1E5E8A;
    }

    .sync-status-badge {
      display: inline-flex;
      align-items: center;
      gap: 5px;
      font-size: .72rem;
      font-weight: 600;
      padding: 3px 9px;
      border-radius: 999px;
      background: #FEF3C7;
      color: #92400E;
      white-space: nowrap;
      border: 1px solid #FDE68A;
    }

    [data-theme="dark"] .sync-status-badge {
      background: rgba(251, 191, 36, .12);
      color: #FBBF24;
      border-color: rgba(251, 191, 36, .25);
    }

    @media (max-width: 700px) {
      .sync-status-badge {
        font-size: .68rem;
        padding: 2px 7px;
      }
    }

    .topbar-actions {
      display: flex;
      align-items: center;
      gap: 8px;
    }

    .btn-icon {
      width: 38px;
      height: 38px;
      border-radius: var(--radius-sm);
      border: 1px solid var(--border);
      background: var(--surface2);
      color: var(--text-muted);
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 0.9rem;
      transition: all 0.2s;
    }

    .btn-icon:hover {
      background: var(--primary-light);
      color: var(--primary);
      border-color: var(--primary);
    }

    .menu-toggle {
      display: flex;
    }


    /* ===== Professional Excel & Print Buttons ===== */
    button[onclick*="Excel"],
    button[onclick*="excel"] {
      background: linear-gradient(135deg, #16a34a 0%, #15803d 100%) !important;
      color: #ffffff !important;
      border: 1px solid #15803d !important;
      box-shadow: 0 4px 14px rgba(22, 163, 74, 0.22) !important;
    }

    button[onclick*="Excel"]:hover,
    button[onclick*="excel"]:hover {
      background: linear-gradient(135deg, #15803d 0%, #166534 100%) !important;
      color: #ffffff !important;
      border-color: #166534 !important;
      transform: translateY(-1px);
    }

    /* ===== Print Buttons ===== */
    button[onclick*="print"] {
      background: linear-gradient(135deg, #1E5E8A 0%, #1d4ed8 100%) !important;
      color: #ffffff !important;
      border: 1px solid #1d4ed8 !important;
      box-shadow: 0 4px 14px rgba(37, 99, 235, 0.22) !important;
    }

    button[onclick*="print"]:hover {
      background: linear-gradient(135deg, #1d4ed8 0%, #14436B 100%) !important;
      color: #ffffff !important;
      border-color: #14436B !important;
      transform: translateY(-1px);
    }

    /* ===== POS Buttons ===== */
    button[onclick*="fullscreen"],
    button[title*="ملء"],
    button[title*="كامل"] {
      background: linear-gradient(135deg, #16a34a 0%, #15803d 100%) !important;
      color: #ffffff !important;
      border: 1px solid #15803d !important;
      box-shadow: 0 4px 14px rgba(22, 163, 74, 0.22) !important;
    }

    button[onclick*="fullscreen"]:hover,
    button[title*="ملء"]:hover,
    button[title*="كامل"]:hover {
      background: linear-gradient(135deg, #15803d 0%, #166534 100%) !important;
      color: #ffffff !important;
      border-color: #166534 !important;
      transform: translateY(-1px);
    }

    /* Icons — keep white in all states (default + hover) */
    button[onclick*="Excel"] i,
    button[onclick*="excel"] i,
    button[onclick*="print"] i,
    button[onclick*="PDF"] i,
    button[onclick*="pdf"] i,
    button[onclick*="fullscreen"] i,
    button[title*="ملء"] i,
    button[title*="كامل"] i,
    button[onclick*="Excel"]:hover i,
    button[onclick*="excel"]:hover i,
    button[onclick*="print"]:hover i,
    button[onclick*="PDF"]:hover i,
    button[onclick*="pdf"]:hover i,
    button[onclick*="fullscreen"]:hover i,
    button[title*="ملء"]:hover i,
    button[title*="كامل"]:hover i {
      color: #ffffff !important;
    }

    /* ===== Professional Action Buttons (Danger / Warning) ===== */
    /* تفريغ السلة + مسح السجل (أزرار حمراء) */
    button[onclick*="clearPOSCart"],
    button[onclick*="clearActivityLog"] {
      background: linear-gradient(135deg, #dc2626 0%, #991b1b 100%) !important;
      color: #ffffff !important;
      border: 1px solid #991b1b !important;
      box-shadow: 0 4px 14px rgba(220, 38, 38, 0.22) !important;
      transition: all 0.2s ease !important;
    }

    button[onclick*="clearPOSCart"]:hover,
    button[onclick*="clearActivityLog"]:hover {
      background: linear-gradient(135deg, #991b1b 0%, #7f1d1d 100%) !important;
      color: #ffffff !important;
      border-color: #7f1d1d !important;
      transform: translateY(-1px);
      box-shadow: 0 6px 18px rgba(220, 38, 38, 0.32) !important;
    }

    /* مردود مبيعات يدوي + مردود مشتريات يدوي (بنفسجي محايد — تصحيح/تعديل، مش خطر أو نجاح) */
    button[onclick*="openManualSalesReturnModal"],
    button[onclick*="openManualPurchaseReturnModal"] {
      background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%) !important;
      color: #ffffff !important;
      border: 1px solid #6d28d9 !important;
      box-shadow: 0 4px 14px rgba(124, 58, 237, 0.22) !important;
      transition: all 0.2s ease !important;
    }

    button[onclick*="openManualSalesReturnModal"]:hover,
    button[onclick*="openManualPurchaseReturnModal"]:hover {
      background: linear-gradient(135deg, #6d28d9 0%, #5b21b6 100%) !important;
      color: #ffffff !important;
      border-color: #5b21b6 !important;
      transform: translateY(-1px);
      box-shadow: 0 6px 18px rgba(124, 58, 237, 0.32) !important;
    }

    /* سند دفع جديد (برتقالي / تحذيرى — زى لون مصروف جديد) */
    button[onclick*="modal-payment"] {
      background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%) !important;
      color: #ffffff !important;
      border: 1px solid #d97706 !important;
      box-shadow: 0 4px 14px rgba(245, 158, 11, 0.22) !important;
      transition: all 0.2s ease !important;
    }

    button[onclick*="modal-payment"]:hover {
      background: linear-gradient(135deg, #d97706 0%, #b45309 100%) !important;
      color: #ffffff !important;
      border-color: #b45309 !important;
      transform: translateY(-1px);
      box-shadow: 0 6px 18px rgba(245, 158, 11, 0.32) !important;
    }

    /* مصروف جديد (برتقالي / تحذيرى) */
    button[onclick*="modal-expense"] {
      background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%) !important;
      color: #ffffff !important;
      border: 1px solid #d97706 !important;
      box-shadow: 0 4px 14px rgba(245, 158, 11, 0.22) !important;
      transition: all 0.2s ease !important;
    }

    button[onclick*="modal-expense"]:hover {
      background: linear-gradient(135deg, #d97706 0%, #b45309 100%) !important;
      color: #ffffff !important;
      border-color: #b45309 !important;
      transform: translateY(-1px);
      box-shadow: 0 6px 18px rgba(245, 158, 11, 0.32) !important;
    }

    /* ضمان أيقونات بيضاء في الحالتين للأزرار دى */
    button[onclick*="openManualSalesReturnModal"] i,
    button[onclick*="openManualPurchaseReturnModal"] i,
    button[onclick*="clearPOSCart"] i,
    button[onclick*="clearActivityLog"] i,
    button[onclick*="modal-payment"] i,
    button[onclick*="modal-expense"] i,
    button[onclick*="openManualSalesReturnModal"]:hover i,
    button[onclick*="openManualPurchaseReturnModal"]:hover i,
    button[onclick*="clearPOSCart"]:hover i,
    button[onclick*="clearActivityLog"]:hover i,
    button[onclick*="modal-payment"]:hover i,
    button[onclick*="modal-expense"]:hover i {
      color: #ffffff !important;
    }


    /* ===== صف الإجمالي أسفل الجداول ===== */
    .table-summary-row td {
      background: var(--surface2);
      border-top: 2px solid var(--border);
      font-weight: 800;
      font-size: 0.88rem;
      color: var(--text);
      padding: 10px 16px;
      position: sticky;
      bottom: 0;
    }

    .table-summary-row td.sum-label {
      color: var(--text-muted);
      font-size: 0.82rem;
    }

    .table-summary-row td.sum-value-success {
      color: var(--success);
    }

    .table-summary-row td.sum-value-danger {
      color: var(--danger);
    }

    .table-summary-row td.sum-value-primary {
      color: var(--primary);
    }

    [data-theme="dark"] .table-summary-row td {
      background: var(--surface2);
      border-top-color: var(--border);
    }

    /* ===== خلية رقم الصف (#) في الجداول ===== */
    .td-idx {
      color: var(--text-muted);
      font-size: .8rem;
      text-align: center;
      font-weight: 600;
    }

    /* ===== Pagination Controls ===== */
    .pagination-bar {
      display: flex;
      align-items: center;
      justify-content: space-between;
      flex-wrap: wrap;
      gap: 12px;
      padding: 14px 18px;
      border-top: 1px solid var(--border);
      background: var(--surface2);
    }

    .pagination-info {
      font-size: 0.85rem;
      color: var(--text-muted);
      font-weight: 600;
    }

    .pagination-info strong {
      color: var(--text);
      font-weight: 700;
    }

    .pagination-controls {
      display: flex;
      align-items: center;
      gap: 4px;
      flex-wrap: wrap;
    }

    .page-btn {
      min-width: 36px;
      height: 36px;
      padding: 0 10px;
      border-radius: 8px;
      border: 1px solid var(--border);
      background: var(--surface);
      color: var(--text);
      font-family: var(--font);
      font-size: 0.85rem;
      font-weight: 700;
      cursor: pointer;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      transition: all 0.15s ease;
    }

    .page-btn:hover:not(:disabled):not(.active) {
      background: var(--surface2);
      border-color: var(--primary);
      color: var(--primary);
    }

    .page-btn.active {
      background: var(--primary);
      border-color: var(--primary);
      color: #fff;
      box-shadow: 0 2px 6px rgba(220, 38, 38, 0.25);
    }

    .page-btn:disabled {
      opacity: 0.4;
      cursor: not-allowed;
    }

    .page-btn-nav {
      gap: 5px;
    }

    .page-ellipsis {
      padding: 0 6px;
      color: var(--text-muted);
      font-weight: 700;
    }

    .pagination-size {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      font-size: 0.82rem;
      color: var(--text-muted);
    }

    .pagination-size select {
      padding: 5px 10px;
      border-radius: 6px;
      border: 1px solid var(--border);
      background: var(--surface);
      color: var(--text);
      font-family: var(--font);
      font-size: 0.82rem;
      font-weight: 600;
      cursor: pointer;
    }

    @media (max-width: 600px) {
      .pagination-bar {
        padding: 10px 12px;
        gap: 8px;
      }

      .pagination-info {
        font-size: 0.78rem;
        width: 100%;
        text-align: center;
      }

      .page-btn {
        min-width: 32px;
        height: 32px;
        font-size: 0.78rem;
      }

      .page-btn-nav .nav-label {
        display: none;
      }
    }

    /* كارت التاريخ في الهيدر */
    .date-card-topbar {
      display: flex;
      align-items: center;
      gap: 7px;
      height: 38px;
      padding: 0 13px;
      border-radius: var(--radius-sm);
      border: 1px solid var(--primary);
      background: var(--primary);
      color: #fff;
      font-family: var(--font);
      white-space: nowrap;
      cursor: default;
      user-select: none;
      font-weight: 700;
    }

    .content {
      flex: 1;
      min-width: 0;
      padding: 20px;
    }

    /* PAGES */
    .page {
      display: none;
      animation: fadeIn 0.2s ease;
    }

    .page.active {
      display: block;
    }

    @keyframes fadeIn {
      from {
        opacity: 0;
        transform: translateY(4px)
      }

      to {
        opacity: 1;
        transform: translateY(0)
      }
    }

    @keyframes topbarBellRing {

      0%,
      100% {
        transform: rotate(0);
      }

      10%,
      30% {
        transform: rotate(-12deg);
      }

      20%,
      40% {
        transform: rotate(12deg);
      }

      50% {
        transform: rotate(0);
      }
    }

    .topbar-notif-ring i.fa-bell {
      display: inline-block;
      animation: topbarBellRing 2.2s ease-in-out infinite;
      color: var(--danger);
    }

    /* ===== قائمة إشعارات الجرس المنسدلة (تجمع كل أنواع الإشعارات، مش خاصة بالطلبات الواردة بس) ===== */
    .topbar-notif-menu {
      left: 0;
      right: auto;
      width: 320px;
      max-width: 88vw;
      padding: 0;
      overflow: hidden;
    }

    .topbar-notif-menu .topbar-notif-menu-header {
      padding: 12px 14px;
      font-weight: 800;
      font-size: .9rem;
      border-bottom: 1px solid var(--border);
      color: var(--text);
    }

    .topbar-notif-menu .topbar-notif-menu-list {
      max-height: 320px;
      overflow-y: auto;
      padding: 6px;
    }

    .topbar-notif-menu .topbar-notif-item {
      display: flex;
      align-items: flex-start;
      gap: 10px;
      padding: 10px;
      border-radius: 8px;
      cursor: pointer;
    }

    .topbar-notif-menu .topbar-notif-item:hover {
      background: var(--primary-light);
    }

    .topbar-notif-menu .topbar-notif-item+.topbar-notif-item {
      margin-top: 2px;
    }

    .topbar-notif-menu .topbar-notif-item-icon {
      width: 32px;
      height: 32px;
      min-width: 32px;
      border-radius: 50%;
      background: var(--primary-light);
      color: var(--primary);
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: .85rem;
    }

    .topbar-notif-menu .topbar-notif-item-title {
      font-weight: 700;
      font-size: .84rem;
      color: var(--text);
      margin-bottom: 2px;
    }

    .topbar-notif-menu .topbar-notif-item-sub {
      font-size: .76rem;
      color: var(--text-muted);
    }

    .topbar-notif-menu .topbar-notif-empty {
      padding: 26px 12px;
      text-align: center;
      color: var(--text-muted);
      font-size: .82rem;
    }

    /* ===== CARDS ===== */
    .card {
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: var(--radius);
      box-shadow: var(--shadow);
    }

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

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

    .card-body {
      padding: 20px;
    }

    /* STATS GRID */
    .stats-grid {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
      gap: 16px;
      margin-bottom: 24px;
    }

    /* Dashboard cards on mobile: 2 cards per row */
    .hr-att-cards-row {
      display: flex;
      flex-wrap: nowrap;
      justify-content: center;
      gap: 10px;
    }

    .hr-att-card {
      flex: 1 1 0;
      min-width: 0;
    }

    @media (max-width: 768px) {
      .hr-att-cards-row {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
      }

      .hr-att-card {
        min-width: 0;
      }
    }

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

      .stat-card {
        padding: 14px;
        gap: 10px;
        min-height: 90px;
      }

      .stat-icon {
        width: 42px;
        height: 42px;
        font-size: 1rem;
      }

      .stat-value {
        font-size: 1rem;
      }

      .stat-label {
        font-size: 0.72rem;
      }
    }

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

      .stat-card {
        padding: 10px;
      }

      .stat-value {
        font-size: .9rem;
      }
    }

    .stat-card {
      background: linear-gradient(135deg, #ffffff 0%, #f8fbff 100%);
      border: 1px solid var(--border);
      border-radius: var(--radius);
      padding: 20px;
      display: flex;
      align-items: center;
      gap: 16px;
      box-shadow: var(--shadow);
      transition: transform 0.2s, box-shadow 0.2s;
      min-width: 0;
      overflow: hidden;
    }

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

    .stat-icon {
      width: 52px;
      height: 52px;
      border-radius: 14px;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 1.3rem;
      flex-shrink: 0;
    }

    .stat-icon.blue {
      background: #eff6ff;
      color: #1E5E8A;
    }

    .stat-icon.green {
      background: #ecfdf5;
      color: #10b981;
    }

    .stat-icon.red {
      background: #fef2f2;
      color: #ef4444;
    }

    .stat-icon.yellow {
      background: #fffbeb;
      color: #f59e0b;
    }

    [data-theme="dark"] .stat-icon.blue {
      background: rgba(30, 94, 138, 0.15);
    }

    [data-theme="dark"] .stat-icon.green {
      background: rgba(16, 185, 129, 0.15);
    }

    [data-theme="dark"] .stat-icon.red {
      background: rgba(239, 68, 68, 0.15);
    }

    [data-theme="dark"] .stat-icon.yellow {
      background: rgba(245, 158, 11, 0.15);
    }

    .stat-info {
      flex: 1;
      min-width: 0;
      overflow: hidden;
    }

    .stat-value {
      font-size: 1.4rem;
      font-weight: 800;
      color: var(--text);
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      max-width: 100%;
    }

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

    /* TABLES */
    .table-wrap {
      overflow-x: auto;
      overflow-y: auto;
      -webkit-overflow-scrolling: touch;
      max-height: 65vh;
      border-radius: 0 0 var(--radius) var(--radius);
    }

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

    .table-wrap::-webkit-scrollbar-track {
      background: var(--surface2);
      border-radius: 3px;
    }

    .table-wrap::-webkit-scrollbar-thumb {
      background: var(--border);
      border-radius: 3px;
    }

    .table-wrap::-webkit-scrollbar-thumb:hover {
      background: var(--primary);
    }

    .table-wrap thead th {
      position: sticky;
      top: 0;
      z-index: 2;
      background: #dce6f5;
    }

    [data-theme="dark"] .table-wrap thead th {
      background: #091525;
    }

    @media (max-width: 900px) {
      .table-wrap {
        overflow-x: auto;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        display: block;
        width: 100%;
        max-height: 60vh;
      }
    }

    table {
      width: 100%;
      border-collapse: collapse;
      min-width: 600px;
    }

    thead tr {
      background: #dce6f5;
    }

    [data-theme="dark"] thead tr {
      background: #091525;
    }

    th {
      padding: 12px 16px;
      text-align: center;
      font-size: 0.8rem;
      font-weight: 700;
      color: #1e3a5f;
      white-space: nowrap;
      border: 1px solid var(--border);
    }

    [data-theme="dark"] th {
      color: #8892b0;
    }

    td {
      padding: 12px 16px;
      font-size: 0.88rem;
      color: var(--text);
      border: 1px solid var(--border);
      text-align: center;
    }

    tbody tr:hover {
      background: var(--surface2);
    }

    tbody tr:last-child td {
      border-bottom: 1px solid var(--border);
    }

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

    .badge-success {
      background: #ecfdf5;
      color: #059669;
    }

    .badge-danger {
      background: #fef2f2;
      color: #dc2626;
    }

    .badge-warning {
      background: #fffbeb;
      color: #d97706;
    }

    .badge-info {
      background: #eff6ff;
      color: #1E5E8A;
    }

    .badge-gray {
      background: var(--surface2);
      color: var(--text-muted);
    }

    [data-theme="dark"] .badge-success {
      background: rgba(16, 185, 129, 0.15);
    }

    [data-theme="dark"] .badge-danger {
      background: rgba(239, 68, 68, 0.15);
    }

    [data-theme="dark"] .badge-warning {
      background: rgba(245, 158, 11, 0.15);
    }

    [data-theme="dark"] .badge-info {
      background: rgba(30, 94, 138, 0.15);
    }

    /* BUTTONS */
    .btn {
      display: inline-flex;
      align-items: center;
      gap: 8px;
      padding: 9px 18px;
      border-radius: var(--radius-sm);
      font-family: var(--font);
      font-size: 0.88rem;
      font-weight: 600;
      cursor: pointer;
      transition: all 0.2s;
      border: none;
      white-space: nowrap;
    }

    .btn-primary {
      background: var(--primary);
      color: white;
    }

    .btn-primary:hover {
      background: var(--primary-dark);
      box-shadow: 0 4px 12px rgba(30, 94, 138, 0.3);
    }

    .btn-success {
      background: var(--success);
      color: white;
    }

    .btn-success:hover {
      background: #059669;
    }

    .btn-danger {
      background: var(--danger);
      color: white;
    }

    .btn-danger:hover {
      background: #dc2626;
    }

    .btn-warning {
      background: var(--warning);
      color: white;
    }

    .btn-outline {
      background: transparent;
      color: var(--text-muted);
      border: 1px solid var(--border);
    }

    .btn-outline:hover {
      background: var(--surface2);
      color: var(--text);
    }

    .btn-sm {
      padding: 6px 12px;
      font-size: 0.8rem;
    }

    .btn-xs {
      padding: 4px 8px;
      font-size: 0.75rem;
      border-radius: 6px;
    }

    /* FORM ELEMENTS */
    .form-row {
      display: grid;
      gap: 16px;
      margin-bottom: 16px;
    }

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

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

    /* ===== لوحة صلاحيات الصفحات (نظام الصلاحيات المخصصة) ===== */
    .perm-pages-grid {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
      gap: 8px;
      padding: 12px 14px;
      background: var(--surface2);
      border-radius: var(--radius-sm);
      max-height: 260px;
      overflow-y: auto;
    }

    .perm-pages-grid label {
      display: flex;
      align-items: center;
      gap: 6px;
      cursor: pointer;
      font-size: .82rem;
      font-weight: 600;
      padding: 4px 6px;
      border-radius: 6px;
      transition: background .15s ease;
    }

    .perm-pages-grid label:hover {
      background: var(--surface);
    }

    /* ✅ توحيد شكل كل تشيك بوكسات الصلاحيات (إعدادات عامة + لوحة الصفحات) مع تشيك بوكس
       اختيار البيانات المطلوب مسحها (نفس المقاس 16px بدل الحجم الافتراضي 18px) —
       بدون أي فرق بين الكمبيوتر والموبايل لأنه مقاس ثابت (px) مش متأثر بحجم الشاشة */
    .perm-pages-grid input[type="checkbox"],
    .perm-checkbox {
      width: 16px;
      height: 16px;
      flex-shrink: 0;
    }

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

    .field {
      display: flex;
      flex-direction: column;
      gap: 6px;
    }

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

    .field input,
    .field select,
    .field textarea {
      background: var(--surface2);
      border: 1px solid var(--border);
      border-radius: var(--radius-sm);
      padding: 9px 12px;
      font-family: var(--font);
      font-size: 0.88rem;
      color: var(--text);
      transition: all 0.2s;
      outline: none;
      width: 100%;
    }

    .field input:focus,
    .field select:focus,
    .field textarea:focus {
      border-color: var(--primary);
      box-shadow: 0 0 0 3px rgba(30, 94, 138, 0.1);
      background: var(--surface);
    }

    .field textarea {
      resize: vertical;
      min-height: 80px;
    }

    .comp-product-dropdown-item:hover {
      background: var(--primary-light, rgba(30, 94, 138, .08));
      color: var(--primary);
    }

    /* MODAL */
    .modal-backdrop {
      position: fixed;
      inset: 0;
      background: rgba(0, 0, 0, 0.5);
      backdrop-filter: blur(4px);
      z-index: 300;
      display: none;
      align-items: center;
      justify-content: center;
      padding: 16px;
    }

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

    /* مودال التأكيد العام لازم يظهر دايماً فوق أي مودال تاني (مثل مودالات نقطة البيع اللي بتستخدم أعلى z-index ممكنة) */
    #modal-confirm.open {
      z-index: 2147483647 !important;
    }

    .modal {
      background: var(--surface);
      border-radius: 16px;
      width: 100%;
      max-width: 600px;
      max-height: 90vh;
      overflow-y: auto;
      box-shadow: var(--shadow-lg);
      animation: modalIn 0.2s ease;
    }

    .modal.modal-lg {
      max-width: 900px;
    }

    .modal.modal-xl {
      max-width: 1100px;
    }

    @keyframes modalIn {
      from {
        opacity: 0;
        transform: scale(0.95)
      }

      to {
        opacity: 1;
        transform: scale(1)
      }
    }

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

    .modal-title {
      font-size: 1.05rem;
      font-weight: 700;
    }

    .modal-close {
      cursor: pointer;
      color: var(--text-muted);
      font-size: 1.1rem;
      transition: color 0.2s;
      background: none;
      border: none;
    }

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

    .modal-body {
      padding: 24px;
    }

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

    /* SEARCH BAR */
    .search-bar {
      display: flex;
      align-items: center;
      gap: 8px;
      background: var(--surface2);
      border: 1px solid var(--border);
      border-radius: var(--radius-sm);
      padding: 8px 12px;
      flex: 1;
      max-width: 300px;
    }

    .search-bar input,
    .search-bar.search-bar input[type="text"] {
      background: none !important;
      border: none !important;
      outline: none !important;
      box-shadow: none !important;
      font-family: var(--font);
      font-size: 0.88rem;
      color: var(--text);
      width: 100%;
    }

    .search-bar i {
      color: var(--text-light);
      font-size: 0.85rem;
    }

    /* PAGE HEADER */
    .page-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 16px;
      margin-bottom: 20px;
      flex-wrap: wrap;
    }

    .page-header-left {
      display: flex;
      align-items: center;
      gap: 12px;
      flex-wrap: wrap;
    }


    .page-actions {
      display: flex;
      align-items: center;
      gap: 10px;
      flex-wrap: wrap;
    }

    .page-actions .btn {
      min-height: 40px;
      border-radius: 10px;
      padding: 10px 16px;
      box-shadow: none;
    }

    .page-header .btn {
      min-height: 40px;
    }

    .report-grid {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: 16px;
    }

    .report-box {
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: var(--radius);
      padding: 18px;
      box-shadow: var(--shadow);
    }

    .report-box h4 {
      display: flex;
      align-items: center;
      gap: 8px;
      margin-bottom: 14px;
      font-size: 1rem;
    }

    .report-row {
      display: flex;
      justify-content: space-between;
      gap: 12px;
      padding: 10px 0;
      border-bottom: 1px solid var(--border);
      font-size: .9rem;
    }

    .report-row.total {
      font-weight: 800;
      color: var(--primary);
    }

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

    .balance-note {
      margin-top: 16px;
      padding: 14px 16px;
      border: 1px dashed var(--border);
      border-radius: 10px;
      background: var(--surface2);
      font-size: .9rem;
      display: flex;
      justify-content: space-between;
      gap: 12px;
      flex-wrap: wrap;
    }

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

      .bl-grid {
        grid-template-columns: 1fr !important;
      }
    }

    /* EMPTY STATE */
    .empty-state {
      text-align: center;
      padding: 48px 24px;
      color: var(--text-muted);
    }

    .empty-state i {
      font-size: 2.5rem;
      margin-bottom: 12px;
      opacity: 0.4;
      display: block;
    }

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

    /* ALERT */
    .alert {
      padding: 12px 16px;
      border-radius: var(--radius-sm);
      font-size: 0.88rem;
      margin-bottom: 16px;
      display: flex;
      align-items: center;
      gap: 8px;
    }

    .alert-success {
      background: #ecfdf5;
      color: #059669;
      border: 1px solid #a7f3d0;
    }

    [data-theme="dark"] .alert-success {
      background: rgba(16, 185, 129, 0.1);
      border-color: rgba(16, 185, 129, 0.3);
    }

    /* TOAST */
    #toast-container {
      position: fixed;
      bottom: 24px;
      left: 24px;
      z-index: 9999;
      display: flex;
      flex-direction: column;
      gap: 8px;
    }

    .toast {
      background: var(--text);
      color: var(--surface);
      padding: 12px 18px;
      border-radius: 10px;
      font-size: 0.88rem;
      font-weight: 500;
      display: flex;
      align-items: center;
      gap: 10px;
      box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
      animation: toastIn 0.3s ease;
      min-width: 240px;
      max-width: 380px;
    }

    .toast.success {
      background: #059669;
      color: white;
    }

    .toast.error {
      background: #dc2626;
      color: white;
    }

    .toast.warning {
      background: #d97706;
      color: white;
    }

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

      to {
        opacity: 1;
        transform: translateX(0)
      }
    }

    /* INVOICE PRINT */
    .invoice-print {
      font-family: var(--font);
      max-width: 800px;
      margin: 0 auto;
      padding: 40px;
      background: white;
      color: #0f172a;
      direction: rtl;
    }

    .invoice-print .inv-header {
      display: flex;
      justify-content: space-between;
      align-items: flex-start;
      margin-bottom: 32px;
      padding-bottom: 20px;
      border-bottom: 3px solid #1E5E8A;
    }

    .invoice-print .company-name {
      font-size: 1.7rem;
      font-weight: 900;
      color: #1E5E8A;
      margin-bottom: 6px;
    }

    .invoice-print .inv-meta {
      text-align: left;
      background: #f1f5f9;
      padding: 14px 18px;
      border-radius: 10px;
      min-width: 200px;
    }

    .invoice-print .inv-number {
      font-size: 1.15rem;
      font-weight: 800;
      color: #0f172a;
      margin-bottom: 6px;
    }

    .invoice-print .party-label {
      font-size: 0.72rem;
      font-weight: 700;
      color: #1E5E8A;
      text-transform: uppercase;
      letter-spacing: 1px;
      margin-bottom: 8px;
    }

    .invoice-print .party-name {
      font-size: 1.05rem;
      font-weight: 700;
      color: #0f172a;
    }

    .invoice-print table {
      width: 100%;
      border-collapse: collapse;
      margin-bottom: 28px;
      border-radius: 8px;
      overflow: hidden;
    }

    .invoice-print th {
      background: #1E5E8A;
      color: white;
      padding: 12px 14px;
      font-size: 0.85rem;
      font-weight: 700;
      text-align: center;
      border: 1px solid #14436B;
    }

    .invoice-print td {
      padding: 11px 14px;
      border: 1px solid #e2e8f0;
      font-size: 0.88rem;
      color: #1e293b;
      text-align: center;
    }

    .invoice-print tbody tr:nth-child(even) td {
      background: #f8fafc;
    }

    .invoice-print .total-row {
      display: flex;
      justify-content: space-between;
      padding: 9px 16px;
      border-bottom: 1px solid #e2e8f0;
      font-size: 0.88rem;
      color: #334155;
    }

    .invoice-print .total-row:last-child {
      border-bottom: none;
    }

    .invoice-print .total-row.grand {
      font-weight: 800;
      font-size: 1.08rem;
      background: #1E5E8A;
      color: white;
      padding: 13px 16px;
    }

    .invoice-print .inv-notes {
      margin-top: 24px;
      padding: 14px 18px;
      background: #fefce8;
      border-radius: 8px;
      border-right: 4px solid #f59e0b;
      font-size: 0.85rem;
      color: #78350f;
    }

    /* ===== CUSTOMER STATEMENT MODAL ===== */
    #modal-customer-statement .modal {
      max-width: 860px;
      max-height: 90vh;
      display: flex;
      flex-direction: column;
    }

    #modal-customer-statement .modal-body {
      overflow-y: hidden;
      flex: 1;
      padding: 0;
      display: flex;
      flex-direction: column;
      min-height: 0;
    }

    #stmt-content {
      display: flex;
      flex-direction: column;
      height: 100%;
      min-height: 0;
    }

    /* ===== قفل سكرول الصفحة أثناء فتح مودالات كشف الحساب ===== */
    body.stmt-modal-open {
      overflow: hidden !important;
      /* touch-action: none أُزيل — كان بيمنع السكرول داخل المودال على الموبايل */
    }

    /* ===== إخفاء العناصر المخصصة للأدمن فقط عن أصحاب الواجهة المبسّطة (كانت خاصة بالكاشير) ===== */
    body.simplified-ui .admin-only-col {
      display: none !important;
    }

    /* ===== إخفاء فلاتر "حسب المستخدم" عن أي حساب مقيّد بـ "رؤية سجلاته فقط" (ownRecordsOnly) —
       بغض النظر عن الواجهة المبسّطة (simplifiedUI)، فهذه صلاحية مستقلة تمامًا: قد يكون الحساب
       مقيّدًا بسجلاته فقط دون واجهة مبسّطة، أو العكس ===== */
    body.own-records-only .hide-for-own-records {
      display: none !important;
    }

    /* ===== إخفاء العناصر الحساسة (زي الرصيد الافتتاحي للخزنة) عن غير الأدمن ===== */
    body:not(.is-admin) .manager-hide {
      display: none !important;
    }

    /* ===== إخفاء أزرار/خيارات "تعديل" عن المستخدمين اللي مالهمش صلاحية تعديل ===== */
    body.no-edit-perm .table-actions .btn-outline[onclick*="edit"],
    body.no-edit-perm .table-actions button[onclick*="edit"],
    body.no-edit-perm .table-actions button[onclick*="openEdit"],
    body.no-edit-perm .table-actions button[onclick*="Modal"]:not([onclick*="print"]):not([onclick*="Print"]):not([onclick*="view"]):not([onclick*="View"]):not([onclick*="Details"]):not([onclick*="Statement"]),
    body.no-edit-perm td button.btn-outline[onclick*="openEdit"],
    body.no-edit-perm td button.btn-outline[onclick*="edit"]:not([onclick*="Statement"]):not([onclick*="View"]):not([onclick*="view"]),
    body.no-edit-perm .export-dropdown-option[onclick*="edit"]:not([onclick*="Statement"]):not([onclick*="Details"]),
    body.no-edit-perm .export-dropdown-option[onclick*="openEdit"],
    body.no-edit-perm .export-dropdown-option[onclick*="openInvoiceModal"],
    body.no-edit-perm .export-dropdown-option[onclick*="openPurchaseModal"] {
      display: none !important;
    }

    /* ===== إخفاء أزرار/خيارات "حذف" و"مرتجع" و"استرجاع نسخة احتياطية" عن المستخدمين اللي مالهمش صلاحية حذف ===== */
    body.no-delete-perm .table-actions .btn-danger,
    body.no-delete-perm .table-actions button[onclick*="delete"],
    body.no-delete-perm .table-actions button[onclick*="Delete"],
    body.no-delete-perm td button.btn-danger[onclick*="delete"],
    body.no-delete-perm td button.btn-danger[onclick*="Delete"],
    body.no-delete-perm .export-dropdown-option[onclick*="delete"],
    body.no-delete-perm .export-dropdown-option[onclick*="Delete"],
    body.no-delete-perm #restore-backup-input,
    body.no-delete-perm button[onclick*="restore-backup-input"] {
      display: none !important;
    }

    /* ===== زر تسجيل الخروج فى الهيدر لأصحاب الواجهة المبسّطة (كانت خاصة بالكاشير) ===== */
    body.simplified-ui .cashier-only-logout {
      display: inline-flex !important;
    }

    body.simplified-ui .cashier-only-logout:hover {
      filter: brightness(0.92);
      transform: translateY(-1px);
      box-shadow: 0 4px 10px rgba(239, 68, 68, 0.35);
    }

    /* ===== رأس كشف الحساب الرسمي (بدون لوجو/اسم الشركة) ===== */
    .stmt-header {
      flex-shrink: 0;
      background: var(--surface);
      color: var(--text);
      padding: 18px 24px;
      display: grid;
      grid-template-columns: 1fr auto;
      gap: 16px 24px;
      align-items: center;
      border-bottom: 2px solid var(--primary);
    }

    .stmt-header .company-info {
      display: flex;
      flex-direction: column;
      gap: 4px;
    }

    .stmt-header .company-info .stmt-doc-title {
      font-size: 1.15rem;
      font-weight: 800;
      color: var(--primary);
      letter-spacing: .3px;
      text-transform: uppercase;
    }

    .stmt-header .company-info .stmt-doc-date {
      font-size: .82rem;
      color: var(--text-muted);
      font-weight: 500;
    }

    .stmt-header .company-info .stmt-doc-date i {
      margin-left: 5px;
      color: var(--text-muted);
    }

    .stmt-header .customer-info {
      text-align: left;
      background: var(--surface2);
      padding: 10px 16px;
      border-radius: 8px;
      border: 1px solid var(--border);
      min-width: 220px;
    }

    .stmt-header .customer-info .stmt-party-label {
      font-size: .7rem;
      color: var(--text-muted);
      font-weight: 600;
      text-transform: uppercase;
      letter-spacing: .5px;
      margin-bottom: 2px;
    }

    .stmt-header .customer-info h4 {
      font-size: 1.05rem;
      font-weight: 800;
      color: var(--text);
      margin: 0;
      line-height: 1.3;
    }

    .stmt-header .customer-info .stmt-party-meta {
      font-size: .8rem;
      color: var(--text-muted);
      margin-top: 4px;
      font-weight: 500;
      display: flex;
      flex-wrap: wrap;
      gap: 4px 12px;
    }

    .stmt-header .customer-info .stmt-party-meta span {
      display: inline-flex;
      align-items: center;
      gap: 4px;
    }

    .stmt-header .customer-info .stmt-party-meta i {
      font-size: .72rem;
      color: var(--primary);
    }

    [data-theme="dark"] .stmt-header {
      background: var(--surface);
      border-bottom-color: #3b72d9;
    }

    [data-theme="dark"] .stmt-header .customer-info {
      background: rgba(255, 255, 255, 0.04);
    }

    .stmt-table-wrap {
      flex: 1;
      overflow-y: auto;
      overflow-x: auto;
      -webkit-overflow-scrolling: touch;
      min-height: 0;
      background: var(--surface);
    }

    .stmt-table {
      width: 100%;
      border-collapse: collapse;
      min-width: 580px;
    }

    /* هيدر الجدول الرسمي ثابت أثناء السكرول */
    .stmt-table thead {
      position: sticky;
      top: 0;
      z-index: 5;
    }

    .stmt-table thead tr {
      background: linear-gradient(180deg, #1e3a5f 0%, #0f2849 100%);
    }

    .stmt-table th {
      padding: 12px 14px;
      font-size: 0.78rem;
      font-weight: 700;
      color: #ffffff;
      text-align: center;
      border: 1px solid #0a1f3d;
      white-space: nowrap;
      letter-spacing: .3px;
      text-transform: uppercase;
      text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
    }

    [data-theme="dark"] .stmt-table thead tr {
      background: linear-gradient(180deg, #0f2849 0%, #091525 100%);
    }

    [data-theme="dark"] .stmt-table th {
      color: #ffffff;
      border-color: #000;
    }

    .stmt-table td {
      padding: 10px 14px;
      font-size: 0.84rem;
      color: var(--text);
      border: 1px solid var(--border);
      text-align: center;
      font-variant-numeric: tabular-nums;
    }

    /* صفوف متناوبة بألوان رسمية */
    .stmt-table tbody tr:nth-child(even) {
      background: var(--surface2);
    }

    .stmt-table tbody tr:hover {
      background: rgba(30, 94, 138, 0.08);
    }

    [data-theme="dark"] .stmt-table tbody tr:hover {
      background: rgba(30, 94, 138, 0.18);
    }

    .stmt-table tbody tr:last-child td {
      border: 1px solid var(--border);
    }

    .stmt-table .td-debit {
      color: var(--danger);
      font-weight: 700;
    }

    .stmt-table .td-credit {
      color: var(--success);
      font-weight: 700;
    }

    .stmt-table .td-balance-pos {
      color: var(--primary);
      font-weight: 700;
    }

    .stmt-table .td-balance-neg {
      color: var(--danger);
      font-weight: 700;
    }

    .stmt-table .td-zero {
      color: var(--text-light);
    }

    /* ===== شريط فلتر التاريخ في كشوف الحساب ===== */
    .stmt-date-filter {
      flex-shrink: 0;
      display: flex;
      align-items: center;
      flex-wrap: wrap;
      gap: 10px;
      padding: 10px 16px;
      background: var(--surface2);
      border-bottom: 1px solid var(--border);
    }

    .stmt-date-filter .stmt-filter-label {
      font-size: .78rem;
      font-weight: 700;
      color: var(--text-muted);
      display: inline-flex;
      align-items: center;
      gap: 5px;
    }

    .stmt-date-filter .stmt-filter-label i {
      color: var(--primary);
    }

    .stmt-date-filter .stmt-date-group {
      display: inline-flex;
      align-items: center;
      gap: 6px;
    }

    .stmt-date-filter .stmt-date-group label {
      font-size: .78rem;
      font-weight: 600;
      color: var(--text-muted);
    }

    .stmt-date-filter input[type="date"] {
      padding: 6px 10px;
      border: 1px solid var(--border);
      border-radius: 6px;
      background: var(--surface);
      color: var(--text);
      font-family: var(--font);
      font-size: .82rem;
      outline: none;
      transition: border-color .15s ease, box-shadow .15s ease;
    }

    .stmt-date-filter input[type="date"]:focus {
      border-color: var(--primary);
      box-shadow: 0 0 0 3px rgba(30, 94, 138, 0.15);
    }

    .stmt-date-filter .stmt-filter-btn {
      padding: 7px 14px;
      border-radius: 6px;
      border: none;
      cursor: pointer;
      font-family: var(--font);
      font-size: .8rem;
      font-weight: 700;
      display: inline-flex;
      align-items: center;
      gap: 5px;
      transition: all .15s ease;
    }

    .stmt-date-filter .stmt-filter-btn.apply {
      background: var(--primary);
      color: #fff;
    }

    .stmt-date-filter .stmt-filter-btn.apply:hover {
      background: var(--primary-dark);
    }

    .stmt-date-filter .stmt-filter-btn.reset {
      background: transparent;
      color: var(--text-muted);
      border: 1px solid var(--border);
    }

    .stmt-date-filter .stmt-filter-btn.reset:hover {
      background: var(--surface);
      color: var(--text);
    }

    @media (max-width: 600px) {
      .stmt-date-filter {
        padding: 10px 12px;
        gap: 8px;
      }

      .stmt-date-filter .stmt-date-group {
        flex: 1;
        min-width: 140px;
      }

      .stmt-date-filter input[type="date"] {
        flex: 1;
        min-width: 0;
      }
    }

    @media print {
      .no-print {
        display: none !important;
      }
    }

    /* ===== جدول تسوية جرد المخزن ===== */
    .adj-items-table select,
    .adj-items-table input[type="number"] {
      max-width: 100%;
      box-sizing: border-box;
    }

    /* تنعيم سكرولبار جدول التسوية */
    .adj-table-scroll {
      scrollbar-width: thin;
    }

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

    .adj-table-scroll::-webkit-scrollbar-thumb {
      background: var(--border);
      border-radius: 3px;
    }

    .adj-table-scroll::-webkit-scrollbar-thumb:hover {
      background: var(--text-muted);
    }

    .stmt-type-badge {
      display: inline-flex;
      align-items: center;
      gap: 5px;
      padding: 3px 9px;
      border-radius: 20px;
      font-size: 0.72rem;
      font-weight: 700;
      white-space: nowrap;
    }

    .stmt-type-opening {
      background: var(--primary-light);
      color: var(--primary);
    }

    .stmt-type-invoice {
      background: #eff6ff;
      color: #1d4ed8;
    }

    .stmt-type-receipt {
      background: #ecfdf5;
      color: #059669;
    }

    [data-theme="dark"] .stmt-type-invoice {
      background: rgba(30, 94, 138, .15);
      color: #60a5fa;
    }

    [data-theme="dark"] .stmt-type-receipt {
      background: rgba(16, 185, 129, .15);
      color: #34d399;
    }

    @media (max-width: 600px) {
      .stmt-header {
        grid-template-columns: 1fr;
        padding: 14px 16px;
        gap: 12px;
      }

      .stmt-header .customer-info {
        text-align: right;
        min-width: 0;
      }

      .stmt-header .company-info .stmt-doc-title {
        font-size: 1rem;
      }

      .stmt-header .customer-info h4 {
        font-size: .95rem;
      }
    }

    /* ===== END CUSTOMER STATEMENT MODAL ===== */

    /* ===== DATE FILTER BAR ===== */
    .date-filter-bar {
      display: flex;
      align-items: center;
      gap: 10px;
      flex-wrap: wrap;
      background: var(--surface2);
      border: 1px solid var(--border);
      border-radius: var(--radius-sm);
      padding: 10px 14px;
      margin-bottom: 14px;
    }

    .date-filter-bar label {
      font-size: 0.8rem;
      font-weight: 600;
      color: var(--text-muted);
      white-space: nowrap;
    }

    .date-filter-bar input[type="date"],
    .date-filter-bar input[type="text"],
    .date-filter-bar select {
      padding: 6px 10px;
      border: 1px solid var(--border);
      border-radius: var(--radius-sm);
      background: var(--surface);
      color: var(--text);
      font-family: var(--font);
      font-size: 0.83rem;
      outline: none;
      transition: border-color 0.2s;
      height: 34px;
    }

    .date-filter-bar input[type="date"]:focus,
    .date-filter-bar input[type="text"]:focus,
    .date-filter-bar select:focus {
      border-color: var(--primary);
    }

    .date-filter-bar .btn-filter-reset {
      padding: 5px 12px;
      border-radius: var(--radius-sm);
      border: 1px solid var(--border);
      background: var(--surface);
      color: var(--text-muted);
      font-family: var(--font);
      font-size: 0.8rem;
      cursor: pointer;
      transition: all 0.2s;
      white-space: nowrap;
      height: 34px;
    }

    .date-filter-bar .btn-filter-reset:hover {
      background: var(--danger);
      color: white;
      border-color: var(--danger);
    }

    .date-filter-bar .filter-result {
      margin-right: auto;
      font-size: 0.78rem;
      color: var(--primary);
      font-weight: 600;
    }

    @media (max-width: 600px) {
      .date-filter-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
      }

      .date-filter-bar input[type="date"],
      .date-filter-bar input[type="text"],
      .date-filter-bar select,
      .date-filter-bar .btn-filter-reset {
        width: 100%;
      }

      .date-filter-bar .filter-result {
        margin-right: 0;
      }

      /* حقل الباركود وزرار الكاميرا يفضلوا فى نفس الصف على الموبايل، والزرار يفضل صغير */
      .date-filter-bar .doc-barcode-row {
        display: flex;
        align-items: center;
        gap: 8px;
        width: 100%;
      }

      .date-filter-bar .doc-barcode-row .search-bar-inline {
        flex: 1;
        min-width: 0 !important;
      }

      .date-filter-bar .doc-barcode-row .mobile-camera-btn {
        flex-shrink: 0;
        width: 38px;
        height: 38px;
        padding: 0 !important;
        justify-content: center;
      }
    }

    /* ===== END DATE FILTER BAR ===== */

    /* ======================================================
       طباعة حرارية فقط — أبيض/أسود، بدون معاينة
    ====================================================== */
    @page {
      margin: 0 !important;
      padding: 0 !important;
      size: auto;
    }

    @page :first {
      margin: 0 !important;
    }

    @media print {

      /* ===== طباعة حرارية مباشرة — أخفِ كل شيء ما عدا الإيصال ===== */
      body>*:not(#print-zone) {
        display: none !important;
      }

      html,
      body {
        background: white !important;
        background-color: white !important;
        margin: 0 !important;
        padding: 0 !important;
        overflow: hidden !important;
        height: auto !important;
      }

      #print-zone {
        display: block !important;
        position: static !important;
        background: white !important;
        padding: 0 !important;
        margin: 0 !important;
        width: 100% !important;
        overflow: visible !important;
      }

      * {
        -webkit-print-color-adjust: economy !important;
        print-color-adjust: economy !important;
        background: transparent !important;
        background-color: transparent !important;
        background-image: none !important;
        color: #000 !important;
        border-color: #000 !important;
        box-shadow: none !important;
        text-shadow: none !important;
      }

      /* الإيصال الحراري */
      .thermal-receipt {
        background: white !important;
        background-color: white !important;
        color: #000 !important;
        overflow: visible !important;
        height: auto !important;
        max-height: none !important;
        page-break-inside: auto !important;
        break-inside: auto !important;
        padding: 3mm 2mm 0mm !important;
        margin: 0 auto !important;
        font-size: 10.5px !important;
        font-weight: 700 !important;
        line-height: 1.5 !important;
        display: block !important;
        box-shadow: none !important;
        border-radius: 0 !important;
      }

      .thermal-receipt.size-58 {
        width: 58mm !important;
        max-width: 58mm !important;
        font-size: 9px !important;
      }

      /* فواصل الصفحة */
      .th-item-row,
      .th-totals-section {
        page-break-inside: avoid !important;
        break-inside: avoid !important;
      }

      /* خطوط الفواصل */
      .th-divider-thick {
        border: none !important;
        border-top: 2px solid #000 !important;
        margin: 4px 0 !important;
      }

      .th-divider-dash {
        border: none !important;
        border-top: 1px dashed #000 !important;
        margin: 3px 0 !important;
      }

      .th-divider-thin {
        border: none !important;
        border-top: 1px solid #000 !important;
        margin: 2px 0 !important;
      }

      /* نصوص الإجمالي */
      .th-totals-row.th-grand {
        font-size: 12px !important;
        font-weight: 900 !important;
        color: #000 !important;
      }

      .th-totals-row.th-paid,
      .th-totals-row.th-change,
      .th-totals-row.th-due,
      .th-totals-row.th-prev {
        color: #000 !important;
        background: transparent !important;
      }

      .th-store-name {
        font-size: 13px !important;
        color: #000 !important;
        background: transparent !important;
      }

      .th-logo {
        display: block !important;
        max-width: 60px !important;
        max-height: 60px !important;
        margin: 0 auto 4px !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
      }

      .th-store-sub,
      .th-branch-name,
      .th-datetime,
      .th-extra-copy-badge {
        color: #000 !important;
        background: transparent !important;
      }
    }

    /* رأس المودال للمرتجع */
    .return-modal-header {
      background: linear-gradient(135deg, #7f1d1d 0%, #dc2626 100%);
      padding: 18px 24px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      border-radius: 16px 16px 0 0;
    }

    .return-modal-header.purchase-return {
      background: linear-gradient(135deg, #14532d 0%, #16a34a 100%);
    }

    .return-modal-header .modal-title {
      color: white;
      font-size: 1rem;
      font-weight: 800;
      display: flex;
      align-items: center;
      gap: 10px;
    }

    .return-modal-header .modal-close {
      color: rgba(255, 255, 255, 0.7);
    }

    .return-modal-header .modal-close:hover {
      color: white;
    }

    /* جدول بنود المرتجع في المودال */
    .return-items-table {
      border: 1px solid var(--border);
      border-radius: var(--radius-sm);
      overflow-x: auto;
      -webkit-overflow-scrolling: touch;
      margin-bottom: 16px;
    }

    .return-items-table table {
      min-width: 650px;
    }

    .return-items-table thead th {
      background: #fef2f2;
      color: #991b1b;
      font-size: 0.78rem;
      font-weight: 700;
      padding: 10px 12px;
    }

    .return-items-table.purchase-return thead th {
      background: #f0fdf4;
      color: #166534;
    }

    [data-theme="dark"] .return-items-table thead th {
      background: #2d1117;
      color: #fca5a5;
    }

    [data-theme="dark"] .return-items-table.purchase-return thead th {
      background: #052e16;
      color: #86efac;
    }

    .return-items-table tbody td {
      padding: 10px 12px;
      font-size: 0.84rem;
      vertical-align: middle;
    }

    .return-qty-input,
    .sr-price,
    .pr-cost {
      width: 80px;
      padding: 6px 8px;
      border: 1px solid var(--border);
      border-radius: 6px;
      font-family: var(--font);
      font-size: 0.84rem;
      text-align: center;
      color: var(--text);
      background: var(--surface);
      transition: border-color 0.2s;
    }

    .sr-product-select,
    .pr-product-select {
      padding: 6px 8px;
      border: 1px solid var(--border);
      border-radius: 6px;
      font-family: var(--font);
      font-size: 0.84rem;
      color: var(--text);
      background: var(--surface);
      transition: border-color 0.2s;
    }

    .return-qty-input:focus,
    .sr-price:focus,
    .sr-product-select:focus,
    .pr-cost:focus,
    .pr-product-select:focus {
      border-color: var(--primary);
      outline: none;
    }

    .sr-product-select option,
    .pr-product-select option {
      color: #000;
      background: #fff;
    }

    /* حذف أسهم الزيادة/النقصان من كل حقول الأرقام في النظام بالكامل، بدون استثناء */
    input[type="number"]::-webkit-outer-spin-button,
    input[type="number"]::-webkit-inner-spin-button {
      -webkit-appearance: none;
      margin: 0;
    }

    input[type="number"] {
      -moz-appearance: textfield;
    }

    .return-qty-input:focus {
      border-color: #dc2626;
      outline: none;
      box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
    }

    .return-qty-input.purchase-input:focus {
      border-color: #16a34a;
      box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.1);
    }

    .return-qty-max {
      font-size: 0.72rem;
      color: var(--text-muted);
      margin-top: 2px;
    }

    .return-qty-max.exceeded {
      color: var(--danger);
      font-weight: 700;
    }

    /* ملخص المرتجع */
    .return-summary-box {
      background: var(--surface2);
      border: 1px solid var(--border);
      border-radius: var(--radius-sm);
      padding: 14px 16px;
      margin-bottom: 16px;
    }

    .return-summary-row {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 5px 0;
      font-size: 0.88rem;
      border-bottom: 1px solid var(--border);
    }

    .return-summary-row:last-child {
      border-bottom: none;
      padding-bottom: 0;
    }

    .return-summary-row.grand {
      font-size: 1.05rem;
      font-weight: 800;
      padding-top: 10px;
      margin-top: 4px;
    }

    .return-summary-row.grand span:last-child {
      color: var(--danger);
    }

    .return-summary-row.grand.purchase-grand span:last-child {
      color: var(--success);
    }

    /* إشعار المرتجع للطباعة */
    .return-notice-print {
      font-family: 'Cairo', sans-serif;
      direction: rtl;
      max-width: 210mm;
      margin: 0 auto;
      padding: 24px 32px;
      background: white;
      color: #000;
    }

    .return-notice-header {
      display: flex;
      justify-content: space-between;
      align-items: flex-start;
      margin-bottom: 20px;
      padding-bottom: 16px;
      border-bottom: 2px solid #000;
    }

    .return-notice-title {
      font-size: 1.6rem;
      font-weight: 900;
      color: #dc2626;
    }

    .return-notice-title.purchase-return {
      color: #16a34a;
    }

    .return-notice-meta {
      text-align: left;
      font-size: 0.9rem;
    }

    .return-notice-parties {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 16px;
      margin-bottom: 16px;
      padding: 14px;
      background: #f8f9fa;
      border-radius: 8px;
    }

    .return-notice-party-label {
      font-size: 0.75rem;
      color: #64748b;
      font-weight: 600;
      text-transform: uppercase;
      margin-bottom: 4px;
    }

    .return-notice-party-name {
      font-size: 1rem;
      font-weight: 700;
    }

    /* ألوان داكن */
    [data-theme="dark"] .return-items-table {
      border-color: var(--border);
    }

    [data-theme="dark"] .return-summary-box {
      background: var(--surface2);
    }

    /* استجابة الجوال */
    @media (max-width: 600px) {
      .return-modal-header {
        padding: 14px 16px;
      }

      .return-qty-input {
        width: 65px;
      }

      .return-notice-parties {
        grid-template-columns: 1fr;
      }
    }

    /* ===== تحسينات إضافية - نسخة محسّنة ===== */

    /* تحسين Scrollbar للمودال */
    .modal::-webkit-scrollbar {
      width: 6px;
    }

    .modal::-webkit-scrollbar-track {
      background: var(--surface2);
    }

    .modal::-webkit-scrollbar-thumb {
      background: var(--border);
      border-radius: 3px;
    }

    .modal::-webkit-scrollbar-thumb:hover {
      background: var(--primary);
    }

    /* تحسين Empty State */
    .empty-state {
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      padding: 48px 24px;
      color: var(--text-light);
      gap: 12px;
    }

    .empty-state i {
      font-size: 2.5rem;
      opacity: 0.4;
    }

    .empty-state p {
      font-size: 0.9rem;
      font-weight: 500;
      color: var(--text-muted);
      margin: 0;
    }

    /* تحسين Toasts */
    .toast-container {
      z-index: 9999 !important;
    }

    /* تحسين بطاقات الإحصاء للموبايل */
    @media (max-width: 480px) {
      .stat-value {
        font-size: 0.85rem !important;
      }
    }

    /* إضافة تأثير لامع على بطاقات الداشبورد */
    .stat-card::after {
      content: '';
      position: absolute;
      top: 0;
      left: 0;
      right: 0;
      height: 3px;
      border-radius: var(--radius) var(--radius) 0 0;
      opacity: 0;
      transition: opacity 0.2s;
    }

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

    .stat-card {
      position: relative;
    }

    /* ===== تحسين مظهر صفحة الفواتير ===== */
    .table-actions {
      display: flex;
      gap: 4px;
      justify-content: center;
      flex-wrap: nowrap;
    }

    /* تحسين التباعد في الفورم */
    .field label {
      display: flex;
      align-items: center;
      gap: 5px;
    }

    /* Badge محسّن */
    .badge {
      letter-spacing: 0.2px;
    }

    /* تأثير Hover على صفوف الجداول */
    tbody tr {
      transition: background 0.15s;
    }

    /* ===== PWA Splash Screen ===== */
    #pwa-splash {
      position: fixed;
      inset: 0;
      background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 50%, #0f172a 100%);
      display: flex;
      align-items: center;
      justify-content: center;
      z-index: 99999;
      transition: opacity 0.5s ease;
    }

    #pwa-splash.hidden {
      opacity: 0;
      pointer-events: none;
    }

    #pwa-splash .splash-logo {
      text-align: center;
      color: white;
    }

    #pwa-splash .splash-icon {
      width: 80px;
      height: 80px;
      background: linear-gradient(135deg, #1E5E8A, #1AA37A);
      border-radius: 22px;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 2.2rem;
      margin: 0 auto 16px;
      box-shadow: 0 8px 32px rgba(30, 94, 138, 0.5);
      animation: splashPulse 1.5s ease-in-out infinite;
    }

    @keyframes splashPulse {

      0%,
      100% {
        transform: scale(1);
      }

      50% {
        transform: scale(1.05);
      }
    }

    #pwa-splash h2 {
      font-size: 1.4rem;
      font-weight: 800;
      margin-bottom: 6px;
    }

    #pwa-splash p {
      font-size: 0.85rem;
      opacity: 0.6;
      margin-bottom: 24px;
    }

    #pwa-splash .splash-bar {
      width: 180px;
      height: 4px;
      background: rgba(255, 255, 255, 0.15);
      border-radius: 2px;
      overflow: hidden;
      margin: 0 auto;
    }

    #pwa-splash .splash-bar-fill {
      height: 100%;
      background: linear-gradient(90deg, #1E5E8A, #1AA37A);
      border-radius: 2px;
      animation: splashLoad 2s ease forwards;
    }

    @keyframes splashLoad {
      from {
        width: 0;
      }

      to {
        width: 100%;
      }
    }


    /* ===== تحسينات الشاشات الصغيرة جداً (أقل من 360px) ===== */
    @media (max-width: 360px) {
      .topbar {
        padding: 0 10px;
        height: 56px;
      }

      .topbar-title {
        font-size: 0.9rem;
      }

      .content {
        padding: 10px 8px;
      }

      .btn {
        padding: 7px 12px;
        font-size: 0.82rem;
      }
    }

    /* ===== تحسين الأزرار عند الطباعة ===== */
    @media print {

      .btn,
      button,
      input[type="button"],
      input[type="submit"] {
        display: none !important;
      }
    }

    /* PROGRESS */
    .progress-bar {
      height: 6px;
      background: var(--border);
      border-radius: 3px;
      overflow: hidden;
    }

    .progress-fill {
      height: 100%;
      border-radius: 3px;
      transition: width 0.4s;
    }

    /* RESPONSIVE */
    @media (max-width: 900px) {
      .sidebar {
        transform: translateX(215px);
        width: 215px !important;
      }

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

      .main {
        margin-right: 0 !important;
        overflow-x: hidden;
      }

      .content {
        overflow-x: hidden;
      }

      /* Hide tooltip on mobile */
      .sidebar.collapsed .nav-item[data-label]::before,
      .sidebar.collapsed .nav-item[data-label]::after {
        display: none;
      }
    }

    @media (max-width: 600px) {
      .content {
        padding: 12px;
      }

      .form-row.cols-2,
      .form-row.cols-3,
      .form-row.cols-4 {
        grid-template-columns: 1fr;
      }

      .form-row.activity-action-row {
        grid-template-columns: 1fr 1fr !important;
      }

      .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
        margin-bottom: 16px;
      }

      .stat-card {
        padding: 12px 10px;
        gap: 10px;
        border-radius: 10px;
        min-width: 0;
        overflow: hidden;
      }

      .stat-icon {
        width: 40px;
        height: 40px;
        font-size: 1rem;
        flex-shrink: 0;
        border-radius: 10px;
      }

      .stat-value {
        font-size: 0.95rem;
      }

      .stat-label {
        font-size: 0.7rem;
        line-height: 1.3;
      }

      .topbar {
        padding: 0 14px;
      }

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

      .page-header-left {
        flex-direction: column;
      }

      .search-bar {
        max-width: 100%;
      }

      .modal.modal-lg,
      .modal.modal-xl {
        max-width: 100%;
      }

      .page-actions {
        width: 100%;
        display: flex;
        flex-direction: column;
      }

      .page-actions .btn {
        width: 100%;
        justify-content: center;
      }

      .field input:not([type="checkbox"]):not([type="radio"]),
      .field select,
      .field textarea {
        min-height: 44px;
      }

      .inline-field {
        flex-direction: column !important;
        align-items: stretch !important;
      }

      .quick-add-btn {
        width: 100%;
        justify-content: center;
      }

      #page-purchases .stats-grid,
      #page-expenses .stats-grid,
      #page-invoicesCenter .stats-grid {
        grid-template-columns: 1fr 1fr !important;
      }
    }

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

      #page-dashboard .stats-grid {
        grid-template-columns: 1fr 1fr !important;
      }

      #page-dashboard .stat-card {
        padding: 10px 8px;
        gap: 8px;
        min-width: 0;
        overflow: hidden;
      }

      #page-dashboard .stat-icon {
        width: 36px;
        height: 36px;
        font-size: 0.95rem;
        flex-shrink: 0;
        border-radius: 9px;
      }

      #page-dashboard .stat-value {
        font-size: 0.85rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
      }

      #page-dashboard .stat-label {
        font-size: 0.65rem;
        line-height: 1.2;
        word-break: break-word;
        white-space: normal;
      }

      #page-purchases .stats-grid,
      #page-expenses .stats-grid,
      #page-invoicesCenter .stats-grid {
        grid-template-columns: 1fr !important;
      }
    }

    /* OVERLAY */
    #sidebar-overlay {
      display: none;
      position: fixed;
      inset: 0;
      background: rgba(0, 0, 0, 0.5);
      z-index: 2147483646;
    }

    #sidebar-overlay.open {
      display: block;
    }

    /* Account Page */
    .profile-header {
      background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 100%);
      border-radius: var(--radius);
      padding: 32px;
      color: white;
      display: flex;
      align-items: center;
      gap: 24px;
      margin-bottom: 24px;
    }

    .profile-avatar {
      width: 80px;
      height: 80px;
      background: linear-gradient(135deg, #1E5E8A, #1AA37A);
      border-radius: 50%;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 2rem;
      font-weight: 800;
      flex-shrink: 0;
    }

    .profile-info h2 {
      font-size: 1.4rem;
      font-weight: 800;
    }

    .profile-info p {
      color: rgba(255, 255, 255, 0.6);
      font-size: 0.9rem;
      margin-top: 4px;
    }

    /* Loading Spinner */
    .spinner {
      width: 20px;
      height: 20px;
      border: 2px solid rgba(255, 255, 255, 0.3);
      border-top-color: white;
      border-radius: 50%;
      animation: spin 0.7s linear infinite;
      display: inline-block;
    }

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

    /* Invoice Items Table */
    .inv-items-table {
      border: 1px solid var(--border);
      border-radius: var(--radius-sm);
      overflow: hidden;
    }

    .inv-items-table table {
      margin: 0;
    }

    .inv-items-table th {
      background: #dce6f5;
      color: #1e3a5f;
    }

    [data-theme="dark"] .inv-items-table th {
      background: #091525;
      color: #8892b0;
    }

    .inv-items-table {
      overflow-x: auto;
      -webkit-overflow-scrolling: touch;
    }

    .inv-items-table table {
      min-width: 760px;
    }

    #purchase-items-body {
      white-space: nowrap;
    }

    /* ★ عمود تاريخ الصلاحية فى فاتورة الشراء: مخفي افتراضيًا، بيظهر بس لو الإعداد مفعّل
       (عن طريق إضافة كلاس pur-expiry-enabled على الحاوية من الجافاسكريبت) */
    #pur-items-table-wrap .pur-expiry-col,
    #pur-items-table-wrap td.pur-expiry-cell {
      display: none;
    }

    #pur-items-table-wrap.pur-expiry-enabled .pur-expiry-col,
    #pur-items-table-wrap.pur-expiry-enabled td.pur-expiry-cell {
      display: table-cell;
    }

    #invoice-items-body {
      white-space: nowrap;
    }

    #page-customers .table-wrap {
      overflow-x: auto;
      -webkit-overflow-scrolling: touch;
    }

    #page-customers table {
      min-width: 860px;
    }

    .checkbox-wrap {
      display: inline-flex;
      align-items: center;
      gap: 8px;
      padding: 8px 10px;
      background: var(--surface2);
      border: 1px solid var(--border);
      border-radius: 10px;
    }

    body.sidebar-open {
      overflow: hidden;
      touch-action: none;
    }

    @media (max-width: 700px) {
      #page-revenues .stats-grid {
        grid-template-columns: 1fr 1fr !important;
      }

      #page-revenues .page-header>span {
        width: 100%;
      }
    }

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

    /* Color dot */
    .dot {
      width: 8px;
      height: 8px;
      border-radius: 50%;
      display: inline-block;
    }

    .dot-green {
      background: #10b981;
    }

    .dot-red {
      background: #ef4444;
    }

    .dot-yellow {
      background: #f59e0b;
    }

    /* ===== ENHANCEMENTS ===== */
    .table-actions {
      display: flex;
      gap: 6px;
      flex-wrap: wrap
    }

    .inline-field {
      display: flex;
      gap: 8px;
      align-items: end
    }

    .inline-field .field {
      flex: 1
    }

    .quick-add-btn {
      min-width: 42px;
      height: 42px;
      padding: 0;
      display: inline-flex;
      align-items: center;
      justify-content: center
    }

    .report-grid {
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 16px
    }

    .report-box {
      background: var(--surface2);
      border: 1px solid var(--border);
      border-radius: 12px;
      padding: 16px
    }

    .report-box h4 {
      font-size: .92rem;
      margin-bottom: 10px
    }

    .report-row {
      display: flex;
      justify-content: space-between;
      gap: 12px;
      padding: 8px 0;
      border-bottom: 1px solid var(--border);
      font-size: .88rem
    }

    .report-row.total {
      font-weight: 800;
      font-size: .96rem
    }

    @media (max-width: 900px) {
      .report-grid {
        grid-template-columns: 1fr
      }
    }

    /* ===== TARGETED MOBILE TUNING ===== */
    #page-customers .table-actions {
      justify-content: flex-end;
    }

    #page-customers tbody td strong {
      display: inline-block;
      max-width: 100%;
      word-break: break-word;
    }

    #page-customers .card,
    #page-treasury .card,
    #page-profits .card {
      overflow: hidden;
    }

    /* ===== جدول ملخص قائمة الدخل الاحترافي ===== */
    .profit-summary-table-wrap {
      margin-top: 0;
      border-radius: var(--radius);
      border: 1px solid var(--border);
      overflow: hidden;
      background: var(--surface);
      box-shadow: var(--shadow);
      width: 100%;
    }

    .profit-summary-scroll {
      width: 100%;
      overflow-x: auto;
      overflow-y: hidden;
      -webkit-overflow-scrolling: touch;
    }

    .profit-summary-scroll::-webkit-scrollbar {
      height: 8px;
    }

    .profit-summary-scroll::-webkit-scrollbar-thumb {
      background: var(--border);
      border-radius: 999px;
    }

    .profit-summary-tbl {
      width: 100%;
      border-collapse: collapse;
      font-size: 0.88rem;
      direction: rtl;
    }

    .profit-summary-tbl thead tr {
      background: var(--primary);
      color: #ffffff !important;
    }

    .profit-summary-tbl thead th {
      padding: 11px 14px;
      font-weight: 800;
      font-size: 0.83rem;
      text-align: center;
      white-space: nowrap;
      color: #ffffff !important;
    }

    .profit-summary-tbl thead th.pst-col-icon {
      width: 34px;
      padding: 11px 8px;
    }

    .profit-summary-tbl tbody tr {
      border-bottom: 1px solid var(--border);
      transition: background 0.15s;
    }

    .profit-summary-tbl tbody tr:hover {
      background: var(--surface2);
    }

    .profit-summary-tbl tbody td {
      padding: 10px 14px;
      color: var(--text);
      vertical-align: middle;
    }

    .pst-icon-cell {
      width: 34px;
      padding: 10px 8px !important;
      text-align: center;
    }

    .pst-dot {
      display: inline-block;
      width: 10px;
      height: 10px;
      border-radius: 50%;
      flex-shrink: 0;
    }

    .pst-val {
      font-weight: 600;
      white-space: nowrap;
    }

    .pst-val.positive {
      color: #059669;
    }

    .pst-val.negative {
      color: #dc2626;
    }

    .pst-detail {
      color: var(--text-muted);
      font-size: 0.81rem;
      white-space: nowrap;
    }

    .pst-pct {
      font-weight: 600;
      font-size: 0.85rem;
      white-space: nowrap;
      text-align: left;
      direction: ltr;
    }

    .pst-pct.pct-positive {
      color: #059669;
    }

    .pst-pct.pct-negative {
      color: #dc2626;
    }

    .profit-summary-tbl tbody tr.pst-section-header {
      background: linear-gradient(90deg, var(--primary-light) 0%, transparent 100%);
      border-bottom: none;
    }

    .profit-summary-tbl tbody tr.pst-section-header td {
      padding: 8px 14px;
      font-weight: 700;
      font-size: 0.82rem;
      color: var(--primary);
      letter-spacing: 0.02em;
    }

    .profit-summary-tbl tbody tr.pst-section-header td i {
      margin-left: 6px;
    }

    .profit-summary-tbl tbody tr.pst-subtotal {
      background: var(--surface2);
    }

    .profit-summary-tbl tbody tr.pst-subtotal td {
      font-weight: 600;
    }

    .profit-summary-tbl tbody tr.pst-total-row {
      background: rgba(30, 94, 138, 0.05);
      border-top: 2px solid var(--primary);
    }

    .profit-summary-tbl tbody tr.pst-total-row td {
      font-size: 0.93rem;
    }

    .profit-summary-tbl tbody tr.pst-net-row {
      background: linear-gradient(135deg, rgba(16, 185, 129, 0.08) 0%, rgba(30, 94, 138, 0.05) 100%);
      border-top: 2px solid #10b981;
    }

    .profit-summary-tbl tbody tr.pst-net-row td {
      padding: 14px;
    }

    @media (max-width: 700px) {
      .profit-summary-table-wrap {
        margin-top: 0;
      }

      .profit-summary-tbl {
        min-width: 720px;
        font-size: 0.82rem;
      }

      .profit-summary-tbl tbody td {
        padding: 9px 10px;
      }
    }

    @media (max-width: 700px) {

      #page-customers .table-wrap,
      #page-treasury .table-wrap {
        overflow-x: visible;
      }

      #page-treasury .stats-grid,
      #page-profits .stats-grid {
        grid-template-columns: 1fr 1fr !important;
      }

      #page-customers .page-actions {
        width: 100%;
      }

      #page-customers .page-actions .btn {
        width: 100%;
        justify-content: center;
      }

      #page-customers .search-bar {
        width: 100%;
        max-width: 100%;
      }

      #page-customers .table-actions {
        width: 100%;
        justify-content: flex-start;
      }

      #page-customers .table-actions .btn {
        min-width: 36px;
      }

      #page-customers tbody td {
        align-items: flex-start;
      }

      #page-customers tbody td::before {
        min-width: 96px;
        flex-shrink: 0;
      }

      #page-profits .card-body {
        padding: 16px;
      }
    }

    @media (max-width: 480px) {

      #page-treasury .stats-grid,
      #page-profits .stats-grid {
        grid-template-columns: 1fr !important;
      }
    }

    /* ===== ERP TABLE MODE (GLOBAL) ===== */
    @media (max-width: 700px) {
      .table-wrap {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
      }

      .table-wrap table,
      .inv-items-table table {
        width: max-content;
        min-width: 100%;
      }

      .table-wrap th,
      .table-wrap td,
      .inv-items-table th,
      .inv-items-table td {
        white-space: nowrap;
        padding: 10px 12px;
        font-size: 0.82rem;
      }

      .table-actions {
        flex-wrap: nowrap;
        gap: 6px;
      }

      .table-actions .btn {
        white-space: nowrap;
      }

      .page-actions {
        width: 100%;
      }

      .page-actions .btn {
        width: 100%;
        justify-content: center;
      }

      .search-bar {
        width: 100%;
        max-width: 100%;
      }

      #page-customers table {
        min-width: 860px !important;
      }

      #page-invoices table {
        min-width: 920px !important;
      }

      #page-products table {
        min-width: 1080px !important;
      }

      #page-treasury table {
        min-width: 860px !important;
      }

      #page-receipts table {
        min-width: 860px !important;
      }

      #page-payments table {
        min-width: 860px !important;
      }

      #page-expenses table {
        min-width: 860px !important;
      }

      #page-revenues table {
        min-width: 860px !important;
      }

      #page-invoicesCenter table {
        min-width: 920px !important;
      }

      #page-treasury .stats-grid,
      #page-profits .stats-grid,
      #page-revenues .stats-grid,
      #page-expenses .stats-grid,
      #page-invoicesCenter .stats-grid {
        grid-template-columns: 1fr 1fr !important;
      }
    }

    @media (max-width: 480px) {

      #page-treasury .stats-grid,
      #page-profits .stats-grid,
      #page-revenues .stats-grid,
      #page-expenses .stats-grid,
      #page-invoicesCenter .stats-grid {
        grid-template-columns: 1fr !important;
      }

      .table-wrap th,
      .table-wrap td,
      .inv-items-table th,
      .inv-items-table td {
        padding: 9px 10px;
        font-size: 0.8rem;
      }
    }


    /* ===== APP LOADER ===== */
    #app-loader {
      position: fixed;
      inset: 0;
      display: flex;
      align-items: center;
      justify-content: center;
      background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 50%, #0f172a 100%);
      z-index: 5000;
    }

    #app-loader.hidden {
      display: none;
    }

    .loader-card {
      width: min(420px, 92vw);
      padding: 34px 28px;
      border-radius: 24px;
      background: rgba(255, 255, 255, 0.08);
      border: 1px solid rgba(255, 255, 255, 0.12);
      backdrop-filter: blur(18px);
      box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
      text-align: center;
      color: white;
    }

    .loader-card .icon {
      width: 72px;
      height: 72px;
      margin: 0 auto 16px;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      border-radius: 22px;
      background: linear-gradient(135deg, #1E5E8A, #1AA37A);
      box-shadow: 0 12px 30px rgba(30, 94, 138, 0.35);
      font-size: 30px;
    }

    .loader-card h2 {
      font-size: 1.25rem;
      margin-bottom: 8px;
    }

    .loader-card p {
      color: rgba(255, 255, 255, 0.72);
      font-size: .92rem;
    }

    .loader-bar {
      margin-top: 18px;
      height: 8px;
      border-radius: 999px;
      background: rgba(255, 255, 255, 0.12);
      overflow: hidden;
    }

    .loader-bar span {
      display: block;
      height: 100%;
      width: 35%;
      border-radius: inherit;
      background: linear-gradient(90deg, #60a5fa, #38bdf8);
      animation: loaderMove 1.1s ease-in-out infinite;
    }

    @keyframes loaderMove {
      0% {
        transform: translateX(170%);
      }

      100% {
        transform: translateX(-220%);
      }
    }

    .sidebar-title {
      display: flex;
      align-items: center;
      min-width: 0;
    }

    .sidebar-title #sb-company {
      display: block;
      font-size: 1rem;
      color: #1e293b;
      font-weight: 800;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    #page-account .account-grid {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 16px;
    }

    #page-account .profile-header {
      min-height: 140px;
      flex-wrap: wrap;
    }

    /* جداول بيانات المستخدم والشركة في صفحة حسابي */
    #page-account .card-body table {
      min-width: unset;
      width: 100%;
    }

    #page-account .card-body table td {
      word-break: break-word;
    }

    .category-pill {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      padding: 5px 13px;
      border-radius: 999px;
      background: var(--surface2);
      color: var(--text-muted);
      font-size: .78rem;
      font-weight: 600;
      border: 1px solid var(--border);
      cursor: pointer;
      transition: all .18s;
    }

    .category-pill:hover {
      background: var(--primary-light);
      color: var(--primary);
      border-color: var(--primary);
    }

    .category-pill.active {
      background: var(--primary);
      color: #fff;
      border-color: var(--primary);
    }

    .pos-page-btn {
      min-width: 32px;
      height: 32px;
      padding: 0 8px;
      border-radius: 8px;
      border: 1px solid var(--border);
      background: var(--surface2);
      color: var(--text);
      font-family: var(--font);
      font-size: .82rem;
      font-weight: 700;
      cursor: pointer;
      transition: all .15s;
      display: inline-flex;
      align-items: center;
      justify-content: center;
    }

    .pos-page-btn:hover:not(:disabled) {
      background: var(--primary-light);
      color: var(--primary);
      border-color: var(--primary);
    }

    .pos-page-btn.active {
      background: var(--primary);
      color: #fff;
      border-color: var(--primary);
    }

    .pos-page-btn:disabled {
      opacity: .4;
      cursor: not-allowed;
    }

    .field input[type="checkbox"],
    .field input[type="radio"],
    input[type="checkbox"],
    input[type="radio"] {
      appearance: none;
      -webkit-appearance: none;
      width: 18px;
      height: 18px;
      border: 2px solid var(--border);
      background: var(--surface);
      border-radius: 6px;
      position: relative;
      cursor: pointer;
      transition: all .2s ease;
      vertical-align: middle;
    }

    input[type="radio"] {
      border-radius: 50%;
    }

    input[type="checkbox"],
    input[type="radio"] {
      accent-color: var(--primary);
    }

    .field input[type="checkbox"]:checked,
    .field input[type="radio"]:checked,
    input[type="checkbox"]:checked,
    input[type="radio"]:checked {
      border-color: var(--primary);
      background: var(--primary);
    }

    input[type="checkbox"]:checked::after {
      content: '\f00c';
      font-family: 'Font Awesome 6 Free';
      font-weight: 900;
      color: #fff;
      font-size: 10px;
      position: absolute;
      inset: 0;
      display: flex;
      align-items: center;
      justify-content: center;
    }

    input[type="radio"]:checked::after {
      content: '';
      width: 8px;
      height: 8px;
      border-radius: 50%;
      background: #fff;
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
    }

    @media (max-width: 900px) {

      #page-account .account-grid {
        grid-template-columns: 1fr;
      }
    }

    @media (max-width: 700px) {
      #page-account .profile-header {
        flex-direction: column;
        align-items: flex-start;
        padding: 20px;
        gap: 14px;
      }

      #page-account .profile-avatar {
        width: 64px;
        height: 64px;
        font-size: 1.6rem;
      }

      #page-account .profile-info h2 {
        font-size: 1.1rem;
      }

      #page-account table td {
        display: block;
        width: 100%;
      }

    }

    @media (max-width: 520px) {
      #page-account .card-body {
        padding: 14px;
      }

      #page-account .card-body table td:first-child {
        padding-bottom: 2px;
        border-bottom: none;
        font-size: .8rem;
      }

      #page-account .card-body table td:last-child {
        padding-top: 2px;
        padding-bottom: 10px;
      }

      #page-account .profile-header {
        padding: 16px;
      }

    }


    .loader-orbit {
      width: 96px;
      height: 96px;
      margin: 0 auto 18px;
      position: relative;
    }

    .loader-orbit::before,
    .loader-orbit::after {
      content: '';
      position: absolute;
      inset: 0;
      border-radius: 50%;
      border: 4px solid transparent;
    }

    .loader-orbit::before {
      border-top-color: #60a5fa;
      border-right-color: #38bdf8;
      animation: spin 1s linear infinite;
      box-shadow: 0 0 28px rgba(56, 189, 248, .22);
    }

    .loader-orbit::after {
      inset: 14px;
      border-bottom-color: rgba(255, 255, 255, .9);
      border-left-color: rgba(255, 255, 255, .55);
      animation: spinReverse 1.2s linear infinite;
    }

    .loader-core {
      position: absolute;
      inset: 28px;
      border-radius: 50%;
      display: grid;
      place-items: center;
      background: rgba(255, 255, 255, .08);
      backdrop-filter: blur(14px);
      font-size: 22px;
      color: #fff;
      box-shadow: inset 0 0 22px rgba(255, 255, 255, .08);
    }

    .loader-dots {
      display: inline-flex;
      gap: 6px;
      margin-top: 8px;
    }

    .loader-dots span {
      width: 8px;
      height: 8px;
      border-radius: 50%;
      background: rgba(255, 255, 255, .9);
      animation: loaderDot 1s infinite ease-in-out;
    }

    .loader-dots span:nth-child(2) {
      animation-delay: .12s;
    }

    .loader-dots span:nth-child(3) {
      animation-delay: .24s;
    }

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

    @keyframes loaderDot {

      0%,
      80%,
      100% {
        transform: scale(.55);
        opacity: .45;
      }

      40% {
        transform: scale(1);
        opacity: 1;
      }
    }

    /* ===== PRINT SETTINGS PAGE ===== */
    .settings-hero {
      background: var(--surface);
      border: 1px solid var(--border);
      color: var(--text);
      border-radius: 18px;
      padding: 22px;
      margin-bottom: 18px;
      box-shadow: var(--shadow-lg);
    }

    .settings-hero h2 {
      color: var(--primary);
    }

    .settings-hero p {
      color: var(--text-muted);
      margin-top: 8px;
      line-height: 1.8;
    }

    /* ===== صفحة "اختصاراتي" ===== */
    .shortcuts-hero {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 14px;
      flex-wrap: wrap;
      background: linear-gradient(135deg, rgba(30, 94, 138, .08) 0%, rgba(16, 185, 129, .06) 100%);
      border: 1px solid var(--border);
      border-radius: 18px;
      padding: 20px 22px;
      margin-bottom: 22px;
    }

    .shortcuts-hero h2 {
      font-size: 1.2rem;
      font-weight: 800;
      color: var(--primary);
      display: flex;
      align-items: center;
      gap: 8px;
    }

    .shortcuts-hero p {
      color: var(--text-muted);
      font-size: .85rem;
      margin-top: 6px;
    }

    .shortcuts-customize-btn {
      white-space: nowrap;
    }

    .shortcuts-grid {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
      gap: 14px;
    }

    .shortcut-card {
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 16px;
      padding: 20px 12px;
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 12px;
      cursor: pointer;
      text-align: center;
      transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
      user-select: none;
    }

    .shortcut-card:hover {
      transform: translateY(-4px);
      box-shadow: var(--shadow-lg);
      border-color: var(--shortcut-color, var(--primary));
    }

    .shortcut-card:active {
      transform: translateY(-1px) scale(.98);
    }

    .shortcut-icon {
      width: 52px;
      height: 52px;
      border-radius: 14px;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 1.3rem;
      color: #fff;
      background: var(--shortcut-color, var(--primary));
      box-shadow: 0 6px 16px -4px var(--shortcut-color, var(--primary));
    }

    .shortcut-label {
      font-size: .84rem;
      font-weight: 700;
      color: var(--text);
      line-height: 1.4;
    }

    @media (max-width: 600px) {
      .shortcuts-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
      }

      .shortcut-card {
        padding: 18px 10px;
        gap: 10px;
      }

      .shortcut-icon {
        width: 48px;
        height: 48px;
        font-size: 1.15rem;
      }

      .shortcut-label {
        font-size: .82rem;
      }
    }

    /* ===== مودال تخصيص الاختصارات ===== */
    .shortcuts-customizer-list {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
      gap: 8px;
      max-height: 55vh;
      overflow-y: auto;
      padding: 4px;
    }

    .shortcut-toggle-item {
      display: flex;
      align-items: center;
      gap: 10px;
      padding: 10px 12px;
      border: 1.5px solid var(--border);
      border-radius: 10px;
      cursor: pointer;
      transition: border-color .15s, background .15s;
    }

    .shortcut-toggle-item:hover {
      border-color: var(--primary);
    }

    .shortcut-toggle-item.active {
      border-color: var(--shortcut-color, var(--primary));
      background: color-mix(in srgb, var(--shortcut-color, var(--primary)) 8%, transparent);
    }

    .shortcut-toggle-item input[type="checkbox"] {
      width: 18px;
      height: 18px;
      accent-color: var(--shortcut-color, var(--primary));
      flex-shrink: 0;
    }

    .shortcut-toggle-icon {
      width: 30px;
      height: 30px;
      border-radius: 8px;
      display: flex;
      align-items: center;
      justify-content: center;
      color: #fff;
      background: var(--shortcut-color, var(--primary));
      font-size: .85rem;
      flex-shrink: 0;
    }

    .shortcut-toggle-label {
      font-size: .82rem;
      font-weight: 700;
      color: var(--text);
    }

    .print-setting-option {
      border: 1px solid var(--border);
      background: var(--surface2);
      border-radius: 14px;
      padding: 14px;
      display: grid;
      gap: 8px;
    }

    .print-setting-option strong {
      color: var(--text);
    }

    .print-setting-option small {
      color: var(--text-muted);
      line-height: 1.7;
    }

    @media(max-width:900px) {

      .settings-bottom-grid {
        grid-template-columns: 1fr !important;
      }
    }

    /* ===== THERMAL RECEIPT ONLY ===== */

    /* ===== إيصال حراري احترافي - نسخة محسّنة 2.1 ===== */
    .thermal-receipt {
      font-family: 'Courier New', Courier, 'Cairo', monospace;
      direction: rtl;
      background: #fff;
      color: #000;
      font-weight: 700;
      width: 80mm;
      max-width: 80mm;
      margin: 0 auto;
      padding: 5mm 3mm 4mm;
      /* تقليل padding السفلي لمنع المساحة الزائدة */
      font-size: 11px;
      line-height: 1.55;
      overflow: visible;
      /* ✅ منع القطع */
      box-sizing: border-box;
    }

    .thermal-receipt.size-58 {
      width: 58mm;
      max-width: 58mm;
      font-size: 9.5px;
      padding: 4mm 2mm 3mm;
    }

    .th-logo {
      display: block;
      max-width: 60px;
      max-height: 60px;
      margin: 0 auto 4px;
    }

    .thermal-receipt .th-store-name {
      text-align: center;
      font-size: 15px;
      font-weight: 900;
      letter-spacing: 0.5px;
      margin-bottom: 2px;
      color: #000;
    }

    .thermal-receipt .th-store-sub {
      text-align: center;
      font-size: 9.5px;
      color: #000;
      margin-bottom: 1px;
    }

    .thermal-receipt .th-branch-name {
      text-align: center;
      font-size: 11px;
      font-weight: 700;
      color: #000;
      margin-bottom: 3px;
    }

    .thermal-receipt .th-divider-thick {
      border: none;
      border-top: 2px solid #000;
      margin: 5px 0;
    }

    .thermal-receipt .th-divider-dash {
      border: none;
      border-top: 1px dashed #000;
      margin: 4px 0;
    }

    .thermal-receipt .th-divider-thin {
      border: none;
      border-top: 1px solid #000;
      margin: 3px 0;
    }

    .thermal-receipt .th-row {
      display: flex;
      justify-content: space-between;
      align-items: flex-start;
      margin: 2px 0;
    }

    .thermal-receipt .th-row .th-label {
      flex: 1;
    }

    .thermal-receipt .th-row .th-val {
      flex-shrink: 0;
      font-weight: 700;
      white-space: nowrap;
      margin-right: 6px;
    }

    .thermal-receipt .th-receipt-num {
      text-align: center;
      font-size: 11px;
      font-weight: 800;
      margin: 3px 0;
      color: #000;
    }

    .thermal-receipt .th-datetime {
      text-align: center;
      font-size: 9px;
      color: #000;
      margin-bottom: 2px;
    }

    .thermal-receipt .th-extra-copy-badge {
      text-align: center;
      font-size: 11px;
      font-weight: 800;
      border: 1.5px dashed #000;
      border-radius: 4px;
      padding: 2px 6px;
      margin: 4px auto 6px;
      display: inline-block;
      letter-spacing: .5px;
    }

    .thermal-receipt .th-cashier {
      text-align: center;
      font-size: 9.5px;
      margin-bottom: 2px;
      color: #000;
    }

    .thermal-receipt .th-customer-section {
      font-size: 9.5px;
      margin: 3px 0;
      color: #000;
    }

    .thermal-receipt .th-items-header {
      display: grid;
      grid-template-columns: 1fr 28px 40px 42px;
      gap: 2px;
      font-weight: 900;
      font-size: 9.5px;
      padding: 2px 0;
      color: #000;
    }

    .thermal-receipt .th-item-row {
      display: grid;
      grid-template-columns: 1fr 28px 40px 42px;
      gap: 2px;
      font-size: 9.5px;
      padding: 2px 0;
      border-bottom: 1px dotted #000;
      color: #000;
    }

    .thermal-receipt .th-item-row:last-child {
      border-bottom: none;
    }

    .thermal-receipt .th-item-name {
      font-weight: 800;
      word-break: break-word;
      color: #000;
    }

    .thermal-receipt .th-col-c {
      text-align: center;
    }

    .thermal-receipt .th-col-r {
      text-align: left;
    }

    .thermal-receipt .th-discount-row {
      font-size: 9px;
      color: #000;
      padding: 1px 0;
      display: grid;
      grid-template-columns: 1fr 42px;
      gap: 2px;
    }

    .thermal-receipt .th-totals-section {
      margin-top: 3px;
    }

    .thermal-receipt .th-totals-row {
      display: flex;
      justify-content: space-between;
      font-size: 10px;
      padding: 2px 0;
      color: #000;
    }

    .thermal-receipt .th-totals-row.th-grand {
      font-size: 13px;
      font-weight: 900;
      padding: 4px 0;
      color: #000;
    }

    .thermal-receipt .th-totals-row.th-paid {
      color: #000;
      font-weight: 700;
    }

    .thermal-receipt .th-totals-row.th-change {
      color: #000;
      font-weight: 800;
    }

    .thermal-receipt .th-totals-row.th-due {
      color: #000;
      font-weight: 800;
    }

    .thermal-receipt .th-totals-row.th-prev {
      font-size: 9.5px;
      color: #000;
    }

    .thermal-receipt .th-footer-msg {
      text-align: center;
      font-size: 9.5px;
      margin: 3px 0 2px;
      color: #000;
    }

    .thermal-receipt .th-items-count {
      text-align: center;
      font-size: 9px;
      color: #000;
    }

    .thermal-receipt .th-barcode-wrap {
      text-align: center;
      margin: 6px 0 2px;
    }

    .thermal-receipt .th-barcode-wrap svg {
      max-width: 100%;
      height: auto;
    }

    .thermal-receipt .th-barcode-number {
      font-family: monospace;
      font-size: 10px;
      letter-spacing: 1px;
      color: #000;
      margin-top: 1px;
    }

    /* ===== POS Save UX Guard ===== */
    #pos-complete-btn:disabled,
    .btn.pos-saving:disabled {
      opacity: .72;
      cursor: not-allowed;
      filter: grayscale(.1);
    }

    .pos-save-spinner {
      width: 16px;
      height: 16px;
      border: 2px solid rgba(255, 255, 255, .45);
      border-top-color: #fff;
      border-radius: 50%;
      animation: spin .7s linear infinite;
      display: inline-block;
    }


    /* ===================================================
   📱 MOBILE RESPONSIVE — COMPREHENSIVE PATCH
   =================================================== */

    /* --- Touch targets minimum 44px --- */
    @media (max-width: 900px) {

      .btn,
      .btn-icon,
      .nav-item {
        min-height: 44px;
      }

      .btn-sm {
        min-height: 38px;
      }

      .btn-xs {
        min-height: 34px;
      }
    }

    /* ---- SIDEBAR: slide-over on mobile ---- */
    @media (max-width: 900px) {
      .sidebar {
        width: 215px;
        transform: translateX(100%);
        box-shadow: none;
        transition: transform 0.28s cubic-bezier(.4, 0, .2, 1), box-shadow 0.28s;
      }

      .sidebar.open {
        transform: translateX(0);
        box-shadow: -8px 0 40px rgba(0, 0, 0, 0.35);
      }

      .main {
        margin-right: 0 !important;
      }

      /* Topbar menu toggle visible */
      .menu-toggle {
        display: flex !important;
      }
    }

    /* ---- TOPBAR on small screens ---- */
    @media (max-width: 900px) {
      .topbar {
        position: fixed;
        top: 30px;
        right: 0;
        left: 0;
        width: 100%;
        z-index: 150;
        background: var(--surface);
        will-change: transform;
      }

      .main {
        margin-top: 0;
        padding-top: 102px;
      }
    }

    @media (max-width: 600px) {
      .topbar {
        padding: 0 12px;
        height: 56px;
        gap: 8px;
      }

      .main {
        padding-top: 102px;
      }

      .topbar-title {
        font-size: 0.95rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        flex: 1;
        min-width: 0;
      }

      .topbar-actions {
        gap: 4px;
        flex-shrink: 0;
      }

      .topbar-actions .btn-icon {
        width: 36px;
        height: 36px;
        font-size: 0.85rem;
      }

      /* إخفاء أزرار الاختصارات على الموبيل */
      .desktop-shortcut {
        display: none !important;
      }
    }

    /* ===== أزرار F-key تظهر فقط في صفحة POS على الديسكتوب ===== */
    .pos-shortcut-btn {
      display: none !important;
    }

    body[data-page="pos"] .pos-shortcut-btn {
      display: inline-flex !important;
    }

    /* إخفاء أزرار F-key على الموبايل حتى في صفحة POS */
    @media (max-width: 900px) {
      body[data-page="pos"] .pos-shortcut-btn {
        display: none !important;
      }
    }

    /* كارت التاريخ يظهر دايماً على الديسكتوب */
    .date-card-topbar {
      display: flex !important;
    }

    @media (max-width: 900px) {
      .date-card-topbar {
        display: none !important;
      }
    }

    /* ===== شريط الإشعارات المتحرك (ticker) — فى لوحة التحكم، بعرض كامل، بدون
       أيقونة جرس ===== */
    .dashboard-notif-ticker {
      display: flex;
      align-items: center;
      background: var(--surface2);
      border: 1px solid var(--border);
      border-radius: 10px;
      padding: 0 14px;
      height: 38px;
      overflow: hidden;
      margin-bottom: 16px;
    }

    .dashboard-notif-ticker.has-danger {
      border-color: var(--danger);
    }

    .dashboard-notif-ticker-track {
      flex: 1;
      height: 100%;
      overflow: hidden;
      position: relative;
      display: flex;
      align-items: center;
      white-space: nowrap;
    }

    .dashboard-notif-ticker-content {
      display: inline-block;
      white-space: nowrap;
      font-size: 0.85rem;
      font-weight: 700;
      color: var(--text);
      animation: dashboard-notif-ticker-scroll 18s linear infinite;
    }

    .dashboard-notif-ticker.empty .dashboard-notif-ticker-content {
      animation: none;
      color: var(--text-muted);
      font-weight: 500;
    }

    @keyframes dashboard-notif-ticker-scroll {
      0% {
        transform: translateX(100%);
      }

      100% {
        transform: translateX(-100%);
      }
    }

    /* ===== فلتر التصنيفات والوحدات في المنتجات — full width على الموبايل ===== */
    @media (max-width: 768px) {
      #page-products .page-header-left {
        width: 100% !important;
        flex-direction: row !important;
      }

      #prod-category-filter,
      #prod-unit-filter {
        width: 100% !important;
        min-width: unset !important;
        flex: 1 1 100% !important;
      }

      /* حقل البحث وزر الكاميرا يشاركوا نفس الصف بدل ما البحث ياخد العرض كامل لوحده */
      #page-products .page-header-left .search-bar {
        flex: 1 1 auto !important;
        width: auto !important;
        min-width: 0 !important;
      }

      #page-products .page-header-left .mobile-camera-btn {
        flex: 0 0 auto !important;
      }
    }

    /* ---- CONTENT PADDING ---- */
    @media (max-width: 600px) {
      .content {
        padding: 12px;
      }
    }

    @media (max-width: 400px) {
      .content {
        padding: 8px;
      }
    }

    /* ---- PAGE HEADER ---- */
    @media (max-width: 700px) {
      .page-header {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        margin-bottom: 14px;
      }

      .page-header-left {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
      }

      .page-actions {
        flex-direction: column;
        gap: 8px;
        width: 100%;
      }

      .page-actions .btn {
        width: 100%;
        justify-content: center;
        min-height: 44px;
      }

      .search-bar {
        max-width: 100%;
        width: 100%;
      }
    }

    /* ---- STATS GRID ---- */
    @media (max-width: 700px) {
      .stats-grid {
        grid-template-columns: 1fr 1fr !important;
        gap: 10px;
      }

      .stat-card {
        padding: 14px 12px;
        gap: 10px;
      }

      .stat-icon {
        width: 44px;
        height: 44px;
        font-size: 1.1rem;
      }

      .stat-value {
        font-size: 1.15rem;
      }

      .stat-label {
        font-size: 0.76rem;
      }
    }

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

    /* ---- CARD HEADER wrap on small screens ---- */
    @media (max-width: 600px) {
      .card-header {
        flex-wrap: wrap;
        gap: 8px;
        padding: 12px 14px;
      }

      .card-body {
        padding: 14px;
      }
    }

    /* ---- FORM ROWS ---- */
    @media (max-width: 700px) {

      .form-row.cols-2,
      .form-row.cols-3,
      .form-row.cols-4 {
        grid-template-columns: 1fr !important;
      }

      .form-row.activity-action-row {
        grid-template-columns: 1fr 1fr !important;
      }

      .form-row.activity-action-row select,
      .form-row.activity-action-row .btn {
        height: 44px;
        min-height: 44px;
        padding-top: 0;
        padding-bottom: 0;
      }

      .form-row.activity-action-row .btn {
        padding-inline: 8px;
        font-size: 0.78rem;
        display: flex;
        align-items: center;
        justify-content: center;
      }

      .field input:not([type="checkbox"]):not([type="radio"]),
      .field select,
      .field textarea {
        min-height: 44px;
        font-size: 16px;
        /* prevents iOS zoom */
      }
    }

    /* ---- MODAL ---- */
    @media (max-width: 600px) {
      .modal-backdrop {
        padding: 0;
        align-items: flex-end;
        /* الـ backdrop نفسه لا يسكرول — الـ modal-body هو اللي بيسكرول */
        overflow: hidden;
      }

      .modal,
      .modal.modal-lg,
      .modal.modal-xl {
        max-width: 100% !important;
        width: 100%;
        border-radius: 20px 20px 0 0;
        /* ★ إصلاح: كانت max-height: 92vh قبل كده — مع مودالات طويلة المحتوى (زي تخصيص
        الاختصارات) وترتيب flex-end (المودال ملتصق بأسفل الشاشة وبينمو لفوق)، كانت
        بتوصل لحد قريب جدًا من أعلى الشاشة، وتدخل تحت شريط "Powered by EasyPOS" الثابت
        (ارتفاعه 30px، وz-index بتاعه أعلى حاجة ممكنة فعليًا، فبيغطي أي حاجة تحته).
        الحساب الصريح ده بيضمن مسافة أمان ثابتة (30px + 16px هامش) بغض النظر عن ارتفاع
        الشاشة، بدل نسبة مئوية تقريبية ممكن تختلف من جهاز لجهاز. */
        max-height: calc(100vh - 46px);
        /* flex column عشان header/footer ثابتين والـ body يسكرول */
        display: flex !important;
        flex-direction: column !important;
        overflow: hidden !important;
      }

      .modal-header {
        padding: 14px 16px 12px;
        flex-shrink: 0 !important;
      }

      .modal-body {
        padding: 16px;
        /* السكرول بيحصل هنا بس */
        flex: 1 1 auto !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        min-height: 0 !important;
        -webkit-overflow-scrolling: touch !important;
        overscroll-behavior: contain !important;
        touch-action: pan-y !important;
      }

      .modal-footer {
        padding: 12px 16px;
        flex-direction: column;
        gap: 8px;
        flex-shrink: 0 !important;
      }

      .modal-footer .btn {
        width: 100%;
        justify-content: center;
        min-height: 44px;
      }
    }

    /* ---- TOAST container ---- */
    @media (max-width: 600px) {
      #toast-container {
        bottom: 80px;
        left: 10px;
        right: 10px;
      }

      .toast {
        max-width: 100%;
        min-width: unset;
        width: 100%;
        font-size: 0.85rem;
      }
    }

    /* ---- TABLE wrapping ---- */
    @media (max-width: 700px) {
      .table-wrap {
        border-radius: var(--radius-sm);
        -webkit-overflow-scrolling: touch;
        overflow-x: auto;
      }

      table {
        min-width: 600px;
      }

      th,
      td {
        padding: 10px 12px;
        font-size: 0.83rem;
        white-space: nowrap;
      }
    }

    /* ---- INVOICE PRINT — mobile ---- */
    @media (max-width: 700px) {
      .invoice-print {
        padding: 20px 16px;
      }

      .invoice-print .inv-header {
        flex-direction: column;
        gap: 12px;
      }

      .invoice-print .inv-meta {
        text-align: right;
        min-width: unset;
        width: 100%;
      }
    }

    /* ---- REPORT GRID ---- */
    @media (max-width: 700px) {
      .report-grid {
        grid-template-columns: 1fr !important;
      }
    }

    /* =========================================
   📱 POS PAGE — MOBILE LAYOUT
   ========================================= */

    /* On screens ≤ 900px: stack columns */
    @media (max-width: 900px) {
      .pos-grid {
        grid-template-columns: 1fr !important;
        gap: 12px;
      }

      #pos-products-grid {
        max-height: 48vh !important;
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)) !important;
        gap: 8px !important;
      }
    }

    /* On screens ≤ 700px: full mobile POS experience */
    @media (max-width: 700px) {

      /* Give space for FAB at bottom */
      #page-pos {
        padding-bottom: 90px !important;
      }

      /* POS top search bar full width */
      #page-pos .card-header {
        flex-wrap: wrap;
        gap: 8px;
      }

      #page-pos #pos-barcode-input,
      #page-pos #pos-search {
        font-size: 16px;
        /* prevent iOS zoom */
        min-height: 44px;
      }

      /* Products grid: 2 columns on phone */
      #pos-products-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        max-height: 52vh !important;
        gap: 8px !important;
      }

      /* Product cards: more compact */
      .pos-product-card {
        padding: 12px 10px !important;
        gap: 5px !important;
        min-height: 100px !important;
      }

      .pos-product-name {
        font-size: 0.82rem !important;
      }

      .pos-product-meta {
        font-size: 0.7rem !important;
        flex-wrap: wrap !important;
      }

      /* Hide desktop cart panel on phone (FAB shows it) */
      .pos-cart-panel {
        display: none !important;
      }

      /* FAB cart button: hidden — replaced by topbar cart icon */
      .pos-mobile-cart-fab {
        display: none !important;
      }

      /* Mobile cart sheet: full bottom sheet */
      .pos-mobile-cart-sheet {
        display: flex;
        transform: translateY(105%);
      }

      .pos-mobile-cart-sheet.open {
        transform: translateY(0) !important;
      }
    }

    /* Even smaller phones: 1 column products */
    @media (max-width: 400px) {

      #pos-products-grid {
        grid-template-columns: 1fr 1fr !important;
        gap: 6px !important;
      }

      .pos-product-card {
        padding: 8px !important;
      }

      .pos-product-name {
        font-size: 0.8rem !important;
      }
    }

    /* ---- Fullscreen mode: topbar stays on top, content flows correctly ---- */
    /* ملحوظة: right محدد بعرض السيدبار (215px/72px) بدل 0، عشان التوبار ما يمتدش تحت
       السيدبار (اللي عنده z-index أعلى) ويغطي زر الهامبورجر ويخفيه بصريًا */
    :fullscreen .topbar,
    :-webkit-full-screen .topbar {
      position: fixed !important;
      top: 30px;
      left: 0;
      right: 215px;
      z-index: 2147483640 !important;
    }

    :fullscreen .main.sidebar-collapsed .topbar,
    :-webkit-full-screen .main.sidebar-collapsed .topbar {
      right: 60px;
    }

    :fullscreen .sidebar,
    :-webkit-full-screen .sidebar {
      position: fixed !important;
      top: 30px !important;
      right: 0 !important;
      bottom: 0 !important;
      z-index: 2147483647 !important;
    }

    :fullscreen #sidebar-overlay,
    :-webkit-full-screen #sidebar-overlay {
      position: fixed !important;
      z-index: 2147483646 !important;
    }

    :fullscreen .main,
    :-webkit-full-screen .main {
      margin-right: 215px;
      margin-top: 0 !important;
      padding-top: 94px !important;
      min-height: 100vh;
      box-sizing: border-box;
    }

    :fullscreen .main.sidebar-collapsed,
    :-webkit-full-screen .main.sidebar-collapsed {
      margin-right: 60px;
    }

    @media (max-width: 900px) {

      :fullscreen .main,
      :-webkit-full-screen .main {
        margin-right: 0 !important;
        padding-top: 94px !important;
      }

      :fullscreen .topbar,
      :-webkit-full-screen .topbar {
        right: 0 !important;
      }
    }

    /* ---- POS fullscreen improvements on mobile ---- */
    @media (max-width: 600px) {
      .pos-mobile-cart-footer {
        padding-bottom: max(16px, env(safe-area-inset-bottom));
      }

      .pos-mobile-cart-fab {
        bottom: max(16px, env(safe-area-inset-bottom));
        left: 12px;
        right: 12px;
      }
    }

    /* ---- DATE FILTER BAR ---- */
    @media (max-width: 600px) {
      .date-filter-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
      }

      .date-filter-bar input[type="date"],
      .date-filter-bar input[type="text"],
      .date-filter-bar select,
      .date-filter-bar .btn-filter-reset {
        width: 100%;
        min-height: 42px;
        font-size: 16px;
      }

      .date-filter-bar .filter-result {
        margin-right: 0;
      }
    }

    /* ---- ACCOUNT PAGE ---- */
    @media (max-width: 700px) {
      #page-account .account-grid {
        grid-template-columns: 1fr !important;
      }

      #page-account .profile-header {
        flex-direction: column;
        align-items: flex-start;
        padding: 18px;
        gap: 12px;
      }

      #page-account .profile-avatar {
        width: 60px;
        height: 60px;
        font-size: 1.5rem;
      }
    }

    /* ---- Login card on small screens ---- */
    @media (max-width: 480px) {
      .login-card {
        padding: 32px 20px;
        border-radius: 20px;
      }

      .login-logo .icon {
        width: 60px;
        height: 60px;
        font-size: 26px;
      }

      .login-logo h1 {
        font-size: 1.3rem;
      }
    }

    /* ---- Profile header responsive ---- */
    @media (max-width: 500px) {
      .profile-header {
        flex-direction: column;
        padding: 20px;
        gap: 14px;
      }

      .profile-avatar {
        width: 64px;
        height: 64px;
        font-size: 1.6rem;
      }
    }

    /* ---- Fix table-actions wrapping on mobile ---- */
    @media (max-width: 600px) {
      .table-actions {
        gap: 4px;
      }

      .table-actions .btn-sm {
        padding: 6px 10px;
        font-size: 0.78rem;
      }

      .table-actions .btn-xs {
        padding: 5px 8px;
      }
    }

    /* ---- iOS safe area support ---- */
    @supports (padding-bottom: env(safe-area-inset-bottom)) {
      @media (max-width: 900px) {
        .sidebar {
          padding-bottom: env(safe-area-inset-bottom);
        }

        #toast-container {
          bottom: calc(80px + env(safe-area-inset-bottom));
        }
      }
    }

    /* ---- Prevent horizontal overflow globally ---- */
    @media (max-width: 900px) {

      #app,
      .main,
      .content,
      .page {
        max-width: 100vw;
        overflow-x: hidden;
      }
    }

    /* =========================================
   END MOBILE RESPONSIVE PATCH
   ========================================= */


    /* ===== OPERATION LOADER OVERLAY ===== */
    #op-loader-overlay.active {
      display: flex !important;
    }

    [data-theme="dark"] #op-loader-box {
      background: #112240;
      border-color: #1e3a5f;
    }

    @keyframes op-pulse {

      0%,
      100% {
        opacity: 1;
      }

      50% {
        opacity: .55;
      }
    }

    #op-loader-icon {
      animation: op-pulse 1.4s ease-in-out infinite;
    }

    /* ===== FIX: منع بقاء المساحة البيضاء بعد الطباعة ===== */
    html,
    body,
    #app,
    #app.visible,
    .main,
    .content,
    .page.active {
      background: var(--bg) !important;
      background-color: var(--bg) !important;
    }

    [data-theme="dark"] html,
    [data-theme="dark"] body,
    [data-theme="dark"] #app,
    [data-theme="dark"] #app.visible,
    [data-theme="dark"] .main,
    [data-theme="dark"] .content,
    [data-theme="dark"] .page.active {
      background: var(--bg) !important;
      background-color: var(--bg) !important;
    }

    @media print {

      html,
      body,
      #app,
      .main,
      .content,
      .page.active {
        background: white !important;
        background-color: white !important;
      }
    }

    /* ===== FINAL MOBILE DASHBOARD FIX: force 2 cards per row ===== */
    @media (max-width: 768px) {

      #dashboard .stats-grid,
      .page.active#dashboard .stats-grid,
      .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 10px !important;
      }

      #dashboard .dashboard-page-cards,
      .page.active#dashboard .dashboard-page-cards,
      .dashboard-page-cards {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 10px !important;
      }

      #dashboard .stat-card,
      .stat-card,
      #dashboard .dashboard-page-card,
      .dashboard-page-card {
        width: 100% !important;
        min-width: 0 !important;
        box-sizing: border-box !important;
      }

      .dashboard-page-card {
        min-height: 110px !important;
        padding: 0 !important;
      }

      .dashboard-page-card .card-title {
        font-size: .82rem !important;
        line-height: 1.35 !important;
      }

      .stat-card {
        padding: 12px !important;
        gap: 8px !important;
      }

      .stat-icon {
        width: 38px !important;
        height: 38px !important;
        font-size: .95rem !important;
      }

      .stat-value {
        font-size: .95rem !important;
      }

      .stat-label {
        font-size: .68rem !important;
        line-height: 1.35 !important;
      }
    }

    @media (max-width: 380px) {

      #dashboard .stats-grid,
      .stats-grid,
      #dashboard .dashboard-page-cards,
      .dashboard-page-cards {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
      }
    }

    /* ════════════════════════════════════════════════════════════════ */
    /* ===== Professional Desktop Accounting Dashboard Theme ====== */
    /* ════════════════════════════════════════════════════════════════ */

    /* ===== الصفحة العامة ===== */
    #page-dashboard {
      max-width: 1100px;
      margin-left: auto;
      margin-right: auto;
      padding: 4px 0 24px;
    }

    [data-theme="dark"] #page-dashboard

    /* ===== كروت التنقل: شكل احترافي زي برامج الديسكتوب ===== */
    #page-dashboard .dashboard-page-cards {
      grid-template-columns: repeat(4, 1fr) !important;
      gap: 12px !important;
      margin-bottom: 8px !important;
    }

    @media (max-width: 900px) {
      #page-dashboard .dashboard-page-cards {
        grid-template-columns: repeat(3, 1fr) !important;
      }
    }

    @media (max-width: 600px) {
      #page-dashboard .dashboard-page-cards {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
      }
    }

    #page-dashboard .dashboard-page-card {
      position: relative !important;
      overflow: hidden !important;
      min-height: 96px !important;
      padding: 14px 14px 12px !important;
      border-radius: 10px !important;
      border: 1px solid var(--border) !important;
      border-top: 3px solid var(--card-accent, var(--primary)) !important;
      background: var(--surface) !important;
      box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04) !important;
      cursor: pointer !important;
      display: flex !important;
      flex-direction: row !important;
      align-items: center !important;
      justify-content: flex-start !important;
      gap: 12px !important;
      transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease, background .15s ease !important;
    }

    #page-dashboard .dashboard-page-card:hover {
      transform: translateY(-4px) scale(1.02);

      box-shadow:
        0 16px 36px rgba(30, 94, 138, 0.35),
        0 6px 18px rgba(0, 0, 0, 0.12);

      filter: brightness(1.04);
    }

    /* النصوص */
    #page-dashboard .dashboard-page-card>div:last-child {
      position: static !important;
      z-index: auto !important;
      padding: 0 !important;
      background: none !important;
      flex: 1 !important;
      min-width: 0 !important;
    }

    #page-dashboard .dashboard-page-card .card-title {
      font-size: .92rem !important;
      font-weight: 700 !important;
      color: var(--text) !important;
      margin: 0 0 2px !important;
      text-shadow: none !important;
      letter-spacing: 0 !important;
      line-height: 1.3 !important;
      overflow: hidden !important;
      text-overflow: ellipsis !important;
      white-space: nowrap !important;
    }

    /* Dark mode للكروت */
    [data-theme="dark"] #page-dashboard .dashboard-page-card {
      background: var(--surface) !important;
      border-color: var(--border) !important;
      box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3) !important;
    }

    [data-theme="dark"] #page-dashboard .dashboard-page-card:hover {
      transform: translateY(-4px) scale(1.02);

      box-shadow:
        0 16px 36px rgba(30, 94, 138, 0.35),
        0 6px 18px rgba(0, 0, 0, 0.12);

      filter: brightness(1.04);
    }


    /* الموبايل: تخطيط رأسي مرتب */
    @media (max-width: 600px) {
      #page-dashboard .dashboard-page-card {
        flex-direction: column !important;
        align-items: flex-start !important;
        min-height: 100px !important;
        padding: 12px !important;
        gap: 8px !important;
      }

      #page-dashboard .dashboard-page-card .card-title {
        font-size: .85rem !important;
      }
    }

    /* ===== شبكة كروت الميزانية والخزنة ===== */
    #page-dashboard .balance-treasury-grid {
      display: grid !important;
      grid-template-columns: 1fr 1fr !important;
      gap: 14px !important;
      margin: 0 0 18px !important;
    }

    @media (max-width: 768px) {
      #page-dashboard .balance-treasury-grid {
        grid-template-columns: 1fr !important;
        gap: 14px !important;
      }
    }

    #page-dashboard .balance-treasury-grid>#balance-status-card,
    #page-dashboard .balance-treasury-grid>#treasury-status-card {
      position: relative !important;
      overflow: hidden !important;
      margin: 0 !important;
      width: auto !important;
      clear: none !important;
      float: none !important;
      display: block !important;
      height: 100% !important;
      border-radius: 12px !important;
      border: 1px solid var(--border) !important;
      box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05), 0 4px 12px rgba(15, 23, 42, 0.03) !important;
    }

    /* تنسيق داخلي لكارت الميزانية - شكل احترافي زي برامج الحسابات */
    #page-dashboard #balance-status-card .bsc-content,
    #page-dashboard #treasury-status-card .tsc-content {
      padding: 16px 18px !important;
    }

    #page-dashboard #balance-status-card .bsc-header,
    #page-dashboard #treasury-status-card .tsc-header {
      display: flex !important;
      align-items: center !important;
      justify-content: space-between !important;
      margin-bottom: 14px !important;
      padding-bottom: 12px !important;
      border-bottom: 1px solid rgba(255, 255, 255, 0.12) !important;
    }

    #page-dashboard #balance-status-card .bsc-title,
    #page-dashboard #treasury-status-card .tsc-title {
      font-size: 1rem !important;
      font-weight: 800 !important;
      margin: 4px 0 0 !important;
      color: #fff !important;
      letter-spacing: .2px !important;
    }

    #page-dashboard #balance-status-card .bsc-status-badge,
    #page-dashboard #treasury-status-card .tsc-status-badge {
      font-size: .68rem !important;
      font-weight: 600 !important;
      padding: 3px 9px !important;
      border-radius: 6px !important;
      background: rgba(255, 255, 255, 0.18) !important;
      border: 1px solid rgba(255, 255, 255, 0.1) !important;
    }

    #page-dashboard #balance-status-card .bsc-action,
    #page-dashboard #treasury-status-card .tsc-action {
      font-size: .75rem !important;
      font-weight: 600 !important;
      padding: 5px 11px !important;
      border-radius: 6px !important;
      background: rgba(255, 255, 255, 0.12) !important;
      border: 1px solid rgba(255, 255, 255, 0.1) !important;
      transition: background .15s ease !important;
    }

    #page-dashboard #balance-status-card:hover .bsc-action,
    #page-dashboard #treasury-status-card:hover .tsc-action {
      background: rgba(255, 255, 255, 0.22) !important;
    }

    /* شبكة القيم - أكثر إحكاما */
    #page-dashboard #balance-status-card .bsc-grid {
      display: grid !important;
      grid-template-columns: 1fr 1fr !important;
      gap: 8px !important;
    }

    #page-dashboard #balance-status-card .bsc-item-diff {
      grid-column: 1 / -1 !important;
    }

    #page-dashboard #treasury-status-card .tsc-grid {
      display: grid !important;
      grid-template-columns: 1fr 1fr !important;
      gap: 8px !important;
    }

    #page-dashboard #treasury-status-card .tsc-item-main {
      grid-column: 1 / -1 !important;
    }

    #page-dashboard #balance-status-card .bsc-item,
    #page-dashboard #treasury-status-card .tsc-item {
      padding: 9px 11px !important;
      border-radius: 8px !important;
      background: rgba(255, 255, 255, 0.10) !important;
      border: 1px solid rgba(255, 255, 255, 0.08) !important;
    }

    #page-dashboard #treasury-status-card .tsc-item-main {
      background: rgba(255, 255, 255, 0.18) !important;
      padding: 11px 13px !important;
    }

    #page-dashboard #balance-status-card .bsc-item-label,
    #page-dashboard #treasury-status-card .tsc-item-label {
      font-size: .7rem !important;
      font-weight: 500 !important;
      margin-bottom: 4px !important;
      opacity: .92 !important;
      display: flex !important;
      align-items: center !important;
      gap: 5px !important;
    }

    #page-dashboard #balance-status-card .bsc-item-value,
    #page-dashboard #treasury-status-card .tsc-item-value {
      font-size: .95rem !important;
      font-weight: 800 !important;
      letter-spacing: .2px !important;
    }

    #page-dashboard #treasury-status-card .tsc-main-value {
      font-size: 1.15rem !important;
    }

    /* إخفاء الأيقونة الخلفية الكبيرة في الموبايل (مشتتة) */
    @media (max-width: 600px) {

      #page-dashboard #balance-status-card .bsc-bg-icon,
      #page-dashboard #treasury-status-card .tsc-bg-icon {
        opacity: .5 !important;
      }
    }

    /* ===== إخفاء الأيقونات الخلفية الكبيرة في كرتي الميزانية والخزنة ===== */
    #page-dashboard #balance-status-card .bsc-bg-icon,
    #page-dashboard #treasury-status-card .tsc-bg-icon {
      display: none !important;
    }

    /* ===== توحيد لون كرتي الميزانية والخزنة + التكيّف مع الوضع الفاتح/الداكن ===== */
    #page-dashboard #balance-status-card,
    #page-dashboard #balance-status-card.is-balanced,
    #page-dashboard #balance-status-card.is-unbalanced,
    #page-dashboard #treasury-status-card,
    #page-dashboard #treasury-status-card.is-positive,
    #page-dashboard #treasury-status-card.is-negative {
      background: var(--finance-card-grad) !important;
      border: 1px solid var(--finance-card-border) !important;
      box-shadow: var(--finance-card-shadow) !important;
      color: var(--finance-card-text) !important;
      transition: transform .2s ease, box-shadow .2s ease, background .25s ease, border-color .25s ease !important;
    }

    #page-dashboard #balance-status-card:hover,
    #page-dashboard #balance-status-card.is-balanced:hover,
    #page-dashboard #balance-status-card.is-unbalanced:hover,
    #page-dashboard #treasury-status-card:hover,
    #page-dashboard #treasury-status-card.is-positive:hover,
    #page-dashboard #treasury-status-card.is-negative:hover {
      box-shadow: var(--finance-card-shadow-hover) !important;
    }

    /* ===== ألوان النصوص داخل الكارتين (متجاوبة مع الوضع) ===== */
    #page-dashboard #balance-status-card .bsc-title,
    #page-dashboard #treasury-status-card .tsc-title {
      color: var(--finance-card-text) !important;
      text-shadow: var(--finance-card-text-shadow) !important;
    }

    #page-dashboard #balance-status-card .bsc-item-value,
    #page-dashboard #treasury-status-card .tsc-item-value,
    #page-dashboard #treasury-status-card .tsc-main-value {
      color: var(--finance-card-text) !important;
      text-shadow: var(--finance-card-text-shadow) !important;
    }

    #page-dashboard #balance-status-card .bsc-item-label,
    #page-dashboard #treasury-status-card .tsc-item-label {
      color: var(--finance-card-text-muted) !important;
      opacity: 1 !important;
    }

    /* ===== الخانات الداخلية (items) ===== */
    #page-dashboard #balance-status-card .bsc-item,
    #page-dashboard #treasury-status-card .tsc-item {
      background: var(--finance-card-item-bg) !important;
      border: 1px solid var(--finance-card-border) !important;
    }

    #page-dashboard #balance-status-card .bsc-item-diff,
    #page-dashboard #treasury-status-card .tsc-item-main {
      background: var(--finance-card-item-bg-main) !important;
    }

    /* ===== شارات الحالة وأزرار الانتقال ===== */
    #page-dashboard #balance-status-card .bsc-status-badge,
    #page-dashboard #treasury-status-card .tsc-status-badge,
    #page-dashboard #balance-status-card .bsc-action,
    #page-dashboard #treasury-status-card .tsc-action {
      background: var(--finance-card-badge-bg) !important;
      color: var(--finance-card-badge-text) !important;
    }

    #page-dashboard #balance-status-card:hover .bsc-action,
    #page-dashboard #treasury-status-card:hover .tsc-action {
      background: var(--finance-card-item-bg-main) !important;
    }

    /* ===== الأنيميشن اتشال بناءً على طلب المستخدم (كان بيعمل fade-in للكروت) ===== */


    /* ===== RUTO Update: جعل كرتي الميزانية والخزنة مثل كروت الأقسام الرئيسية ===== */
    #page-dashboard .balance-treasury-grid>#balance-status-card,
    #page-dashboard .balance-treasury-grid>#treasury-status-card,
    #page-dashboard #balance-status-card,
    #page-dashboard #balance-status-card.is-balanced,
    #page-dashboard #balance-status-card.is-unbalanced,
    #page-dashboard #treasury-status-card,
    #page-dashboard #treasury-status-card.is-positive,
    #page-dashboard #treasury-status-card.is-negative {
      min-height: 170px !important;
      border-radius: 10px !important;
      border: 1px solid var(--border) !important;
      border-top: 3px solid var(--finance-accent, var(--primary)) !important;
      background: var(--surface) !important;
      color: var(--text) !important;
      box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04) !important;
      transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease, background .15s ease !important;
      filter: none !important;
    }

    #page-dashboard #balance-status-card,
    #page-dashboard #balance-status-card.is-balanced,
    #page-dashboard #balance-status-card.is-unbalanced {
      --finance-accent: #1E5E8A;
      --finance-accent-soft: rgba(30, 94, 138, .10);
    }

    #page-dashboard #treasury-status-card,
    #page-dashboard #treasury-status-card.is-positive,
    #page-dashboard #treasury-status-card.is-negative {
      --finance-accent: #1E5E8A;
      --finance-accent-soft: rgba(30, 94, 138, .10);
    }

    #page-dashboard #balance-status-card:hover,
    #page-dashboard #balance-status-card.is-balanced:hover,
    #page-dashboard #balance-status-card.is-unbalanced:hover,
    #page-dashboard #treasury-status-card:hover,
    #page-dashboard #treasury-status-card.is-positive:hover,
    #page-dashboard #treasury-status-card.is-negative:hover {
      transform: translateY(-1px) !important;
      border-color: var(--finance-accent) !important;
      box-shadow: 0 4px 14px color-mix(in srgb, var(--finance-accent) 18%, transparent),
        0 1px 2px rgba(15, 23, 42, 0.06) !important;
      background: color-mix(in srgb, var(--finance-accent) 3%, var(--surface)) !important;
      filter: none !important;
    }

    #page-dashboard #balance-status-card .bsc-content,
    #page-dashboard #treasury-status-card .tsc-content {
      padding: 14px !important;
      gap: 10px !important;
    }

    #page-dashboard #balance-status-card .bsc-header,
    #page-dashboard #treasury-status-card .tsc-header {
      border-bottom: 1px solid var(--border) !important;
      padding-bottom: 12px !important;
      margin-bottom: 12px !important;
      align-items: center !important;
    }

    #page-dashboard #balance-status-card .bsc-title,
    #page-dashboard #treasury-status-card .tsc-title {
      color: var(--text) !important;
      text-shadow: none !important;
      font-size: .95rem !important;
      font-weight: 800 !important;
      letter-spacing: 0 !important;
    }

    #page-dashboard #balance-status-card .bsc-status-badge,
    #page-dashboard #treasury-status-card .tsc-status-badge,
    #page-dashboard #balance-status-card .bsc-action,
    #page-dashboard #treasury-status-card .tsc-action {
      background: var(--finance-accent-soft) !important;
      color: var(--finance-accent) !important;
      border: 1px solid color-mix(in srgb, var(--finance-accent) 18%, transparent) !important;
      border-radius: 8px !important;
      text-shadow: none !important;
    }

    #page-dashboard #balance-status-card:hover .bsc-action,
    #page-dashboard #treasury-status-card:hover .tsc-action {
      background: var(--finance-accent) !important;
      color: #fff !important;
    }

    #page-dashboard #balance-status-card .bsc-grid,
    #page-dashboard #treasury-status-card .tsc-grid {
      grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
      gap: 8px !important;
    }

    #page-dashboard #balance-status-card .bsc-item,
    #page-dashboard #treasury-status-card .tsc-item,
    #page-dashboard #balance-status-card .bsc-item-diff,
    #page-dashboard #treasury-status-card .tsc-item-main {
      background: color-mix(in srgb, var(--finance-accent) 7%, var(--surface)) !important;
      border: 1px solid color-mix(in srgb, var(--finance-accent) 14%, var(--border)) !important;
      border-radius: 8px !important;
      padding: 10px 11px !important;
    }

    #page-dashboard #balance-status-card .bsc-item-label,
    #page-dashboard #treasury-status-card .tsc-item-label {
      color: var(--text-muted) !important;
      opacity: 1 !important;
      font-weight: 700 !important;
      text-shadow: none !important;
    }

    #page-dashboard #balance-status-card .bsc-item-label i,
    #page-dashboard #treasury-status-card .tsc-item-label i {
      width: 24px !important;
      height: 24px !important;
      min-width: 24px !important;
      display: inline-flex !important;
      align-items: center !important;
      justify-content: center !important;
      border-radius: 7px !important;
      color: var(--item-icon-color, var(--finance-accent)) !important;
      background: color-mix(in srgb, var(--item-icon-color, var(--finance-accent)) 12%, transparent) !important;
      font-size: .78rem !important;
    }

    #page-dashboard #balance-status-card .bsc-item:nth-child(1) {
      --item-icon-color: #1E5E8A;
    }

    #page-dashboard #balance-status-card .bsc-item:nth-child(2) {
      --item-icon-color: #f59e0b;
    }

    #page-dashboard #balance-status-card .bsc-item:nth-child(3) {
      --item-icon-color: #1AA37A;
    }

    #page-dashboard #treasury-status-card .tsc-item:nth-child(1) {
      --item-icon-color: #1E5E8A;
    }

    #page-dashboard #treasury-status-card .tsc-item:nth-child(2) {
      --item-icon-color: #1AA37A;
    }

    #page-dashboard #treasury-status-card .tsc-item:nth-child(3) {
      --item-icon-color: #ef4444;
    }

    #page-dashboard #balance-status-card .bsc-item-value,
    #page-dashboard #treasury-status-card .tsc-item-value,
    #page-dashboard #treasury-status-card .tsc-main-value,
    #page-dashboard #bsc-assets,
    #page-dashboard #bsc-liabequity,
    #page-dashboard #bsc-diff,
    #page-dashboard #tsc-balance,
    #page-dashboard #tsc-inflow,
    #page-dashboard #tsc-outflow {
      color: var(--text) !important;
      text-shadow: none !important;
      font-weight: 800 !important;
    }

    #page-dashboard #balance-status-card .bsc-bg-icon,
    #page-dashboard #treasury-status-card .tsc-bg-icon {
      display: flex !important;
      inset: auto 14px auto auto !important;
      top: 16px !important;
      width: 44px !important;
      height: 44px !important;
      font-size: 1.25rem !important;
      color: var(--finance-accent) !important;
      background: var(--finance-accent-soft) !important;
      border-radius: 8px !important;
      opacity: 1 !important;
      z-index: 3 !important;
    }

    #page-dashboard #balance-status-card .bsc-title-wrap,
    #page-dashboard #treasury-status-card .tsc-title-wrap {
      padding-right: 56px !important;
    }

    [data-theme="dark"] #page-dashboard #balance-status-card,
    [data-theme="dark"] #page-dashboard #balance-status-card.is-balanced,
    [data-theme="dark"] #page-dashboard #balance-status-card.is-unbalanced,
    [data-theme="dark"] #page-dashboard #treasury-status-card,
    [data-theme="dark"] #page-dashboard #treasury-status-card.is-positive,
    [data-theme="dark"] #page-dashboard #treasury-status-card.is-negative {
      background: var(--surface) !important;
      border-color: var(--border) !important;
      box-shadow: 0 1px 2px rgba(0, 0, 0, .30) !important;
    }

    [data-theme="dark"] #page-dashboard #balance-status-card:hover,
    [data-theme="dark"] #page-dashboard #treasury-status-card:hover {
      background: var(--surface2) !important;
      border-color: var(--finance-accent) !important;
      box-shadow: 0 4px 14px rgba(0, 0, 0, .40) !important;
    }

    @media (max-width: 600px) {

      #page-dashboard #balance-status-card .bsc-grid,
      #page-dashboard #treasury-status-card .tsc-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
      }

      #page-dashboard #balance-status-card .bsc-item-diff,
      #page-dashboard #treasury-status-card .tsc-item-main {
        grid-column: 1 / -1 !important;
      }

      #page-dashboard #balance-status-card .bsc-bg-icon,
      #page-dashboard #treasury-status-card .tsc-bg-icon {
        width: 38px !important;
        height: 38px !important;
        font-size: 1.1rem !important;
      }

      #page-dashboard #balance-status-card .bsc-title-wrap,
      #page-dashboard #treasury-status-card .tsc-title-wrap {
        padding-right: 48px !important;
      }
    }

    /* ====================================================== */
    /* ===== تحسينات الأزرار وحقل البحث (CUSTOM ENHANCEMENTS) ===== */
    /* ====================================================== */

    /* ===== Body scroll lock عند فتح المودالات ===== */
    body.modal-open {
      overflow: hidden !important;
      /* touch-action: none أُزيل — كان بيمنع السكرول داخل المودال على الموبايل */
    }

    /* لمنع سكرول العنصر .main / .content الداخلي أيضاً */
    body.modal-open .main,
    body.modal-open .content {
      overflow: hidden !important;
      touch-action: none;
    }

    /* الحفاظ على سكرول داخل المودال نفسه */
    body.modal-open .modal-backdrop.open {
      overflow-y: auto;
      touch-action: auto;
    }

    /* الـ modal-body يسكرول بحرية على الموبايل */
    body.modal-open .modal-backdrop.open .modal-body {
      touch-action: pan-y !important;
      -webkit-overflow-scrolling: touch !important;
      overscroll-behavior: contain !important;
    }

    /* ===== 1) زر التعديل بلون شيك في عمود الإجراءات ===== */
    .table-actions .btn.btn-outline.btn-xs[onclick*="edit"] {
      background: linear-gradient(135deg, #1AA37A 0%, #1E5E8A 100%) !important;
      color: #ffffff !important;
      border: 1px solid transparent !important;
      box-shadow: 0 2px 8px rgba(14, 165, 233, 0.28), 0 1px 2px rgba(37, 99, 235, 0.15) !important;
      transition: all 0.2s ease !important;
    }

    .table-actions .btn.btn-outline.btn-xs[onclick*="edit"]:hover {
      background: linear-gradient(135deg, #0284c7 0%, #1d4ed8 100%) !important;
      transform: translateY(-1px);
      box-shadow: 0 4px 14px rgba(14, 165, 233, 0.40), 0 2px 4px rgba(37, 99, 235, 0.20) !important;
    }

    .table-actions .btn.btn-outline.btn-xs[onclick*="edit"]:active {
      transform: translateY(0);
    }

    /* استبعاد أزرار كشف الحساب (showCustomerStatement / showSupplierStatement) لأنها تحتوي على نص onclick مختلف */
    .table-actions .btn.btn-outline.btn-xs[onclick*="Statement"] {
      background: transparent !important;
      color: var(--primary) !important;
      border: 1px solid var(--primary) !important;
      box-shadow: none !important;
    }

    .table-actions .btn.btn-outline.btn-xs[onclick*="Statement"]:hover {
      background: var(--primary) !important;
      color: #ffffff !important;
      transform: none;
    }

    /* ===== 2) زر "سجل المبيعات" في صفحة نقطة البيع (POS) — أزرق بدون شادو ===== */
    #page-pos .page-actions .btn[onclick*="invoices"] {
      background: var(--primary) !important;
      color: #ffffff !important;
      border: 1px solid var(--primary) !important;
      box-shadow: none !important;
      font-weight: 600;
      transition: all 0.25s ease !important;
    }

    #page-pos .page-actions .btn[onclick*="invoices"]:hover {
      background: var(--primary-dark) !important;
      border-color: var(--primary-dark) !important;
      box-shadow: none !important;
    }

    #page-pos .page-actions .btn[onclick*="invoices"] i {
      color: #ffffff !important;
    }

    /* ===== 3) زر "اليوم" بجانب فلتر التاريخ في جميع الصفحات ===== */
    .date-filter-bar .btn-filter-reset {
      background: linear-gradient(135deg, #10b981 0%, #059669 100%) !important;
      color: #ffffff !important;
      border: 1px solid transparent !important;
      font-weight: 600;
      padding: 6px 14px !important;
      box-shadow: 0 2px 8px rgba(16, 185, 129, 0.28), 0 1px 2px rgba(5, 150, 105, 0.15) !important;
      transition: all 0.2s ease !important;
    }

    .date-filter-bar .btn-filter-reset:hover {
      background: linear-gradient(135deg, #059669 0%, #047857 100%) !important;
      color: #ffffff !important;
      border-color: transparent !important;
      transform: translateY(-1px);
      box-shadow: 0 4px 14px rgba(16, 185, 129, 0.40), 0 2px 4px rgba(5, 150, 105, 0.20) !important;
    }

    /* استثناء زر "كل الفترات" عشان عنده ستايل خاص بالـ inline style */
    .date-filter-bar .btn-filter-reset[style*="primary"] {
      background: var(--primary) !important;
      box-shadow: 0 2px 8px rgba(30, 94, 138, 0.28) !important;
    }

    .date-filter-bar .btn-filter-reset[style*="primary"]:hover {
      background: var(--primary-dark) !important;
      box-shadow: 0 4px 14px rgba(30, 94, 138, 0.40) !important;
    }

    /* ===== أزرار "إنشاء مرتجع" (بيع/شراء) — لون بنفسجي محايد موحّد يدل على "تصحيح/تعديل"
       بدل الأحمر (يوحي بخطر) أو الأخضر (يوحي بنجاح/إجراء موصى به) ===== */
    .btn-return-action {
      background: #7c3aed !important;
      border-color: #7c3aed !important;
      color: #ffffff !important;
      box-shadow: 0 2px 8px rgba(124, 58, 237, 0.32) !important;
      transition: all 0.2s ease !important;
    }

    .btn-return-action:hover {
      background: #6d28d9 !important;
      border-color: #6d28d9 !important;
      box-shadow: 0 4px 14px rgba(124, 58, 237, 0.45) !important;
    }

    /* اسم قديم (توافق خلفي) */
    .btn-purchase-return-manual {
      background: #7c3aed !important;
      border-color: #7c3aed !important;
      color: #ffffff !important;
      box-shadow: 0 2px 8px rgba(124, 58, 237, 0.32) !important;
      transition: all 0.2s ease !important;
    }

    .btn-purchase-return-manual:hover {
      background: #6d28d9 !important;
      border-color: #6d28d9 !important;
      box-shadow: 0 4px 14px rgba(124, 58, 237, 0.45) !important;
    }

    /* ===== أزرار الإجراءات في منتصف الصف عمودياً ===== */
    td .table-actions,
    td>.table-actions {
      display: flex !important;
      align-items: center !important;
      justify-content: center !important;
      gap: 4px !important;
      flex-wrap: nowrap !important;
    }

    tbody td:has(.table-actions),
    tbody td[data-label="الإجراءات"] {
      vertical-align: middle !important;
    }

    /* ===== 4) إبراز حقل البحث أعلى كل صفحة بها سجل ===== */
    .page-header .search-bar {
      background: var(--surface) !important;
      border: 2px solid var(--primary-light) !important;
      border-radius: 12px !important;
      padding: 10px 14px !important;
      min-width: 280px !important;
      max-width: 360px !important;
      width: 100% !important;
      box-shadow: 0 2px 8px rgba(30, 94, 138, 0.08), inset 0 1px 2px rgba(0, 0, 0, 0.02) !important;
      transition: all 0.25s ease !important;
    }

    .page-header .search-bar:hover {
      border-color: var(--primary) !important;
      box-shadow: 0 4px 14px rgba(30, 94, 138, 0.15) !important;
    }

    .page-header .search-bar:focus-within {
      border-color: var(--primary) !important;
      box-shadow: 0 0 0 4px rgba(30, 94, 138, 0.12), 0 4px 14px rgba(30, 94, 138, 0.18) !important;
    }

    .page-header .search-bar i {
      color: var(--primary) !important;
      font-size: 0.95rem !important;
    }

    .page-header .search-bar input[type="text"] {
      font-size: 0.92rem !important;
      font-weight: 500 !important;
      color: var(--text) !important;
      border: none !important;
      background: none !important;
      box-shadow: none !important;
    }

    .page-header .search-bar input::placeholder {
      color: var(--text-muted) !important;
      opacity: 0.75;
    }

    .page-header-left {
      min-width: 280px;
      flex: 1;
    }

    /* ===== Dark mode support ===== */
    [data-theme="dark"] .page-header .search-bar {
      background: var(--surface2) !important;
      border-color: rgba(30, 94, 138, 0.35) !important;
    }

    [data-theme="dark"] .page-header .search-bar:hover,
    [data-theme="dark"] .page-header .search-bar:focus-within {
      border-color: var(--primary) !important;
    }

    /* ===== Mobile responsive ===== */
    @media (max-width: 768px) {
      .page-header .search-bar {
        min-width: 100% !important;
        max-width: 100% !important;
      }

      .page-header-left {
        width: 100%;
        min-width: 100%;
      }
    }

    /* ===== عرض ثابت لحقول بحث معيّنة (سندات القبض/الدفع، الإيراد/المصروف الخارجي) — على
       سطح المكتب بس، عشان مايتحولش لارتفاع غريب لما الشريط يتكدّس عمودي على الموبايل ===== */
    @media (min-width: 769px) {
      .search-bar-fixed-240 {
        flex: 0 0 240px !important;
        max-width: 240px !important;
      }
    }

    /* ===== Search bar داخل شريط فلتر التاريخ (مدمج مع الفلاتر) ===== */
    .date-filter-bar .search-bar.search-bar-inline {
      flex: 1;
      min-width: 200px;
      max-width: 320px;
      height: 34px;
      padding: 4px 12px;
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: var(--radius-sm);
      box-shadow: none;
      transition: all 0.2s ease;
    }

    .date-filter-bar .search-bar.search-bar-inline:hover {
      border-color: var(--primary);
    }

    .date-filter-bar .search-bar.search-bar-inline:focus-within {
      border-color: var(--primary);
    }

    .date-filter-bar .search-bar.search-bar-inline i {
      color: var(--primary);
      font-size: 0.82rem;
    }

    .date-filter-bar .search-bar.search-bar-inline input {
      font-size: 0.85rem;
      font-weight: 500;
      color: var(--text);
      background: transparent !important;
      border: none !important;
      outline: none !important;
      box-shadow: none !important;
      width: 100%;
      font-family: var(--font);
    }

    .date-filter-bar .search-bar.search-bar-inline input::placeholder {
      color: var(--text-muted);
      opacity: 0.75;
    }

    @media (max-width: 768px) {
      .date-filter-bar .search-bar.search-bar-inline {
        max-width: 100%;
        width: 100%;
        min-width: 100%;
      }
    }

    /* إخفاء page-header-left فاضي (مفيش حاجة جواه) عشان ما يخلقش مساحة فارغة على الشمال */
    .page-header>.page-header-left:empty {
      flex: 0;
      min-width: 0;
      display: none;
    }

    /* ===== Dashboard Quick Actions - Safe Modal Only ===== */
    .quick-actions-panel {
      position: relative;
      overflow: hidden;
      margin: 0 0 22px;
      border: 1px solid color-mix(in srgb, var(--primary) 16%, var(--border));
      background: linear-gradient(135deg, color-mix(in srgb, var(--surface) 92%, var(--primary-light)) 0%, var(--surface) 62%, color-mix(in srgb, var(--surface) 86%, #1AA37A 14%) 100%);
    }

    .quick-actions-panel::before {
      content: '';
      position: absolute;
      inset: -80px auto auto -80px;
      width: 190px;
      height: 190px;
      border-radius: 50%;
      background: radial-gradient(circle, color-mix(in srgb, var(--primary) 18%, transparent) 0%, transparent 70%);
      pointer-events: none;
    }

    .quick-actions-panel .card-header {
      position: relative;
      z-index: 1;
      align-items: flex-start;
    }

    .quick-actions-grid {
      position: relative;
      z-index: 1;
      display: grid;
      grid-template-columns: repeat(6, minmax(0, 1fr));
      gap: 12px;
    }

    .quick-action-card {
      --qa-color: var(--primary);
      position: relative;
      overflow: hidden;
      min-height: 112px;
      padding: 14px 10px;
      border: 0;
      border-radius: 16px;
      font-family: var(--font);
      color: #fff;
      background: linear-gradient(135deg, var(--qa-color), color-mix(in srgb, var(--qa-color) 76%, #020617));
      box-shadow: 0 8px 22px color-mix(in srgb, var(--qa-color) 24%, transparent);
      cursor: pointer;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 9px;
      transition: transform .2s ease, box-shadow .2s ease, filter .2s ease;
      isolation: isolate;
    }

    .quick-action-card::before {
      content: '';
      position: absolute;
      inset: auto -28px -34px auto;
      width: 92px;
      height: 92px;
      border-radius: 50%;
      background: rgba(255, 255, 255, .14);
      z-index: -1;
    }

    .quick-action-card::after {
      content: '';
      position: absolute;
      inset: 0;
      background: linear-gradient(180deg, rgba(255, 255, 255, .14), transparent 48%);
      pointer-events: none;
    }

    .quick-action-card:hover {
      transform: translateY(-4px);
      filter: saturate(1.08) brightness(1.03);
      box-shadow: 0 14px 32px color-mix(in srgb, var(--qa-color) 34%, transparent);
    }

    .quick-action-card i {
      font-size: 1.65rem;
      line-height: 1;
      text-shadow: 0 3px 10px rgba(0, 0, 0, .18);
    }

    .quick-action-card span {
      font-size: .82rem;
      line-height: 1.45;
      font-weight: 800;
      text-align: center;
      text-shadow: 0 1px 4px rgba(0, 0, 0, .22);
    }

    .quick-action-card small {
      margin-top: -5px;
      font-size: .68rem;
      opacity: .82;
      font-weight: 700;
      text-align: center;
    }

    [data-theme="dark"] .quick-actions-panel {
      background: linear-gradient(135deg, #112240 0%, #0d1b2e 58%, #162d4a 100%);
      border-color: #1e3a5f;
    }

    @media(max-width:900px) {
      .quick-actions-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 10px;
      }

      .quick-action-card {
        min-height: 104px;
        border-radius: 14px;
      }
    }

    @media(max-width:560px) {
      .quick-actions-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
      }

      .quick-action-card {
        min-height: 96px;
        padding: 12px 8px;
      }

      .quick-action-card i {
        font-size: 1.38rem;
      }

      .quick-action-card span {
        font-size: .75rem;
      }

      .quick-action-card small {
        display: none;
      }
    }

    /* ════════════════════════════════════════════════════════════════════
   ███  هوية بوابة مصر الرقمية الرسمية - Government Egypt Theme  ███
   ════════════════════════════════════════════════════════════════════ */

    /* ===== 1. شريط حكومى علوى ذهبى رفيع (Top Gov Strip) ===== */
    body::before {
      content: '';
      position: fixed;
      top: 0;
      left: 0;
      right: 0;
      height: 4px;
      background: linear-gradient(90deg,
          #1E5E8A 0%,
          #1E5E8A 33%,
          #C9A961 33%,
          #C9A961 66%,
          #1E5E8A 66%,
          #1E5E8A 100%);
      z-index: 9999;
      pointer-events: none;
    }

    [data-theme="dark"] body::before {
      background: linear-gradient(90deg,
          #2E94FF 0%,
          #2E94FF 33%,
          #D4B978 33%,
          #D4B978 66%,
          #2E94FF 66%,
          #2E94FF 100%);
    }

    /* ===== 2. تعديل التوب بار - ستايل حكومى رسمى ===== */
    .topbar {
      background: var(--surface) !important;
      border-bottom: 2px solid var(--primary) !important;
      box-shadow: 0 2px 8px rgba(30, 94, 138, 0.08) !important;
      padding: 0 20px !important;
      height: 68px !important;
    }

    .topbar::after {
      content: '';
      position: absolute;
      bottom: -2px;
      left: 0;
      width: 120px;
      height: 2px;
      background: var(--gov-gold);
    }

    .topbar-title {
      font-weight: 800 !important;
      color: var(--primary) !important;
      letter-spacing: 0.2px;
      position: relative;
      padding-right: 14px;
    }

    .topbar-title::before {
      content: '';
      position: absolute;
      right: 0;
      top: 50%;
      transform: translateY(-50%);
      width: 4px;
      height: 22px;
      background: var(--gov-gold);
      border-radius: 2px;
    }

    /* ===== 3. الأزرار - ستايل حكومى رسمى ===== */
    .btn {
      border-radius: 8px !important;
      font-weight: 700 !important;
      letter-spacing: 0.1px;
      transition: all 0.18s ease !important;
      border: 1px solid transparent !important;
      position: relative;
      overflow: hidden;
    }

    .btn-primary {
      background: var(--primary) !important;
      color: #fff !important;
      border-color: var(--primary-dark) !important;
      box-shadow: 0 1px 2px rgba(30, 94, 138, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.12) !important;
    }

    .btn-primary:hover {
      background: var(--primary-dark) !important;
      box-shadow: 0 4px 12px rgba(30, 94, 138, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.12) !important;
      transform: translateY(-1px);
    }

    .btn-success {
      background: var(--success) !important;
      border-color: #0F8870 !important;
      box-shadow: 0 1px 2px rgba(22, 160, 133, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.12) !important;
    }

    .btn-success:hover {
      background: #138970 !important;
      box-shadow: 0 4px 12px rgba(22, 160, 133, 0.28) !important;
      transform: translateY(-1px);
    }

    .btn-danger {
      background: var(--danger) !important;
      border-color: #962B21 !important;
    }

    .btn-warning {
      background: var(--warning) !important;
      border-color: #B07209 !important;
      color: #fff !important;
    }

    .btn-outline {
      background: var(--surface) !important;
      border: 1.5px solid var(--primary) !important;
      color: var(--primary) !important;
      box-shadow: 0 1px 2px rgba(30, 94, 138, 0.06) !important;
    }

    .btn-outline:hover {
      background: var(--primary-light) !important;
      color: var(--primary-dark) !important;
    }

    /* ===== 4. الكروت - ستايل حكومى مع شريط جانبى ===== */
    .card {
      background: var(--surface) !important;
      border: 1px solid var(--border) !important;
      border-radius: 10px !important;
      box-shadow: 0 1px 3px rgba(26, 46, 42, 0.04), 0 2px 8px rgba(30, 94, 138, 0.04) !important;
      overflow: hidden;
      position: relative;
      transition: box-shadow 0.2s ease;
    }

    .card:hover {
      box-shadow: 0 2px 6px rgba(26, 46, 42, 0.06), 0 6px 18px rgba(30, 94, 138, 0.08) !important;
    }

    .card-header {
      background: linear-gradient(180deg, var(--surface) 0%, var(--surface2) 100%) !important;
      border-bottom: 1px solid var(--border) !important;
      padding: 14px 18px !important;
      position: relative;
    }

    .card-header::before {
      content: '';
      position: absolute;
      right: 0;
      top: 14px;
      bottom: 14px;
      width: 3px;
      background: var(--primary);
      border-radius: 2px 0 0 2px;
    }

    .card-title {
      color: var(--text) !important;
      font-weight: 800 !important;
      font-size: 1rem !important;
      padding-right: 12px;
    }

    .card-title i {
      color: var(--primary) !important;
    }

    /* ===== 5. الـ Modals - ستايل حكومى ===== */
    .modal {
      border-radius: 12px !important;
      border: 1px solid var(--border) !important;
      box-shadow: 0 20px 60px rgba(26, 46, 42, 0.20), 0 8px 24px rgba(30, 94, 138, 0.08) !important;
      overflow: hidden;
    }

    .modal-header {
      background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%) !important;
      color: #fff !important;
      padding: 16px 22px !important;
      border-bottom: 3px solid var(--gov-gold) !important;
      position: relative;
    }

    .modal-header::after {
      content: '';
      position: absolute;
      bottom: -3px;
      right: 0;
      width: 80px;
      height: 3px;
      background: var(--gov-gold);
    }

    .modal-header .modal-title,
    .modal-header .modal-title i {
      color: #fff !important;
      font-weight: 800 !important;
    }

    .modal-close {
      color: rgba(255, 255, 255, 0.85) !important;
      background: rgba(255, 255, 255, 0.10) !important;
      border-radius: 6px !important;
      width: 32px !important;
      height: 32px !important;
      display: flex !important;
      align-items: center !important;
      justify-content: center !important;
      transition: background 0.2s;
    }

    .modal-close:hover {
      background: rgba(255, 255, 255, 0.22) !important;
      color: #fff !important;
    }

    /* ===== 6. الـ Inputs - ستايل حكومى ===== */
    input[type="text"]:not(.no-gov),
    input[type="email"]:not(.no-gov),
    input[type="password"]:not(.no-gov),
    input[type="number"]:not(.no-gov),
    input[type="tel"]:not(.no-gov),
    input[type="search"]:not(.no-gov),
    input[type="date"]:not(.no-gov),
    input[type="datetime-local"]:not(.no-gov),
    select:not(.no-gov),
    textarea:not(.no-gov) {
      border-radius: 8px !important;
      border: 1.5px solid var(--border) !important;
      background: var(--surface) !important;
      transition: border-color 0.15s, box-shadow 0.15s !important;
      font-family: var(--font) !important;
    }

    input[type="text"]:not(.no-gov):focus,
    input[type="email"]:not(.no-gov):focus,
    input[type="password"]:not(.no-gov):focus,
    input[type="number"]:not(.no-gov):focus,
    input[type="tel"]:not(.no-gov):focus,
    input[type="search"]:not(.no-gov):focus,
    input[type="date"]:not(.no-gov):focus,
    input[type="datetime-local"]:not(.no-gov):focus,
    select:not(.no-gov):focus,
    textarea:not(.no-gov):focus {
      border-color: var(--primary) !important;
      box-shadow: 0 0 0 3px rgba(30, 94, 138, 0.12) !important;
      outline: none !important;
    }

    /* ===== 7. السايدبار - شعار رسمى ===== */
    .sidebar {
      border-left: 1px solid var(--border) !important;
      box-shadow: -1px 0 4px rgba(30, 94, 138, 0.04) !important;
    }

    .sidebar-header {
      background: linear-gradient(180deg, var(--surface) 0%, var(--primary-light) 100%) !important;
      border-bottom: 2px solid var(--primary) !important;
      position: relative;
    }

    .sidebar-header::after {
      content: '';
      position: absolute;
      bottom: -2px;
      right: 20px;
      width: 60px;
      height: 2px;
      background: var(--gov-gold);
    }

    [data-theme="dark"] .sidebar-header {
      background: linear-gradient(180deg, var(--sidebar-bg) 0%, rgba(46, 148, 255, 0.06) 100%) !important;
      border-bottom-color: var(--primary) !important;
    }

    /* أيقونة الشعار فى السايدبار */
    .sidebar .company-logo,
    .sidebar .logo-icon,
    .sidebar .brand-icon {
      background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%) !important;
      color: #fff !important;
      border-radius: 10px !important;
      box-shadow: 0 4px 12px rgba(30, 94, 138, 0.25) !important;
    }

    /* عناصر النافيجيشن النشطة */
    .nav-item.active,
    .nav-link.active {
      background: var(--sidebar-active-bg) !important;
      color: var(--sidebar-active-color) !important;
      border-right: 3px solid transparent !important;
      font-weight: 700 !important;
    }

    .nav-item.active i,
    .nav-link.active i {
      color: var(--primary) !important;
    }

    /* ===== 8. الجداول - ستايل رسمى حكومى ===== */
    table {
      border-collapse: separate !important;
      border-spacing: 0;
    }

    table thead th {
      background: linear-gradient(180deg, var(--primary) 0%, var(--primary-dark) 100%) !important;
      color: #fff !important;
      font-weight: 700 !important;
      font-size: 0.86rem !important;
      letter-spacing: 0.2px;
      padding: 12px 14px !important;
      text-align: right;
      border-bottom: 2px solid var(--gov-gold) !important;
      position: sticky;
      top: 0;
      z-index: 1;
    }

    table thead th:first-child {
      border-top-right-radius: 8px;
    }

    table thead th:last-child {
      border-top-left-radius: 8px;
    }

    table tbody tr {
      transition: background 0.15s;
    }

    table tbody tr:nth-child(even) {
      background: var(--surface2) !important;
    }

    table tbody tr:hover {
      background: var(--primary-light) !important;
    }

    table tbody td {
      padding: 10px 14px !important;
      border-bottom: 1px solid var(--border) !important;
      font-size: 0.88rem;
    }

    /* ===== 9. الكروت الإحصائية - الستات كاردز ===== */
    .stat-card {
      border-radius: 10px !important;
      border: 1px solid var(--border) !important;
      background: var(--surface) !important;
      box-shadow: 0 1px 3px rgba(26, 46, 42, 0.04), 0 2px 8px rgba(30, 94, 138, 0.04) !important;
      position: relative;
      overflow: hidden;
      transition: all 0.2s;
    }

    .stat-card::before {
      content: '';
      position: absolute;
      top: 0;
      right: 0;
      bottom: 0;
      width: 4px;
      background: var(--primary);
    }

    .stat-card:hover {
      transform: translateY(-2px);
      box-shadow: 0 6px 20px rgba(30, 94, 138, 0.12), 0 2px 8px rgba(26, 46, 42, 0.06) !important;
    }

    /* ===== 10. الـ Page Header ===== */
    .page-header {
      background: var(--surface) !important;
      border: 1px solid var(--border) !important;
      border-right: 4px solid var(--primary) !important;
      border-radius: 10px !important;
      padding: 16px !important;
      margin-bottom: 18px;
      box-shadow: 0 1px 3px rgba(30, 94, 138, 0.04) !important;
      position: relative;
    }

    .page-header h1,
    .page-header h2,
    .page-header .page-title {
      color: var(--primary) !important;
      font-weight: 800 !important;
    }

    /* ===== 11. شارات الحالة (Badges) - باستيل رسمى ===== */
    .badge,
    .status-badge {
      border-radius: 6px !important;
      font-weight: 700 !important;
      padding: 4px 10px !important;
      font-size: 0.76rem !important;
      letter-spacing: 0.2px;
      border: 1px solid transparent;
    }

    .badge-success,
    .status-paid,
    .status-completed {
      background: rgba(22, 160, 133, 0.12) !important;
      color: #0F8870 !important;
      border-color: rgba(22, 160, 133, 0.25) !important;
    }

    .badge-danger,
    .status-unpaid,
    .status-cancelled {
      background: rgba(192, 57, 43, 0.10) !important;
      color: #962B21 !important;
      border-color: rgba(192, 57, 43, 0.22) !important;
    }

    .badge-warning,
    .status-pending {
      background: rgba(214, 137, 16, 0.12) !important;
      color: #9E660C !important;
      border-color: rgba(214, 137, 16, 0.25) !important;
    }

    .badge-info {
      background: rgba(40, 116, 166, 0.10) !important;
      color: #1F5C85 !important;
      border-color: rgba(40, 116, 166, 0.22) !important;
    }

    /* ===== 12. أزرار الأيقونة (btn-icon) ===== */
    .btn-icon {
      border-radius: 8px !important;
      border: 1px solid var(--border) !important;
      background: var(--surface) !important;
      color: var(--text-muted) !important;
      transition: all 0.15s !important;
    }

    .btn-icon:hover {
      border-color: var(--primary) !important;
      color: var(--primary) !important;
      background: var(--primary-light) !important;
    }

    /* ===== 13. شاشة تسجيل الدخول - ستايل حكومى ===== */
    .btn-login {
      background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%) !important;
      border: 1px solid var(--primary-dark) !important;
      border-radius: 8px !important;
      box-shadow: 0 4px 12px rgba(30, 94, 138, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.15) !important;
      font-weight: 800 !important;
      letter-spacing: 0.3px;
      position: relative;
      overflow: hidden;
    }

    .btn-login::before {
      content: '';
      position: absolute;
      bottom: 0;
      right: 0;
      width: 50%;
      height: 2px;
      background: var(--gov-gold);
    }

    .btn-login:hover {
      background: linear-gradient(135deg, var(--primary-dark) 0%, #084538 100%) !important;
      box-shadow: 0 6px 20px rgba(30, 94, 138, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.15) !important;
    }

    /* ===== 14. سكرول بار رسمى ===== */
    *::-webkit-scrollbar {
      width: 10px;
      height: 10px;
    }

    *::-webkit-scrollbar-track {
      background: var(--surface2);
    }

    *::-webkit-scrollbar-thumb {
      background: rgba(30, 94, 138, 0.25);
      border-radius: 5px;
      border: 2px solid var(--surface2);
    }

    *::-webkit-scrollbar-thumb:hover {
      background: rgba(30, 94, 138, 0.45);
    }

    [data-theme="dark"] *::-webkit-scrollbar-track {
      background: var(--surface);
    }

    [data-theme="dark"] *::-webkit-scrollbar-thumb {
      background: rgba(46, 148, 255, 0.25);
      border-color: var(--surface);
    }

    /* ===== 15. الخلفية الرئيسية - بترن خفيف رسمى ===== */
    body {
      background-color: var(--bg) !important;
      background-image:
        radial-gradient(circle at 1px 1px, rgba(30, 94, 138, 0.04) 1px, transparent 0);
      background-size: 24px 24px;
    }

    [data-theme="dark"] body {
      background-image:
        radial-gradient(circle at 1px 1px, rgba(46, 148, 255, 0.05) 1px, transparent 0);
    }

    /* ===== 16. الـ Tabs ===== */
    .tab-btn,
    .tab-link {
      border-radius: 8px 8px 0 0 !important;
      border-bottom: 2px solid transparent !important;
      font-weight: 700 !important;
      color: var(--text-muted) !important;
      transition: all 0.15s !important;
    }

    .tab-btn.active,
    .tab-link.active {
      color: var(--primary) !important;
      border-bottom-color: var(--primary) !important;
      background: var(--primary-light) !important;
    }

    /* ===== 17. الـ Toast Notifications ===== */
    .toast {
      border-radius: 8px !important;
      box-shadow: 0 8px 24px rgba(26, 46, 42, 0.16) !important;
      border-right: 4px solid var(--primary) !important;
      font-weight: 600;
    }

    .toast.toast-success {
      border-right-color: var(--success) !important;
    }

    .toast.toast-error,
    .toast.toast-danger {
      border-right-color: var(--danger) !important;
    }

    .toast.toast-warning {
      border-right-color: var(--warning) !important;
    }

    /* ===== 18. القوائم المنسدلة (Dropdowns) ===== */
    .dropdown-menu,
    .menu-popup {
      border-radius: 8px !important;
      border: 1px solid var(--border) !important;
      box-shadow: 0 8px 24px rgba(26, 46, 42, 0.12), 0 2px 6px rgba(30, 94, 138, 0.04) !important;
      padding: 6px !important;
    }

    .dropdown-item:hover,
    .menu-popup-item:hover {
      background: var(--primary-light) !important;
      color: var(--primary) !important;
    }

    /* ===== 19. Quick Action Cards ===== */
    .quick-action-card {
      border-radius: 10px !important;
      border: 1px solid var(--border) !important;
      background: var(--surface) !important;
      color: var(--text) !important;
      transition: all 0.18s !important;
      position: relative;
      overflow: hidden;
    }

    .quick-action-card::before {
      content: '';
      position: absolute;
      top: 0;
      right: 0;
      width: 100%;
      height: 3px;
      background: linear-gradient(90deg, var(--primary), var(--gov-gold));
      transform: scaleX(0);
      transform-origin: right;
      transition: transform 0.25s;
    }

    .quick-action-card:hover {
      border-color: var(--primary) !important;
      transform: translateY(-2px);
      box-shadow: 0 8px 20px rgba(30, 94, 138, 0.12) !important;
    }

    .quick-action-card:hover::before {
      transform: scaleX(1);
    }

    .quick-action-card i {
      color: var(--qa-color, var(--primary)) !important;
      text-shadow: none !important;
    }

    .quick-action-card span {
      color: var(--text) !important;
      text-shadow: none !important;
    }

    .quick-action-card small {
      color: var(--text-muted, var(--text)) !important;
      opacity: .75;
    }

    /* ===== 20. تثبيت ارتفاع الـ body بالنسبة للشريط العلوى ===== */
    body {
      padding-top: 0;
    }

    /* ===== Print: نخفى الشريط العلوى عند الطباعة ===== */
    @media print {
      body::before {
        display: none !important;
      }

      body {
        padding-top: 0 !important;
      }
    }

    /* ============================================================ */
    /* ===== صفحة التقارير المحاسبية — Responsive Complete ======== */
    /* ============================================================ */

    /* === الـ Container الرئيسى === */
    #page-reports {
      width: 100%;
      max-width: 100%;
      box-sizing: border-box;
    }

    #page-reports * {
      box-sizing: border-box;
    }

    /* === كارت اختيار التقارير — تصميم حكومي رسمي صغير === */
    #page-reports .rep-tabs-card {
      margin-bottom: 12px;
      padding: 12px;
      overflow: visible;
      border: 1px solid rgba(30, 94, 138, 0.16);
      background: linear-gradient(180deg, var(--surface) 0%, var(--surface2) 100%);
      box-shadow: var(--shadow);
    }

    #page-reports .rep-tabs-card::before {
      content: '';
      display: block;
      height: 3px;
      margin: -12px -12px 10px;
      border-radius: var(--radius) var(--radius) 0 0;
      background: linear-gradient(90deg, var(--primary), var(--secondary), var(--gov-gold));
    }

    #page-reports .rep-tabs-wrap {
      display: flex;
      flex-direction: column;
      gap: 8px;
    }

    #page-reports .rep-section-group {
      display: grid;
      grid-template-columns: 150px 1fr;
      align-items: center;
      gap: 10px;
      padding: 6px;
      border: 1px solid rgba(30, 94, 138, 0.10);
      border-radius: 10px;
      background: rgba(30, 94, 138, 0.025);
    }

    #page-reports .rep-section-label {
      display: inline-flex;
      align-items: center;
      gap: 7px;
      min-height: 34px;
      padding: 7px 10px;
      border-radius: 8px;
      color: var(--primary-dark);
      background: rgba(30, 94, 138, 0.08);
      border: 1px solid rgba(30, 94, 138, 0.14);
      font-size: 0.78rem;
      font-weight: 800;
      white-space: nowrap;
    }

    #page-reports .rep-section-label i {
      color: var(--primary);
      font-size: 0.82rem;
    }

    #page-reports .rep-section-row {
      display: flex;
      flex-wrap: wrap;
      gap: 6px;
      align-items: center;
    }

    #page-reports .rep-tab {
      min-height: 34px;
      padding: 7px 11px;
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 8px;
      cursor: pointer;
      font-family: var(--font);
      font-size: 0.78rem;
      font-weight: 700;
      color: var(--text-muted);
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 6px;
      transition: background .16s ease, color .16s ease, border-color .16s ease, box-shadow .16s ease, transform .16s ease;
      white-space: nowrap;
      position: relative;
      box-shadow: 0 1px 2px rgba(26, 46, 42, 0.04);
    }

    #page-reports .rep-tab i {
      font-size: 0.8rem;
      color: var(--primary);
      opacity: .82;
    }

    #page-reports .rep-tab:hover {
      color: var(--primary-dark);
      border-color: rgba(30, 94, 138, 0.32);
      background: rgba(30, 94, 138, 0.06);
      transform: translateY(-1px);
    }

    #page-reports .rep-tab.active {
      color: #ffffff;
      border-color: var(--primary);
      background: linear-gradient(135deg, var(--primary-dark), var(--primary));
      box-shadow: 0 6px 14px rgba(30, 94, 138, 0.20);
    }

    #page-reports .rep-tab.active i {
      color: #ffffff;
      opacity: 1;
    }

    /* اختيار سريع رسمي — يظهر أكثر على الموبايل */
    #page-reports .rep-select-row {
      display: grid;
      grid-template-columns: 120px 1fr;
      align-items: center;
      gap: 10px;
      padding: 0;
      margin-bottom: 8px;
      border-radius: 0;
      border: none;
      background: transparent;
    }

    #page-reports .rep-select-label {
      display: inline-flex;
      align-items: center;
      gap: 7px;
      color: var(--primary-dark);
      font-size: 0.8rem;
      font-weight: 800;
      white-space: nowrap;
    }

    #page-reports .rep-select-label i {
      color: var(--primary);
    }

    #page-reports .rep-report-select {
      width: 100%;
      min-height: 38px;
      border: 1px solid rgba(30, 94, 138, 0.24);
      border-radius: 9px;
      background: var(--surface);
      color: var(--text);
      padding: 0 12px;
      font-family: var(--font);
      font-size: 0.86rem;
      font-weight: 700;
      outline: none;
    }

    /* ===== قائمة "اختر التقرير" المخصّصة بالكامل — تفتح جوه الصفحة نفسها بتصميمنا،
   بدل قائمة النظام الافتراضية على الموبايل ===== */
    .custom-dd {
      position: relative;
      width: 100%;
    }

    .custom-dd-trigger {
      width: 100%;
      min-height: 38px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 8px;
      border: 1px solid rgba(30, 94, 138, 0.24);
      border-radius: 9px;
      background: var(--surface);
      color: var(--text);
      padding: 0 12px;
      font-family: var(--font);
      font-size: 0.86rem;
      font-weight: 700;
      cursor: pointer;
      outline: none;
      transition: border-color .15s ease, box-shadow .15s ease;
    }

    .custom-dd-trigger:hover {
      border-color: var(--primary);
    }

    .custom-dd.open .custom-dd-trigger {
      border-color: var(--primary);
      box-shadow: 0 0 0 3px rgba(30, 94, 138, 0.12);
    }

    .custom-dd.open .custom-dd-trigger i {
      transform: rotate(180deg);
    }

    .custom-dd-trigger i {
      transition: transform .15s ease;
      color: var(--text-muted);
      font-size: .78rem;
    }

    .custom-dd-panel {
      display: none;
      position: absolute;
      z-index: 60;
      top: calc(100% + 6px);
      right: 0;
      left: 0;
      max-height: 280px;
      overflow-y: auto;
      background: var(--surface);
      border: 1px solid rgba(30, 94, 138, 0.2);
      border-radius: 12px;
      box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
      padding: 6px;
    }

    .custom-dd.open .custom-dd-panel {
      display: block;
    }

    .custom-dd-option {
      padding: 11px 14px;
      border-radius: 8px;
      font-size: .86rem;
      font-weight: 600;
      color: var(--text);
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 8px;
    }

    .custom-dd-option:hover {
      background: rgba(30, 94, 138, 0.08);
    }

    .custom-dd-option.selected {
      background: var(--primary);
      color: #fff;
    }

    .custom-dd-option .placeholder-txt {
      color: var(--text-muted);
      font-weight: 600;
    }

    .custom-dd-overlay {
      display: none;
      position: fixed;
      inset: 0;
      z-index: 55;
      background: transparent;
    }

    .custom-dd-overlay.open {
      display: block;
    }

    [data-theme="dark"] .custom-dd-trigger {
      background: #0d1b2e;
      color: #E8F0EE;
      border-color: rgba(46, 148, 255, 0.22);
    }

    [data-theme="dark"] .custom-dd-panel {
      background: #0d1b2e;
      border-color: rgba(46, 148, 255, 0.28);
    }

    [data-theme="dark"] .custom-dd-option:hover {
      background: rgba(46, 148, 255, 0.12);
    }

    #page-reports .rep-report-select:focus {
      border-color: var(--primary);
      box-shadow: 0 0 0 3px rgba(30, 94, 138, 0.12);
    }

    [data-theme="dark"] #page-reports .rep-tabs-card {
      background: linear-gradient(180deg, rgba(15, 42, 36, .96) 0%, rgba(10, 31, 27, .98) 100%);
      border-color: rgba(46, 148, 255, 0.18);
    }

    [data-theme="dark"] #page-reports .rep-section-group {
      background: rgba(46, 148, 255, 0.045);
      border-color: rgba(46, 148, 255, 0.12);
    }

    [data-theme="dark"] #page-reports .rep-section-label,
    [data-theme="dark"] #page-reports .rep-select-label {
      color: #CFF8EA;
    }

    [data-theme="dark"] #page-reports .rep-section-label {
      background: rgba(46, 148, 255, 0.10);
      border-color: rgba(46, 148, 255, 0.16);
    }

    [data-theme="dark"] #page-reports .rep-section-label i,
    [data-theme="dark"] #page-reports .rep-select-label i,
    [data-theme="dark"] #page-reports .rep-tab i {
      color: #2E94FF;
    }

    [data-theme="dark"] #page-reports .rep-tab {
      background: rgba(255, 255, 255, 0.035);
      border-color: rgba(255, 255, 255, 0.08);
      color: rgba(232, 240, 238, 0.76);
    }

    [data-theme="dark"] #page-reports .rep-tab:hover {
      color: #E8F0EE;
      border-color: rgba(46, 148, 255, 0.28);
      background: rgba(46, 148, 255, 0.08);
    }

    [data-theme="dark"] #page-reports .rep-tab.active {
      background: linear-gradient(135deg, #14436B, #1E5E8A);
      border-color: #2E94FF;
      color: #fff;
      box-shadow: 0 8px 18px rgba(0, 0, 0, .30), 0 0 0 1px rgba(46, 148, 255, 0.10) inset;
    }

    [data-theme="dark"] #page-reports .rep-tab.active i {
      color: #fff;
    }

    [data-theme="dark"] #page-reports .rep-select-row {
      background: transparent;
      border-color: transparent;
    }

    [data-theme="dark"] #page-reports .rep-report-select {
      background: #0d1b2e;
      color: #E8F0EE;
      border-color: rgba(46, 148, 255, 0.22);
    }

    @media (max-width: 900px) {
      #page-reports .rep-tabs-card {
        padding: 10px !important;
      }

      #page-reports .rep-tabs-card::before {
        margin: -10px -10px 9px !important;
      }

      #page-reports .rep-select-row {
        display: grid !important;
        grid-template-columns: 105px 1fr !important;
      }

      #page-reports .rep-section-group {
        grid-template-columns: 1fr !important;
        gap: 6px !important;
        padding: 6px !important;
      }

      #page-reports .rep-section-label {
        min-height: 30px !important;
        padding: 6px 9px !important;
        font-size: .74rem !important;
      }

      #page-reports .rep-section-row {
        overflow-x: auto !important;
        overflow-y: hidden !important;
        flex-wrap: nowrap !important;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
        padding-bottom: 2px;
      }

      #page-reports .rep-section-row::-webkit-scrollbar {
        height: 3px;
      }

      #page-reports .rep-section-row::-webkit-scrollbar-thumb {
        background: var(--primary);
        border-radius: 6px;
      }

      #page-reports .rep-tab {
        flex: 0 0 auto !important;
        min-height: 32px !important;
        padding: 6px 10px !important;
        font-size: .75rem !important;
      }
    }

    @media (max-width: 520px) {
      #page-reports .rep-tabs-wrap {
        display: none !important;
      }

      #page-reports .rep-select-row {
        margin-bottom: 0 !important;
        grid-template-columns: 1fr !important;
        gap: 7px !important;
      }

      #page-reports .rep-report-select {
        min-height: 40px !important;
        font-size: .84rem !important;
      }
    }

    /* === التخطيط: Sidebar + Main === */
    #page-reports .rep-layout {
      display: grid;
      grid-template-columns: 280px 1fr;
      gap: 16px;
      align-items: start;
      width: 100%;
    }

    /* ★ لما مفيش تقرير مختار، الفلاتر مختفية والعرض الرئيسي (رسالة التوجيه) لازم ياخد
   العرض بالكامل بدل ما يفضل محصور فى مساحة عمود الفلاتر (280px) القديمة */
    #page-reports .rep-layout.rep-layout-full {
      grid-template-columns: 1fr;
    }

    /* === Sidebar الفلاتر === */
    #page-reports .rep-sidebar {
      padding: 0;
      position: sticky;
      top: 84px;
      max-height: calc(100vh - 100px);
      overflow-y: auto;
    }

    #page-reports .rep-sidebar-header {
      display: flex;
      align-items: center;
      gap: 8px;
      padding: 14px 16px;
      background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
      color: #fff;
      font-weight: 700;
      font-size: 0.95rem;
    }

    #page-reports .rep-filter-group {
      padding: 14px 16px;
      border-bottom: 1px solid var(--border);
    }

    #page-reports .rep-filter-group:last-of-type {
      border-bottom: none;
    }

    #page-reports .rep-filter-label {
      display: block;
      font-size: 0.82rem;
      font-weight: 700;
      color: var(--text);
      margin-bottom: 10px;
    }

    #page-reports .rep-mini-label {
      display: block;
      font-size: 0.75rem;
      color: var(--text-muted);
      margin-bottom: 4px;
    }

    #page-reports .rep-input {
      width: 100%;
      max-width: 100%;
      padding: 8px 10px;
      border: 1px solid var(--border);
      border-radius: 7px;
      background: var(--surface);
      color: var(--text);
      font-size: 0.85rem;
      font-family: var(--font);
    }

    #page-reports .rep-input:focus {
      outline: none;
      border-color: var(--primary);
      box-shadow: 0 0 0 3px rgba(30, 94, 138, 0.12);
    }

    #page-reports .rep-dates-stack {
      display: flex;
      flex-direction: column;
      gap: 8px;
      margin-top: 10px;
    }

    /* === Chips الفترة === */
    #page-reports .rep-period-chips {
      display: flex;
      flex-wrap: wrap;
      gap: 6px;
    }

    #page-reports .rep-period-chip {
      padding: 6px 10px;
      border: 1px solid var(--border);
      border-radius: 16px;
      background: var(--surface);
      color: var(--text);
      font-size: 0.78rem;
      font-weight: 600;
      cursor: pointer;
      transition: all 0.15s ease;
    }

    #page-reports .rep-period-chip:hover {
      border-color: var(--primary);
      color: var(--primary);
    }

    #page-reports .rep-period-chip.active {
      background: var(--primary);
      color: #fff;
      border-color: var(--primary);
    }

    /* === أزرار التطبيق === */
    #page-reports .rep-filter-actions {
      display: flex;
      flex-direction: column;
      gap: 8px;
      padding: 14px 16px;
      background: var(--surface2);
    }

    #page-reports .rep-apply-btn {
      padding: 10px 14px;
      background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
      color: #fff;
      border: none;
      border-radius: 8px;
      font-weight: 700;
      font-size: 0.88rem;
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 6px;
    }

    #page-reports .rep-reset-btn {
      padding: 8px 14px;
      background: transparent;
      color: var(--text-muted);
      border: 1px solid var(--border);
      border-radius: 8px;
      font-weight: 600;
      font-size: 0.82rem;
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 6px;
    }

    /* === العرض الرئيسى === */
    #page-reports .rep-main {
      display: flex;
      flex-direction: column;
      gap: 14px;
      min-width: 0;
      /* مهم لـ overflow الصحيح فى grid */
    }

    #page-reports .rep-actions-bar {
      display: flex;
      justify-content: space-between;
      align-items: center;
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 10px;
      padding: 12px 18px;
      gap: 12px;
      flex-wrap: wrap;
    }

    #page-reports .rep-doc-meta {
      flex: 1 1 200px;
      min-width: 0;
    }

    #page-reports .rep-doc-title {
      margin: 0;
      font-size: 1.15rem;
      font-weight: 800;
      color: var(--primary);
    }

    #page-reports .rep-doc-subtitle {
      font-size: 0.82rem;
      color: var(--text-muted);
      margin-top: 4px;
    }

    /* === الوثيقة المحاسبية === */
    #page-reports .rep-doc {
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 10px;
      padding: 26px 30px;
      min-height: 400px;
      box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    }

    #page-reports .rep-doc-header {
      text-align: center;
      padding-bottom: 18px;
      margin-bottom: 22px;
      border-bottom: 2px solid var(--primary);
      position: relative;
    }

    #page-reports .rep-doc-header::after {
      content: '';
      position: absolute;
      bottom: -2px;
      left: 50%;
      transform: translateX(-50%);
      width: 140px;
      height: 2px;
      background: var(--gov-gold, #C9A961);
    }

    #page-reports .rep-doc-header h1 {
      margin: 0 0 6px;
      font-size: 1.55rem;
      color: var(--primary);
      font-weight: 800;
    }

    #page-reports .rep-doc-header .rep-doc-period {
      font-size: 0.92rem;
      color: var(--text);
      margin: 6px 0 4px;
      font-weight: 600;
    }

    #page-reports .rep-doc-header .rep-doc-issued {
      font-size: 0.78rem;
      color: var(--text-muted);
    }

    /* === جدول الوثيقة المحاسبية === */
    #page-reports #rep-doc-body {
      width: 100%;
      overflow-x: auto;
      -webkit-overflow-scrolling: touch;
    }

    #page-reports .rep-table {
      width: 100%;
      border-collapse: collapse;
      font-size: 0.92rem;
      margin: 0;
    }

    #page-reports .rep-table thead th {
      background: linear-gradient(180deg, #1E5E8A 0%, #14436B 100%);
      color: #fff;
      padding: 12px 14px;
      text-align: right;
      font-weight: 700;
      font-size: 0.88rem;
      border: 1px solid #14436B;
      white-space: nowrap;
    }

    #page-reports .rep-table tbody td {
      padding: 11px 14px;
      border: 1px solid var(--border);
      color: var(--text);
    }

    #page-reports .rep-table tbody tr:nth-child(even) td {
      background: var(--surface2);
    }

    #page-reports .rep-table tbody tr:hover td {
      background: rgba(30, 94, 138, 0.04);
    }

    #page-reports .rep-table .rep-num {
      text-align: left;
      font-variant-numeric: tabular-nums;
      font-weight: 600;
      direction: ltr;
      white-space: nowrap;
    }

    #page-reports .rep-table .rep-neg {
      color: #dc2626;
    }

    #page-reports .rep-table .rep-pos {
      color: #1E5E8A;
    }

    #page-reports .rep-table .rep-section-row td {
      background: linear-gradient(135deg, #1E5E8A 0%, #14436B 100%) !important;
      font-weight: 800 !important;
      color: #ffffff !important;
      border-top: 2px solid #14436B !important;
      border-bottom: 2px solid #14436B !important;
      font-size: 0.95rem;
      letter-spacing: 0.3px;
      padding: 12px 14px !important;
    }

    [data-theme="dark"] #page-reports .rep-table .rep-section-row td {
      background: linear-gradient(135deg, #1AA37A 0%, #1E5E8A 100%) !important;
      color: #ffffff !important;
    }

    #page-reports .rep-table .rep-total-row td {
      background: var(--primary) !important;
      color: #fff !important;
      font-weight: 800;
      font-size: 1rem;
      border-color: var(--primary-dark);
    }

    #page-reports .rep-table .rep-subtotal-row td {
      background: var(--surface2);
      font-weight: 700;
      border-top: 1.5px solid var(--text-muted);
    }

    #page-reports .rep-empty {
      text-align: center;
      padding: 60px 20px;
      color: var(--text-muted);
    }

    #page-reports .rep-empty i {
      font-size: 3rem;
      display: block;
      margin-bottom: 14px;
      opacity: 0.3;
    }

    /* ============================================================ */
    /* ===== Responsive Breakpoints — Override Everything ========= */
    /* ============================================================ */

    /* تابلت كبير ≤ 1024px */
    @media (max-width: 1024px) {
      #page-reports .rep-layout {
        grid-template-columns: 240px 1fr !important;
        gap: 12px !important;
      }

      #page-reports .rep-tab {
        flex: 1 1 auto !important;
        padding: 10px 10px !important;
        font-size: 0.8rem !important;
      }

      #page-reports .rep-doc {
        padding: 22px 18px !important;
      }

      #page-reports .rep-doc-header h1 {
        font-size: 1.4rem !important;
      }
    }

    /* موبايل/تابلت صغير ≤ 900px */
    @media (max-width: 900px) {
      #page-reports .rep-layout {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
      }

      #page-reports .rep-sidebar {
        position: static !important;
        max-height: none !important;
        overflow: visible !important;
      }

      /* كل قسم: صف واحد قابل للسكرول */
      #page-reports .rep-section-row {
        overflow-x: auto !important;
        overflow-y: hidden !important;
        flex-wrap: nowrap !important;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
      }

      #page-reports .rep-section-row::-webkit-scrollbar {
        height: 3px;
      }

      #page-reports .rep-section-row::-webkit-scrollbar-thumb {
        border-radius: 4px;
      }

      #page-reports .rep-section-group.grp-sales .rep-section-row::-webkit-scrollbar-thumb {
        background: #1E5E8A;
      }

      #page-reports .rep-section-group.grp-finance .rep-section-row::-webkit-scrollbar-thumb {
        background: #2874A6;
      }

      #page-reports .rep-section-group.grp-clients .rep-section-row::-webkit-scrollbar-thumb {
        background: #7D3C98;
      }

      #page-reports .rep-tab {
        flex: 0 0 auto !important;
        min-width: auto !important;
        padding: 10px 13px !important;
        font-size: 0.8rem !important;
      }

      /* شريط الإجراءات: عمودى */
      #page-reports .rep-actions-bar {
        flex-direction: column !important;
        align-items: stretch !important;
        padding: 12px !important;
      }

      /* الوثيقة */
      #page-reports .rep-doc {
        padding: 18px 14px !important;
      }

      #page-reports .rep-doc-header h1 {
        font-size: 1.2rem !important;
      }

      #page-reports .rep-doc-header .rep-doc-period {
        font-size: 0.82rem !important;
      }

      #page-reports .rep-doc-header .rep-doc-issued {
        font-size: 0.72rem !important;
      }

      /* الجدول: سكرول أفقى */
      #page-reports #rep-doc-body {
        margin: 0 -14px !important;
        padding: 0 14px !important;
      }

      #page-reports .rep-table {
        font-size: 0.8rem !important;
        min-width: 600px !important;
      }

      #page-reports .rep-table thead th {
        padding: 9px 8px !important;
        font-size: 0.78rem !important;
      }

      #page-reports .rep-table tbody td {
        padding: 8px !important;
        font-size: 0.78rem !important;
      }

      #page-reports .rep-table .rep-total-row td {
        font-size: 0.85rem !important;
      }

      #page-reports .rep-table .rep-section-row td {
        font-size: 0.85rem !important;
      }

      /* chips */
      #page-reports .rep-period-chips {
        gap: 5px !important;
      }

      #page-reports .rep-period-chip {
        padding: 6px 9px !important;
        font-size: 0.74rem !important;
      }
    }

    /* موبايل ≤ 600px */
    @media (max-width: 600px) {
      #page-reports .rep-tab {
        padding: 10px 11px !important;
        font-size: 0.76rem !important;
        gap: 5px !important;
      }

      #page-reports .rep-tab i {
        font-size: 0.78rem !important;
      }

      #page-reports .rep-sidebar-header {
        padding: 11px 13px !important;
        font-size: 0.88rem !important;
      }

      #page-reports .rep-filter-group {
        padding: 11px 13px !important;
      }

      #page-reports .rep-filter-label {
        font-size: 0.78rem !important;
      }

      #page-reports .rep-doc {
        padding: 14px 10px !important;
        border-radius: 8px !important;
      }

      #page-reports .rep-doc-header {
        padding-bottom: 12px !important;
        margin-bottom: 14px !important;
      }

      #page-reports .rep-doc-header h1 {
        font-size: 1.05rem !important;
        line-height: 1.4 !important;
      }

      #page-reports .rep-doc-header .rep-doc-period {
        font-size: 0.76rem !important;
        margin: 4px 0 2px !important;
      }

      #page-reports .rep-doc-header .rep-doc-issued {
        font-size: 0.7rem !important;
      }

      #page-reports .rep-table {
        font-size: 0.74rem !important;
        min-width: 520px !important;
      }

      #page-reports .rep-table thead th {
        padding: 8px 6px !important;
        font-size: 0.72rem !important;
      }

      #page-reports .rep-table tbody td {
        padding: 7px 6px !important;
        font-size: 0.74rem !important;
      }

      #page-reports .rep-table .rep-section-row td {
        font-size: 0.82rem !important;
        padding: 9px 8px !important;
      }

      #page-reports .rep-table .rep-total-row td {
        font-size: 0.8rem !important;
      }

      #page-reports .rep-table .rep-num {
        font-size: 0.74rem !important;
      }

      #page-reports .rep-doc-title {
        font-size: 1rem !important;
      }

      #page-reports .rep-doc-subtitle {
        font-size: 0.72rem !important;
      }

      #page-reports .rep-period-chip {
        padding: 5px 8px !important;
        font-size: 0.72rem !important;
      }

      #page-reports #rep-doc-body>div:not(table) {
        font-size: 0.72rem !important;
        padding: 9px 11px !important;
      }
    }

    /* موبايل صغير جداً ≤ 380px */
    @media (max-width: 380px) {
      #page-reports .rep-tab {
        padding: 9px 8px !important;
        font-size: 0.72rem !important;
      }

      #page-reports .rep-tab i {
        display: none !important;
      }
    }

    /* الطباعة لصفحة التقارير تتم عبر نافذة منفصلة من printActiveReport() */




    /* ===== توحيد محاذاة عناوين رؤوس الجداول =====
       يجعل عناوين خلايا الهيدر في منتصف الخلية، مع احترام أي خلية لها محاذاة خاصة مكتوبة inline أو بكلاس مخصص. */
    table thead th:not([style*="text-align"]):not(.text-start):not(.text-end):not(.align-start):not(.align-end),
    .table-wrap thead th:not([style*="text-align"]):not(.text-start):not(.text-end):not(.align-start):not(.align-end),
    .rep-table thead th:not([style*="text-align"]):not(.text-start):not(.text-end):not(.align-start):not(.align-end),
    .stmt-table thead th:not([style*="text-align"]):not(.text-start):not(.text-end):not(.align-start):not(.align-end),
    .inv-items-table th:not([style*="text-align"]):not(.text-start):not(.text-end):not(.align-start):not(.align-end),
    .return-items-table thead th:not([style*="text-align"]):not(.text-start):not(.text-end):not(.align-start):not(.align-end) {
      text-align: center !important;
      vertical-align: middle;
    }

    /* ===== كل الأرقام فى النظام تظهر بخط بولد (يشمل المبالغ، الكميات، الأرقام التسلسلية... إلخ) ===== */
    .auto-num-bold {
      font-weight: 800;
    }

    /* ===== أزرار كاميرا الموبايل (فى مودالات البيع/الشراء/المرتجعات وصفحة المنتجات): تظهر على الموبايل فقط لتحسين تجربة المستخدم على الكمبيوتر ===== */
    .mobile-camera-btn {
      display: none !important;
    }

    @media (max-width: 900px) {
      .mobile-camera-btn {
        display: inline-flex !important;
      }
    }

    /* ===== قائمة "طباعة / تصدير" المنسدلة (نمط عام يُستخدم فوق جداول كل الصفحات) ===== */
    .export-dropdown {
      position: relative;
      display: inline-block;
    }

    .export-dropdown-menu {
      display: none;
      position: absolute;
      top: calc(100% + 6px);
      left: 0;
      z-index: 60;
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 10px;
      box-shadow: 0 10px 30px rgba(15, 23, 42, .18);
      min-width: 100%;
      width: max-content;
      max-width: 280px;
      box-sizing: border-box;
      padding: 6px;
    }

    .export-dropdown-menu.open {
      display: block;
    }

    .export-dropdown-option {
      display: flex;
      align-items: center;
      gap: 8px;
      padding: 8px 10px;
      border-radius: 8px;
      cursor: pointer;
      font-size: .86rem;
      color: var(--text);
      font-weight: 600;
      white-space: nowrap;
    }

    .export-dropdown-option:hover {
      background: var(--primary-light);
    }

    .export-dropdown-option.opt-disabled {
      opacity: .45;
      cursor: not-allowed;
      pointer-events: none;
    }

    /* أسماء قديمة (توافق خلفي) */
    .trs-export-dropdown {
      position: relative;
      display: inline-block;
    }

    .trs-export-menu {
      display: none;
      position: absolute;
      top: calc(100% + 6px);
      left: 0;
      z-index: 60;
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 10px;
      box-shadow: 0 10px 30px rgba(15, 23, 42, .18);
      width: 100%;
      box-sizing: border-box;
      padding: 6px;
    }

    .trs-export-menu.open {
      display: block;
    }

    .trs-export-option {
      display: flex;
      align-items: center;
      gap: 8px;
      padding: 8px 10px;
      border-radius: 8px;
      cursor: pointer;
      font-size: .86rem;
      color: var(--text);
      font-weight: 600;
    }

    .trs-export-option:hover {
      background: var(--primary-light);
    }

    /* ===== تنعيم اللون الأبيض الحاد فى رؤوس كل الجداول (كان #fff نقي بيدي إحساس حاد جداً فوق خلفية رأس الجدول الغامقة) ===== */
    thead th,
    thead th *,
    table thead th,
    table thead th *,
    .table-wrap thead th,
    .rep-table thead th,
    #page-reports .rep-table thead th,
    .stmt-table thead th,
    .return-items-table thead th,
    .profit-summary-tbl thead th,
    .profit-summary-tbl thead tr,
    .bs-table thead th,
    .bs-table thead tr,
    .inv-items-table thead th,
    [data-theme="dark"] thead th,
    [data-theme="dark"] .bs-table thead th,
    [data-theme="dark"] .profit-summary-tbl thead th,
    #page-customers table thead th,
    #page-customers table thead th *,
    #page-suppliers table thead th,
    #page-suppliers table thead th *,
    #page-products table thead th,
    #page-products table thead th *,
    #page-invoices table thead th,
    #page-invoices table thead th *,
    #page-purchases table thead th,
    #page-purchases table thead th *,
    #page-salesReturns table thead th,
    #page-salesReturns table thead th *,
    #page-purchaseReturns table thead th,
    #page-purchaseReturns table thead th *,
    #page-receipts table thead th,
    #page-receipts table thead th *,
    #page-payments table thead th,
    #page-payments table thead th *,
    #page-treasury table thead th,
    #page-treasury table thead th *,
    #page-treasury .stats-table thead th {
      color: #d9e2ee !important;
      text-shadow: none !important;
    }

    /* ===== تنسيق قسم فلتر قائمة الدخل على الموبايل ===== */
    @media (max-width: 700px) {
      .prof-filter-bar {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 10px !important;
      }

      .prof-filter-fields {
        flex-direction: column !important;
        align-items: stretch !important;
        width: 100%;
        gap: 10px !important;
      }

      .prof-filter-label {
        font-size: 0.88rem !important;
      }

      .prof-filter-date-group {
        width: 100%;
      }

      .prof-filter-date-group label {
        min-width: 28px;
        flex-shrink: 0;
      }

      .prof-filter-date {
        flex: 1 1 auto;
        width: 100%;
      }

      .prof-filter-actions {
        width: 100%;
      }

      .prof-filter-select {
        flex: 1 1 100%;
        width: 100%;
      }

      .prof-filter-btn {
        flex: 1 1 auto;
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        gap: 4px;
      }
    }
