:root {
    --primary: #004C40;
    --primary-light: #E6F3F0;
    --primary-dark: #00382F;
    --success: #047857;
    --success-light: #d1fae5;
    --warning: #b45309;
    --warning-light: #fef3c7;
    --danger: #be123c;
    --danger-light: #ffe4e6;
    --info: #0e7490;
    --info-light: #cffafe;
    --dark: #0f172a;
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;
    --sidebar-width: 280px;
    --header-height: 72px;
    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 2px rgba(15,23,42,0.05);
    --shadow: 0 1px 3px rgba(15,23,42,0.08), 0 1px 2px rgba(15,23,42,0.04);
    --shadow-md: 0 4px 6px -1px rgba(15,23,42,0.08), 0 2px 4px -1px rgba(15,23,42,0.04);
    --shadow-lg: 0 10px 15px -3px rgba(15,23,42,0.08), 0 4px 6px -2px rgba(15,23,42,0.04);
    --shadow-xl: 0 20px 25px -5px rgba(15,23,42,0.08), 0 10px 10px -5px rgba(15,23,42,0.04);
    --motion-fast: 0.16s;
    --motion-base: 0.22s;
    --motion-slow: 0.36s;
    --ease-premium: cubic-bezier(.2,.8,.2,1);
    --ease-spring: cubic-bezier(.16,1,.3,1);
    --shadow-lift: 0 10px 24px rgba(15,23,42,.12);
}

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

html { scroll-behavior: smooth; }

body {
    font-family: 'Tajawal', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--gray-50);
    color: var(--gray-800);
    font-size: 0.9rem;
    line-height: 1.6;
    overflow-x: hidden;
}

.bg-primary { background-color: var(--primary) !important; }
.text-primary { color: var(--primary) !important; }
.btn-outline-primary { color: var(--primary); border-color: var(--primary); }
.btn-outline-primary:hover { background: var(--primary); border-color: var(--primary); color: #fff; }

/* Layout */
.app-wrapper {
    display: flex;
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
    width: 100%;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: #ffffff;
    border-left: 1px solid var(--gray-200);
    display: flex;
    flex-direction: column;
    position: fixed;
    right: 0;
    top: 0;
    height: 100vh;
    z-index: 1040;
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-lg);
}

.sidebar-brand {
    padding: 24px 20px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    border-bottom: 1px solid var(--gray-100);
}

.brand-icon {
    width: 92px;
    min-width: 92px;
    height: 42px;
    background: #fff;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px 6px;
    box-shadow: 0 4px 12px rgba(0,76,64,0.12);
    border: 1px solid var(--primary-light);
}
.brand-logo { width: 100%; height: 100%; object-fit: contain; display: block; }

.brand-text { display: flex; flex-direction: column; }
.brand-title { font-size: 1.02rem; font-weight: 800; color: var(--primary); line-height: 1.2; }
.brand-subtitle { font-size: 0.7rem; color: var(--gray-400); font-weight: 500; letter-spacing: 0.3px; }

.sidebar-menu {
    flex: 1;
    padding: 16px 14px;
    overflow-y: auto;
}

.menu-group { margin-bottom: 24px; }
.menu-label {
    display: block;
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--gray-400);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 8px;
    padding: 0 10px;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    color: var(--gray-600);
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 600;
    transition: all 0.2s ease;
    margin-bottom: 4px;
    position: relative;
}

.menu-item:hover {
    background: var(--gray-100);
    color: var(--gray-900);
}

.menu-item.active {
    background: linear-gradient(135deg, var(--primary-light), #eff6ff);
    color: var(--primary);
    box-shadow: inset 2px 0 0 var(--primary);
}

.menu-item.highlight {
    background: linear-gradient(135deg, var(--danger-light), #fff1f2);
    color: var(--danger);
}

.menu-item.highlight:hover { background: #ffe4e6; }

.menu-icon { width: 22px; text-align: center; font-size: 0.95rem; }
.menu-text { flex: 1; }
.menu-badge {
    font-size: 0.65rem;
    padding: 3px 8px;
    border-radius: 20px;
    font-weight: 700;
    background: var(--gray-200);
    color: var(--gray-600);
}
.menu-item.active .menu-badge { background: var(--primary); color: #fff; }

.sidebar-footer { padding: 16px 20px; border-top: 1px solid var(--gray-100); }
.storage-widget small { font-size: 0.7rem; color: var(--gray-400); }

/* Overlay */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,0.3);
    backdrop-filter: blur(2px);
    z-index: 1035;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}
.sidebar-overlay.show { opacity: 1; visibility: visible; }

/* Main Content */
.main-content {
    flex: 1;
    margin-right: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    min-width: 0; /* Critical for responsive flex children */
    overflow-x: hidden;
}

/* Header */
.main-header {
    height: var(--header-height);
    background: #ffffff;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    position: sticky;
    top: 0;
    z-index: 1020;
    box-shadow: var(--shadow-sm);
}

.header-start { display: flex; align-items: center; gap: 18px; }
.toggle-sidebar {
    display: none;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--gray-200);
    background: #fff;
    color: var(--gray-500);
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.2s;
}
.toggle-sidebar:hover { background: var(--gray-100); color: var(--gray-800); }

.header-title h1 {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--gray-900);
    margin: 0;
}
.breadcrumb { font-size: 0.75rem; color: var(--gray-400); margin: 0; padding: 0; }
.breadcrumb-item + .breadcrumb-item::before { float: right; padding-left: 0.5rem; padding-right: 0; }

.header-end { display: flex; align-items: center; gap: 10px; }
.header-search {
    position: relative;
}
.header-search i {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-400);
    font-size: 0.85rem;
}
.header-search input {
    padding: 9px 38px 9px 16px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: 0.85rem;
    width: 260px;
    font-family: inherit;
    background: var(--gray-50);
    transition: all 0.2s;
}
.header-search input:focus {
    outline: none;
    border-color: var(--primary);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(30,64,175,0.08);
}

.search-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    left: 0;
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: 0 0 var(--radius) var(--radius);
    box-shadow: var(--shadow-lg);
    max-height: 400px;
    overflow-y: auto;
    z-index: 1050;
}
.search-dropdown .search-group-title {
    padding: 8px 14px;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--gray-400);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-100);
}
.search-dropdown .search-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    cursor: pointer;
    transition: background 0.15s;
    border-bottom: 1px solid var(--gray-50);
}
.search-dropdown .search-item:hover { background: var(--primary-light); }
.search-dropdown .search-item .si-icon {
    width: 32px; height: 32px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.85rem; flex-shrink: 0;
}
.search-dropdown .search-item .si-icon.emp { background: #eff6ff; color: #3b82f6; }
.search-dropdown .search-item .si-icon.ast { background: #ecfdf5; color: #10b981; }
.search-dropdown .search-item .si-icon.phn { background: #fffbeb; color: #f59e0b; }
.search-dropdown .search-item .si-icon.cst { background: #f5f3ff; color: #8b5cf6; }
.search-dropdown .search-item .si-body { flex: 1; min-width: 0; }
.search-dropdown .search-item .si-name { font-weight: 600; font-size: 0.85rem; color: var(--gray-800); }
.search-dropdown .search-item .si-sub { font-size: 0.72rem; color: var(--gray-400); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-dropdown .search-empty { padding: 24px; text-align: center; color: var(--gray-400); font-size: 0.85rem; }

.header-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--radius);
    border: 1px solid var(--gray-200);
    background: #fff;
    color: var(--gray-500);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    cursor: pointer;
    transition: all 0.2s;
}
.header-btn:hover { background: var(--gray-100); color: var(--gray-800); }
.notif-dot {
    position: absolute;
    top: 7px;
    left: 8px;
    width: 8px;
    height: 8px;
    background: var(--danger);
    border-radius: 50%;
    border: 2px solid #fff;
    display: none;
    box-shadow: 0 0 0 0 rgba(190,18,60,0.28);
}
.notif-dot.show { display: block; animation: notifPulse 1.8s infinite; }
.notif-count {
    position: absolute;
    top: -7px;
    left: -7px;
    min-width: 20px;
    height: 20px;
    border-radius: 999px;
    font-size: 0.66rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    border: 2px solid #fff;
    box-shadow: 0 8px 16px rgba(190,18,60,0.22);
}
.notification-menu {
    width: 390px;
    max-width: calc(100vw - 32px);
    border: 1px solid rgba(0,76,64,0.12);
    box-shadow: 0 22px 55px rgba(15,23,42,0.16);
    border-radius: 16px;
    overflow: hidden;
    padding: 0;
}
.notification-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--gray-100);
    background: linear-gradient(135deg, #ffffff, var(--primary-light));
}
.notification-title {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}
.notification-title-icon {
    width: 34px;
    height: 34px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--primary);
    color: #fff;
    box-shadow: 0 8px 18px rgba(0,76,64,0.18);
    flex-shrink: 0;
}
.notification-title strong { display: block; color: var(--gray-900); font-size: 0.92rem; }
.notification-subtitle { display: block; color: var(--gray-500); font-size: 0.72rem; margin-top: 1px; }
.notification-mark-all {
    border: 0;
    background: rgba(255,255,255,0.72);
    color: var(--primary);
    font-weight: 700;
    font-size: 0.75rem;
    border-radius: 999px;
    padding: 6px 10px;
    white-space: nowrap;
}
.notification-mark-all:hover,
.notification-mark-all:focus {
    background: #fff;
    color: var(--primary-dark);
    box-shadow: 0 0 0 3px rgba(0,76,64,0.08);
}
.notification-actions {
    padding: 10px 12px;
    border-bottom: 1px solid var(--gray-100);
    background: #fff;
}
.notification-enable-push {
    width: 100%;
    border: 1px solid rgba(0,76,64,0.16);
    background: #f7fbfa;
    color: var(--primary);
    border-radius: 10px;
    padding: 9px 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-weight: 800;
    font-size: 0.82rem;
}
.notification-enable-push:hover,
.notification-enable-push:focus {
    background: var(--primary-light);
    color: var(--primary-dark);
    box-shadow: 0 0 0 3px rgba(0,76,64,0.08);
}
.notification-list {
    max-height: 390px;
    overflow-y: auto;
    padding: 10px;
    background: #f8fafb;
}
.notification-item {
    display: flex;
    align-items: flex-start;
    gap: 11px;
    width: 100%;
    text-align: inherit;
    background: #fff;
    border: 1px solid var(--gray-100);
    border-right: 3px solid transparent;
    border-radius: 12px;
    padding: 11px 12px;
    color: var(--gray-700);
    cursor: pointer;
    margin-bottom: 8px;
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}
.notification-item:last-child { margin-bottom: 0; }
.notification-item:hover,
.notification-item:focus {
    background: #fff;
    border-color: rgba(0,76,64,0.16);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
    outline: none;
}
.notification-item.unread {
    background: linear-gradient(135deg, #ffffff, var(--primary-light));
    border-right-color: var(--primary);
    color: var(--gray-900);
}
.notification-item-icon {
    width: 36px;
    height: 36px;
    border-radius: 11px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-light);
    color: var(--primary);
    flex-shrink: 0;
}
.notification-item.unread .notification-item-icon {
    background: var(--primary);
    color: #fff;
}
.notification-item-body { flex: 1; min-width: 0; }
.notification-item-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 3px;
}
.notification-kind {
    color: var(--primary);
    font-size: 0.72rem;
    font-weight: 800;
}
.notification-state {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary);
    flex-shrink: 0;
}
.notification-message {
    color: var(--gray-800);
    font-size: 0.82rem;
    line-height: 1.45;
    font-weight: 650;
}
.notification-time {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 6px;
    font-size: 0.72rem;
    color: var(--gray-500);
}
.notification-empty {
    padding: 28px 18px;
    text-align: center;
    color: var(--gray-500);
}
.notification-empty-icon {
    width: 48px;
    height: 48px;
    border-radius: 16px;
    margin: 0 auto 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-light);
    color: var(--primary);
    font-size: 1.15rem;
}
@keyframes notifPulse {
    0% { box-shadow: 0 0 0 0 rgba(190,18,60,0.28); }
    70% { box-shadow: 0 0 0 8px rgba(190,18,60,0); }
    100% { box-shadow: 0 0 0 0 rgba(190,18,60,0); }
}

/* Pages Container */
.pages-container { flex: 1; padding: 24px 28px 40px; }
.page-section { display: none; animation: pageEnter 0.35s ease; }
.page-section.active { display: block; }

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

/* Page Toolbar */
.page-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}
.toolbar-title h2 {
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--gray-900);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}
.toolbar-title h2 i { color: var(--primary); }
.toolbar-actions { display: flex; gap: 8px; }

/* Content Card */
.content-card {
    background: #ffffff;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    margin-bottom: 24px;
    transition: box-shadow 0.3s;
}

canvas {
    max-width: 100% !important;
    height: auto !important;
}
.content-card {
    border: 1px solid var(--gray-100);
    overflow: hidden;
}
.card-header-custom {
    padding: 18px 24px;
    border-bottom: 1px solid var(--gray-100);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.card-header-custom h5 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--gray-800);
    display: flex;
    align-items: center;
    gap: 8px;
}
.card-header-custom h5 i { color: var(--primary); }
.card-actions { display: flex; gap: 6px; }

/* Employee text polish */
#page-employees,
#employeeModal,
#bulkDeleteEmployeesModal,
.employee-profile-page,
#empApp {
    text-rendering: optimizeLegibility;
}

#page-employees .form-label,
#employeeModal .form-label,
#empApp .form-label,
#empApp .profile-info-item small {
    color: var(--gray-500);
    font-weight: 800;
    line-height: 1.55;
}

#employeeModal .tab-content,
#page-employees .modern-table,
#empApp .modern-table,
#empApp .profile-info-item p,
#empApp .notification-message {
    line-height: 1.75;
}

#empApp .employee-copy-chip,
#page-employees .badge,
#employeeModal .badge,
#empApp .badge {
    font-weight: 800;
}

#employeeModal .emp-permission-check + .form-check-label {
    line-height: 1.5;
}

#empApp .text-muted,
#page-employees .text-muted,
#employeeModal .text-muted {
    color: var(--gray-500) !important;
}

#empApp .profile-name,
#employeeModal .modal-title,
#page-employees .toolbar-title h2 {
    letter-spacing: 0;
}

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

.stat-box {
    background: #ffffff;
    border-radius: var(--radius-lg);
    padding: 22px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-100);
    position: relative;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
}
.stat-box::before {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
}
.stat-box:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-box[style*="cursor: pointer"]:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--primary); }

.stat-box.blue::before { background: #3b82f6; }
.stat-box.emerald::before { background: #10b981; }
.stat-box.amber::before { background: #f59e0b; }
.stat-box.rose::before { background: #f43f5e; }
.stat-box.violet::before { background: #8b5cf6; }
.stat-box.cyan::before { background: #06b6d4; }

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}
.stat-box.blue .stat-icon { background: #eff6ff; color: #3b82f6; }
.stat-box.emerald .stat-icon { background: #ecfdf5; color: #10b981; }
.stat-box.amber .stat-icon { background: #fffbeb; color: #f59e0b; }
.stat-box.rose .stat-icon { background: #fff1f2; color: #f43f5e; }
.stat-box.violet .stat-icon { background: #f5f3ff; color: #8b5cf6; }
.stat-box.cyan .stat-icon { background: #ecfeff; color: #06b6d4; }
.stat-box.danger::before { background: #ef4444; }
.stat-box.danger .stat-icon { background: #fef2f2; color: #ef4444; }
.stat-box.warning::before { background: #b45309; }
.stat-box.warning .stat-icon { background: #fffbeb; color: #b45309; }
.stat-box.primary::before { background: var(--primary); }
.stat-box.primary .stat-icon { background: var(--primary-light); color: var(--primary); }

.stat-body { flex: 1; }
.stat-value {
    display: block;
    font-size: 1.7rem;
    font-weight: 800;
    color: var(--gray-900);
    line-height: 1.2;
}
.stat-label {
    font-size: 0.8rem;
    color: var(--gray-400);
    font-weight: 500;
}
.stat-trend {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 6px;
}

/* Modern Table */
.modern-table { font-size: 0.85rem; margin: 0; }
.modern-table thead th {
    font-weight: 700;
    color: var(--gray-500);
    background: var(--gray-50);
    border-bottom: 2px solid var(--gray-200);
    padding: 14px 18px;
    white-space: nowrap;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.modern-table tbody td {
    padding: 14px 18px;
    vertical-align: middle;
    border-bottom: 1px solid var(--gray-100);
    color: var(--gray-700);
}
.modern-table tbody tr:hover td { background: var(--gray-50); }
.modern-table tbody tr:last-child td { border-bottom: none; }

/* Badges */
.badge {
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 0.72rem;
    font-weight: 600;
}
.badge-soft-success { background: var(--success-light); color: var(--success); }
.badge-soft-danger { background: var(--danger-light); color: var(--danger); }
.badge-soft-warning { background: var(--warning-light); color: var(--warning); }
.badge-soft-info { background: var(--info-light); color: var(--info); }
.badge-soft-primary { background: var(--primary-light); color: var(--primary); }
.badge-soft-secondary { background: var(--gray-100); color: var(--gray-500); }

/* Search Input */
.search-input { position: relative; }
.search-input i {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-400);
    font-size: 0.85rem;
    pointer-events: none;
}
.search-input input { padding-right: 40px; }

/* Wizard */
.wizard-container { max-width: 1000px; margin: 0 auto; }
.wizard-header { text-align: center; margin-bottom: 36px; }
.wizard-header h2 { font-weight: 800; font-size: 1.5rem; color: var(--gray-900); margin-bottom: 8px; }
.wizard-header p { color: var(--gray-400); font-size: 0.9rem; }

.wizard-track {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 36px;
    gap: 0;
}
.wizard-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    position: relative;
    z-index: 2;
}
.step-circle {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--gray-100);
    color: var(--gray-400);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.95rem;
    transition: all 0.3s;
    border: 2px solid transparent;
}
.wizard-step.active .step-circle {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 4px 12px rgba(30,64,175,0.3);
}
.wizard-step.completed .step-circle {
    background: var(--success);
    color: #fff;
}
.step-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--gray-400);
    white-space: nowrap;
}
.wizard-step.active .step-title { color: var(--primary); font-weight: 700; }
.wizard-step.completed .step-title { color: var(--success); }

.wizard-connector {
    width: 80px;
    height: 2px;
    background: var(--gray-200);
    margin: 0 8px;
    margin-bottom: 24px;
    position: relative;
    overflow: hidden;
}
.wizard-connector::after {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 0;
    background: var(--success);
    transition: width 0.4s;
}

.wizard-panels { position: relative; }
.wizard-panel { display: none; }
.wizard-panel.active { display: block; animation: panelSlide 0.4s ease; }

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

/* Employee Card in Wizard */
.emp-card {
    background: linear-gradient(135deg, var(--gray-50), #ffffff);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 28px;
}
.emp-avatar-large {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, var(--primary-light), #eff6ff);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    margin: 0 auto;
}
.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--gray-100);
    font-size: 0.88rem;
}
.detail-row:last-child { border-bottom: none; }
.detail-row span { color: var(--gray-400); }
.detail-row strong { color: var(--gray-800); font-weight: 600; }

/* Asset Fate Item */
.fate-item {
    background: #ffffff;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 14px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    align-items: start;
    transition: box-shadow 0.2s;
}
.fate-item:hover { box-shadow: var(--shadow-md); }
.fate-header {
    grid-column: 1 / -1;
    padding-bottom: 12px;
    border-bottom: 1px dashed var(--gray-200);
    margin-bottom: 4px;
}
.fate-header strong { color: var(--primary); font-size: 1rem; }
.fate-header .text-muted { font-size: 0.8rem; }

/* Report Tiles */
.report-tile {
    background: #ffffff;
    border-radius: var(--radius-lg);
    padding: 32px 24px;
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-100);
    cursor: pointer;
    transition: all 0.3s;
    text-align: center;
    height: 100%;
}
.report-tile:hover {
    border-color: var(--primary);
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
}
/* ============================================================
   Org Chart Module (Native RTL Top-Down CSS Tree)
   ============================================================ */

.org-chart-wrapper {
    display: inline-block;
    padding: 32px;
    min-width: 100%;
    direction: rtl; /* Native RTL for Arabic */
    transform-origin: top center;
    transition: transform 0.1s ease-out;
}

.org-tree {
    text-align: center;
    direction: rtl;
}

.org-tree ul {
    padding-top: 24px;
    position: relative;
    display: flex;
    justify-content: center;
    padding-left: 0;
    padding-right: 0; /* Reset Bootstrap RTL padding */
    margin: 0;
}

.org-tree li {
    text-align: center;
    list-style-type: none;
    position: relative;
    padding: 24px 12px 0 12px;
}

/* Connectors for RTL */
/* In RTL: ::before covers left half, ::after covers right half */
.org-tree li::before, .org-tree li::after {
    content: '';
    position: absolute; 
    top: 0; 
    right: 50%;
    border-top: 2px solid var(--gray-400);
    width: 50%; 
    height: 24px;
    z-index: 0;
}
.org-tree li::after {
    right: auto; 
    left: 50%;
    border-left: 0; 
}

/* Vertical drop-down line is drawn by the right border of ::before */
.org-tree li::before {
    border-right: 2px solid var(--gray-400);
}

/* Remove lines for only child */
.org-tree li:only-child::after, .org-tree li:only-child::before {
    display: none;
}
.org-tree li:only-child {
    padding-top: 0;
}

/* First child (on the RIGHT in RTL). Needs line going LEFT (::before). Hide ::after. */
.org-tree li:first-child::after {
    border: 0 none;
}
.org-tree li:first-child::before {
    border-radius: 0 6px 0 0; /* Curve top-right */
}

/* Last child (on the LEFT in RTL). Needs line going RIGHT (::after). Hide ::before. */
.org-tree li:last-child::before {
    border: 0 none;
}
.org-tree li:last-child::after {
    border-radius: 6px 0 0 0; /* Curve top-left */
    border-left: 2px solid var(--gray-400); /* Needs its own vertical drop-down line */
}

/* Parent vertical line dropping down to the horizontal bracket */
.org-tree ul::before {
    content: '';
    position: absolute; 
    top: 0; 
    left: 50%;
    border-left: 2px solid var(--gray-400);
    width: 0; 
    height: 24px;
    transform: translateX(-50%);
    z-index: 0;
}
/* Root ul doesn't need the top vertical line */
.org-tree > ul::before {
    display: none;
}

/* ---- Gradient Node Card ---- */
.org-node {
    display: inline-block;
    width: 220px; /* Fixed width for consistency */
    border-radius: 16px;
    padding: 20px 20px 16px;
    text-align: center;
    color: #fff;
    cursor: grab;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    position: relative;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    border: 2px solid rgba(255,255,255,0.2);
    z-index: 2;
    background-color: var(--gray-800);
}
.org-node:active {
    cursor: grabbing;
}
.org-node:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 32px rgba(0,0,0,0.2);
}
.org-node.org-selected {
    box-shadow: 0 0 0 4px rgba(255,255,255,0.6), 0 12px 32px rgba(0,0,0,0.2);
}

.org-node.drag-over {
    border: 2px dashed #fff;
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(255,255,255,0.5);
}

/* Department Gradients */
.dept-sales   { background: linear-gradient(135deg, #3b82f6, #6366f1); }
.dept-hr      { background: linear-gradient(135deg, #ec4899, #f43f5e); }
.dept-it      { background: linear-gradient(135deg, #10b981, #14b8a6); }
.dept-accounting { background: linear-gradient(135deg, #f59e0b, #f97316); }
.dept-engineering { background: linear-gradient(135deg, #8b5cf6, #a855f7); }
.dept-marketing { background: linear-gradient(135deg, #06b6d4, #3b82f6); }
.dept-operation { background: linear-gradient(135deg, #64748b, #94a3b8); }
.dept-board   { background: linear-gradient(135deg, #1e293b, #475569); }
.dept-ceo     { background: linear-gradient(135deg, #d97706, #b45309); }
.dept-legel   { background: linear-gradient(135deg, #84cc16, #65a30d); }
.dept-default { background: linear-gradient(135deg, #475569, #64748b); }

/* ---- Avatar ---- */
.org-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #fff;
    color: #333;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: 700;
    margin: 0 auto 12px;
    border: 3px solid rgba(255,255,255,0.5);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    overflow: hidden;
}
.org-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

/* ---- Text ---- */
.org-name { font-weight: 800; font-size: 1.05rem; margin-bottom: 2px; text-shadow: 0 1px 2px rgba(0,0,0,0.2); }
.org-title { font-size: 0.82rem; opacity: 0.95; margin-bottom: 2px; }
.org-dept { font-size: 0.72rem; opacity: 0.8; }
.org-empid { font-size: 0.7rem; opacity: 0.7; margin-top: 6px; letter-spacing: 0.5px; }

/* ---- Inline Actions (bottom of card) ---- */
.org-actions {
    display: none;
    justify-content: center;
    border-top: 1px solid rgba(255,255,255,0.2);
    margin-top: 12px;
    padding-top: 12px;
    gap: 6px;
}
.org-node:hover .org-actions,
.org-node.org-selected .org-actions { display: flex; }
.org-actions .btn {
    padding: 4px 10px;
    font-size: 0.7rem;
    backdrop-filter: blur(4px);
    background: rgba(255,255,255,0.15);
    color: #fff;
    border: none;
    border-radius: 6px;
}
.org-actions .btn:hover { background: rgba(255,255,255,0.3); color: #fff; }

/* ---- Expand / Collapse Toggle ---- */
.org-toggle {
    position: absolute;
    bottom: -14px;
    left: 50%;
    transform: translateX(-50%);
    width: 28px;
    height: 28px;
    background: #fff;
    border: 2px solid var(--primary);
    border-radius: 50%;
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    cursor: pointer;
    z-index: 10;
    transition: all 0.2s;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}
.org-toggle:hover { background: var(--primary); color: #fff; transform: translateX(-50%) scale(1.1); } 
.rt-icon {
    width: 64px;
    height: 64px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    margin: 0 auto 18px;
}
.rt-icon.blue { background: #eff6ff; color: #3b82f6; }
.rt-icon.emerald { background: #ecfdf5; color: #10b981; }
.rt-icon.amber { background: #fffbeb; color: #f59e0b; }
.rt-icon.rose { background: #fff1f2; color: #f43f5e; }
.rt-icon.violet { background: #f5f3ff; color: #8b5cf6; }
.rt-icon.cyan { background: #ecfeff; color: #06b6d4; }
.report-tile h5 { font-weight: 700; font-size: 1rem; margin-bottom: 8px; }
.report-tile p { color: var(--gray-400); font-size: 0.85rem; margin: 0; }

/* Upload Zone */
.upload-zone {
    border: 2px dashed var(--gray-300);
    border-radius: var(--radius-lg);
    padding: 48px 24px;
    text-align: center;
    transition: all 0.2s;
    cursor: pointer;
}
.upload-zone:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}

/* Tags Cloud */
.tags-cloud { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-chip {
    background: var(--primary-light);
    color: var(--primary);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.82rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 10px;
}
.tag-chip .remove {
    cursor: pointer;
    opacity: 0.5;
    transition: opacity 0.2s;
}
.tag-chip .remove:hover { opacity: 1; }

/* Alerts Box */
.alert-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 18px;
    border-radius: var(--radius);
    background: var(--gray-50);
    margin-bottom: 10px;
    border-right: 3px solid transparent;
    font-size: 0.88rem;
}
.alert-row.danger { background: var(--danger-light); border-right-color: var(--danger); }
.alert-row.warning { background: var(--warning-light); border-right-color: var(--warning); }
.alert-row.info { background: var(--info-light); border-right-color: var(--info); }
.alert-row.success { background: var(--success-light); border-right-color: var(--success); }
.alert-row i { font-size: 1.1rem; flex-shrink: 0; }

/* Toast */
.toast-container { z-index: 1060; }
.custom-toast {
    background: #ffffff;
    border-radius: var(--radius);
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--gray-100);
    padding: 14px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 300px;
    animation: toastSlide 0.3s ease;
}
@keyframes toastSlide {
    from { transform: translateX(-20px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.app-toast-container {
    position: fixed;
    top: 18px;
    right: 18px;
    left: auto !important;
    bottom: auto !important;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: min(420px, calc(100vw - 24px));
    pointer-events: none;
}

.app-toast {
    position: relative;
    pointer-events: auto;
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) 34px;
    align-items: center;
    gap: 12px;
    min-height: 72px;
    padding: 14px;
    border: 1px solid rgba(148, 163, 184, 0.22);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 18px 45px rgba(15, 23, 42, 0.16);
    backdrop-filter: blur(14px);
    animation: appToastIn 0.34s cubic-bezier(.2, .8, .2, 1);
    overflow: hidden;
}

.app-toast::before {
    content: '';
    position: absolute;
    inset-inline-start: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--info);
}

.app-toast-success::before { background: var(--success); }
.app-toast-error::before { background: var(--danger); }
.app-toast-warning::before { background: var(--warning); }
.app-toast-info::before { background: var(--info); }

.app-toast-icon {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    background: var(--info);
    font-size: 1.1rem;
}

.app-toast-success .app-toast-icon { background: var(--success); }
.app-toast-error .app-toast-icon { background: var(--danger); }
.app-toast-warning .app-toast-icon { background: var(--warning); color: #7c2d12; }
.app-toast-info .app-toast-icon { background: var(--info); }

.app-toast-body {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.app-toast-title {
    font-weight: 800;
    color: var(--gray-800);
    font-size: 0.92rem;
    line-height: 1.2;
}

.app-toast-message {
    color: var(--gray-600);
    font-size: 0.86rem;
    line-height: 1.45;
    overflow-wrap: anywhere;
}

.app-toast-close {
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--gray-400);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.app-toast-close:hover {
    background: var(--gray-100);
    color: var(--gray-800);
}

.app-toast.is-leaving {
    animation: appToastOut 0.24s ease forwards;
}

@keyframes appToastIn {
    from { opacity: 0; transform: translate3d(22px, -8px, 0) scale(0.98); }
    to { opacity: 1; transform: translate3d(0, 0, 0) scale(1); }
}

@keyframes appToastOut {
    to { opacity: 0; transform: translate3d(22px, -8px, 0) scale(0.98); }
}

/* Modal enhancements */
.modal-content { border: none; border-radius: var(--radius-lg); box-shadow: var(--shadow-xl); }
.modal-header { border-bottom: 1px solid var(--gray-100); padding: 20px 24px; }
.modal-title { font-weight: 700; font-size: 1rem; }
.modal-footer { border-top: 1px solid var(--gray-100); padding: 16px 24px; }

/* Buttons */
.btn { font-weight: 600; font-size: 0.85rem; padding: 8px 18px; border-radius: var(--radius-sm); transition: all 0.2s; }
.btn-lg { padding: 10px 24px; font-size: 0.9rem; }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-success { background: var(--success); border-color: var(--success); }
.btn-outline-secondary { color: var(--gray-500); border-color: var(--gray-200); }
.btn-outline-secondary:hover { background: var(--gray-100); color: var(--gray-800); border-color: var(--gray-300); }

/* Form enhancements */
.form-control, .form-select {
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    padding: 10px 14px;
    font-family: inherit;
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(30,64,175,0.08);
}
.form-label { font-size: 0.82rem; font-weight: 600; color: var(--gray-600); margin-bottom: 6px; }

/* Responsive */
@media (max-width: 992px) {
    .sidebar { transform: translateX(100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-right: 0; }
    .toggle-sidebar { display: flex; align-items: center; justify-content: center; }
    .header-search input { width: 180px; }
    .stats-grid { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
}

@media (max-width: 768px) {
    .pages-container { padding: 12px; }
    .header-search { display: none; }
    .wizard-track { flex-wrap: wrap; gap: 16px; justify-content: flex-start; }
    .wizard-connector { display: none; }
    .page-toolbar { flex-direction: column; align-items: stretch; gap: 10px; }
    .page-toolbar .toolbar-actions { display: flex; flex-wrap: wrap; justify-content: flex-start; gap: 8px; width: 100%; }
    .page-toolbar .toolbar-actions .btn { flex: 1; text-align: center; }
    .fate-item { grid-template-columns: 1fr; }
    .stat-box { padding: 12px; }
    .content-card { margin-bottom: 16px; border-radius: var(--radius-sm); }
    .main-header { padding: 0 10px; }
    .table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 0; }
    .modern-table th, .modern-table td { padding: 10px 8px; font-size: 0.85rem; white-space: nowrap; }
    .modal-dialog { margin: 10px auto; }
    .modal-body { padding: 16px; }
    .card-header-custom { flex-direction: column; align-items: stretch; gap: 10px; }
    .card-header-custom .btn { width: 100%; }
}

@media (max-width: 576px) {
    .app-toast-container {
        top: auto !important;
        right: 12px !important;
        left: 12px !important;
        bottom: 14px !important;
        width: auto;
    }

    .app-toast {
        grid-template-columns: 38px minmax(0, 1fr) 32px;
        min-height: 66px;
        padding: 12px;
        border-radius: 14px;
    }

    .app-toast-icon {
        width: 38px;
        height: 38px;
        border-radius: 12px;
    }

    @keyframes appToastIn {
        from { opacity: 0; transform: translate3d(0, 18px, 0) scale(0.98); }
        to { opacity: 1; transform: translate3d(0, 0, 0) scale(1); }
    }

    @keyframes appToastOut {
        to { opacity: 0; transform: translate3d(0, 18px, 0) scale(0.98); }
    }

    .stats-grid { grid-template-columns: 1fr; }
    .header-start h5 { font-size: 1.1rem; }
    .stat-box .stat-icon { width: 40px; height: 40px; font-size: 1.2rem; }
    .stat-box .stat-value { font-size: 1.3rem; }
    .inv-card-row { flex-direction: column; align-items: flex-start; gap: 4px; }
    .inv-tabs-bar { justify-content: center; }
    .inv-tab { flex: 1; text-align: center; justify-content: center; padding: 8px; }
}

@media print {
    .sidebar, .main-header, .page-toolbar, .btn, .toggle-sidebar { display: none !important; }
    .main-content { margin: 0 !important; }
    .page-section { display: block !important; }
    .content-card { box-shadow: none; border: 1px solid #ddd; }
}
/* Timeline for Reign History Map */
.reign-timeline { padding: 20px; }
.timeline-header { margin-bottom: 30px; text-align: center; }
.timeline-track { position: relative; padding-right: 40px; border-right: 3px solid var(--gray-200); }
.timeline-node { position: relative; margin-bottom: 30px; padding-right: 30px; }
.timeline-node:last-child { margin-bottom: 0; }
.timeline-dot { 
    position: absolute; right: -14px; top: 0; 
    width: 28px; height: 28px; border-radius: 50%; 
    background: var(--gray-300); display: flex; align-items: center; justify-content: center;
    color: white; font-size: 0.7rem; z-index: 2;
}

/* Responsive Overhaul & Animation Injection */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.page-section.active { animation: fadeIn 0.4s ease-in-out; }
.tab-pane.show,
.tab-animate-in { animation: fadeInUp 0.22s ease-out; }

.modal.fade .modal-dialog {
    transform: translateY(20px) scale(0.985);
    transition: transform 0.28s ease, opacity 0.28s ease;
}
.modal.show .modal-dialog { transform: translateY(0) scale(1); }

.btn, .menu-item, .clickable-row, .entity-link, .modern-table tbody tr {
    transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease, color 0.2s ease;
}

@media (hover: hover) and (pointer: fine) {
    .btn:hover, .clickable-row:hover, .modern-table tbody tr:hover {
        transform: translateY(-2px);
        box-shadow: 0 4px 8px rgba(15, 23, 42, 0.10);
    }
}

.form-control, .form-select, .btn, .nav-link, .header-btn, .menu-item {
    min-height: 44px;
}

@media (max-width: 768px) {
    body.sidebar-open { overflow: hidden; }

    .sidebar {
        right: auto;
        left: 0;
        width: min(84vw, 320px);
        transform: translateX(-105%);
        border-left: 0;
        border-right: 1px solid var(--gray-200);
        z-index: 1060;
    }

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

    .sidebar-overlay.show {
        opacity: 1;
        visibility: visible;
        z-index: 1050;
    }

    .main-content {
        margin-right: 0;
        width: 100%;
    }

    .main-header {
        min-height: 64px;
        padding: 0 12px;
    }

    .toggle-sidebar {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
    }

    .pages-container { padding: 12px; }

    .page-toolbar,
    .card-header-custom,
    #tab-assets .alert {
        flex-direction: column;
        align-items: stretch !important;
        gap: 10px;
    }

    .toolbar-actions {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }

    .toolbar-actions .btn,
    .card-header-custom .btn {
        flex: 1 1 140px;
        width: auto;
    }

    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: var(--radius-sm);
    }

    .modern-table { min-width: 720px; }

    .modern-table th,
    .modern-table td {
        padding: 12px 10px;
        white-space: nowrap;
    }

    #employeeModal .modal-dialog {
        margin: 0;
        max-width: 100%;
        min-height: 100vh;
        display: flex;
        align-items: flex-end;
    }

    #employeeModal .modal-content {
        max-height: 94vh;
        overflow: auto;
        border-radius: 18px 18px 0 0;
    }

    #employeeModal .modal-body { padding: 14px; }

    #empProfileTabs {
        flex-wrap: nowrap;
        gap: 8px;
        overflow-x: auto;
        padding-bottom: 8px;
        scrollbar-width: none;
    }

    #empProfileTabs::-webkit-scrollbar { display: none; }

    #empProfileTabs .nav-item { flex: 0 0 auto; }

    #empProfileTabs .nav-link {
        border-radius: 999px;
        padding: 10px 16px;
        white-space: nowrap;
    }

    #employeeModal .tab-pane .row > [class*="col-"] {
        flex: 0 0 100%;
        max-width: 100%;
    }

    #tab-assets .row.g-2 { flex-direction: column; }

    #tab-assets .row.g-2 > [class*="col-"] {
        width: 100%;
        max-width: 100%;
    }
}

@media (max-width: 576px) {
    .mobile-card-table { overflow: visible; }
    .mobile-card-table .modern-table { min-width: 0; }

    .mobile-card-table table,
    .mobile-card-table thead,
    .mobile-card-table tbody,
    .mobile-card-table tr,
    .mobile-card-table td {
        display: block;
        width: 100%;
    }

    .mobile-card-table thead { display: none; }

    .mobile-card-table tr {
        margin-bottom: 12px;
        padding: 10px;
        border: 1px solid var(--gray-200);
        border-radius: var(--radius);
        background: #fff;
        box-shadow: var(--shadow-sm);
    }

    .mobile-card-table td {
        min-height: 44px;
        padding: 10px 4px;
        white-space: normal !important;
        border-bottom: 1px solid var(--gray-100);
        display: flex;
        justify-content: space-between;
        gap: 14px;
        text-align: end;
    }

    .mobile-card-table td:last-child { border-bottom: 0; }

    .mobile-card-table td::before {
        content: attr(data-label);
        font-weight: 800;
        color: var(--gray-500);
        text-align: start;
    }
}
.timeline-node.active .timeline-dot { background: var(--primary); box-shadow: 0 0 0 4px var(--primary-light); }
.timeline-node.returned .timeline-dot { background: var(--success); }
.timeline-node.transferred .timeline-dot { background: var(--warning); }
.timeline-node.current .timeline-dot { animation: pulse 2s infinite; }
.timeline-card { 
    background: white; border: 1px solid var(--gray-200); 
    border-radius: var(--radius); padding: 16px; 
    box-shadow: var(--shadow-sm);
}
.timeline-date { font-size: 0.75rem; color: var(--gray-400); margin-bottom: 4px; }
.timeline-employee { font-weight: 700; color: var(--gray-800); }
.timeline-action { font-size: 0.8rem; color: var(--gray-500); }
.timeline-notes { font-size: 0.8rem; color: var(--gray-400); margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--gray-100); }
.recording { animation: pulse 1s infinite; }
@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(220, 38, 38, 0); }
    100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0); }
}
.table-danger { background-color: #fef2f2 !important; }

/* Smart Inventory */
.inv-tabs-bar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; background: #fff; padding: 10px 14px; border-radius: var(--radius); border: 1px solid var(--gray-200); box-shadow: var(--shadow-sm); }
.inv-tab { background: var(--gray-100); border: none; border-radius: 20px; padding: 6px 16px; font-size: 0.85rem; font-weight: 600; color: var(--gray-600); cursor: pointer; transition: all 0.2s; white-space: nowrap; }
.inv-tab:hover { background: var(--primary-light); color: var(--primary); }
.inv-tab.active { background: var(--primary); color: #fff; box-shadow: 0 2px 8px rgba(30,64,175,0.25); }
.inv-tab-badge { display: inline-block; margin-right: 4px; background: rgba(255,255,255,0.25); border-radius: 10px; padding: 1px 7px; font-size: 0.7rem; }
.inv-tab.active .inv-tab-badge { background: rgba(255,255,255,0.3); }

.inv-chips-bar { display: flex; gap: 8px; flex-wrap: wrap; }
.inv-chip { background: #fff; border: 1px solid var(--gray-200); border-radius: 20px; padding: 5px 14px; font-size: 0.8rem; font-weight: 500; color: var(--gray-600); cursor: pointer; transition: all 0.2s; }
.inv-chip:hover { border-color: var(--primary); color: var(--primary); }
.inv-chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }

.inv-card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.inv-card { background: #fff; border: 1px solid var(--gray-200); border-radius: var(--radius-lg); padding: 18px; box-shadow: var(--shadow-sm); transition: transform 0.2s, box-shadow 0.2s; display: flex; flex-direction: column; }
.inv-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.inv-card.available { border-right: 4px solid var(--success); }
.inv-card-header { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.inv-card-icon { width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 1rem; flex-shrink: 0; }
.inv-card-title { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.inv-card-title strong { font-size: 0.95rem; color: var(--gray-900); }
.inv-card-title small { font-size: 0.75rem; }
.inv-card-body { flex: 1; }
.inv-card-row { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--gray-50); font-size: 0.82rem; }
.inv-card-row:last-child { border-bottom: none; }
.inv-card-row span { color: var(--gray-400); }
.inv-card-row strong, .inv-card-row code { color: var(--gray-700); font-weight: 600; }
.inv-card-footer { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--gray-100); }

.stat-box.primary::before { background: var(--primary); }
.stat-box.primary .stat-icon { background: var(--primary-light); color: var(--primary); }

/* ============================================================
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.15s;
    border: 1px solid transparent;
}
.move-emp-item:hover { background: var(--gray-50); border-color: var(--gray-200); }
.move-emp-item.selected { background: var(--primary-light); border-color: var(--primary); }
.move-emp-avatar {
    width: 40px; height: 40px; border-radius: 50%; background: var(--primary-light);
    color: var(--primary); display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.9rem; flex-shrink: 0; overflow: hidden;
}
.move-emp-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }

/* ============================================================
   Premium Micro-Interactions
   Lightweight CSS motion layer: transform, opacity, and shimmer only.
   ============================================================ */
@keyframes uiFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

@keyframes uiSlideUp {
    from { opacity: 0; transform: translateY(20px) scale(0.985); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

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

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

@keyframes uiSkeletonShimmer {
    from { background-position: 220% 0; }
    to { background-position: -220% 0; }
}

.btn,
.content-card,
.stat-box,
.inv-card,
.emp-card,
.dropdown-menu,
.modern-table tbody tr {
    transition:
        transform var(--motion-base) var(--ease-premium),
        box-shadow var(--motion-base) var(--ease-premium),
        background-color var(--motion-base) var(--ease-premium),
        border-color var(--motion-base) var(--ease-premium),
        opacity var(--motion-base) var(--ease-premium);
}

.content-card,
.stat-box,
.inv-card,
.emp-card {
    animation: uiFadeInUp var(--motion-slow) var(--ease-premium) both;
}

@media (hover: hover) and (pointer: fine) {
    .btn:hover {
        transform: translateY(-2px);
        box-shadow: var(--shadow-lift);
    }

    .content-card:hover,
    .stat-box:hover,
    .inv-card:hover,
    .emp-card:hover {
        transform: translateY(-3px);
        box-shadow: var(--shadow-lift);
    }

    .modern-table tbody tr:hover {
        transform: translateY(-1px);
        box-shadow: 0 4px 12px rgba(15,23,42,.08);
    }
}

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

.modal-backdrop.fade {
    transition: opacity var(--motion-slow) var(--ease-premium);
}

.modal.fade .modal-dialog {
    transform: translateY(20px) scale(0.985);
    transition:
        transform var(--motion-slow) var(--ease-spring),
        opacity var(--motion-slow) var(--ease-premium);
}

.modal.show .modal-dialog {
    transform: translateY(0) scale(1);
}

.dropdown-menu {
    transform-origin: top center;
}

.dropdown-menu.show {
    animation: uiDropdownIn var(--motion-base) var(--ease-premium) both;
}

.stagger-rows tbody tr,
.stagger-list > * {
    opacity: 0;
    animation: uiRowCascade var(--motion-slow) var(--ease-premium) forwards;
}

.stagger-rows tbody tr:nth-child(1), .stagger-list > *:nth-child(1) { animation-delay: 0.04s; }
.stagger-rows tbody tr:nth-child(2), .stagger-list > *:nth-child(2) { animation-delay: 0.07s; }
.stagger-rows tbody tr:nth-child(3), .stagger-list > *:nth-child(3) { animation-delay: 0.10s; }
.stagger-rows tbody tr:nth-child(4), .stagger-list > *:nth-child(4) { animation-delay: 0.13s; }
.stagger-rows tbody tr:nth-child(5), .stagger-list > *:nth-child(5) { animation-delay: 0.16s; }
.stagger-rows tbody tr:nth-child(6), .stagger-list > *:nth-child(6) { animation-delay: 0.19s; }
.stagger-rows tbody tr:nth-child(7), .stagger-list > *:nth-child(7) { animation-delay: 0.22s; }
.stagger-rows tbody tr:nth-child(8), .stagger-list > *:nth-child(8) { animation-delay: 0.25s; }
.stagger-rows tbody tr:nth-child(9), .stagger-list > *:nth-child(9) { animation-delay: 0.28s; }
.stagger-rows tbody tr:nth-child(10), .stagger-list > *:nth-child(10) { animation-delay: 0.31s; }
.stagger-rows tbody tr:nth-child(11), .stagger-list > *:nth-child(11) { animation-delay: 0.34s; }
.stagger-rows tbody tr:nth-child(12), .stagger-list > *:nth-child(12) { animation-delay: 0.37s; }
.stagger-rows tbody tr:nth-child(13), .stagger-list > *:nth-child(13) { animation-delay: 0.40s; }
.stagger-rows tbody tr:nth-child(14), .stagger-list > *:nth-child(14) { animation-delay: 0.43s; }
.stagger-rows tbody tr:nth-child(15), .stagger-list > *:nth-child(15) { animation-delay: 0.46s; }
.stagger-rows tbody tr:nth-child(16), .stagger-list > *:nth-child(16) { animation-delay: 0.49s; }
.stagger-rows tbody tr:nth-child(17), .stagger-list > *:nth-child(17) { animation-delay: 0.52s; }
.stagger-rows tbody tr:nth-child(18), .stagger-list > *:nth-child(18) { animation-delay: 0.55s; }
.stagger-rows tbody tr:nth-child(19), .stagger-list > *:nth-child(19) { animation-delay: 0.58s; }
.stagger-rows tbody tr:nth-child(20), .stagger-list > *:nth-child(20) { animation-delay: 0.61s; }
.stagger-rows tbody tr:nth-child(n+21), .stagger-list > *:nth-child(n+21) { animation-delay: 0.64s; }

.skeleton,
.skeleton-line,
.skeleton-title,
.skeleton-avatar,
.skeleton-card,
.skeleton-row {
    background: linear-gradient(90deg, var(--gray-100), var(--gray-200), var(--gray-100));
    background-size: 220% 100%;
    animation: uiSkeletonShimmer 1.25s linear infinite;
}

.skeleton {
    display: block;
    border-radius: var(--radius-sm);
    min-height: 14px;
}

.skeleton-line {
    height: 12px;
    border-radius: 999px;
}

.skeleton-title {
    height: 18px;
    width: min(220px, 70%);
    border-radius: 999px;
}

.skeleton-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    flex: 0 0 auto;
}

.skeleton-card {
    min-height: 96px;
    border-radius: var(--radius);
    border: 1px solid var(--gray-100);
}

.skeleton-table {
    display: grid;
    gap: 10px;
    padding: 12px;
}

.skeleton-row {
    height: 42px;
    border-radius: var(--radius-sm);
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .001ms !important;
        scroll-behavior: auto !important;
    }
}

/* Monthly Attendance Report */
.monthly-attendance-report {
    display: grid;
    gap: 18px;
}

.report-action-bar {
    position: sticky;
    top: 74px;
    z-index: 20;
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, .96);
    box-shadow: var(--shadow-sm);
}

.report-action-bar .form-field {
    min-width: 180px;
    flex: 1 1 220px;
}

.employee-report-page {
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    background: #fff;
    box-shadow: var(--shadow-sm);
    padding: 20px;
}

.employee-report-header {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    border-bottom: 1px solid var(--gray-200);
    padding-bottom: 14px;
    margin-bottom: 14px;
}

.employee-report-header h3 {
    margin: 0 0 4px;
    font-weight: 900;
    color: var(--gray-900);
}

.summary-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.summary-badges span {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--gray-100);
    color: var(--gray-700);
    font-size: .82rem;
    font-weight: 800;
}

.attendance-report-table {
    min-width: 980px;
}

.attendance-workflow-note {
    border-inline-start: 4px solid var(--info);
    line-height: 1.8;
    font-weight: 500;
}

.attendance-workflow-note strong {
    font-weight: 800;
}

@media (max-width: 768px) {
    .report-action-bar {
        position: static;
        align-items: stretch;
    }

    .report-action-bar .btn,
    .report-action-bar .form-field {
        flex: 1 1 100%;
    }

    .employee-report-page {
        padding: 14px;
    }
}

@media print {
    .no-print,
    .sidebar,
    .main-header,
    .page-toolbar {
        display: none !important;
    }

    .main-content,
    .pages-container,
    #reportResultCard,
    #reportResultBody {
        margin: 0 !important;
        padding: 0 !important;
        box-shadow: none !important;
        border: 0 !important;
    }

    .employee-report-page {
        page-break-after: always;
        page-break-inside: avoid;
        break-after: page;
        break-inside: avoid;
        padding: 16mm;
        border: 0;
        box-shadow: none;
    }

    .employee-report-page:last-child {
        page-break-after: auto;
        break-after: auto;
    }

    .attendance-report-table {
        min-width: 0;
        width: 100%;
        font-size: 10px;
    }
}

