:root {
    /* ألوان أكثر حداثة وعمق */
    --primary: #0f172a;       /* كحلي داكن ملكي معاصر */
    --primary-light: #1e293b; /* كحلي وسيط للتفاعل */
    --accent: #3b82f6;        /* أزرق حيوي للمؤشرات الهامة */
    --white: #ffffff;
    --light-bg: #f8fafc;     /* خلفية رمادية ثلجية مريحة جداً للعين */
    --border: #e2e8f0;       /* حدود ناعمة وخفيفة */
    --text-dark: #0f172a;    /* نصوص داكنة واضحة */
    --text-muted: #64748b;   /* نصوص فرعية رمادية */
    --success: #10b981;      /* أخضر مالي مريح */
    --danger: #ef4444;       /* أحمر تحذيري ناعم */
    --warning: #f59e0b;      /* برتقالي/أصفر تحذيري متزن */
    --radius: 12px;          /* زوايا دائرية عصرية وكبيرة */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.05), 0 1px 2px rgba(0,0,0,0.02);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.05), 0 2px 4px -1px rgba(0,0,0,0.03);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.05), 0 4px 6px -2px rgba(0,0,0,0.02);
}

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

body {
    font-family: 'Tajawal', 'Cairo', 'Noto Sans Arabic', 'Almarai', Tahoma, Arial, sans-serif;
    direction: rtl;
    text-align: right;
    background-color: var(--light-bg);
    color: var(--text-dark);
    font-size: 14px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

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

/* Sidebar العصري الممتد */
.sidebar {
    width: 260px;
    background-color: var(--primary);
    color: var(--white);
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    overflow-y: auto;
    z-index: 1000;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: -4px 0 24px rgba(0,0,0,0.15);
}

.sidebar-header {
    padding: 24px 20px;
    text-align: center;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.sidebar-header h2 {
    font-size: 16px;
    font-weight: 700;
    margin: 0;
    letter-spacing: 0.5px;
    color: #f8fafc;
}

.sidebar-header small {
    font-size: 11px;
    opacity: 0.6;
    display: block;
    margin-top: 4px;
}

.sidebar-nav {
    list-style: none;
    padding: 16px 12px;
}

.sidebar-nav li {
    margin-bottom: 4px;
}

.sidebar-nav li a {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    color: #94a3b8; /* نصوص خافتة قبل التحويم */
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.sidebar-nav li a:hover,
.sidebar-nav li a.active {
    background-color: rgba(255, 255, 255, 0.08);
    color: var(--white);
}

.sidebar-nav li a .nav-icon {
    margin-left: 12px;
    font-size: 16px;
    width: 20px;
    display: inline-block;
    text-align: center;
}

/* Main Content */
.main-content {
    margin-right: 260px;
    flex: 1;
    padding: 30px 40px;
    min-height: 100vh;
    transition: all 0.3s ease;
}

/* Top Bar المطور */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 20px;
    margin-bottom: 25px;
    border-bottom: 1px solid var(--border);
}

.top-bar h1 {
    font-size: 20px;
    color: var(--primary);
    font-weight: 700;
}

.top-bar .user-info {
    font-size: 13px;
    color: var(--text-muted);
    background: var(--white);
    padding: 6px 14px;
    border-radius: 30px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}

/* Cards عصرية ثلاثية الأبعاد خفيفة */
.card {
    background: var(--white);
    border: 1px solid rgba(0,0,0,0.02);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-md);
}

.card-header {
    font-size: 15px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
    position: relative;
}

/* خط كحلي صغير تحت عنوان الكارت كعلامة جمالية بدلاً من الخط الكامل السميك */
.card-header::after {
    content: '';
    position: absolute;
    bottom: -1px;
    right: 0;
    width: 40px;
    height: 2px;
    background: var(--accent);
    border-radius: 2px;
}

/* Stats Grid كروت مالية واحصائية مذهلة */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--white);
    border: 1px solid rgba(0,0,0,0.01);
    border-radius: var(--radius);
    padding: 24px;
    text-align: right; /* محاذاة لليمين أكثر احترافية من السنتر */
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
}

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

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

.stat-card .stat-number {
    font-size: 26px;
    font-weight: 800;
    color: var(--primary);
    display: block;
    margin-bottom: 4px;
    letter-spacing: -0.5px;
}

.stat-card .stat-label {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
}

/* Tables نظيفة جدا ومريحة للقرأة */
.table-responsive {
    overflow-x: auto;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--white);
}

table th {
    background-color: #f8fafc; /* خلفية هيدر فاتحة ومودرن بدلا من الغامقة الكاتمة */
    color: var(--text-muted);
    padding: 14px 18px;
    font-weight: 600;
    font-size: 12.5px;
    text-align: right;
    border-bottom: 1px solid var(--border);
}

table td {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    font-size: 13.5px;
    color: #334155;
    vertical-align: middle;
}

table tr:last-child td {
    border-bottom: none;
}

table tr:hover {
    background-color: #f1f5f9;
}

/* Forms حقول إدخال بلمسة توهج ناعمة */
.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    color: #475569;
    font-size: 12.5px;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 13.5px;
    font-family: inherit;
    color: var(--text-dark);
    background-color: var(--white);
    transition: all 0.2s ease;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.02);
}

.form-control:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12), inset 0 1px 2px rgba(0,0,0,0.02);
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left 14px center;
    padding-left: 35px;
}

/* Buttons مسطحة وأنيقة وتفاعلية */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 18px;
    font-size: 13.5px;
    font-weight: 600;
    font-family: inherit;
    text-decoration: none;
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
    box-shadow: var(--shadow-sm);
}

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

.btn-primary:hover {
    background-color: #2563eb;
    transform: translateY(-1px);
}

.btn-outline {
    background-color: transparent;
    color: #475569;
    border-color: #cbd5e1;
}

.btn-outline:hover {
    background-color: #f8fafc;
    border-color: #94a3b8;
    color: var(--text-dark);
}

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

.btn-danger:hover {
    background-color: #dc2626;
    transform: translateY(-1px);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
    border-radius: 6px;
}

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

/* Badges زوايا دائرية بالكامل */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 30px;
}

.badge-primary { background-color: #eff6ff; color: #1e40af; }
.badge-success { background-color: #ecfdf5; color: #065f46; }
.badge-warning { background-color: #fffbeb; color: #92400e; }
.badge-danger { background-color: #fef2f2; color: #991b1b; }

/* Form Grid */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 18px;
}

/* Search Bar */
.search-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
}

.search-bar .form-control {
    max-width: 320px;
}

/* Login Page صفحة دخول متميزة تليق بالشركات الكبرى */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--primary);
    background-image: radial-gradient(circle at top right, var(--primary-light), var(--primary));
}

.login-box {
    background: var(--white);
    padding: 40px;
    border-radius: var(--radius);
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3);
}

.login-box h1 {
    color: var(--primary);
    text-align: center;
    margin-bottom: 8px;
    font-size: 22px;
    font-weight: 700;
}

.login-box .subtitle {
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 28px;
    font-size: 13px;
}

/* Validation */
.text-danger {
    color: var(--danger);
    font-size: 12px;
    margin-top: 4px;
    display: block;
}

.validation-summary-errors ul {
    list-style: none;
    padding: 12px 16px;
    background: #fef2f2;
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 8px;
    margin-bottom: 18px;
}

.validation-summary-errors ul li {
    color: #b91c1c;
    font-size: 13px;
}

/* Alerts */
.alert {
    padding: 14px 18px;
    border-radius: 8px;
    margin-bottom: 18px;
    font-size: 13px;
    border: 1px solid transparent;
}

.alert-success {
    background: #ecfdf5;
    border-color: rgba(16, 185, 129, 0.2);
    color: #065f46;
}

.alert-danger {
    background: #fef2f2;
    border-color: rgba(239, 68, 68, 0.2);
    color: #991b1b;
}

/* Action bar */
.action-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

/* Detail view */
.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.detail-item {
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.detail-item:last-child {
    border-bottom: none;
}

.detail-item .detail-label {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 4px;
    font-weight: 500;
}

.detail-item .detail-value {
    font-size: 14.5px;
    font-weight: 600;
    color: var(--primary);
}

/* Toggle Menu Button Responsive */
.menu-toggle {
    display: none;
    background: var(--primary);
    color: var(--white);
    border: none;
    padding: 10px 14px;
    font-size: 16px;
    cursor: pointer;
    border-radius: 8px;
    position: fixed;
    top: 15px;
    right: 15px;
    z-index: 1001;
    box-shadow: var(--shadow-md);
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(100%);
    }

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

    .main-content {
        margin-right: 0;
        padding: 20px 16px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

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

    .top-bar {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
        padding-top: 40px; /* لترك مساحة لزر القائمة المنسدلة الموبايل */
    }

    .menu-toggle {
        display: block !important;
    }
}