:root {
    --brand: #1e4bd8;
    --brand-dark: #16389f;
    --brand-soft: #eef2ff;
    --sidebar-w: 268px;
    --ink: #0f172a;
    --muted: #64748b;
    --line: #e6e9f0;
    --bg: #f4f6fb;
}

* { font-family: 'Cairo', 'Segoe UI', Tahoma, sans-serif; }

body {
    background: var(--bg);
    color: var(--ink);
    font-size: 14px;
}

/* ============ الهيكل العام ============ */
.app-wrapper { display: flex; min-height: 100vh; }

.app-sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: #0d1b3e;
    color: #cbd5e1;
    position: fixed;
    inset-block: 0;
    inset-inline-start: 0;
    overflow-y: auto;
    z-index: 1040;
    transition: transform .25s ease;
}
.app-sidebar::-webkit-scrollbar { width: 6px; }
.app-sidebar::-webkit-scrollbar-thumb { background: #29406e; border-radius: 6px; }

.sidebar-brand {
    display: flex; align-items: center; gap: 12px;
    padding: 20px 18px;
    border-bottom: 1px solid rgba(255,255,255,.08);
    position: sticky; top: 0; background: #0d1b3e; z-index: 2;
}
.brand-icon {
    width: 42px; height: 42px; border-radius: 12px;
    display: grid; place-items: center;
    background: linear-gradient(135deg, var(--brand), #4f7cff);
    color: #fff; font-size: 18px;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.3; overflow: hidden; }
.brand-name { color: #fff; font-weight: 700; font-size: 14px; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }
.brand-sub { color: #7d93bd; font-size: 11px; }

.sidebar-nav { padding: 12px 10px 30px; }
.nav-section {
    color: #64789f; font-size: 11px; font-weight: 700;
    padding: 16px 12px 6px; letter-spacing: .3px;
}
.nav-list { list-style: none; padding: 0; margin: 0; }
.nav-list .nav-link {
    display: flex; align-items: center; gap: 11px;
    padding: 10px 12px; border-radius: 10px;
    color: #b9c6de; font-size: 13.5px; font-weight: 500;
    text-decoration: none; transition: .15s;
}
.nav-list .nav-link i { width: 20px; text-align: center; font-size: 14px; }
.nav-list .nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-list .nav-link.active { background: linear-gradient(135deg, var(--brand), #4f7cff); color: #fff; box-shadow: 0 6px 16px rgba(30,75,216,.35); }

.app-main {
    flex: 1;
    margin-inline-start: var(--sidebar-w);
    display: flex; flex-direction: column;
    min-width: 0;
}

/* ============ الشريط العلوي ============ */
.app-navbar {
    height: 66px;
    background: #fff;
    border-bottom: 1px solid var(--line);
    display: flex; align-items: center; gap: 14px;
    padding: 0 22px;
    position: sticky; top: 0; z-index: 1030;
}
.navbar-search { position: relative; flex: 1; max-width: 520px; }
.navbar-search i { position: absolute; inset-inline-start: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 13px; }
.navbar-search .form-control { padding-inline-start: 38px; background: var(--bg); border-color: transparent; border-radius: 10px; height: 40px; font-size: 13px; }
.navbar-search .form-control:focus { background: #fff; border-color: var(--brand); box-shadow: none; }

.navbar-right { margin-inline-start: auto; display: flex; align-items: center; gap: 10px; }
.btn-icon { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; border-color: var(--line); }
.badge-dot {
    position: absolute; top: -5px; inset-inline-end: -5px;
    background: #ef4444; color: #fff; font-size: 10px;
    min-width: 18px; height: 18px; border-radius: 9px;
    display: grid; place-items: center; padding: 0 4px;
}
.user-btn { display: flex; align-items: center; gap: 8px; border-radius: 10px; border-color: var(--line); height: 40px; font-size: 13px; }
.user-btn img { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; }
.notif-menu { min-width: 320px; max-height: 400px; overflow-y: auto; }

/* ============ المحتوى ============ */
.app-content { padding: 22px; flex: 1; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.page-title { font-size: 21px; font-weight: 700; margin: 0 0 4px; }
.breadcrumb { font-size: 12.5px; }
.breadcrumb a { color: var(--brand); text-decoration: none; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.app-footer {
    padding: 14px 22px; border-top: 1px solid var(--line);
    background: #fff; font-size: 12.5px; color: var(--muted);
    display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px;
}

/* ============ البطاقات ============ */
.card { border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 1px 2px rgba(16,24,40,.04); }
.card-header {
    background: #fff; border-bottom: 1px solid var(--line);
    padding: 15px 18px; font-weight: 700; font-size: 15px;
    border-radius: 14px 14px 0 0 !important;
    display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
}
.card-body { padding: 18px; }

/* بطاقات الإحصائيات */
.stat-card { display: flex; align-items: center; gap: 14px; padding: 18px; height: 100%; }
.stat-icon { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; font-size: 20px; flex-shrink: 0; }
.stat-value { font-size: 22px; font-weight: 700; line-height: 1.2; }
.stat-label { color: var(--muted); font-size: 12.5px; }
.stat-meta { font-size: 11.5px; }

/* ============ الجداول ============ */
table.dataTable { font-size: 13px; width: 100% !important; }
table.dataTable thead th {
    background: #f8fafc; border-bottom: 1px solid var(--line) !important;
    font-weight: 700; font-size: 12.5px; color: #475569; white-space: nowrap; padding: 11px 10px;
}
table.dataTable tbody td { padding: 10px; vertical-align: middle; border-color: #f1f5f9; }
table.dataTable tbody tr:hover { background: #fafbff; }
.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
    border: 1px solid var(--line); border-radius: 8px; padding: 5px 10px; font-size: 13px;
}
.dataTables_wrapper .dataTables_filter { margin-bottom: 10px; }
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate { font-size: 12.5px; padding-top: 12px; }
.page-link { border-radius: 8px !important; margin: 0 2px; border-color: var(--line); font-size: 13px; }
.page-item.active .page-link { background: var(--brand); border-color: var(--brand); }

.table-actions { display: flex; gap: 5px; justify-content: center; }
.table-actions .btn { width: 30px; height: 30px; padding: 0; display: grid; place-items: center; border-radius: 8px; font-size: 12px; }

/* ============ النماذج ============ */
.form-label { font-weight: 600; font-size: 13px; margin-bottom: 5px; color: #334155; }
.form-label .req { color: #ef4444; }
.form-control, .form-select { border-radius: 9px; border-color: var(--line); font-size: 13.5px; padding: 9px 12px; }
.form-control:focus, .form-select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(30,75,216,.1); }
.form-control:disabled, .form-control[readonly] { background: #f8fafc; }
textarea.form-control { min-height: 90px; }
.input-group-text { background: #f8fafc; border-color: var(--line); font-size: 13px; }

.btn { border-radius: 9px; font-size: 13.5px; font-weight: 600; padding: 9px 16px; }
.btn-primary { background: var(--brand); border-color: var(--brand); }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }

.select2-container--bootstrap-5 .select2-selection { border-radius: 9px !important; border-color: var(--line) !important; min-height: 40px; font-size: 13.5px; }
.select2-container { width: 100% !important; }

.form-section-title {
    font-weight: 700; font-size: 14px; color: var(--brand);
    padding-bottom: 8px; margin: 6px 0 14px;
    border-bottom: 2px solid var(--brand-soft);
    display: flex; align-items: center; gap: 8px;
}

/* ============ الشارات والحالات ============ */
.badge { font-weight: 600; font-size: 11.5px; padding: 5px 10px; border-radius: 7px; }

/* ============ صفحة العرض (التفاصيل) ============ */
.detail-list { list-style: none; padding: 0; margin: 0; }
.detail-list li { display: flex; gap: 10px; padding: 9px 0; border-bottom: 1px dashed #eef1f6; font-size: 13.5px; }
.detail-list li:last-child { border-bottom: 0; }
.detail-list .dl-label { color: var(--muted); min-width: 130px; font-weight: 600; }
.detail-list .dl-value { flex: 1; }

.profile-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.profile-avatar {
    width: 64px; height: 64px; border-radius: 16px; display: grid; place-items: center;
    background: linear-gradient(135deg, var(--brand), #4f7cff); color: #fff; font-size: 24px; flex-shrink: 0;
}

/* الخط الزمني للأنشطة */
.timeline { list-style: none; padding: 0; margin: 0; position: relative; }
.timeline::before { content: ''; position: absolute; inset-inline-start: 15px; top: 6px; bottom: 6px; width: 2px; background: #eef1f6; }
.timeline-item { position: relative; padding-inline-start: 44px; padding-bottom: 18px; }
.timeline-dot {
    position: absolute; inset-inline-start: 4px; top: 2px;
    width: 24px; height: 24px; border-radius: 50%;
    display: grid; place-items: center; font-size: 10px; color: #fff; background: var(--brand);
}
.timeline-title { font-weight: 600; font-size: 13.5px; }
.timeline-meta { font-size: 11.5px; color: var(--muted); }

/* ============ صفحة الطباعة ============ */
.print-doc { background: #fff; padding: 34px; border-radius: 14px; border: 1px solid var(--line); }
.print-head { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; border-bottom: 3px solid var(--brand); padding-bottom: 18px; margin-bottom: 22px; }
.print-title { font-size: 26px; font-weight: 800; color: var(--brand); }
.print-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.print-table th { background: var(--brand); color: #fff; padding: 10px; font-weight: 600; }
.print-table td { padding: 9px 10px; border-bottom: 1px solid #eef1f6; }
.print-totals { margin-inline-start: auto; max-width: 340px; }
.print-totals tr td { padding: 7px 10px; font-size: 13.5px; }
.print-totals tr:last-child td { font-weight: 800; font-size: 15px; border-top: 2px solid var(--brand); color: var(--brand); }

@media print {
    .app-sidebar, .app-navbar, .app-footer, .page-head, .no-print, .sidebar-backdrop { display: none !important; }
    .app-main { margin: 0 !important; }
    .app-content { padding: 0 !important; }
    body { background: #fff; }
    .print-doc { border: 0; padding: 0; }
}

/* ============ تسجيل الدخول ============ */
.login-page {
    min-height: 100vh; display: grid; place-items: center; padding: 20px;
    background: linear-gradient(135deg, #0d1b3e 0%, #1e4bd8 100%);
}
.login-card { width: 100%; max-width: 420px; background: #fff; border-radius: 18px; padding: 34px; box-shadow: 0 24px 60px rgba(0,0,0,.28); }
.login-logo { width: 62px; height: 62px; border-radius: 18px; display: grid; place-items: center; margin: 0 auto 14px; background: linear-gradient(135deg, var(--brand), #4f7cff); color: #fff; font-size: 26px; }

/* ============ الشاشات الصغيرة ============ */
.sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 1035; }
.sidebar-backdrop.show { display: block; }

@media (max-width: 991.98px) {
    .app-sidebar { transform: translateX(100%); }
    .app-sidebar.show { transform: translateX(0); }
    .app-main { margin-inline-start: 0; }
    .app-content { padding: 16px; }
}
