* {
    box-sizing: border-box;
}
html, body {
    font-family: 'Cairo', Tahoma, Arial, sans-serif;
    background-color: #0B0E14;
    color: #fff;
    user-select: none;
    overflow: hidden;
    max-width: 100vw;
    width: 100%;
    overscroll-behavior-y: none !important;
    touch-action: pan-y;
    -webkit-tap-highlight-color: transparent;
    transition: background-color 0.2s, color 0.2s;
}
input, textarea, select {
    user-select: text !important;
    -webkit-user-select: text !important;
    max-width: 100%;
}
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: #0B0E14; }
::-webkit-scrollbar-thumb { background: #1E2738; border-radius: 3px; }
.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }

input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type=number] { -moz-appearance: textfield; appearance: textfield; }
#cfgCloudToken, #cfgCloudChatId, #mobCloudToken, #mobCloudChatId, #initLinkToken, #initLinkChatId { direction: ltr !important; unicode-bidi: bidi-override !important; text-align: left !important; }

/* ☀️ نظام الألوان النهاري الفاخر (Martline Executive Day Theme v2 — تباين عالٍ ومريح للعين 10+ ساعات) */
body.light-mode {
    background-color: #EEF2F7 !important;
    color: #0F172A !important;
}
body.light-mode ::-webkit-scrollbar-track { background: #E2E8F0; }
body.light-mode ::-webkit-scrollbar-thumb { background: #94A3B8; border-radius: 4px; }
body.light-mode ::-webkit-scrollbar-thumb:hover { background: #64748B; }

body.light-mode .bg-\[\#0B0E14\],
body.light-mode .bg-\[\#0B0E14\]\/90,
body.light-mode .bg-\[\#0B0E14\]\/80 {
    background-color: #F4F7FB !important;
    color: #0F172A !important;
}
body.light-mode .bg-\[\#121824\],
body.light-mode .bg-\[\#121824\]\/95,
body.light-mode .bg-\[\#151B28\],
body.light-mode .bg-\[\#161D2C\] {
    background-color: #FFFFFF !important;
    color: #0F172A !important;
    box-shadow: 0 2px 12px rgba(15, 23, 42, 0.055), 0 1px 2px rgba(15, 23, 42, 0.04) !important;
}
body.light-mode header,
body.light-mode aside,
body.light-mode #mobileBottomNav,
body.light-mode #mobileDrawer {
    background-color: #FFFFFF !important;
    border-color: #DCE4F0 !important;
    box-shadow: 0 2px 14px rgba(15, 23, 42, 0.06) !important;
}

body.light-mode input,
body.light-mode select,
body.light-mode textarea {
    background-color: #FFFFFF !important;
    color: #0F172A !important;
    border-color: #CBD5E1 !important;
}
body.light-mode input::placeholder,
body.light-mode textarea::placeholder {
    color: #94A3B8 !important;
}
body.light-mode input:focus,
body.light-mode select:focus,
body.light-mode textarea:focus {
    border-color: #0D9488 !important;
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.14) !important;
}
body.light-mode option {
    background-color: #FFFFFF !important;
    color: #0F172A !important;
}

body.light-mode .text-white { color: #0F172A !important; }
body.light-mode .text-gray-100,
body.light-mode .text-gray-200 { color: #1E293B !important; }
body.light-mode .text-gray-300 { color: #334155 !important; }
body.light-mode .text-gray-400 { color: #52637A !important; }
body.light-mode .text-gray-500 { color: #64748B !important; }

body.light-mode .border-white\/5 { border-color: #E8EEF5 !important; }
body.light-mode .border-white\/10,
body.light-mode .border-white\/15,
body.light-mode .border-white\/20 { border-color: #D5DFEC !important; }
body.light-mode .divide-white\/5 > :not([hidden]) ~ :not([hidden]),
body.light-mode .divide-white\/10 > :not([hidden]) ~ :not([hidden]) { border-color: #E2E8F0 !important; }

body.light-mode .bg-white\/\[0\.02\],
body.light-mode .bg-white\/\[0\.03\],
body.light-mode .bg-white\/\[0\.04\],
body.light-mode .bg-white\/\[0\.05\],
body.light-mode .bg-white\/\[0\.06\] {
    background-color: #F1F5FA !important;
}
body.light-mode .bg-white\/5 {
    background-color: #EEF2F7 !important;
    color: #1E293B !important;
}
body.light-mode .bg-white\/10 {
    background-color: #E4EBF3 !important;
    color: #0F172A !important;
}
body.light-mode .hover\:bg-white\/5:hover,
body.light-mode .hover\:bg-white\/10:hover,
body.light-mode .hover\:bg-white\/\[0\.03\]:hover {
    background-color: #E6EDF6 !important;
}
body.light-mode .hover\:bg-white\/20:hover {
    background-color: #D6E1EE !important;
}
body.light-mode .hover\:text-white:hover { color: #0F172A !important; }

/* ألوان الهوية والتمييز العميقة (تنهي بهتان الألوان الفسفورية على الخلفية الفاتحة) */
body.light-mode .text-\[\#00ECB9\],
body.light-mode .text-emerald-300,
body.light-mode .text-emerald-400,
body.light-mode .text-teal-300,
body.light-mode .text-teal-400 { color: #047857 !important; }

body.light-mode .text-\[\#F0B90B\],
body.light-mode .text-amber-300,
body.light-mode .text-amber-400,
body.light-mode .text-yellow-300,
body.light-mode .text-yellow-400 { color: #B45309 !important; }

body.light-mode .text-cyan-300,
body.light-mode .text-cyan-400 { color: #0E7490 !important; }

body.light-mode .text-sky-300,
body.light-mode .text-sky-400,
body.light-mode .text-blue-300,
body.light-mode .text-blue-400 { color: #0369A1 !important; }

body.light-mode .text-orange-300,
body.light-mode .text-orange-400 { color: #C2410C !important; }

body.light-mode .text-red-300,
body.light-mode .text-red-400,
body.light-mode .text-rose-300,
body.light-mode .text-rose-400 { color: #BE123C !important; }

body.light-mode .text-purple-300,
body.light-mode .text-purple-400,
body.light-mode .text-indigo-300,
body.light-mode .text-indigo-400 { color: #6D28D9 !important; }

/* الأزرار الأساسية المعبّأة بنص أبيض واضح 100% */
body.light-mode .bg-\[\#00ECB9\],
body.light-mode .bg-emerald-500,
body.light-mode .bg-emerald-400 {
    background-color: #059669 !important;
    color: #FFFFFF !important;
}
body.light-mode .bg-\[\#00ECB9\] *,
body.light-mode .bg-emerald-500 *,
body.light-mode .bg-emerald-400 * {
    color: #FFFFFF !important;
}
body.light-mode .bg-\[\#F0B90B\],
body.light-mode .bg-amber-500,
body.light-mode .bg-amber-400 {
    background-color: #D97706 !important;
    color: #FFFFFF !important;
}
body.light-mode .bg-\[\#F0B90B\] *,
body.light-mode .bg-amber-500 *,
body.light-mode .bg-amber-400 * {
    color: #FFFFFF !important;
}
body.light-mode .bg-orange-500 {
    background-color: #EA580C !important;
    color: #FFFFFF !important;
}
body.light-mode .bg-orange-500 * { color: #FFFFFF !important; }
body.light-mode .bg-cyan-400,
body.light-mode .bg-cyan-500 {
    background-color: #0891B2 !important;
    color: #FFFFFF !important;
}
body.light-mode .bg-cyan-400 *,
body.light-mode .bg-cyan-500 * { color: #FFFFFF !important; }
body.light-mode .bg-rose-500,
body.light-mode .bg-red-500 {
    background-color: #E11D48 !important;
    color: #FFFFFF !important;
}
body.light-mode .bg-rose-500 *,
body.light-mode .bg-red-500 * { color: #FFFFFF !important; }

/* شارات وبطاقات الحالة الملوّنة بظلال ناعمة راقية */
body.light-mode .bg-\[\#00ECB9\]\/10,
body.light-mode .bg-\[\#00ECB9\]\/15,
body.light-mode .bg-\[\#00ECB9\]\/20,
body.light-mode .bg-emerald-500\/10,
body.light-mode .bg-emerald-500\/15,
body.light-mode .bg-emerald-500\/20 {
    background-color: #ECFDF5 !important;
}
body.light-mode .bg-amber-500\/10,
body.light-mode .bg-amber-500\/15,
body.light-mode .bg-amber-500\/20,
body.light-mode .bg-\[\#F0B90B\]\/10,
body.light-mode .bg-\[\#F0B90B\]\/15,
body.light-mode .bg-\[\#F0B90B\]\/20 {
    background-color: #FFFBEB !important;
}
body.light-mode .bg-orange-500\/10,
body.light-mode .bg-orange-500\/15,
body.light-mode .bg-orange-500\/20 {
    background-color: #FFF7ED !important;
}
body.light-mode .bg-cyan-500\/10,
body.light-mode .bg-cyan-500\/15,
body.light-mode .bg-cyan-500\/20,
body.light-mode .bg-sky-500\/10,
body.light-mode .bg-sky-500\/15,
body.light-mode .bg-sky-500\/20 {
    background-color: #ECFEFF !important;
}
body.light-mode .bg-red-500\/10,
body.light-mode .bg-red-500\/15,
body.light-mode .bg-red-500\/20,
body.light-mode .bg-rose-500\/10,
body.light-mode .bg-rose-500\/15,
body.light-mode .bg-rose-500\/20 {
    background-color: #FFF1F2 !important;
}
body.light-mode .bg-purple-500\/10,
body.light-mode .bg-purple-500\/15,
body.light-mode .bg-purple-500\/20,
body.light-mode .bg-indigo-500\/15 {
    background-color: #F5F3FF !important;
}

body.light-mode .border-\[\#00ECB9\]\/45,
body.light-mode .border-\[\#00ECB9\]\/50,
body.light-mode .border-\[\#00ECB9\]\/60,
body.light-mode .border-emerald-500\/30,
body.light-mode .border-emerald-500\/35,
body.light-mode .border-emerald-500\/40 { border-color: #6EE7B7 !important; }
body.light-mode .border-amber-500\/30,
body.light-mode .border-amber-500\/35,
body.light-mode .border-amber-500\/40,
body.light-mode .border-amber-500\/50,
body.light-mode .border-\[\#F0B90B\]\/40,
body.light-mode .border-\[\#F0B90B\]\/50 { border-color: #FCD34D !important; }
body.light-mode .border-cyan-500\/35,
body.light-mode .border-cyan-500\/40,
body.light-mode .border-cyan-400\/40 { border-color: #67E8F9 !important; }
body.light-mode .border-rose-500\/40,
body.light-mode .border-rose-500\/50,
body.light-mode .border-red-500\/30,
body.light-mode .border-red-500\/40 { border-color: #FDA4AF !important; }

body.light-mode .ux-group-btn.text-\[\#00ECB9\] {
    background-color: #ECFDF5 !important;
    border-color: #10B981 !important;
    color: #065F46 !important;
    font-weight: 900 !important;
}
body.light-mode #uxActiveGroupSubTabsBar {
    background-color: #FFFFFF !important;
    border-color: #DCE4F0 !important;
}

body.light-mode table thead {
    background-color: #F1F5FA !important;
    color: #334155 !important;
}
body.light-mode table thead th {
    color: #334155 !important;
}

body.light-mode .bg-black\/80,
body.light-mode .bg-black\/85,
body.light-mode .bg-black\/75,
body.light-mode .mob-sheet-overlay {
    background-color: rgba(15, 23, 42, 0.45) !important;
}
body.light-mode .mob-sheet-panel {
    background-color: #FFFFFF !important;
    border-top-color: #059669 !important;
}
body.light-mode .mob-sheet-handle {
    background-color: #CBD5E1 !important;
}

/* 📱 القائمة الجانبية */
.mobile-drawer-open #mobileDrawer { transform: translateX(0) !important; }
.mobile-drawer-open #mobileDrawerBackdrop { display: block !important; }

/* حصر التمرير الأفقي داخل حاويات الجداول فقط — لا يسمح أبداً بخروج الصفحة عن عرض الشاشة */
#viewsContainer {
    overflow-x: hidden !important;
    max-width: 100vw !important;
    width: 100%;
}
#viewsContainer > section {
    max-width: 100% !important;
    overflow-x: hidden !important;
}
#viewsContainer > section div:has(> table),
#modalsContainer div:has(> table) {
    max-width: 100% !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
}
#viewsContainer table, #modalsContainer table {
    min-width: 480px;
}

/* 🧾 النوافذ المنزلقة من الأسفل (Native Bottom Sheets) */
.mob-sheet-overlay {
    position: fixed;
    inset: 0;
    background: rgba(5, 8, 14, 0.82);
    /* backdrop-filter removed for fast Android WebView GPU */
    z-index: 460;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}
.mob-sheet-overlay.hidden {
    display: none !important;
}
.mob-sheet-panel {
    width: 100%;
    max-width: 540px;
    max-height: 90vh;
    background: #121824;
    border-top: 2px solid rgba(0, 236, 185, 0.45);
    border-radius: 24px 24px 0 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.65);
    animation: mobSheetSlideUp 0.18s ease-out;
}
@keyframes mobSheetSlideUp {
    from { transform: translateY(36px); opacity: 0.7; }
    to { transform: translateY(0); opacity: 1; }
}
.mob-sheet-handle {
    width: 42px;
    height: 4px;
    border-radius: 99px;
    background: rgba(255, 255, 255, 0.2);
    margin: 8px auto 2px;
    flex-shrink: 0;
}
.mob-sheet-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px calc(max(env(safe-area-inset-bottom, 0px), 24px) + 16px);
    -webkit-overflow-scrolling: touch;
}

/* زر الإضافة العائم (FAB) */
.mob-fab {
    position: fixed;
    left: 16px;
    bottom: calc(max(env(safe-area-inset-bottom, 0px), 48px) + 66px);
    z-index: 35;
    width: 54px;
    height: 54px;
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 26px rgba(0, 236, 185, 0.35);
    transition: transform 0.12s ease;
}
.mob-fab:active { transform: scale(0.93); }

/* شريط الإجراء العائم السفلي (السلة / اعتماد الفاتورة) */
.mob-sticky-bar {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(max(env(safe-area-inset-bottom, 0px), 48px) + 60px);
    z-index: 35;
}

/* شرائح السحب الأفقية */
.mob-chips-bar {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 2px;
    scrollbar-width: none;
}
.mob-chips-bar::-webkit-scrollbar { display: none; }

/* 📱 قفل العرض الصارم للشاشات المحمولة (Zero Overflow Guarantee) */
@media (max-width: 1023px) {
    #viewsContainer {
        padding: 10px 10px calc(max(env(safe-area-inset-bottom, 0px), 48px) + 125px) 10px !important;
    }

    #viewsContainer .grid-cols-12:not(.keep-grid-mobile),
    #modalsContainer .grid-cols-12:not(.keep-grid-mobile) {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
    }
    #viewsContainer .grid-cols-12:not(.keep-grid-mobile) > [class*="col-span-"],
    #modalsContainer .grid-cols-12:not(.keep-grid-mobile) > [class*="col-span-"] {
        grid-column: span 1 / span 1 !important;
        min-width: 0 !important;
    }

    #viewsContainer .grid-cols-10,
    #viewsContainer .grid-cols-9,
    #viewsContainer .grid-cols-8,
    #viewsContainer .grid-cols-7,
    #viewsContainer .grid-cols-6,
    #viewsContainer .grid-cols-5,
    #viewsContainer .grid-cols-4:not(.keep-cols-mobile),
    #viewsContainer .grid-cols-3:not(.keep-cols-mobile) {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 8px !important;
    }

    #viewsContainer #tab-pos,
    #viewsContainer #tab-expenses,
    #viewsContainer #tab-pos > div,
    #viewsContainer #tab-expenses > div {
        height: auto !important;
        overflow: visible !important;
    }

    #viewsContainer #dynamicBoxesGrid,
    #viewsContainer #dashBoxesGrid {
        grid-template-columns: 1fr !important;
    }

    /* إلغاء أي عرض ثابت قد يدفع العناصر خارج الشاشة */
    #viewsContainer [class*="min-w-["],
    #modalsContainer [class*="min-w-["] {
        min-width: 0 !important;
    }
    #viewsContainer .w-72,
    #viewsContainer .w-64,
    #viewsContainer .w-60,
    #viewsContainer .w-56,
    #viewsContainer .w-52,
    #viewsContainer .w-48 {
        width: 100% !important;
        max-width: 100% !important;
    }

    #viewsContainer input[type="text"],
    #viewsContainer input[type="number"],
    #viewsContainer input[type="date"],
    #viewsContainer input[type="time"],
    #viewsContainer select,
    #modalsContainer input[type="text"],
    #modalsContainer input[type="number"],
    #modalsContainer input[type="date"],
    #modalsContainer select {
        font-size: 13px;
        min-height: 40px;
    }

    #viewsContainer .flex.justify-between.items-center:not(.no-wrap-mobile) {
        flex-wrap: wrap;
        gap: 8px;
    }

    /* المودالات القياسية تتحول لنوافذ مريحة بعرض كامل */
    #modalsContainer > div:not(.mob-sheet-overlay) {
        padding: 10px !important;
    }
    #modalsContainer > div:not(.mob-sheet-overlay) > div {
        width: 100% !important;
        max-width: 100% !important;
        max-height: 90vh !important;
        overflow-y: auto !important;
        padding: 16px !important;
        border-radius: 20px !important;
    }
}

/* شريط التنقل السفلي فوق أزرار أندرويد */
#mobileBottomNav {
    padding-top: 7px !important;
    padding-bottom: max(env(safe-area-inset-bottom, 0px), 48px) !important;
}

#mobileDrawer {
    padding-bottom: max(env(safe-area-inset-bottom, 0px), 56px) !important;
}

/* ⚡ تسريع الرسم على معالجات الهواتف (Android WebView) */
#posProductsGrid, #inventoryCardsList, #auditCardsList, #repMobileCardsContainer {
    contain: layout style;
}
.backdrop-blur-md, .backdrop-blur-sm, .backdrop-blur-xs {
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
}


/* 🃏 تنسيقات بطاقات التنقل الرئيسية (Cards Hub — ليلي + نهاري) */
.ux-hub-card {
    transition: transform 0.16s ease, border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}
.ux-hub-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
}
.ux-hub-card:hover .ux-hub-arrow {
    transform: translateX(-4px);
    color: #00ECB9 !important;
}
.ux-hub-card-active {
    border-color: rgba(0, 236, 185, 0.72) !important;
    box-shadow: 0 0 0 1px rgba(0, 236, 185, 0.25), 0 10px 30px rgba(0, 236, 185, 0.14) !important;
}
body.light-mode .ux-hub-card {
    background-color: #FFFFFF !important;
    border-color: #D5DFEC !important;
    box-shadow: 0 3px 14px rgba(15, 23, 42, 0.055) !important;
}
body.light-mode .ux-hub-card:hover {
    border-color: #059669 !important;
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.10) !important;
}
body.light-mode .ux-hub-card-active {
    border-color: #059669 !important;
    box-shadow: 0 0 0 1px rgba(5, 150, 105, 0.22), 0 10px 26px rgba(5, 150, 105, 0.12) !important;
}
body.light-mode .ux-hub-card:hover .ux-hub-arrow {
    color: #059669 !important;
}

