/* EXTREME ERP - SMART FIELD EDITION (CSS) */
@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;600;700;800&display=swap');

:root {
    --bg-main: #F3F6F9; --bg-glass: rgba(255, 255, 255, 0.85); --border-glass: rgba(255, 255, 255, 1);
    --primary: #4361EE; --secondary: #3A0CA3; --accent: #F72585; --success: #10B981; --danger: #EF4444; --warning: #F59E0B;
    --text-main: #1E293B; --text-muted: #64748B;
    --shadow-soft: 0 10px 25px -5px rgba(0, 0, 0, 0.05); --shadow-hover: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    --gradient-primary: linear-gradient(135deg, #4361EE 0%, #3A0CA3 100%);
    --gradient-success: linear-gradient(135deg, #10B981 0%, #059669 100%);
    --radius-lg: 20px; --radius-md: 12px; --radius-sm: 8px; --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Cairo', sans-serif; }
body { background-color: var(--bg-main); color: var(--text-main); font-size: 15px; -webkit-font-smoothing: antialiased; }
a { text-decoration: none; color: inherit; } button { cursor: pointer; border: none; font-family: inherit; outline: none; } ul { list-style: none; }

/* Utilities */
.text-primary { color: var(--primary); } .text-secondary { color: var(--secondary); } .text-success { color: var(--success); } .text-danger { color: var(--danger); } .text-warning { color: var(--warning); } .text-muted { color: var(--text-muted); }
.bold { font-weight: 700; } .w-100 { width: 100%; } .p-15 { padding: 15px; } .p-20 { padding: 20px; } .mt-20 { margin-top: 20px; } .mt-10 { margin-top: 10px; } .mb-20 { margin-bottom: 20px; } .mb-10 { margin-bottom: 10px; }
.gap-10 { gap: 10px; } .flex-between { display: flex; justify-content: space-between; align-items: center; } .text-center { text-align: center; } .text-right { text-align: right; } .border-dashed { border: 2px dashed #E2E8F0; }

/* Glass & Shadows */
.light-glass { background: var(--bg-glass); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border: 1px solid var(--border-glass); border-radius: var(--radius-lg); box-shadow: var(--shadow-soft); }
.shadow-lg { box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25); }

/* Animations & Effects */
.fade-in { animation: fadeIn 0.4s ease-out forwards; } @keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.slide-down { animation: slideDown 0.3s ease-out forwards; } @keyframes slideDown { from { opacity: 0; transform: translateY(-10px); height: 0; overflow: hidden; } to { opacity: 1; transform: translateY(0); height: auto; } }
.pulse-icon { animation: pulseIcon 2s infinite; } @keyframes pulseIcon { 0% { transform: scale(1); } 50% { transform: scale(1.1); filter: drop-shadow(0 0 8px currentColor); } 100% { transform: scale(1); } }
.pulse-badge { animation: pulseBadge 1.5s infinite; } @keyframes pulseBadge { 0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); } 70% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); } 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); } }
.glow-effect { position: relative; overflow: hidden; } .glow-effect::after { content: ''; position: absolute; top: -50%; left: -50%; width: 200%; height: 200%; background: linear-gradient(to right, rgba(255,255,255,0) 0%, rgba(255,255,255,0.3) 50%, rgba(255,255,255,0) 100%); transform: rotate(30deg) translate(-100%, -100%); transition: 0.5s; } .glow-effect:hover::after { transform: rotate(30deg) translate(100%, 100%); }

/* Layout */
.app-container { display: flex; height: 100vh; overflow: hidden; }
.sidebar { width: 280px; margin: 15px; display: flex; flex-direction: column; z-index: 10; }
.sidebar-header { padding: 25px 20px; display: flex; align-items: center; gap: 15px; border-bottom: 1px solid rgba(0,0,0,0.05); }
.logo-circle { width: 45px; height: 45px; border-radius: 12px; background: var(--gradient-primary); color: white; display: flex; align-items: center; justify-content: center; font-size: 20px; box-shadow: 0 10px 15px -3px rgba(67, 97, 238, 0.4); }
.logo-circle.small { width: 35px; height: 35px; font-size: 16px; }
.sidebar-header h2 { font-size: 22px; font-weight: 800; color: var(--text-main); } .sidebar-header h2 span { color: var(--primary); }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 15px 10px; } .nav-section-title { font-size: 12px; color: var(--text-muted); padding: 10px 15px; margin-top: 15px; font-weight: 700; letter-spacing: 0.5px; }
.sidebar-nav li a { display: flex; align-items: center; gap: 15px; padding: 12px 15px; color: var(--text-muted); font-weight: 600; border-radius: var(--radius-md); transition: var(--transition); }
.sidebar-nav li a:hover { background: rgba(67, 97, 238, 0.05); color: var(--primary); transform: translateX(-5px); }
.sidebar-nav li.active a { background: var(--primary); color: white; box-shadow: 0 4px 10px rgba(67, 97, 238, 0.3); }

/* Main Content & Header */
.main-content { flex: 1; display: flex; flex-direction: column; padding: 15px 15px 15px 0; overflow: hidden; }
.top-header { height: 70px; display: flex; justify-content: space-between; align-items: center; padding: 0 25px; margin-bottom: 20px; border-radius: var(--radius-lg); }
.search-bar { display: flex; align-items: center; background: #F1F5F9; border-radius: var(--radius-md); padding: 10px 15px; width: 400px; border: 1px solid transparent; transition: var(--transition); }
.search-bar:focus-within { border-color: var(--primary); background: white; box-shadow: 0 0 0 4px rgba(67, 97, 238, 0.1); }
.search-bar input { border: none; background: transparent; outline: none; width: 100%; margin-right: 10px; color: var(--text-main); font-weight: 600; }
.header-actions { display: flex; align-items: center; gap: 20px; position: relative; }
.user-profile { display: flex; align-items: center; gap: 10px; font-weight: 700; cursor: pointer; } .user-profile img { width: 40px; height: 40px; border-radius: 50%; border: 2px solid var(--primary); padding: 2px; }

/* Buttons & Components */
.btn { padding: 10px 20px; border-radius: var(--radius-md); font-weight: 700; display: inline-flex; align-items: center; gap: 8px; justify-content: center; transition: var(--transition); }
.btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); }
.btn-primary { background: var(--gradient-primary); color: white; } .btn-success { background: var(--gradient-success); color: white; } .btn-outline { background: transparent; border: 2px solid var(--primary); color: var(--primary); }
.btn-danger { background: linear-gradient(135deg, var(--danger), #B91C1C); color: white; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: #F1F5F9; color: var(--text-muted); font-size: 16px; transition: var(--transition); position: relative; }
.icon-btn:hover { background: var(--primary); color: white; }
.icon-btn.danger:hover { background: var(--danger); color: white; }
.icon-btn.small { width: 32px; height: 32px; font-size: 13px; border-radius: 8px; }
.badge { background: var(--danger); color: white; font-size: 11px; font-weight: 800; padding: 2px 6px; border-radius: 10px; position: absolute; top: -5px; right: -5px; }
.badge-type { padding: 5px 12px; border-radius: 20px; font-size: 12px; font-weight: 800; } .badge-type.active { background: rgba(16, 185, 129, 0.1); color: var(--success); } .badge-type.inactive { background: rgba(239, 68, 68, 0.1); color: var(--danger); }

/* Content Area */
.content-wrapper { flex: 1; overflow-y: auto; padding-right: 5px; } .content-wrapper::-webkit-scrollbar { width: 6px; } .content-wrapper::-webkit-scrollbar-thumb { background: #CBD5E1; border-radius: 10px; }
.page-header { margin-bottom: 25px; } .page-header h1 { font-size: 26px; font-weight: 800; color: var(--text-main); } .page-header p { color: var(--text-muted); font-weight: 600; }

/* Dashboard Cards */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; }
.stat-card { padding: 25px; display: flex; align-items: center; gap: 20px; transition: var(--transition); } .card-hover:hover { transform: translateY(-5px); box-shadow: var(--shadow-hover); }
.stat-icon { width: 60px; height: 60px; border-radius: 16px; display: flex; align-items: center; justify-content: center; font-size: 24px; color: white; }
.purple-bg { background: linear-gradient(135deg, #8B5CF6, #6D28D9); box-shadow: 0 10px 15px -3px rgba(139, 92, 246, 0.4); } .blue-bg { background: linear-gradient(135deg, #3B82F6, #1D4ED8); box-shadow: 0 10px 15px -3px rgba(59, 130, 246, 0.4); } .green-bg { background: linear-gradient(135deg, #10B981, #047857); box-shadow: 0 10px 15px -3px rgba(16, 185, 129, 0.4); } .red-bg { background: linear-gradient(135deg, #EF4444, #B91C1C); box-shadow: 0 10px 15px -3px rgba(239, 68, 68, 0.4); }

/* Tables & Tabs */
.table-container { padding: 20px; overflow: hidden; }
.data-table { width: 100%; border-collapse: collapse; text-align: right; } .data-table th { padding: 15px; color: var(--text-muted); font-weight: 700; font-size: 13px; border-bottom: 2px solid #E2E8F0; } .data-table td { padding: 15px; font-weight: 600; font-size: 14px; border-bottom: 1px solid #F1F5F9; } .data-table tbody tr:hover { background: #F8FAFC; }
.tabs-header { display: flex; border-bottom: 1px solid #E2E8F0; background: #F8FAFC; border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
.tab-btn { flex: 1; padding: 18px; background: transparent; color: var(--text-muted); font-weight: 700; font-size: 15px; border-bottom: 3px solid transparent; display: flex; align-items: center; justify-content: center; gap: 8px; } .tab-btn:hover { background: white; color: var(--primary); } .tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); background: white; }
.tab-content { display: none; padding: 25px; } .tab-content.active { display: block; animation: fadeIn 0.4s ease; }

/* Dynamic Forms */
.form-group { margin-bottom: 18px; text-align: right; } .form-group label { display: block; margin-bottom: 8px; font-weight: 700; color: var(--text-main); font-size: 14px; }
.form-control.solid { width: 100%; padding: 12px 15px; background: #F1F5F9; border: 1px solid #E2E8F0; border-radius: var(--radius-md); color: var(--text-main); font-weight: 600; font-size: 15px; transition: var(--transition); } .form-control.solid:focus { background: white; border-color: var(--primary); box-shadow: 0 0 0 4px rgba(67, 97, 238, 0.15); } .form-control.solid[readonly] { background: #E2E8F0; color: var(--text-muted); } .border-primary { border-color: rgba(67, 97, 238, 0.4) !important; }

/* Editor / Rich Text */
.editor-content:focus { outline: none; background: #fafafa; }
.editor-content p { margin-bottom: 10px; line-height: 1.6; }
.editor-content ul { list-style-type: disc; margin-right: 20px; }

/* QR Builder Checkboxes */
input[type="checkbox"] { accent-color: var(--primary); transform: scale(1.2); margin-left: 5px; }

/* Mobile Portal Mockup Layout */
.portal-mockup-wrapper { display: flex; gap: 50px; padding: 20px; align-items: flex-start; justify-content: center; }
.mobile-device { width: 375px; height: 812px; background: white; border-radius: 45px; border: 14px solid #1E293B; position: relative; overflow: hidden; display: flex; flex-direction: column; flex-shrink: 0; }
.mobile-notch { position: absolute; top: 0; left: 50%; transform: translateX(-50%); width: 150px; height: 28px; background: #1E293B; border-bottom-left-radius: 18px; border-bottom-right-radius: 18px; z-index: 10; }
.mobile-header { background: #F8FAFC; padding: 45px 20px 20px; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid #E2E8F0; } .mobile-header h3 { font-size: 20px; font-weight: 800; color: var(--text-main); }
.mobile-body { flex: 1; padding: 25px; overflow-y: auto; background: white; } .mobile-body::-webkit-scrollbar { display: none; }
.portal-info { flex: 1; max-width: 500px; } .portal-info li { margin-bottom: 10px; font-weight: 600; }

/* Modals */
.modal { display: none; position: fixed; z-index: 1000; left: 0; top: 0; width: 100%; height: 100%; background: rgba(15, 23, 42, 0.6); backdrop-filter: blur(8px); }
.modal-content { margin: 8% auto; position: relative; animation: modalZoom 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); } @keyframes modalZoom { from { transform: scale(0.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.close-btn { width: 30px; height: 30px; background: #F1F5F9; border-radius: 50%; display: flex; justify-content: center; align-items: center; cursor: pointer; color: var(--text-muted); font-size: 16px; transition: var(--transition); } .close-btn:hover { background: var(--danger); color: white; }

/* Success & Error Alert Animations */
.success-anim { animation: successPop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
.error-anim { animation: errorShake 0.5s ease-in-out; }
@keyframes successPop { 0% { transform: scale(0); opacity: 0; } 80% { transform: scale(1.2); } 100% { transform: scale(1); opacity: 1; } }
@keyframes errorShake { 0% { transform: translateX(0); } 20% { transform: translateX(-10px); } 40% { transform: translateX(10px); } 60% { transform: translateX(-10px); } 80% { transform: translateX(10px); } 100% { transform: translateX(0); } }

/* Ink Selection & Upload */
.ink-selection { display: flex; gap: 15px; justify-content: center; }
.ink-color { width: 50px; height: 50px; border-radius: 50%; display: flex; align-items: center; justify-content: center; cursor: pointer; border: 3px solid transparent; transition: var(--transition); color: white; font-weight: 800; font-size: 18px; position: relative; }
.ink-color.black { background: #1E293B; } .ink-color.cyan { background: #06b6d4; } .ink-color.magenta { background: #ec4899; } .ink-color.yellow { background: #eab308; color: #1E293B; }
.ink-color.active { transform: scale(1.1); box-shadow: 0 0 15px rgba(0,0,0,0.2); } .ink-color.active::after { content: '\f00c'; font-family: "Font Awesome 6 Free"; position: absolute; bottom: -5px; right: -5px; background: white; color: var(--success); border-radius: 50%; width: 20px; height: 20px; font-size: 12px; display: flex; align-items: center; justify-content: center; box-shadow: 0 2px 5px rgba(0,0,0,0.2); }
.file-upload-box { border: 2px dashed #CBD5E1; border-radius: var(--radius-md); padding: 20px; text-align: center; cursor: pointer; transition: var(--transition); background: #F8FAFC; }
.file-upload-box:hover { border-color: var(--primary); background: rgba(67, 97, 238, 0.05); } .file-upload-box i { font-size: 30px; color: var(--text-muted); margin-bottom: 10px; } .file-upload-box p { color: var(--text-muted); font-size: 13px; font-weight: 600; }

/* ===================== DARK MODE ===================== */
body.dark-mode { --bg-main: #0F172A; --bg-glass: rgba(30, 41, 59, 0.92); --border-glass: rgba(255,255,255,0.08); --text-main: #E2E8F0; --text-muted: #94A3B8; --shadow-soft: 0 10px 25px -5px rgba(0,0,0,0.4); }
body.dark-mode .form-control, body.dark-mode .form-control.solid { background: #1E293B; color: #E2E8F0; border-color: #334155; }
body.dark-mode .data-table thead tr { background: #1E293B; }
body.dark-mode .data-table tbody tr:hover { background: rgba(67,97,238,0.1); }
body.dark-mode .data-table tbody tr:nth-child(even) { background: rgba(255,255,255,0.03); }
body.dark-mode .search-bar { background: #1E293B; border-color: #334155; }
body.dark-mode label { color: #94A3B8; }
body.dark-mode .nav-section-title { color: #475569; }
body.dark-mode .stat-card { background: rgba(30,41,59,0.9); }
body.dark-mode .page-section { background: transparent; }
.dark-toggle { width: 44px; height: 24px; background: #CBD5E1; border-radius: 12px; position: relative; cursor: pointer; transition: var(--transition); border: none; }
.dark-toggle.on { background: var(--primary); }
.dark-toggle::before { content: ''; position: absolute; width: 18px; height: 18px; background: white; border-radius: 50%; top: 3px; right: 3px; transition: var(--transition); box-shadow: 0 2px 4px rgba(0,0,0,0.2); }
.dark-toggle.on::before { right: 23px; }

/* ===================== GLOBAL SEARCH ===================== */
#global-search-overlay { position: fixed; inset: 0; background: rgba(15,23,42,0.85); z-index: 99999; display: none; align-items: flex-start; justify-content: center; padding-top: 80px; backdrop-filter: blur(8px); }
#global-search-overlay.open { display: flex; animation: fadeIn 0.2s ease; }
#global-search-box { width: 620px; background: white; border-radius: 20px; padding: 20px; box-shadow: 0 40px 80px rgba(0,0,0,0.4); }
body.dark-mode #global-search-box { background: #1E293B; }
#global-search-input { width: 100%; border: 2px solid var(--primary); border-radius: 12px; padding: 15px 20px; font-size: 18px; font-family: 'Cairo', sans-serif; outline: none; background: transparent; color: var(--text-main); }
.search-result-item { padding: 12px 15px; border-radius: 10px; cursor: pointer; display: flex; align-items: center; gap: 12px; transition: var(--transition); }
.search-result-item:hover { background: rgba(67,97,238,0.08); }
.search-result-icon { width: 36px; height: 36px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 14px; color: white; flex-shrink: 0; }
#item-inquiry-modal .item-inquiry-cat-badge,
#item-inquiry-modal .item-inquiry-qty-badge { box-shadow: 0 1px 2px rgba(15,23,42,0.06); }
#item-inquiry-modal #item-inquiry-tbody td { vertical-align: middle; }
body.dark-mode #item-inquiry-modal .item-inquiry-cat-badge,
body.dark-mode #item-inquiry-modal .item-inquiry-qty-badge { filter: saturate(1.15) brightness(0.92); }
.voucher-type-menu { list-style: none; margin: 0; padding: 0; }
.voucher-type-menu li { margin-bottom: 8px; }
.voucher-type-menu button { width: 100%; text-align: right; padding: 12px 14px; border: 1px solid #E2E8F0; border-radius: 10px; background: #fff; cursor: pointer; font-weight: 700; display: flex; align-items: center; gap: 10px; transition: var(--transition); }
.voucher-type-menu button:hover { border-color: var(--primary); background: rgba(67,97,238,0.05); }
.voucher-toolbar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 18px; background: linear-gradient(135deg,#F8FAFC,#EEF2FF); border-bottom: 1px solid #E2E8F0; position: sticky; top: 0; z-index: 12; }
.voucher-toolbar .voucher-toolbar-actions button { pointer-events: auto !important; }
.voucher-toolbar .voucher-toolbar-actions button.vch-toolbar-interactive { cursor: pointer; }
.voucher-toolbar .voucher-toolbar-actions button.vch-toolbar-interactive:disabled { opacity: 1 !important; pointer-events: auto !important; cursor: pointer; }
.voucher-toolbar-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.voucher-title { margin: 0; font-size: 1.1rem; }
.voucher-header-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.voucher-party-row { display: grid; grid-template-columns: 1.2fr 1.5fr; gap: 12px; margin-bottom: 12px; }
.voucher-mini-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.voucher-section-title { font-weight: 800; color: var(--primary); margin: 12px 0 8px; font-size: 13px; }
.voucher-footer-grid { display: grid; grid-template-columns: 1.5fr 1fr; gap: 16px; align-items: start; }
.voucher-totals-box { border: 1px solid #E2E8F0; border-radius: 12px; }
@media (max-width: 900px) { .voucher-header-grid, .voucher-party-row, .voucher-footer-grid { grid-template-columns: 1fr; } }

body.erp-data-loading .main-wrapper { opacity: 0.92; pointer-events: none; }
body.erp-data-loading .main-wrapper::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 999;
    background: rgba(248, 250, 252, 0.35);
    pointer-events: none;
}

/* سندات — نافذة بارتفاع الشاشة مع تمرير المحتوى (المرفقات والتذييل ظاهران بالكامل) */
.modal.modal-voucher-shell {
    align-items: center;
    justify-content: center;
    padding: max(10px, env(safe-area-inset-top, 0px)) max(10px, env(safe-area-inset-right, 0px)) max(10px, env(safe-area-inset-bottom, 0px)) max(10px, env(safe-area-inset-left, 0px));
    overflow: hidden;
    box-sizing: border-box;
}
.modal-content.voucher-workspace {
    display: flex;
    flex-direction: column;
    width: min(1100px, 98vw);
    max-width: 98vw;
    max-height: min(94vh, calc(100dvh - 20px));
    height: min(94vh, calc(100dvh - 20px));
    margin: 0 auto !important;
    padding: 0 !important;
    overflow: hidden;
    box-sizing: border-box;
}
.voucher-workspace .voucher-toolbar {
    flex-shrink: 0;
    position: relative;
    top: auto;
}
.voucher-workspace .voucher-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: 20px;
    padding-bottom: 32px;
}
.voucher-workspace .voucher-body.p-20 {
    padding: 20px;
    padding-bottom: 32px;
}
.voucher-workspace .voucher-table-wrap {
    overflow-x: auto;
    max-width: 100%;
    margin-bottom: 10px;
}
.voucher-workspace #vch-attachments-list {
    max-height: min(320px, 42vh);
    overflow-y: auto;
    overflow-x: hidden;
}
.voucher-workspace .voucher-footer-grid {
    margin-bottom: 8px;
}
.voucher-workspace .voucher-collapsible {
    margin-bottom: 10px;
}
/* نوافذ استعلام السندات */
.modal-content.modal-voucher-lookup {
    display: flex;
    flex-direction: column;
    max-height: min(90vh, calc(100dvh - 24px));
    margin: max(12px, 2vh) auto !important;
    overflow: hidden;
    box-sizing: border-box;
}
.modal-content.modal-voucher-lookup .modal-voucher-lookup-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 16px;
}
#search-results { max-height: 420px; overflow-y: auto; margin-top: 8px; }
.search-result-item.active { background: rgba(67,97,238,0.12); outline: 2px solid rgba(67,97,238,0.25); }
.notification-panel { position: absolute; top: calc(100% + 10px); left: 0; width: min(340px, 92vw); z-index: 1200; border: 1px solid rgba(67,97,238,0.25); box-shadow: var(--shadow-lg); max-height: 420px; overflow: hidden; display: flex; flex-direction: column; }
.notification-panel #notif-list { overflow-y: auto; max-height: 320px; }
.notif-row { display: flex; gap: 10px; padding: 10px 8px; border-bottom: 1px solid #EEF2F7; cursor: default; }
.notif-row.unread { background: rgba(67,97,238,0.04); }
.notif-row-icon { width: 34px; height: 34px; border-radius: 10px; display: flex; align-items: center; justify-content: center; color: #fff; flex-shrink: 0; font-size: 13px; }
.header-user-profile { display: flex; align-items: center; gap: 10px; cursor: pointer; padding: 4px 8px; border-radius: 12px; transition: var(--transition); }
.header-user-profile:hover { background: rgba(67,97,238,0.06); }
.header-avatar-slot { flex-shrink: 0; }
.header-logout-btn { padding: 6px 10px !important; margin-inline-start: 4px; }
.user-profile-modal-layout { display: grid; grid-template-columns: 140px 1fr; gap: 20px; align-items: start; }
.profile-avatar-preview { min-height: 96px; display: flex; align-items: center; justify-content: center; }
@media (max-width: 560px) { .user-profile-modal-layout { grid-template-columns: 1fr; } }

/* ===================== SMART ALERTS BANNER ===================== */
.smart-alert-bar { background: linear-gradient(135deg, #7C3AED, #4361EE); color: white; padding: 10px 25px; border-radius: 12px; margin-bottom: 15px; display: flex; align-items: center; gap: 15px; font-size: 14px; font-weight: 600; }
.smart-alert-bar .alert-item { display: flex; align-items: center; gap: 8px; padding: 4px 12px; background: rgba(255,255,255,0.15); border-radius: 20px; cursor: pointer; transition: var(--transition); }
.smart-alert-bar .alert-item:hover { background: rgba(255,255,255,0.25); }

/* ===================== APPROVAL FLOW ===================== */
.approval-step { display: flex; align-items: center; gap: 10px; padding: 12px 15px; border-radius: 10px; margin-bottom: 8px; }
.approval-step.pending { background: #FEF3C7; border-right: 3px solid #F59E0B; }
.approval-step.approved { background: #F0FDF4; border-right: 3px solid #10B981; }
.approval-step.rejected { background: #FEF2F2; border-right: 3px solid #EF4444; }
.approval-avatar { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 14px; color: white; }

/* ===================== KEYBOARD SHORTCUT TOOLTIP ===================== */
.kbd { display: inline-flex; align-items: center; justify-content: center; background: #E2E8F0; border: 1px solid #CBD5E1; border-radius: 5px; padding: 2px 7px; font-size: 11px; font-weight: 700; font-family: monospace; color: #475569; box-shadow: 0 2px 0 #B2BFCA; }
body.dark-mode .kbd { background: #334155; border-color: #475569; color: #94A3B8; }

/* ===================== VOUCHERS SEARCH INLINE HINT ===================== */
.vouchers-search-wrap {
    position: relative;
}
.vouchers-search-input {
    padding-left: 36px !important;
    padding-right: 132px !important;
}
.vouchers-search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #94A3B8;
    pointer-events: none;
    z-index: 2;
}
.vouchers-search-inline-hint {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    pointer-events: none;
    z-index: 2;
    max-height: calc(100% - 8px);
}
.vouchers-search-inline-label {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    font-weight: 700;
    color: #4361EE;
    white-space: nowrap;
}
.vouchers-search-inline-label i {
    font-size: 12px;
}
.vouchers-search-kbd {
    font-size: 10px !important;
    padding: 2px 6px !important;
    margin: 0;
}
body.dark-mode .vouchers-search-inline-label { color: #93C5FD; }

/* ===================== TONER ALERT PULSE ===================== */
.toner-critical { animation: tonerPulse 1.5s infinite; }
@keyframes tonerPulse { 0%,100% { box-shadow: 0 0 0 0 rgba(239,68,68,0.4); } 50% { box-shadow: 0 0 0 8px rgba(239,68,68,0); } }

/* ===================== WHATSAPP BTN ===================== */
.btn-whatsapp { background: #25D366; color: white; border-radius: var(--radius-md); padding: 8px 16px; font-weight: 700; font-size: 13px; display: inline-flex; align-items: center; gap: 8px; transition: var(--transition); }
.btn-whatsapp:hover { background: #128C7E; transform: translateY(-2px); box-shadow: 0 8px 20px rgba(37,211,102,0.3); }

/* ===================== PROGRESS RING ===================== */
.progress-ring-wrap { position: relative; display: inline-flex; align-items: center; justify-content: center; }
.progress-ring-label { position: absolute; font-weight: 800; font-size: 18px; color: var(--text-main); }

/* text-sm utility */
.text-sm { font-size: 12px; }

/* ===================== LOGIN PAGE ENHANCEMENTS ===================== */
.login-glass {
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border: 1px solid rgba(67, 97, 238, 0.25);
    border-radius: var(--radius-lg);
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.5), inset 0 0 20px rgba(67, 97, 238, 0.1);
}

@keyframes slideDownFade {
    0% { opacity: 0; transform: translateY(-30px) scale(0.95); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}

.mr-5 { margin-right: 5px; }

/* ===================== PROFESSIONAL TOASTS ===================== */
#toast-container {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 200000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 420px;
}
.toast-notification {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 12px;
    background: #FFFFFF;
    box-shadow: 0 10px 30px rgba(2, 6, 23, 0.16);
    border-right: 4px solid #4361EE;
    animation: toastIn .22s ease-out;
    position: relative;
    overflow: hidden;
}
.toast-notification.success { border-right-color: #10B981; }
.toast-notification.error { border-right-color: #EF4444; }
.toast-notification.warning { border-right-color: #F59E0B; }
.toast-notification.info { border-right-color: #4361EE; }
.toast-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #fff;
    font-size: 12px;
}
.toast-notification.success .toast-icon { background: #10B981; }
.toast-notification.error .toast-icon { background: #EF4444; }
.toast-notification.warning .toast-icon { background: #F59E0B; }
.toast-notification.info .toast-icon { background: #4361EE; }
.toast-body { flex: 1; min-width: 0; }
.toast-title { font-size: 13px; font-weight: 800; color: #1E293B; margin-bottom: 2px; }
.toast-message { font-size: 12px; color: #475569; line-height: 1.5; word-break: break-word; }
.toast-close {
    width: 20px;
    height: 20px;
    border: none;
    background: transparent;
    color: #64748B;
    cursor: pointer;
    border-radius: 6px;
}
.toast-close:hover { background: #F1F5F9; color: #0F172A; }
.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    width: 100%;
    background: rgba(67, 97, 238, 0.35);
    transition: width linear;
}
.toast-notification.success .toast-progress { background: rgba(16, 185, 129, 0.35); }
.toast-notification.error .toast-progress { background: rgba(239, 68, 68, 0.35); }
.toast-notification.warning .toast-progress { background: rgba(245, 158, 11, 0.35); }
body.dark-mode .toast-notification {
    background: #1E293B;
    box-shadow: 0 10px 28px rgba(0,0,0,0.45);
}
body.dark-mode .toast-title { color: #E2E8F0; }
body.dark-mode .toast-message { color: #CBD5E1; }
@keyframes toastIn {
    from { opacity: 0; transform: translateY(-8px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ===================== PROFESSIONAL GRID & HELPERS ===================== */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.align-center { align-items: center; }
.gap-8 { gap: 8px; }
.gap-15 { gap: 15px; }
.mt-30 { margin-top: 30px; }
.mb-25 { margin-bottom: 25px; }
.d-block { display: block; }

.stat-mini { background: white; padding: 5px 12px; border-radius: 10px; box-shadow: var(--shadow-soft); font-size: 13px; }
body.dark-mode .stat-mini { background: #1E293B; }

.inventory-grid { margin-top: 20px; }
.inventory-card { transition: var(--transition); }
.inventory-card:hover { transform: translateY(-5px); border-top-width: 8px; }

.ai-printer-card { border-radius: 15px; transition: var(--transition); }
.ai-printer-card:hover { background: rgba(67, 97, 238, 0.03); }
body.dark-mode .ai-printer-card:hover { background: rgba(255,255,255,0.02); }

.metric-box { transition: var(--transition); border: 1px solid transparent; }
.metric-box:hover { border-color: var(--primary); transform: scale(1.02); }

canvas#mainDashboardChart {
    max-height: 350px !important;
}

/* RTL Adjustments for charts */
.chart-container { direction: ltr !important; }

.maint-chk-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 8px 12px;
    padding: 12px;
    background: #F8FAFC;
    border: 1px solid #E2E8F0;
    border-radius: 10px;
    max-height: 220px;
    overflow-y: auto;
}
.maint-chk-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    cursor: pointer;
    margin: 0;
}
.maint-chk-item input { width: 16px; height: 16px; flex-shrink: 0; }
body.dark-mode .maint-chk-grid { background: #1E293B; border-color: #334155; }


.maint-parts-other-wrap {
    padding: 8px 10px;
    background: #FFFBEB;
    border: 1px dashed #F59E0B;
    border-radius: 8px;
}
.maint-parts-other-wrap input { max-width: 100%; }
body.dark-mode .maint-parts-other-wrap { background: #422006; border-color: #B45309; }

/* قالب طباعة العقود — معاينة مرئية */
.cpt-preview-paper {
    background: #fff;
    box-shadow: 0 14px 48px rgba(15, 23, 42, 0.14);
    border-radius: 6px;
    padding: 10px 12px 20px;
    margin-bottom: 16px;
}
#cpt-live-preview-wrap .cpt-preview-paper table { width: 100%; }
#contract-print-template-modal .cpt-preview-section {
    cursor: pointer;
    transition: outline-color 0.15s ease, box-shadow 0.15s ease;
}
#contract-print-template-modal .cpt-preview-section:hover {
    outline: 2px solid #4361EE;
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(67, 97, 238, 0.12);
}
.cpt-html-block summary { list-style: none; }
.cpt-html-block summary::-webkit-details-marker { display: none; }
#contract-print-template-modal .tox-tinymce { border-radius: 10px; }
#contract-print-template-modal .tox .tox-edit-area__iframe {
    background: #fff;
}
/* ارتفاع ثابت للمنطقة الوسطى حتى لا تنهار (flex-basis:0 بدون height للأب = ارتفاع 0) */
#contract-print-template-modal .cpt-modal-shell {
    min-height: 0;
    max-height: 94vh;
    /* ارتفاع صريح حتى يُوزَّع flex بين الرأس / الجسم / الأزرار */
    height: min(94vh, 920px);
}
#contract-print-template-modal .cpt-editor-body {
    flex: 1 1 auto;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: clamp(280px, calc(94vh - 220px), 800px);
    max-height: calc(94vh - 170px);
}
#contract-print-template-modal .cpt-editor-grid {
    flex: 1 1 auto;
    min-height: 260px;
    display: grid;
    grid-template-columns: minmax(320px, 1.5fr) minmax(280px, 1fr);
    gap: 18px;
    overflow: hidden;
    align-items: stretch;
}
#contract-print-template-modal .cpt-preview-scroll,
#contract-print-template-modal .cpt-controls-scroll {
    min-height: 0;
    max-height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
#contract-print-template-modal #cpt-live-preview-wrap {
    min-height: 200px;
}
@media (max-width: 900px) {
    .cpt-editor-grid { grid-template-columns: 1fr !important; }
    #contract-print-template-modal .cpt-editor-grid {
        overflow-y: auto;
        max-height: none;
    }
    #cpt-live-preview-wrap { min-height: 240px !important; max-height: 48vh !important; }
    #contract-print-template-modal .cpt-controls-scroll { max-height: none !important; }
}

/* —— Document verification (QR / enterprise) —— */
.erp-doc-verify-modal {
    z-index: 10050 !important;
    align-items: center;
    justify-content: center;
    padding: clamp(12px, 3vw, 24px);
    background: rgba(15, 23, 42, 0.72);
    backdrop-filter: blur(12px);
}
.erp-doc-verify-modal .erp-doc-verify-card {
    width: min(520px, 100%);
    margin: 0;
    padding: 0;
    border-radius: 20px;
    overflow: hidden;
    border: 1px solid rgba(226, 232, 240, 0.9);
    box-shadow: 0 28px 60px rgba(15, 23, 42, 0.22), 0 0 0 1px rgba(67, 97, 238, 0.06);
    animation: modalZoom 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.2);
}
.erp-doc-verify-body { min-height: 120px; }
.erp-verify-shell { font-family: Cairo, "Segoe UI", sans-serif; direction: rtl; }
.erp-verify-brand {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 22px 24px 18px;
    background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 48%, #312e81 100%);
    color: #fff;
    position: relative;
}
.erp-verify-brand::after {
    content: "";
    position: absolute;
    inset-inline-end: -20%;
    top: -40%;
    width: 55%;
    height: 140%;
    background: radial-gradient(circle, rgba(67, 97, 238, 0.35) 0%, transparent 70%);
    pointer-events: none;
}
.erp-verify-logo-wrap {
    width: 72px;
    height: 72px;
    border-radius: 16px;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
    overflow: hidden;
    position: relative;
    z-index: 1;
}
.erp-verify-logo-wrap img {
    max-width: 88%;
    max-height: 88%;
    object-fit: contain;
}
.erp-verify-logo-fallback {
    font-size: 28px;
    color: #4361EE;
}
.erp-verify-brand-text { position: relative; z-index: 1; flex: 1; min-width: 0; }
.erp-verify-brand-text h2 {
    margin: 0 0 4px;
    font-size: 1.15rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.35;
}
.erp-verify-brand-text p {
    margin: 0;
    font-size: 12px;
    opacity: 0.88;
    font-weight: 600;
}
.erp-verify-close {
    position: absolute;
    top: 14px;
    left: 14px;
    z-index: 2;
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}
.erp-verify-close:hover { background: rgba(255, 255, 255, 0.28); }
.erp-verify-main { padding: 22px 24px 20px; background: #fff; }
.erp-verify-status {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    padding: 16px 18px;
    border-radius: 14px;
    margin-bottom: 20px;
    border: 1px solid transparent;
}
.erp-verify-status__icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}
.erp-verify-status__title {
    margin: 0 0 6px;
    font-size: 1.05rem;
    font-weight: 800;
    line-height: 1.4;
}
.erp-verify-status__sub {
    margin: 0;
    font-size: 13px;
    line-height: 1.75;
    color: #64748b;
    font-weight: 600;
}
.erp-verify-status--success {
    background: linear-gradient(135deg, #ecfdf5 0%, #f0fdf4 100%);
    border-color: #a7f3d0;
}
.erp-verify-status--success .erp-verify-status__icon {
    background: #10b981;
    color: #fff;
}
.erp-verify-status--success .erp-verify-status__title { color: #047857; }
.erp-verify-status--warning {
    background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
    border-color: #fde68a;
}
.erp-verify-status--warning .erp-verify-status__icon {
    background: #f59e0b;
    color: #fff;
}
.erp-verify-status--warning .erp-verify-status__title { color: #b45309; }
.erp-verify-status--error {
    background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
    border-color: #fecaca;
}
.erp-verify-status--error .erp-verify-status__icon {
    background: #ef4444;
    color: #fff;
}
.erp-verify-status--error .erp-verify-status__title { color: #b91c1c; }
.erp-verify-status--info {
    background: linear-gradient(135deg, #eff6ff 0%, #e0e7ff 100%);
    border-color: #c7d2fe;
}
.erp-verify-status--info .erp-verify-status__icon {
    background: #4361EE;
    color: #fff;
}
.erp-verify-status--info .erp-verify-status__title { color: #3730a3; }
.erp-verify-meta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px 16px;
    margin: 0 0 18px;
    padding: 0;
}
.erp-verify-meta dt {
    margin: 0 0 4px;
    font-size: 11px;
    font-weight: 700;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.erp-verify-meta dd {
    margin: 0;
    font-size: 14px;
    font-weight: 700;
    color: #1e293b;
    word-break: break-word;
}
.erp-verify-meta dd code {
    font-family: ui-monospace, monospace;
    font-size: 13px;
    background: #f1f5f9;
    padding: 4px 10px;
    border-radius: 8px;
    color: #4361EE;
    letter-spacing: 0.06em;
}
.erp-verify-foot {
    padding: 14px 24px 20px;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    font-size: 11px;
    color: #94a3b8;
    line-height: 1.7;
    font-weight: 600;
}
.erp-verify-foot time { color: #64748b; font-weight: 700; }
.erp-verify-actions {
    padding: 0 24px 22px;
    background: #f8fafc;
}
.erp-verify-actions .btn {
    width: 100%;
    padding: 14px;
    font-weight: 800;
    border-radius: 12px;
}
.erp-verify-loading {
    text-align: center;
    padding: 48px 24px;
    color: #64748b;
}
.erp-verify-loading i { font-size: 32px; color: #4361EE; margin-bottom: 12px; display: block; }
@media (max-width: 480px) {
    .erp-verify-meta { grid-template-columns: 1fr; }
    .erp-verify-brand { flex-direction: column; text-align: center; padding-top: 44px; }
    .erp-verify-close { top: 10px; left: 10px; }
}

/* بوابة العميل العامة + تقييم الخدمة */
.erp-portal-rating {
    background: linear-gradient(135deg, #ecfdf5, #f0fdf4);
    border: 1px solid #86efac;
    border-radius: 14px;
    padding: 14px;
}
.erp-portal-rating .portal-star-btn { cursor: pointer; transition: transform 0.15s ease; }
.erp-portal-rating .portal-star-btn:hover { transform: scale(1.12); }
#customer-portal .mobile-header {
    background: linear-gradient(135deg, #1e3a8a 0%, #6366f1 55%, #8b5cf6 100%) !important;
}
#sla-report .page-header.flex-between { align-items: flex-end; flex-wrap: wrap; gap: 12px; }

body.erp-portal-public-active .sidebar,
body.erp-portal-public-active .top-header,
body.erp-portal-public-active .erp-sidebar-toggle {
    display: none !important;
}
body.erp-portal-public-active .main-content {
    margin: 0 !important;
    padding: 0 !important;
    max-width: 100% !important;
    width: 100% !important;
}
body.erp-portal-public-active #customer-portal {
    min-height: 100vh;
    padding: 12px 16px 28px;
    background: linear-gradient(160deg, #0f172a 0%, #1e3a8a 42%, #4f46e5 100%);
}
#customer-portal.erp-portal-public-mode .portal-mockup-wrapper {
    max-width: 520px;
    margin: 0 auto;
}
#customer-portal.erp-portal-public-mode .mobile-device {
    border-color: rgba(255, 255, 255, 0.15);
    box-shadow: 0 32px 64px -16px rgba(15, 23, 42, 0.55);
}
.erp-portal-ro-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 12px;
}
.erp-portal-ro-label {
    display: block;
    font-size: 10px;
    color: #64748b;
    font-weight: 700;
    margin-bottom: 4px;
}
.erp-portal-ro-grid strong {
    font-size: 12px;
    color: #0f172a;
}
.erp-portal-pin-gate {
    background: linear-gradient(135deg, #eff6ff, #f8fafc);
    border: 1px solid #bfdbfe;
    border-radius: 14px;
    padding: 14px;
}
/* مدخلات ملف — مخفية بصرياً لكن تبقى قابلة للتفعيل عبر <label for> على iOS/Android */
.erp-public-file-offscreen,
.erp-public-file-native {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
    opacity: 0.01 !important;
}
label.erp-public-file-label {
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin: 0;
    text-align: center;
}
.erp-public-media-fallback {
    margin-top: 12px;
    padding: 12px;
    border-radius: 12px;
    background: #f8fafc;
    border: 1px dashed #94a3b8;
}
.erp-portal-camera-modal {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    align-items: stretch;
    justify-content: center;
}
.erp-portal-camera-modal[hidden] {
    display: none !important;
}
.erp-portal-camera-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.92);
}
.erp-portal-camera-panel {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 520px;
    margin: 0 auto;
    padding: max(12px, env(safe-area-inset-top)) 12px max(16px, env(safe-area-inset-bottom));
    box-sizing: border-box;
}
.erp-portal-camera-video {
    flex: 1;
    width: 100%;
    min-height: 50vh;
    max-height: calc(100dvh - 120px);
    object-fit: cover;
    border-radius: 16px;
    background: #000;
}
.erp-portal-camera-status {
    color: #e2e8f0;
    text-align: center;
    font-size: 13px;
    margin: 10px 0;
}
.erp-portal-camera-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: center;
}
.erp-portal-camera-actions .erp-public-btn-primary {
    flex: 1;
    max-width: 220px;
}
.erp-portal-camera-timer {
    color: #fbbf24;
    text-align: center;
    font-size: 18px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    margin: 8px 0;
    letter-spacing: 0.05em;
}
.erp-public-media-btns {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.erp-public-btn-video .erp-video-max-badge {
    font-size: 10px;
    opacity: 0.85;
    margin-inline-start: 2px;
}
.erp-portal-rec-btn[hidden] {
    display: none !important;
}
.erp-public-media-hint {
    margin: 0 0 10px;
    font-size: 12px;
}
.portal-attach-preview {
    display: none;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}
.portal-attach-thumb {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    max-width: 88px;
}
.portal-attach-thumb--over {
    outline: 2px solid #ef4444;
    border-radius: 10px;
    padding: 2px;
}
.portal-attach-meta {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    width: 100%;
    font-size: 10px;
    line-height: 1.25;
    text-align: center;
    color: #475569;
}
.portal-attach-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 84px;
}
.portal-attach-size {
    font-weight: 600;
    color: #334155;
}
.portal-attach-size--over {
    color: #dc2626;
}
.erp-public-attach-summary {
    margin-top: 8px;
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 12px;
    line-height: 1.45;
    background: #f1f5f9;
    color: #334155;
}
.erp-public-attach-summary--error {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}
.portal-attach-remove {
    position: absolute;
    top: -6px;
    left: -6px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: none;
    background: #ef4444;
    color: #fff;
    font-size: 10px;
    cursor: pointer;
}

/* بوابة QR — إخفاء الدخول فور تحميل الصفحة */
html.erp-portal-qr-boot #login-overlay {
    display: none !important;
}
html.erp-portal-qr-boot body {
    background: linear-gradient(165deg, #0f172a 0%, #1e3a8a 38%, #4338ca 72%, #6366f1 100%);
    min-height: 100dvh;
}

/* بوابة الخدمة العامة — واجهة موبايل كاملة */
body.erp-portal-public-active {
    overflow-x: hidden;
    background: linear-gradient(165deg, #0f172a 0%, #1e3a8a 38%, #4338ca 72%, #6366f1 100%);
}
body.erp-portal-public-active #login-overlay {
    display: none !important;
}
body.erp-portal-public-active .app-container {
    display: flex !important;
    height: 100dvh !important;
    min-height: 100dvh;
    background: linear-gradient(165deg, #0f172a 0%, #1e3a8a 38%, #4338ca 72%, #6366f1 100%);
}
body.erp-portal-public-active .sidebar,
body.erp-portal-public-active .top-header,
body.erp-portal-public-active #smartAlertBar,
body.erp-portal-public-active .notification-wrap {
    display: none !important;
}
body.erp-portal-public-active .main-content {
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    max-width: none !important;
    flex: 1 !important;
    overflow: auto !important;
    background: transparent !important;
}
body.erp-portal-public-active .page-section:not(#customer-portal) {
    display: none !important;
}
body.erp-portal-public-active #customer-portal {
    display: block !important;
    min-height: 100dvh;
    padding: 0 !important;
    margin: 0 !important;
    background: transparent !important;
}
body.erp-portal-public-active #erp-public-service-shell:not([hidden]) {
    display: block !important;
}
.erp-public-service-shell {
    min-height: 100dvh;
    padding: max(12px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
    box-sizing: border-box;
    font-family: "Cairo", "Segoe UI", Tahoma, sans-serif;
}
.erp-public-service-inner {
    max-width: 480px;
    margin: 0 auto;
}
.erp-public-secure-banner {
    margin-bottom: 12px;
    padding: 10px 12px;
    border-radius: 12px;
    background: #fef3c7;
    border: 1px solid #f59e0b;
    color: #92400e;
    font-size: 0.88rem;
    line-height: 1.45;
}
.erp-public-secure-banner i {
    margin-inline-end: 6px;
}
.erp-public-header {
    margin-bottom: 16px;
}
.erp-public-hero {
    text-align: center;
    margin-bottom: 18px;
    padding: 0 4px;
}
.erp-public-tagline {
    margin: 0 0 14px;
    font-size: clamp(0.95rem, 3.8vw, 1.12rem);
    font-weight: 700;
    line-height: 1.65;
    color: rgba(255, 255, 255, 0.96);
    letter-spacing: 0.01em;
    text-shadow: 0 2px 12px rgba(15, 23, 42, 0.25);
}
.erp-public-company-brand {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 10px 22px 12px;
    border-radius: 14px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.22) 0%, rgba(255, 255, 255, 0.08) 100%);
    border: 1px solid rgba(255, 255, 255, 0.35);
    box-shadow: 0 8px 28px rgba(15, 23, 42, 0.18);
    backdrop-filter: blur(8px);
}
.erp-public-company-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.78);
    letter-spacing: 0.12em;
    text-transform: uppercase;
}
.erp-public-company-name {
    font-size: clamp(1.15rem, 4.5vw, 1.45rem);
    font-weight: 800;
    color: #fff;
    letter-spacing: 0.02em;
    line-height: 1.3;
}
.erp-public-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    color: #fff;
}
.erp-public-logo {
    max-height: 52px;
    max-width: 120px;
    object-fit: contain;
    border-radius: 10px;
    background: #fff;
    padding: 6px;
}
.erp-public-logo-fallback {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: #fbbf24;
}
.erp-public-title {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 800;
}
.erp-public-sub {
    margin: 4px 0 0;
    font-size: 0.85rem;
    opacity: 0.88;
}
.erp-public-loading,
.erp-public-error {
    text-align: center;
    padding: 28px 16px;
    color: #e2e8f0;
    font-size: 0.95rem;
}
.erp-public-error {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(248, 113, 113, 0.5);
    border-radius: 14px;
    color: #fecaca;
}
.erp-public-card {
    background: #fff;
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: 0 8px 32px rgba(15, 23, 42, 0.12);
}
.erp-public-card-title {
    margin: 0 0 12px;
    font-size: 0.95rem;
    font-weight: 800;
    color: #1e293b;
}
.erp-public-dl {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin: 0;
}
.erp-public-dl dt {
    font-size: 0.7rem;
    color: #64748b;
    font-weight: 700;
    margin: 0 0 2px;
}
.erp-public-dl dd {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 800;
    color: #0f172a;
}
.erp-public-pin-card {
    border: 2px solid #93c5fd;
}
.erp-public-hint {
    font-size: 0.8rem;
    color: #64748b;
    margin: 0 0 10px;
}
.erp-public-input,
.erp-public-textarea {
    width: 100%;
    min-height: 48px;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    padding: 12px 14px;
    font-size: 1rem;
    font-family: inherit;
    box-sizing: border-box;
}
.erp-public-textarea {
    min-height: 100px;
    resize: vertical;
}
.erp-public-pin-error {
    color: #dc2626;
    font-size: 0.8rem;
    margin: 6px 0;
}
.erp-public-pin-card.erp-portal-pin-locked {
    border-color: #f59e0b;
    background: linear-gradient(180deg, #fffbeb 0%, #ffffff 40%);
}
.erp-public-pin-card.erp-portal-pin-locked #portal-pin-input {
    opacity: 0.55;
    pointer-events: none;
}
.erp-public-captcha-gate {
    margin-top: 12px;
    padding: 14px;
    border-radius: 12px;
    border: 2px dashed #f59e0b;
    background: #fffbeb;
}
.erp-public-captcha-warn {
    color: #b45309;
    font-size: 0.85rem;
    font-weight: 800;
    margin: 0 0 10px;
    line-height: 1.5;
}
.erp-public-captcha-question {
    font-size: 1.1rem;
    font-weight: 900;
    color: #0f172a;
    margin: 0 0 10px;
}
.erp-public-btn {
    min-height: 48px;
    border-radius: 12px;
    border: none;
    font-weight: 800;
    font-size: 0.95rem;
    cursor: pointer;
    font-family: inherit;
    padding: 12px 16px;
    width: 100%;
    margin-top: 8px;
}
.erp-public-btn-primary {
    background: linear-gradient(135deg, #2563eb, #4f46e5);
    color: #fff;
    min-height: 52px;
    font-size: 1.05rem;
    box-shadow: 0 8px 24px rgba(37, 99, 235, 0.35);
}
.erp-public-btn-secondary {
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
}
.erp-public-btn-outline {
    background: #fff;
    color: #334155;
    border: 2px solid #e2e8f0;
}
.erp-public-service-chips {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}
.erp-public-chip {
    min-height: 44px;
    border-radius: 12px;
    border: 2px solid #e2e8f0;
    background: #f8fafc;
    font-weight: 800;
    font-size: 0.85rem;
    cursor: pointer;
    font-family: inherit;
}
.erp-public-chip.active {
    border-color: #4f46e5;
    background: #eef2ff;
    color: #3730a3;
}
.erp-public-select-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}
.erp-public-ink {
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    padding: 14px 8px;
    text-align: center;
    font-weight: 800;
    cursor: pointer;
}
.erp-public-ink.active {
    border-color: #fff !important;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.9), 0 0 0 5px #4f46e5;
    transform: scale(1.04);
}
.erp-ink-k { background: #0f172a !important; color: #fff !important; border-color: #334155 !important; }
.erp-ink-c { background: #06b6d4 !important; color: #fff !important; border-color: #0891b2 !important; }
.erp-ink-m { background: #ec4899 !important; color: #fff !important; border-color: #db2777 !important; }
.erp-ink-y { background: #eab308 !important; color: #1e293b !important; border-color: #ca8a04 !important; }
.erp-ink-k.active { background: #0f172a !important; }
.erp-ink-c.active { background: #06b6d4 !important; }
.erp-ink-m.active { background: #ec4899 !important; }
.erp-ink-y.active { background: #eab308 !important; color: #1e293b !important; }
#portal-service-panel.portal-service-locked {
    display: none !important;
    pointer-events: none;
}
.erp-public-history-table-wrap { overflow-x: auto; margin-top: 8px; }
.erp-public-history-scroll { max-height: 320px; overflow: auto; }
.erp-public-history-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
    background: #fff;
    border-radius: 10px;
    overflow: hidden;
}
.erp-public-history-table th,
.erp-public-history-table td {
    padding: 8px 6px;
    border-bottom: 1px solid #e2e8f0;
    text-align: right;
    white-space: nowrap;
}
.erp-public-history-table th {
    background: #f1f5f9;
    color: #334155;
    font-weight: 700;
}
.erp-public-att-badge {
    display: inline-block;
    font-size: 10px;
    color: #4f46e5;
    margin-right: 4px;
}
.erp-public-success-screen {
    position: fixed;
    inset: 0;
    z-index: 12000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(15, 23, 42, 0.72);
    backdrop-filter: blur(6px);
}
.erp-public-success-screen[hidden] { display: none !important; }
.erp-public-success-card {
    max-width: 420px;
    width: 100%;
    background: linear-gradient(165deg, #ffffff 0%, #f8fafc 100%);
    border-radius: 20px;
    padding: 28px 24px;
    text-align: center;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(79, 70, 229, 0.15);
}
.erp-public-success-icon {
    width: 72px;
    height: 72px;
    margin: 0 auto 16px;
    border-radius: 50%;
    background: linear-gradient(135deg, #10b981, #059669);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
}
.erp-public-success-card h2 {
    margin: 0 0 10px;
    font-size: 1.35rem;
    color: #0f172a;
}
.erp-public-success-lead {
    color: #475569;
    line-height: 1.6;
    margin: 0 0 14px;
}
.erp-public-success-hours {
    list-style: none;
    padding: 12px;
    margin: 0 0 16px;
    background: #eef2ff;
    border-radius: 12px;
    text-align: right;
    font-size: 13px;
    color: #3730a3;
}
.erp-public-success-hours li { margin: 6px 0; }
.erp-public-success-ticket {
    font-weight: 700;
    color: #4f46e5;
    margin: 0 0 12px;
}
.erp-public-success-footer {
    font-size: 1.1rem;
    font-weight: 800;
    color: #6366f1;
    margin: 16px 0 20px;
    letter-spacing: 0.02em;
}
.erp-public-media-btns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 8px;
}
.erp-public-success-inline {
    color: #059669;
    font-weight: 700;
    text-align: center;
}
#portal-service-panel[style*="display: none"] {
    opacity: 0.4;
    pointer-events: none;
}
.erp-svc-tickets-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 16px;
}
.erp-svc-tickets-tab {
    border: 1px solid #e2e8f0;
    background: #fff;
    color: #475569;
    border-radius: 10px;
    padding: 8px 14px;
    font-size: 13px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.erp-svc-tickets-tab:hover {
    border-color: #c7d2fe;
    color: #4338ca;
}
.erp-svc-tickets-tab.active {
    background: linear-gradient(135deg, #4f46e5, #6366f1);
    border-color: #4f46e5;
    color: #fff;
}
.erp-svc-tab-count {
    font-size: 11px;
    opacity: 0.85;
}
.erp-svc-section-title {
    font-size: 15px;
    margin: 0 0 10px;
    color: #0f172a;
    display: flex;
    align-items: center;
    gap: 8px;
}
.erp-svc-tickets-section {
    margin-bottom: 22px;
}
.erp-portal-tickets-scroll {
    overflow-x: auto;
}
.erp-portal-tickets-table {
    min-width: 1100px;
    font-size: 12px;
}
.erp-public-att-thumb {
    max-height: 36px;
    border-radius: 4px;
    vertical-align: middle;
}
.erp-public-gps-link {
    font-size: 11px;
    color: #4f46e5;
}
.erp-maint-visit-modal .erp-maint-visit-modal-content {
    max-height: 94vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.erp-maint-visit-modal-scroll {
    overflow-y: auto;
    flex: 1;
    min-height: 0;
    max-height: calc(94vh - 220px);
    padding: 4px 2px 12px;
    -webkit-overflow-scrolling: touch;
}
.maint-visit-ticket-banner {
    display: none;
    padding: 12px 14px;
    background: #EEF2FF;
    border: 1px solid #C7D2FE;
    border-radius: 10px;
    flex-shrink: 0;
}
.maint-visit-portal-context {
    margin-bottom: 16px;
    padding: 14px 16px;
    background: #F8FAFC;
    border: 1px solid #E2E8F0;
    border-radius: 12px;
}
.maint-portal-section-title {
    font-size: 13px;
    font-weight: 700;
    color: #334155;
    margin: 0 0 8px;
}
.maint-portal-readonly {
    background: #fff;
    border: 1px solid #E2E8F0;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 13px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 140px;
    overflow-y: auto;
}
.maint-portal-meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px 14px;
    font-size: 13px;
}
.maint-portal-attachments-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: flex-start;
}
.maint-portal-att-item {
    display: inline-block;
    border: 1px solid #E2E8F0;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
}
.maint-portal-att-item img {
    display: block;
    max-height: 72px;
    max-width: 96px;
    object-fit: cover;
}
.maint-portal-att-file {
    padding: 8px 10px;
    font-size: 12px;
    color: #4f46e5;
}

/* —— تصفية ذكية للصفحة (Page smart filter) —— */
.erp-page-filter-overlay {
    position: fixed;
    inset: 0;
    z-index: 99990;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(15, 23, 42, 0.72);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}
.erp-page-filter-overlay.open {
    display: flex;
    animation: fadeIn 0.22s ease;
}
.erp-page-filter-panel {
    width: min(520px, 100%);
    max-height: min(420px, 90vh);
    overflow: auto;
    border-radius: 22px;
    padding: 22px 24px;
    background: linear-gradient(155deg, rgba(255, 255, 255, 0.98) 0%, rgba(248, 250, 252, 0.96) 100%);
    border: 1px solid rgba(226, 232, 240, 0.95);
    box-shadow: 0 28px 60px -20px rgba(67, 97, 238, 0.35), 0 0 0 1px rgba(255, 255, 255, 0.6) inset;
}
body.dark-mode .erp-page-filter-panel,
html.dark .erp-page-filter-panel {
    background: linear-gradient(155deg, rgba(30, 41, 59, 0.98), rgba(15, 23, 42, 0.95));
    border-color: rgba(71, 85, 105, 0.6);
    box-shadow: 0 28px 50px rgba(0, 0, 0, 0.45);
}
.erp-page-filter-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 16px;
}
.erp-page-filter-head h3 {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 8px;
}
.erp-page-filter-sub {
    margin: 6px 0 0;
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.55;
}
.erp-page-filter-close {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    border: 1px solid #E2E8F0;
    background: #fff;
    color: #64748B;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}
.erp-page-filter-close:hover {
    background: #FEF2F2;
    border-color: #FECACA;
    color: #B91C1C;
}
.erp-page-filter-field {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 14px;
    background: #fff;
    border: 2px solid #E2E8F0;
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.06);
    transition: border-color 0.2s, box-shadow 0.2s;
}
.erp-page-filter-field:focus-within {
    border-color: rgba(67, 97, 238, 0.55);
    box-shadow: 0 0 0 4px rgba(67, 97, 238, 0.12);
}
.erp-page-filter-field i {
    color: var(--primary);
    font-size: 18px;
}
.erp-page-filter-field input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 15px;
    font-weight: 600;
    background: transparent;
}
.erp-page-filter-meta {
    margin-top: 12px;
    font-size: 12px;
    color: var(--text-muted);
    min-height: 1.4em;
}
.erp-page-filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 14px;
}
.erp-chip {
    font-size: 11px;
    font-weight: 700;
    padding: 5px 10px;
    border-radius: 999px;
    background: linear-gradient(135deg, #EEF2FF, #E0E7FF);
    color: #4338CA;
    border: 1px solid #C7D2FE;
}
.erp-page-filter-fab {
    position: fixed;
    inset-inline-start: 20px;
    bottom: 22px;
    z-index: 9990;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-radius: 999px;
    border: none;
    font-family: inherit;
    font-size: 13px;
    font-weight: 800;
    color: #fff;
    cursor: pointer;
    background: linear-gradient(135deg, #6366F1 0%, #8B5CF6 45%, #A855F7 100%);
    box-shadow: 0 12px 28px -6px rgba(99, 102, 241, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.25) inset;
    transition: transform 0.2s, box-shadow 0.2s;
}
.erp-page-filter-fab:hover {
    transform: translateY(-2px);
    box-shadow: 0 16px 36px -8px rgba(99, 102, 241, 0.6);
}
.erp-page-filter-fab i {
    font-size: 15px;
}
/* —— سلة المحذوفات: بحث وتصفية ذكية —— */
.erp-trash-smart-bar {
    margin-bottom: 14px;
    padding: 16px 18px;
    border-radius: var(--radius-lg);
    border: 1px solid rgba(67, 97, 238, 0.18);
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.96) 0%, rgba(248, 250, 252, 0.92) 100%);
    box-shadow: 0 8px 24px -8px rgba(67, 97, 238, 0.2);
}
.erp-trash-smart-top {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-bottom: 14px;
}
.erp-trash-smart-search {
    flex: 1;
    min-width: 220px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 14px;
    background: #fff;
    border: 2px solid #E2E8F0;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.erp-trash-smart-search:focus-within {
    border-color: rgba(239, 68, 68, 0.45);
    box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.1);
}
.erp-trash-smart-search i {
    color: #EF4444;
    font-size: 17px;
}
.erp-trash-smart-search input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 14px;
    font-weight: 600;
    background: transparent;
}
.erp-trash-smart-filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
}
.erp-trash-filter-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.erp-trash-filter-field span {
    font-size: 11px;
    font-weight: 800;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.02em;
}
.erp-trash-filter-field select {
    font-size: 13px;
    font-weight: 600;
    min-height: 40px;
}
.erp-trash-filter-meta {
    margin: 12px 0 0;
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 600;
}

@media (max-width: 640px) {
    .erp-page-filter-fab span {
        display: none;
    }
    .erp-page-filter-fab {
        width: 52px;
        height: 52px;
        padding: 0;
        justify-content: center;
        border-radius: 50%;
    }
}
