/* MAJD ERP - Main Stylesheet v3.0 */

:root {
    --primary: #1a3a6b;
    --primary-dark: #0f2744;
    --primary-light: #e8eef5;
    --primary-accent: #2d6cdf;
    --success: #34a853;
    --warning: #f9ab00;
    --danger: #ea4335;
    --info: #4285f4;
    --secondary: #5f6368;

    --surface-success: #e8f5e9;
    --surface-warning: #fff8e1;
    --surface-danger: #fce8e6;
    --surface-info: #e8f0fe;
    --surface-muted: #f1f3f4;
    --surface-primary: #e8eef5;

    --bg-body: #eef2f7;
    --bg-card: #ffffff;
    --bg-sidebar: #1e2532;
    --bg-topbar: #ffffff;
    --bg-input: #ffffff;

    --text-primary: #1a1a2e;
    --text-secondary: #5f6368;
    --text-muted: #9aa0a6;
    --text-sidebar: #c4c9d4;
    --text-sidebar-active: #ffffff;

    --border: #e0e4ea;
    --border-light: #eef1f5;
    --shadow-sm: 0 1px 3px rgba(15, 39, 68, 0.05);
    --shadow: 0 4px 14px rgba(15, 39, 68, 0.08);
    --shadow-lg: 0 12px 32px rgba(15, 39, 68, 0.12);

    --sidebar-width: 260px;
    --sidebar-collapsed: 70px;
    --topbar-height: 60px;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 14px;
    --gap-page: 16px;
    --gap-section: 24px;
    --transition: 0.2s ease;
    --font-ar: 'Tajawal', 'IBM Plex Sans Arabic', sans-serif;
    --font-en: 'Inter', sans-serif;
    --sidebar-bg: linear-gradient(180deg, #0f2744 0%, #1a2d4a 100%);
}

[data-theme="dark"] {
    --primary-light: rgba(45, 108, 223, 0.15);
    --surface-success: rgba(52, 168, 83, 0.15);
    --surface-warning: rgba(249, 171, 0, 0.15);
    --surface-danger: rgba(234, 67, 53, 0.15);
    --surface-info: rgba(66, 133, 244, 0.15);
    --surface-muted: rgba(255, 255, 255, 0.06);
    --surface-primary: rgba(45, 108, 223, 0.12);
    --bg-body: #0f1117;
    --bg-card: #1a1d27;
    --bg-sidebar: #12151c;
    --bg-topbar: #1a1d27;
    --bg-input: #252836;
    --text-primary: #e8eaed;
    --text-secondary: #9aa0a6;
    --text-muted: #6b7280;
    --border: #2d3142;
    --border-light: #1f2233;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.2);
    --shadow: 0 4px 14px rgba(0,0,0,0.25);
    --shadow-lg: 0 12px 32px rgba(0,0,0,0.35);
}

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

html { font-size: 15px; scroll-behavior: smooth; -webkit-font-smoothing: antialiased; }

body {
    font-family: var(--font-ar);
    background: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.65;
    overflow-x: hidden;
    font-weight: 400;
}

[dir="ltr"] body { font-family: var(--font-en); }

/* Layout */
.app-wrapper { min-height: 100vh; }

.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    background-image: var(--sidebar-bg);
    position: fixed;
    top: 0;
    bottom: 0;
    z-index: 1000;
    transition: width var(--transition), transform var(--transition);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

[dir="rtl"] .sidebar { right: 0; }
[dir="ltr"] .sidebar { left: 0; }

.sidebar.collapsed { width: var(--sidebar-collapsed); }
.sidebar.collapsed .sidebar-brand,
.sidebar.collapsed .nav-section-title,
.sidebar.collapsed .nav-item span { display: none; }
.sidebar.collapsed .sidebar-brand-logo { display: block; }

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    min-height: var(--topbar-height);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    font-weight: 700;
    font-size: 1.1rem;
}

.sidebar-logo .sidebar-brand-logo {
    height: 42px;
    width: 42px;
    max-width: 42px;
    object-fit: cover;
    background: #0f2744;
    border-radius: 10px;
    padding: 0;
    filter: none;
}

.sidebar.collapsed .sidebar-brand-logo {
    display: block;
    max-width: 36px;
    padding: 2px;
}

.sidebar-logo i { font-size: 1.5rem; color: var(--primary); }

.sidebar-toggle {
    background: none;
    border: none;
    color: var(--text-sidebar);
    font-size: 1.3rem;
    cursor: pointer;
    padding: 4px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}
.sidebar-toggle:hover { background: rgba(255,255,255,0.1); color: #fff; }

.sidebar-search {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 8px 12px 4px;
    padding: 6px 10px;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(201, 162, 39, 0.28);
    border-radius: 10px;
}
.sidebar-search i { color: #f0d78c; font-size: 0.9rem; flex-shrink: 0; }
.sidebar-search input {
    width: 100%;
    border: 0;
    background: transparent;
    color: #fff;
    font-size: 0.86rem;
    outline: none;
    min-width: 0;
}
.sidebar-search input::placeholder { color: rgba(255,255,255,0.45); }
.sidebar.collapsed .sidebar-search { display: none; }
.nav-section.is-nav-hidden { display: none; }
.nav-item.is-nav-hidden { display: none; }
.nav-item.is-nav-hit {
    background: rgba(201, 162, 39, 0.18);
    outline: 1px solid rgba(201, 162, 39, 0.55);
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 12px 0;
    scroll-behavior: auto;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 4px; }

.nav-section { margin-bottom: 8px; }

.nav-section-title {
    display: block;
    padding: 8px 20px 4px;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: rgba(255,255,255,0.35);
    font-weight: 600;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    color: var(--text-sidebar);
    text-decoration: none;
    transition: var(--transition);
    font-size: 0.9rem;
    border-radius: 0;
    margin: 2px 8px;
    border-radius: var(--radius-sm);
}

.nav-item i { font-size: 1.15rem; width: 22px; text-align: center; flex-shrink: 0; }

.nav-item:hover { background: rgba(255,255,255,0.08); color: #fff; }

.nav-item.active {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(15, 39, 68, 0.35);
}

.nav-item.active i { transform: scale(1.05); }

.main-content {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-width: 0;
    box-sizing: border-box;
    transition: margin var(--transition), width var(--transition);
}

[dir="rtl"] .main-content {
    margin-right: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
}

[dir="ltr"] .main-content {
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
}

[dir="rtl"] .sidebar.collapsed ~ .main-content {
    margin-right: var(--sidebar-collapsed);
    width: calc(100% - var(--sidebar-collapsed));
}

[dir="ltr"] .sidebar.collapsed ~ .main-content {
    margin-left: var(--sidebar-collapsed);
    width: calc(100% - var(--sidebar-collapsed));
}

/* Topbar */
.topbar {
    height: var(--topbar-height);
    background: var(--bg-topbar);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.topbar-start, .topbar-end { display: flex; align-items: center; gap: 8px; }

.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    font-size: 1.4rem;
    color: var(--text-primary);
    cursor: pointer;
    padding: 6px;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-body);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 6px 16px;
    min-width: 300px;
    transition: var(--transition);
    position: relative;
}

.search-box:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.search-box i { color: var(--text-muted); flex-shrink: 0; }
.search-box input {
    border: none;
    background: none;
    outline: none;
    flex: 1;
    font-size: 0.95rem;
    color: var(--text-primary);
    font-family: inherit;
    min-width: 0;
}

.search-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    max-height: 380px;
    overflow-y: auto;
    z-index: 2000;
}

[dir="rtl"] .search-dropdown { left: 0; right: 0; }

.search-dropdown.show { display: block; }

.search-dropdown__item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    text-decoration: none;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-light);
    transition: background var(--transition);
}

.search-dropdown__item:last-child { border-bottom: none; }
.search-dropdown__item:hover,
.search-dropdown__item.active { background: var(--primary-light); }

.search-dropdown__icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--surface-primary);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.search-dropdown__body { flex: 1; min-width: 0; }
.search-dropdown__title { display: block; font-weight: 600; font-size: 0.92rem; }
.search-dropdown__subtitle { display: block; font-size: 0.82rem; color: var(--text-muted); margin-top: 2px; }
.search-dropdown__type {
    font-size: 0.72rem;
    padding: 3px 8px;
    border-radius: 999px;
    background: var(--surface-muted);
    color: var(--text-secondary);
    white-space: nowrap;
}

.search-dropdown__empty,
.search-dropdown__loading {
    padding: 24px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}

@keyframes spin { to { transform: rotate(360deg); } }
.spin { display: inline-block; animation: spin 0.8s linear infinite; }

.topbar-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.1rem;
    transition: var(--transition);
    position: relative;
    font-family: inherit;
}
.topbar-btn:hover { background: var(--bg-body); color: var(--text-primary); }

.notif-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    background: var(--danger);
    color: #fff;
    font-size: 0.65rem;
    padding: 1px 5px;
    border-radius: 10px;
    font-weight: 600;
    line-height: 1.4;
}

.user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-accent) 0%, var(--primary) 100%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    box-shadow: 0 2px 8px rgba(26, 58, 107, 0.25);
}

.user-btn {
    padding: 6px 12px 6px 8px !important;
    border: 1px solid var(--border);
    border-radius: 24px !important;
    background: var(--bg-card) !important;
}

.user-btn:hover {
    border-color: rgba(26, 58, 107, 0.2);
    box-shadow: var(--shadow-sm);
}

.user-name { font-size: 0.85rem; font-weight: 600; color: var(--text-primary); }

.lang-label { font-size: 0.75rem; font-weight: 600; }

/* Dropdown */
.dropdown { position: relative; }

.dropdown-menu {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    min-width: 200px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 200;
    padding: 6px;
    animation: fadeIn 0.15s ease;
}

[dir="rtl"] .dropdown-menu { left: 0; }
[dir="ltr"] .dropdown-menu { right: 0; }
.dropdown-menu-end { min-width: 240px; }

.dropdown.open .dropdown-menu { display: block; }

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    color: var(--text-primary);
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    transition: var(--transition);
}
.dropdown-item:hover { background: var(--bg-body); }
.dropdown-item.active { background: var(--primary-light); color: var(--primary); font-weight: 500; }
.dropdown-item.text-danger { color: var(--danger); }

.dropdown-menu hr { border: none; border-top: 1px solid var(--border); margin: 4px 0; }

.user-info {
    padding: 14px 14px 12px;
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--bg-card) 100%);
    border-radius: var(--radius-sm);
    margin-bottom: 4px;
}

.user-info-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-accent) 0%, var(--primary) 100%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.1rem;
    margin-bottom: 10px;
    box-shadow: 0 4px 12px rgba(26, 58, 107, 0.2);
}

.user-info strong { display: block; font-size: 0.95rem; font-weight: 700; }
.user-info small { color: var(--text-secondary); font-size: 0.8rem; }

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

.notif-header-link {
    padding: 2px 8px !important;
    font-size: 0.75rem !important;
}
.notif-empty { padding: 20px; text-align: center; color: var(--text-muted); font-size: 0.85rem; }
.notif-item { display: block; padding: 10px 12px; text-decoration: none; color: var(--text-primary); border-radius: var(--radius-sm); }
.notif-item:hover { background: var(--bg-body); }
.notif-item.unread { background: var(--primary-light); }
.notif-title { font-size: 0.85rem; font-weight: 500; }
.notif-time { font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; }

/* Page Content */
.page-content {
    flex: 1;
    padding: 24px;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.page-title { font-size: 1.5rem; font-weight: 800; color: var(--text-primary); letter-spacing: -0.02em; }
.page-subtitle { font-size: 0.9rem; color: var(--text-secondary); margin-top: 4px; }

.app-footer {
    padding: 12px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-muted);
    background: var(--bg-topbar);
}

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    min-width: 0;
    max-width: 100%;
}

.card:hover { box-shadow: var(--shadow); }

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

.card-body { padding: 20px; }
.card-footer { padding: 12px 20px; border-top: 1px solid var(--border); }

/* Stat Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
    width: 100%;
}

.stats-grid--4 {
    grid-template-columns: repeat(4, 1fr);
}

.stats-grid--3 {
    grid-template-columns: repeat(3, 1fr);
}

.stats-grid--compact {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
}

.dashboard-section {
    margin-bottom: 28px;
}

.dashboard-section-title {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--border-light);
    display: flex;
    align-items: center;
    gap: 8px;
}

.dashboard-section-title i {
    color: var(--primary);
    font-size: 1rem;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 18px;
    display: flex;
    align-items: flex-start;
    gap: 14px;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
    min-width: 0;
}

.stat-card--compact {
    padding: 14px 16px;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
}

.stat-card--compact .stat-value {
    font-size: 1.25rem;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 4px;
    height: 100%;
    background: var(--primary);
    opacity: 0;
    transition: var(--transition);
}

[dir="ltr"] .stat-card::before { right: auto; left: 0; }

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow);
    border-color: rgba(26, 58, 107, 0.15);
}

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

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

.stat-icon.primary { background: var(--surface-primary); color: var(--primary); }
.stat-icon.success { background: var(--surface-success); color: var(--success); }
.stat-icon.warning { background: var(--surface-warning); color: var(--warning); }
.stat-icon.danger { background: var(--surface-danger); color: var(--danger); }
.stat-icon.info { background: var(--surface-info); color: var(--info); }
.stat-icon.secondary { background: var(--surface-muted); color: var(--secondary); }

[data-theme="dark"] .stat-icon.primary { background: var(--surface-primary); }
[data-theme="dark"] .stat-icon.success { background: var(--surface-success); }
[data-theme="dark"] .stat-icon.warning { background: var(--surface-warning); }
[data-theme="dark"] .stat-icon.danger { background: var(--surface-danger); }

.stat-info { flex: 1; min-width: 0; }
.stat-label { font-size: 0.8rem; color: var(--text-secondary); margin-bottom: 4px; }
.stat-value { font-size: 1.2rem; font-weight: 800; color: var(--text-primary); line-height: 1.35; letter-spacing: -0.02em; word-break: break-word; }
.stat-value .text-muted { font-size: 0.68rem; font-weight: 500; color: var(--text-muted); display: block; margin-top: 3px; }

/* Charts */
.module-nav-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.module-nav-card {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 20px 22px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    text-decoration: none;
    color: inherit;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
    min-width: 0;
}

.module-nav-card::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 4px;
    height: 100%;
    background: var(--primary);
    opacity: 0;
    transition: var(--transition);
}

[dir="ltr"] .module-nav-card::before { right: auto; left: 0; }

.module-nav-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow);
    border-color: rgba(26, 58, 107, 0.18);
}

.module-nav-card:hover::before { opacity: 1; }

.module-nav-card__icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    flex-shrink: 0;
}

.module-nav-card__body { flex: 1; min-width: 0; padding-inline-end: 20px; }

.module-nav-card__title {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 5px;
    color: var(--text-primary);
}

.module-nav-card__desc {
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin: 0;
}

.module-nav-card__meta {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 10px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--primary);
    background: var(--primary-light);
    padding: 4px 10px;
    border-radius: 20px;
}

.module-nav-card__arrow {
    position: absolute;
    top: 50%;
    left: 18px;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 1.1rem;
    opacity: 0;
    transition: var(--transition);
}

[dir="ltr"] .module-nav-card__arrow { left: auto; right: 18px; }

.module-nav-card:hover .module-nav-card__arrow {
    opacity: 1;
    transform: translateY(-50%) translateX(-4px);
}

[dir="ltr"] .module-nav-card:hover .module-nav-card__arrow {
    transform: translateY(-50%) translateX(4px);
}

.card-header-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
}

.card-header-title i {
    color: var(--primary);
    font-size: 1.05rem;
}

.empty-state-inline {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.empty-state-inline i {
    font-size: 2.5rem;
    display: block;
    margin-bottom: 10px;
    opacity: 0.35;
}

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

/* Layout utilities */
.p-0 { padding: 0 !important; }
.mt-section { margin-top: var(--gap-section); }
.mb-section { margin-bottom: var(--gap-section); }
.card-stack { margin-bottom: var(--gap-page); }
.card-stack:last-child { margin-bottom: 0; }

.layout-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--gap-page);
    margin-bottom: var(--gap-page);
}

.layout-detail {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: var(--gap-page);
    align-items: start;
}

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.kv-list { display: grid; gap: 10px; }

.kv-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-light);
}

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

.kv-label { color: var(--text-secondary); font-size: 0.85rem; }
.kv-value { font-weight: 600; text-align: end; }

.form-inline { display: inline; }
.form-narrow { max-width: 640px; }
.search-wide { min-width: 220px; }

.form-check {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.9rem;
}

.form-check input { width: auto; cursor: pointer; }

.pagination-wrap { padding: 0 16px 12px; }

/* Profile */
.profile-layout {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: var(--gap-section);
    align-items: start;
}

.profile-card {
    text-align: center;
    padding: 28px 20px;
}

.profile-avatar-lg {
    width: 88px;
    height: 88px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-accent) 0%, var(--primary) 100%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 2rem;
    margin: 0 auto 14px;
    box-shadow: 0 8px 24px rgba(26, 58, 107, 0.25);
}

.profile-name { font-size: 1.15rem; font-weight: 800; margin-bottom: 4px; }
.profile-role {
    display: inline-block;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--primary);
    background: var(--surface-primary);
    padding: 4px 12px;
    border-radius: 20px;
    margin-bottom: 16px;
}

.profile-meta {
    display: grid;
    gap: 10px;
    text-align: start;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-light);
}

.profile-meta-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.profile-meta-item i {
    color: var(--primary);
    font-size: 1rem;
    width: 20px;
    text-align: center;
}

.profile-section { margin-bottom: var(--gap-page); }
.profile-section:last-child { margin-bottom: 0; }

.profile-section-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 14px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    gap: 8px;
}

.profile-section-title i { color: var(--primary); }

.qr-thumb {
    width: 100px;
    height: 100px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 4px;
    object-fit: contain;
}

.detail-field small {
    display: block;
    color: var(--text-muted);
    font-size: 0.78rem;
    margin-bottom: 3px;
}

.detail-field > div:last-child { font-weight: 600; }

.flex-wrap-gap {
    display: flex;
    gap: 20px;
    align-items: center;
    flex-wrap: wrap;
}

.file-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.9rem;
}

.file-link:hover { color: var(--primary); }

/* Charts */
.charts-grid {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
    gap: 16px;
    margin-bottom: 24px;
    width: 100%;
}

.chart-container { position: relative; height: 280px; width: 100%; }
.chart-container canvas { max-width: 100% !important; }

/* Tables */
.table-wrapper { overflow-x: auto; transition: opacity 0.2s ease; }
.table-wrapper.is-loading { opacity: 0.55; pointer-events: none; }

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92rem;
}

.data-table th {
    background: var(--surface-muted);
    padding: 14px 16px;
    text-align: start;
    font-weight: 700;
    color: var(--text-secondary);
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

.data-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
}

.data-table tbody tr { transition: var(--transition); }
.data-table tbody tr:hover { background: var(--bg-body); }

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.4;
}

.badge-success { background: #e6f4ea; color: var(--success); }
.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-warning { background: #fef7e0; color: #e37400; }
.badge-danger { background: #fce8e6; color: var(--danger); }
.badge-info { background: #e8f0fe; color: var(--info); }
.badge-secondary { background: #f1f3f4; color: var(--secondary); }
.badge-dark { background: #e8eaed; color: #3c4043; }

[data-theme="dark"] .badge-success { background: rgba(52,168,83,0.2); }
[data-theme="dark"] .badge-primary { background: rgba(26,115,232,0.2); }
[data-theme="dark"] .badge-warning { background: rgba(249,171,0,0.2); }
[data-theme="dark"] .badge-danger { background: rgba(234,67,53,0.2); }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    font-family: inherit;
    line-height: 1.5;
    white-space: nowrap;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #2d9249; }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #d33426; }

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

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

.btn-group { display: flex; gap: 6px; }

/* Forms */
.form-group { margin-bottom: 16px; }

.form-label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 0.85rem;
    color: var(--text-primary);
}

.form-control {
    width: 100%;
    padding: 9px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    background: var(--bg-input);
    color: var(--text-primary);
    transition: var(--transition);
    font-family: inherit;
}

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

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

select.form-control { cursor: pointer; }

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

.form-check {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

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

.alert-success { background: #e6f4ea; color: #1e7e34; border: 1px solid #c3e6cb; }
.alert-danger { background: #fce8e6; color: #c5221f; border: 1px solid #f5c6cb; }
.alert-warning { background: #fef7e0; color: #e37400; border: 1px solid #ffeeba; }
.alert-info { background: #e8f0fe; color: #1a73e8; border: 1px solid #b8d4fe; }

[data-theme="dark"] .alert-success { background: rgba(52,168,83,0.15); }
[data-theme="dark"] .alert-danger { background: rgba(234,67,53,0.15); }

.btn-close {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    margin-inline-start: auto;
    opacity: 0.5;
    color: inherit;
}
.btn-close:hover { opacity: 1; }

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    flex-wrap: wrap;
    gap: 12px;
}

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

.pagination-links { display: flex; gap: 4px; }

.page-link {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.85rem;
    transition: var(--transition);
}

.page-link:hover { background: var(--bg-body); border-color: var(--primary); color: var(--primary); }
.page-link.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-link.disabled { opacity: 0.4; pointer-events: none; }

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(10, 22, 40, 0.55);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 2000;
    align-items: flex-start;
    justify-content: center;
    padding: 24px 16px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    animation: fadeIn 0.2s ease;
}

.modal-overlay.show { display: flex; }

body.modal-open {
    overflow: hidden !important;
}

.modal {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: 0 24px 64px rgba(15, 39, 68, 0.22);
    border: 1px solid rgba(201, 162, 39, 0.35);
    outline: none;
    width: 100%;
    max-width: 560px;
    max-height: calc(100vh - 48px);
    max-height: calc(100dvh - 48px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.25s ease;
    position: relative;
    z-index: 2001;
    margin: auto;
}

.modal > form {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 600;
    font-size: 1.05rem;
    flex-shrink: 0;
}

.modal-body {
    padding: 20px;
    overflow-x: hidden;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    flex: 1 1 auto;
    min-height: 0;
    max-height: calc(100vh - 160px);
    max-height: calc(100dvh - 160px);
    overscroll-behavior: contain;
    touch-action: pan-y;
}
.modal-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    flex-shrink: 0;
}

/* Login Page - moved to auth.css */
.login-page-legacy {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f2744 0%, #1a3a6b 50%, #1e2532 100%);
    padding: 20px;
}

.login-card-legacy {
    background: var(--bg-card);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 420px;
    padding: 40px 36px;
    animation: slideUp 0.4s ease;
}

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

.login-logo i { font-size: 3rem; color: var(--primary); }
.login-logo h1 { font-size: 1.4rem; margin-top: 12px; font-weight: 700; }
.login-logo p { color: var(--text-secondary); font-size: 0.85rem; margin-top: 4px; }

.login-form .form-group { margin-bottom: 20px; }
.login-form .btn { width: 100%; padding: 12px; font-size: 1rem; justify-content: center; margin-top: 8px; }

.login-footer {
    text-align: center;
    margin-top: 24px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Filters bar */
.filters-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
    flex-wrap: wrap;
    padding: 14px 16px;
    background: var(--surface-muted);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
}

.filters-bar .form-control { width: auto; min-width: 180px; flex: 1; max-width: 320px; }
.filters-bar__search { min-width: 220px; }
.filters-bar__hint {
    font-size: 0.78rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}
.filters-bar__hint i { color: var(--warning); }

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

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

/* Animations */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

/* Responsive */
@media (max-width: 1200px) {
    .stats-grid--4 { grid-template-columns: repeat(2, 1fr); }
    .stats-grid--3 { grid-template-columns: repeat(2, 1fr); }
    .module-nav-grid { grid-template-columns: repeat(2, 1fr); }
}

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

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(100%);
        width: var(--sidebar-width) !important;
    }
    [dir="ltr"] .sidebar { transform: translateX(-100%); }

    .sidebar.mobile-open { transform: translateX(0) !important; }
    .sidebar.collapsed { width: min(88vw, 300px) !important; }
    .sidebar.collapsed .sidebar-brand,
    .sidebar.collapsed .nav-section-title,
    .sidebar.collapsed .nav-item span { display: inline; }

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

    .mobile-menu-btn { display: flex; }
    .search-box { min-width: auto; flex: 1; }
    .user-name { display: none; }

    .stats-grid,
    .stats-grid--4,
    .stats-grid--3 { grid-template-columns: repeat(2, 1fr); }
    .stats-grid--compact { grid-template-columns: repeat(2, 1fr); }
    .module-nav-grid { grid-template-columns: 1fr; }
    .layout-grid-2,
    .layout-detail,
    .profile-layout { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
    .stats-grid,
    .stats-grid--4,
    .stats-grid--3,
    .stats-grid--compact { grid-template-columns: 1fr; }
    .module-nav-grid { grid-template-columns: 1fr; }
}

/* Print */
.card-body.p-0 { padding: 0 !important; }
.card-body.p-0 .pagination { padding: 12px 16px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
td .btn-group { flex-wrap: nowrap; }
.modal-overlay .modal { max-width: 640px; }
.stat-card.compact { padding: 14px; }
.stat-card.compact .stat-value { font-size: 1.2rem; }
.breadcrumb { font-size: 0.85rem; color: var(--text-secondary); }
.breadcrumb a { color: var(--primary); text-decoration: none; }
.filters-bar .form-control { min-width: 140px; }

/* Western numerals for amounts, dates, and counters */
body, .stat-value, .data-table, .num-en {
    font-variant-numeric: lining-nums;
}

input[type="number"],
input[type="date"],
input[type="month"],
.num-en {
    font-family: 'Inter', 'Segoe UI', sans-serif;
    direction: ltr !important;
    unicode-bidi: isolate;
    text-align: left;
}

@media print {
    /* Shared print rules: assets/css/print.css */
    .invoice-doc { box-shadow: none !important; }
}

/* WhatsApp + toasts + enhancements */
.btn-whatsapp {
    background: #25d366;
    color: #fff;
    border: none;
}
.btn-whatsapp:hover {
    background: #1da851;
    color: #fff;
}
.toast-stack {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 360px;
}
[dir="ltr"] .toast-stack { left: auto; right: 20px; }
.toast-pop {
    padding: 14px 18px;
    border-radius: 10px;
    color: #fff;
    box-shadow: 0 8px 24px rgba(0,0,0,.18);
    animation: toastIn .35s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
}
.toast-pop--success { background: linear-gradient(135deg, #059669, #10b981); }
.toast-pop--error { background: linear-gradient(135deg, #dc2626, #ef4444); }
@keyframes toastIn {
    from { opacity: 0; transform: translateY(-12px); }
    to { opacity: 1; transform: translateY(0); }
}
.payroll-inline-form {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}
.payroll-inline-form .form-control-sm { width: 100px; }
.statement-desc { white-space: normal; min-width: 220px; max-width: 420px; }
.statement-row--payment td { background: rgba(16, 185, 129, 0.04); }
.statement-row--invoice td { background: rgba(37, 99, 235, 0.04); }

.price-dual-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 1.25rem;
}
@media (max-width: 768px) {
    .price-dual-row { grid-template-columns: 1fr; }
}
.modal .price-dual-row { grid-template-columns: 1fr; }
.price-dual {
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 10px;
    padding: 12px 14px;
    background: var(--surface-muted, #f8fafc);
}
.price-dual__title {
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--primary-dark);
}
.price-dual__grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.price-dual__field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
}
