/* ==========================================
   ملف التنسيقات المخصص - منصة راسخ
========================================== */

/* ألوان المنصة: فحمي + زمردي. كل الألوان الأساسية تُقرأ من هذه المتغيرات */
:root {
    --c-bg: #0b0d0e;
    --c-surface-rgb: 16 18 20;
    --c-container-rgb: 23 26 29;
    --c-card: #1c2024;
    --c-field: #22272b;
    --c-border: #30363b;
    --c-text: #ececec;
    --c-primary-rgb: 52 211 153;
    --c-glow-1: rgba(52,211,153,0.07);
    --c-glow-2: rgba(255,255,255,0.02);
    --c-surface: rgb(var(--c-surface-rgb));
    --c-container: rgb(var(--c-container-rgb));
    --c-primary: rgb(var(--c-primary-rgb));
}

/* 1. الإعدادات العامة للخطوط والخلفية */
body { 
    font-family: 'Tajawal', sans-serif; 
    background-color: var(--c-bg); 
    background-image: radial-gradient(900px 520px at 100% -10%, var(--c-glow-1), transparent 60%), radial-gradient(800px 520px at -10% 110%, var(--c-glow-2), transparent 60%); 
    background-attachment: fixed; 
    color: var(--c-text); 
    overflow-x: hidden; 
}

/* 2. تأثيرات تنقل الصفحات (Fade In) */
.page-section { display: none; }
.page-section.active { 
    display: block; 
    animation: fadeIn 0.4s ease-out; 
}
@keyframes fadeIn { 
    from { opacity: 0; transform: translateY(10px); } 
    to { opacity: 1; transform: translateY(0); } 
}

/* 3. تنسيقات حقول الإدخال الاحترافية */
input, select, textarea { 
    background-color: var(--c-field) !important; 
    border: none !important; 
    border-bottom: 2px solid var(--c-border) !important; 
    border-radius: 6px 6px 0 0 !important; 
    color: var(--c-text) !important; 
    transition: all 0.3s ease; 
    width: 100%; 
}
input:focus, select:focus, textarea:focus { 
    border-bottom-color: var(--c-primary) !important; 
    outline: none; 
    box-shadow: 0 1px 0 0 var(--c-primary) !important;
}

/* === إخفاء الأسهم والتنسيق الشرطي الدائم === */

/* 1. إخفاء سهم القوائم المنسدلة (الحضور/النتيجة) وتوسيط النص */
select {
    appearance: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    background-image: none !important;
    padding-left: 0.5rem !important; 
    padding-right: 0.5rem !important;
    text-align: center !important; 
    text-align-last: center !important;
    cursor: pointer;
}

/* 2. إخفاء أسهم الزيادة والنقصان في حقول الأرقام (الصفحات) */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none !important;
    margin: 0 !important;
}
input[type="number"] {
    -moz-appearance: textfield !important; /* لمتصفح فايرفوكس */
}

/* 3. فئات التلوين الشرطي (لإجبار المتصفح على تغيير اللون وتجاوز الحماية) */
select.state-present, select.state-pass { 
    background-color: rgba(16, 185, 129, 0.2) !important; 
    color: #34d399 !important; 
    border-bottom: 2px solid #10b981 !important; 
}
select.state-late { 
    background-color: rgba(245, 158, 11, 0.2) !important; 
    color: #fbbf24 !important; 
    border-bottom: 2px solid #f59e0b !important; 
}
select.state-absent, select.state-fail { 
    background-color: rgba(239, 68, 68, 0.2) !important; 
    color: #f87171 !important; 
    border-bottom: 2px solid #ef4444 !important; 
}

/* إصلاح تداخل السهم مع النص في الاتجاه العربي */
select {
    background-position: left 0.5rem center !important;
    padding-left: 1.5rem !important;
    padding-right: 0.5rem !important;
}/* 3. تنسيقات حقول الإدخال الاحترافية */
input, select, textarea { 
    background-color: var(--c-field) !important; 
    border: none !important; 
    border-bottom: 2px solid var(--c-border) !important; 
    border-radius: 6px 6px 0 0 !important; 
    color: var(--c-text) !important; 
    transition: all 0.3s ease; 
    width: 100%; 
}

/* إصلاح تداخل السهم مع النص في الاتجاه العربي */
select {
    background-position: left 0.5rem center !important;
    padding-left: 1.5rem !important;
    padding-right: 0.5rem !important;
}
input:focus, select:focus, textarea:focus { 
    border-bottom-color: var(--c-primary) !important; 
    outline: none; 
    box-shadow: 0 1px 0 0 var(--c-primary) !important;
}
input[type="checkbox"] { 
    background-color: transparent !important; 
    border: 1px solid var(--c-border) !important; 
}
#export-center-page input[type="checkbox"],
#export-center-page input[type="radio"] {
    min-width: 1.25rem;
    min-height: 1.25rem;
}
#export-center-page .export-option-card:has(input:checked) {
    border-color: rgba(16, 185, 129, 0.65);
    background: rgba(16, 185, 129, 0.12);
}

/* 4. تنسيقات الأزرار والبطاقات (UI Components) */
select.exam-status-pass {
    background-color: rgba(16, 185, 129, 0.2) !important;
    color: #34d399 !important;
    border-bottom: 2px solid #10b981 !important;
}
select.exam-status-fail {
    background-color: rgba(239, 68, 68, 0.2) !important;
    color: #f87171 !important;
    border-bottom: 2px solid #ef4444 !important;
}
select.exam-status-absent {
    background-color: rgba(245, 158, 11, 0.2) !important;
    color: #fbbf24 !important;
    border-bottom: 2px solid #f59e0b !important;
}
select.exam-status-empty {
    background-color: rgba(148, 163, 184, 0.12) !important;
    color: #94a3b8 !important;
    border-bottom: 2px solid #475569 !important;
}

.nav-item.active { color: var(--c-primary); }
.nav-item.active .icon-container { 
    background-color: rgb(var(--c-primary-rgb) / 0.12); 
    border-radius: 50%; 
    padding: 8px; 
}
.stat-card { 
    background: linear-gradient(145deg, var(--c-container), var(--c-card)); 
    border: 1px solid rgba(255,255,255,0.05); 
}
.modal-overlay { 
    backdrop-filter: blur(8px); 
}

/* 5. أزرار لوحة السرد والاختبار (المتفاعلة) */
.part-btn { 
    font-size: 10px; 
    border-radius: 4px; 
    background: var(--c-field); 
    border: 1px solid var(--c-border); 
    cursor: pointer; 
    transition: all 0.2s; 
    display: flex; 
    justify-content: center; 
    align-items: center; 
    aspect-ratio: 1; 
}
.part-btn:hover { background: var(--c-border); }
.part-btn.active { 
    background: var(--c-primary); 
    color: var(--c-bg); 
    font-weight: bold; 
    border-color: var(--c-primary); 
    transform: scale(1.05); 
}
.part-btn.range { 
    background: rgb(var(--c-primary-rgb) / 0.28); 
    border-color: var(--c-primary); 
}
.hifz-page-btn { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; touch-action: manipulation; position: relative; }
/* نصف صفحة: نصف الزر ملون والنصف الآخر فارغ مع علامة ½ */
.part-btn.half {
    background: linear-gradient(to top, var(--c-primary) 50%, var(--c-field) 50%);
    color: var(--c-text, inherit);
    text-shadow: 0 0 3px var(--c-bg);
}
.part-btn.half::after {
    content: '½';
    position: absolute; top: -6px; left: -6px;
    font-size: 9px; line-height: 1; padding: 2px 3px;
    border-radius: 6px; background: #f59e0b; color: #111; font-weight: bold;
}


/* 6. شريط التمرير المخصص (Scrollbar) */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { 
    background: var(--c-border); 
    border-radius: 10px; 
}
::-webkit-scrollbar-thumb:hover { background: var(--c-primary); }
.custom-scrollbar::-webkit-scrollbar { height: 4px; }

/* 7. إعدادات الطباعة للتقارير (Print Media) */
/* بدون هوامش للصفحة حتى لا يطبع المتصفح الرابط والعنوان والتاريخ في الأعلى والأسفل */
@page { margin: 0; }
@media print { 
    #official-print-template { padding: 12mm !important; }
    /* إخفاء كل شيء في الموقع */
    body > *:not(#official-print-template) { display: none !important; }
    
    /* إظهار قالب الطباعة فقط وتنسيقه */
    #official-print-template { 
        display: block !important; 
        width: 100% !important; 
        position: absolute; 
        top: 0; 
        left: 0; 
    }
    
    body { background: white !important; color: black !important; }
    table { width: 100% !important; border-collapse: collapse !important; }
    th, td { border: 1px solid black !important; padding: 4px !important; }
}/* 8. تنسيقات إشعارات النظام الذكية (Toasts) */
.toast { animation: slideInLeft 0.3s ease-out forwards; }
.toast.hide { animation: fadeOut 0.3s ease-out forwards; }

@keyframes slideInLeft { 
    from { transform: translateX(-100%); opacity: 0; } 
    to { transform: translateX(0); opacity: 1; } 
}
@keyframes fadeOut { 
    to { opacity: 0; visibility: hidden; } 
}

/* ==========================================
   واجهة التفقد: أزرار الحضور السريعة + بطاقات الموبايل
========================================== */
.att-seg { display: inline-flex; gap: 4px; justify-content: center; }
.att-seg-btn {
    width: 46px; height: 44px;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
    border-radius: 12px; background: var(--c-field); border: 1px solid rgba(255,255,255,0.07);
    color: #64748b; transition: background-color .15s, color .15s, transform .1s;
    -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.att-seg-btn:active { transform: scale(0.94); }
.att-seg-btn .material-symbols-outlined { font-size: 20px; line-height: 1; }
.att-seg-label { font-size: 9px; font-weight: 800; line-height: 1.1; }
.att-seg-btn.is-present:hover { color: #34d399; }
.att-seg-btn.is-late:hover { color: #fbbf24; }
.att-seg-btn.is-absent:hover { color: #f87171; }
.att-seg-btn.is-present.is-selected { background: #10b981; border-color: #10b981; color: #022c1e; }
.att-seg-btn.is-late.is-selected { background: #f59e0b; border-color: #f59e0b; color: #2b1700; }
.att-seg-btn.is-absent.is-selected { background: #ef4444; border-color: #ef4444; color: #fff; }
.att-seg-btn.is-selected .material-symbols-outlined { font-variation-settings: 'wght' 700; }
/* صلى المغرب جماعة: إشارة ذهبية صغيرة فوق زر حاضر */
.att-seg-btn.is-present { position: relative; overflow: visible; }
.att-maghrib-badge { display: none; position: absolute; top: -7px; left: -6px; width: 18px; height: 18px; border-radius: 999px;
    align-items: center; justify-content: center; background: linear-gradient(135deg, #fde68a, #f59e0b 60%, #b45309);
    border: 1.5px solid var(--c-container, #181b1e); box-shadow: 0 0 8px rgba(251,191,36,0.65); z-index: 2; pointer-events: none; }
.att-maghrib-badge .material-symbols-outlined { font-size: 12px !important; color: #422006; font-variation-settings: 'FILL' 1, 'wght' 700; }
.att-seg.has-maghrib .att-seg-btn.is-present .att-maghrib-badge { display: flex; animation: maghribPop .25s ease-out; }
.att-seg.has-maghrib .att-seg-btn.is-present.is-selected { box-shadow: 0 0 0 2px #fbbf24; }
.att-seg[data-mode="fast"] .att-seg-btn.is-present { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
@keyframes maghribPop { from { transform: scale(0.3); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* شريط تقدم التفقد */
#att-quickbar { position: sticky; top: 8px; z-index: 30; backdrop-filter: blur(8px); background-color: rgb(var(--c-container-rgb) / 0.94); }
.att-qb-chip { display: inline-flex; align-items: center; gap: 2px; padding: 2px 7px; border-radius: 999px; font-family: monospace; }
.att-qb-chip .material-symbols-outlined { font-size: 13px; }
.att-qb-chip.is-present { background: rgba(16,185,129,.15); color: #34d399; }
.att-qb-chip.is-late { background: rgba(245,158,11,.15); color: #fbbf24; }
.att-qb-chip.is-absent { background: rgba(239,68,68,.15); color: #f87171; }
.att-qb-track { height: 6px; border-radius: 999px; background: var(--c-bg); overflow: hidden; }
.att-qb-fill { height: 100%; width: 0; border-radius: 999px; background: linear-gradient(90deg, #10b981, #34d399); transition: width .3s ease; }
.att-qb-bulk, .att-qb-complete-msg {
    height: 34px; border-radius: 10px; font-size: 11px; font-weight: 800; white-space: nowrap;
    display: inline-flex; align-items: center; justify-content: center; gap: 4px; padding: 0 12px;
}
.att-qb-bulk { background: rgba(16,185,129,.15); color: #34d399; border: 1px solid rgba(16,185,129,.4); }
.att-qb-bulk:active { background: rgba(16,185,129,.3); }
.att-qb-bulk .material-symbols-outlined, .att-qb-complete-msg .material-symbols-outlined { font-size: 18px; }
.att-qb-complete-msg { color: #34d399; }
#att-quickbar:not(.is-complete) .att-qb-complete-msg { display: none; }
/* بعد اكتمال التفقد: سطر واحد رفيع */
#att-quickbar.is-complete { padding-top: 6px; padding-bottom: 6px; }
#att-quickbar.is-complete .att-qb-row2,
#att-quickbar.is-complete .att-qb-progress-text { display: none; }
#att-quickbar.is-complete .att-qb-complete-msg { height: auto; padding: 0; font-size: 12px; }

/* لون حالة الطالب على الشاشات الكبيرة: خط جانبي */
tr.att-row td:first-child { box-shadow: inset -3px 0 0 transparent; }
tr.att-row[data-att="حاضر"] td:first-child { box-shadow: inset -3px 0 0 #10b981; }
tr.att-row[data-att="متأخر"] td:first-child { box-shadow: inset -3px 0 0 #f59e0b; }
tr.att-row[data-att="غائب"] td:first-child { box-shadow: inset -3px 0 0 #ef4444; }

/* لمسة إضاءة خفيفة على البطاقات في كل المنصة */
.bg-surface-container { box-shadow: inset 0 1px 0 rgba(255,255,255,0.04); }

/* رأس صفحة التفقد: سطرين مضغوطين */
.att-tab {
    height: 38px; padding: 0 4px; border-radius: 9px; font-weight: 800; font-size: 11px;
    display: flex; align-items: center; justify-content: center; gap: 4px;
    transition: background-color .15s, color .15s; white-space: nowrap; -webkit-tap-highlight-color: transparent;
}
.att-tab .material-symbols-outlined { font-size: 16px; }
@media (min-width: 768px) { .att-tab { padding: 0 14px; font-size: 12px; } }
.att-day-btn {
    width: 26px; height: 40px; flex-shrink: 0; border-radius: 8px; display: flex; align-items: center; justify-content: center;
    color: #94a3b8; -webkit-tap-highlight-color: transparent;
}
.att-day-btn .material-symbols-outlined { font-size: 20px; }
.att-day-btn:hover { color: var(--c-primary); background: rgb(var(--c-primary-rgb) / 0.1); }
.att-day-btn:active { transform: scale(0.92); }
#date-day-badge { font-size: 8px; padding: 1px 5px; border-radius: 999px; line-height: 1.4; }
#attendance-page input.att-date-input {
    width: 100%; min-width: 0; height: 18px; padding: 0 !important; font-size: 11px; line-height: 18px;
    background: transparent !important; border: 0 !important; box-shadow: none !important; border-radius: 0 !important;
    color: #cbd5e1 !important; color-scheme: dark; text-align: center;
}
#attendance-page input.att-date-input::-webkit-calendar-picker-indicator { display: none; }
#attendance-page select.att-ring-select {
    flex: 1; min-width: 0; height: 40px; padding: 0 !important; font-size: 12px; font-weight: 700;
    background: transparent !important; border: 0 !important; box-shadow: none !important; border-radius: 0 !important;
    text-align: right !important; text-align-last: right !important; text-overflow: ellipsis;
}
#attendance-page select.att-ring-select.hidden { display: none; }
.att-ring-picker:focus-within, .att-date:focus-within { border-color: rgb(var(--c-primary-rgb) / 0.5); }
#attendance-page .att-filters > select {
    height: 34px; padding: 0 10px !important; font-size: 11px; font-weight: 700;
    background-color: rgb(var(--c-primary-rgb) / 0.08) !important; border: 1px solid rgb(var(--c-primary-rgb) / 0.3) !important;
    border-radius: 10px !important; color: var(--c-primary) !important; text-align: right !important; text-align-last: right !important;
}

/* زر السرد: ظاهر كزر حتى لو ما في سرد */
.att-sard-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 3px; width: 100%; min-height: 32px;
    padding: 4px 6px; border-radius: 8px; font-size: 10px; font-weight: 700; line-height: 1.2;
    background: rgb(var(--c-primary-rgb) / 0.1); border: 1px solid rgb(var(--c-primary-rgb) / 0.35); color: var(--c-primary);
}
.att-sard-btn .material-symbols-outlined { font-size: 15px; }
.att-sard-btn.is-empty { border-style: dashed; background: transparent; white-space: nowrap; }
.att-sard-cell:hover .att-sard-btn { background: rgb(var(--c-primary-rgb) / 0.2); }

/* "التنبيهات:" قبل صندوق التنبيه */
.att-alert-wrap { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.att-alert-title { font-size: 10px; font-weight: 800; color: #fbbf24; }

/* الموبايل: كل طالب بطاقة - السطر الأول الاسم وأزرار الحضور، والثاني كل خانات الحفظ ظاهرة */
@media (max-width: 767px) {
    #attendance-page table.att-cards { min-width: 0 !important; display: block; }
    #attendance-page table.att-cards thead { display: none; }
    #attendance-page table.att-cards tbody { display: flex; flex-direction: column; gap: 8px; padding: 6px; }
    #attendance-page table.att-cards tr:not(.att-row) { display: block; }
    #attendance-page table.att-cards tr:not(.att-row) td { display: block; }

    /* شبكة 30 عمود لتوزيع الخانات بمرونة */
    tr.att-row {
        display: grid; grid-template-columns: repeat(30, minmax(0, 1fr)); gap: 6px 4px; align-items: center;
        background: var(--c-card); border: 1px solid rgba(255,255,255,0.06); border-inline-start: 4px solid var(--c-border);
        border-radius: 14px; padding: 8px;
    }
    tr.att-row:hover { background: var(--c-card); }
    tr.att-row[data-att="حاضر"] { border-inline-start-color: #10b981; }
    tr.att-row[data-att="متأخر"] { border-inline-start-color: #f59e0b; }
    tr.att-row[data-att="غائب"] { border-inline-start-color: #ef4444; background: rgba(239,68,68,0.06); }
    tr.att-row td { display: block; padding: 0 !important; border: 0; min-width: 0; order: 4; }
    tr.att-row td:first-child { box-shadow: none !important; }

    tr.att-row td[data-cell="name"] { order: 1; grid-column: span 14; font-size: 13px; line-height: 1.35; }
    tr.att-row td[data-cell="status"] { order: 2; grid-column: span 16; }
    tr.att-row td[data-cell="status"] .att-seg { width: 100%; justify-content: flex-end; }
    tr.att-row td[data-cell="alert"] { order: 3; grid-column: 1 / -1; text-align: right; }
    tr.att-row td[data-cell="alert"].att-empty-alert { display: none; }
    tr.att-row td[data-cell="alert"] .att-alert-wrap > div { display: block; font-size: 11px; padding: 4px 8px; text-align: right; }

    /* خانات التفاصيل: عنوان صغير فوق كل خانة */
    tr.att-row td[data-cell="detail"] { grid-column: span 6; text-align: center; align-self: start; }
    tr.att-row td[data-cell="wide"] { grid-column: 1 / -1; }
    tr.att-row td[data-cell="detail"]::before,
    tr.att-row td[data-cell="wide"]::before {
        content: attr(data-label); display: block; font-size: 9px; color: #94a3b8; font-weight: 700;
        margin-bottom: 2px; line-height: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: center;
    }
    tr.att-row td[data-cell="wide"]::before { text-align: right; }
    tr.att-row td[data-cell="detail"] input,
    tr.att-row td[data-cell="detail"] select,
    tr.att-row td[data-cell="detail"] > button,
    tr.att-row td[data-cell="wide"] input { max-width: none !important; width: 100%; height: 38px; padding: 0 2px !important; font-size: 13px !important; }
    tr.att-row td[data-cell="detail"] > button { font-size: 10px !important; border-radius: 6px; }
    tr.att-row td.att-sard-cell .att-sard-btn { height: 38px; font-size: 10px; }
    tr.att-row td[data-cell="alert"] .att-alert-wrap { flex-direction: row; align-items: center; gap: 6px; }
    tr.att-row td[data-cell="alert"] .att-alert-wrap > div { flex: 1; }
    tr.att-row td[data-cell="alert"] .att-alert-title { font-size: 11px; white-space: nowrap; }
    /* خانة الحفظ: زر شبكة الصفحات بعرض أكبر */
    tr.att-row td.att-hifz-cell { grid-column: span 9; }
    tr.att-row td.att-hifz-cell .att-range-btn { height: 38px; padding: 0 4px !important; font-size: 11px !important; margin: 0; }
    /* توزيع جدول الحفظ: الحفظ | سرد | اختبار | النتيجة */
    #attendance-hifz-grid tr.att-row td[data-cell="detail"]:not(.att-hifz-cell) { grid-column: span 7; }
}


/* ==========================================
   صفحة ذكاء الأعمال
========================================== */
.bi-icon {
    width: 40px; height: 40px; flex-shrink: 0; border-radius: 12px; display: flex; align-items: center; justify-content: center;
    background: rgb(var(--c-primary-rgb) / 0.12); border: 1px solid rgb(var(--c-primary-rgb) / 0.3); color: var(--c-primary);
}
.bi-field {
    display: flex; align-items: center; gap: 6px; min-width: 0; height: 44px; padding: 0 10px;
    background: var(--c-surface); border: 1px solid rgba(255,255,255,0.06); border-radius: 12px; cursor: pointer;
}
.bi-field > .material-symbols-outlined { font-size: 18px; color: var(--c-primary); }
.bi-field:focus-within { border-color: rgb(var(--c-primary-rgb) / 0.5); }
#reports-page .bi-field select, #reports-page .bi-field input {
    flex: 1; min-width: 0; height: 42px; padding: 0 !important; font-size: 12px; font-weight: 700;
    background: transparent !important; border: 0 !important; box-shadow: none !important; border-radius: 0 !important;
    text-align: right !important; text-align-last: right !important; color-scheme: dark;
}
#reports-page select.bi-plain-select {
    height: 44px; padding: 0 12px !important; font-size: 12px; font-weight: 700; border-radius: 12px !important;
    background: var(--c-surface) !important; border: 1px solid rgba(255,255,255,0.06) !important;
    text-align: right !important; text-align-last: right !important;
}
@media (min-width: 768px) { .bi-field { min-width: 170px; } }
.bi-refresh {
    height: 44px; padding: 0 16px; border-radius: 12px; font-size: 12px; font-weight: 800;
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    background: var(--c-primary); color: var(--c-bg);
}
.bi-refresh:active { transform: scale(0.97); }

.bi-kpi { background: rgb(var(--c-container-rgb)); border: 1px solid rgba(255,255,255,0.05); border-radius: 16px; padding: 12px; }
.bi-kpi-head { display: flex; align-items: center; gap: 4px; font-size: 10px; font-weight: 700; color: #9ca3af; }
.bi-kpi-head .material-symbols-outlined { font-size: 15px; }
.bi-kpi-value { margin-top: 6px; font-size: 26px; line-height: 1; font-weight: 900; font-family: ui-monospace, monospace; }
@media (min-width: 768px) { .bi-kpi { padding: 16px; } .bi-kpi-value { font-size: 32px; } }

/* بطاقات "بطل الحفظ" و"الانضباط" أصغر */
#smart-alerts-container > .grid { gap: 8px; margin-bottom: 0; }
#smart-alerts-container > .grid > div { padding: 10px; gap: 10px; border-radius: 14px; }
#smart-alerts-container > .grid > div > div:first-child { padding: 6px; }
#smart-alerts-container > .grid .text-3xl { font-size: 22px; }
@media (max-width: 767px) { #smart-alerts-container > .grid { grid-template-columns: 1fr 1fr; } #smart-alerts-container > .grid p.font-bold { font-size: 11px; } }

.bi-exports-summary {
    list-style: none; cursor: pointer; min-height: 48px; padding: 0 14px; display: flex; align-items: center; justify-content: space-between; gap: 8px;
    font-size: 13px; font-weight: 800; color: #fff;
}
.bi-exports-summary::-webkit-details-marker { display: none; }
.bi-exports-summary .bi-chevron { color: #9ca3af; transition: transform .2s; }
.bi-exports[open] .bi-chevron { transform: rotate(180deg); }
.bi-exports-summary > span:nth-child(2) { margin-inline-start: auto; }
.bi-export-group { background: var(--c-surface); border: 1px solid rgba(255,255,255,0.05); border-radius: 14px; padding: 12px; }
.bi-export-group h3 { display: flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 800; color: #d1d5db; margin-bottom: 8px; }
.bi-action {
    min-height: 40px; padding: 6px 8px; border-radius: 10px; font-size: 11px; font-weight: 700; color: #e5e7eb;
    display: inline-flex; align-items: center; justify-content: center; gap: 4px; text-align: center;
    background: rgb(var(--c-container-rgb)); border: 1px solid rgba(255,255,255,0.08);
}
.bi-action .material-symbols-outlined { font-size: 16px; }
.bi-action:hover { background: rgba(255,255,255,0.05); }
.bi-action.is-excel { color: #6ee7b7; background: rgba(16,185,129,0.1); border-color: rgba(16,185,129,0.3); }
.bi-action.is-primary { color: var(--c-bg); background: var(--c-primary); border-color: var(--c-primary); }

/* جداول تتحول لبطاقات على الموبايل (العناوين تأتي من CSS حسب ترتيب الخانة) */
@media (max-width: 767px) {
    table.mcards { min-width: 0 !important; display: block; }
    table.mcards thead { display: none; }
    table.mcards tbody { display: flex; flex-direction: column; gap: 8px; }
    table.mcards tbody tr {
        display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; align-items: center;
        background: var(--c-card); border: 1px solid rgba(255,255,255,0.06); border-radius: 14px; padding: 10px;
    }
    table.mcards tbody td { display: block; padding: 0 !important; border: 0; min-width: 0; text-align: right; }

    /* متابعة تفقد الحلقات */
    .bi-insp-table td:nth-child(1) { grid-column: span 4; font-size: 13px; }
    .bi-insp-table td:nth-child(6) { grid-column: span 2; text-align: left; }
    .bi-insp-table td:nth-child(2) { grid-column: span 6; order: 1; font-size: 11px; color: #9ca3af; }
    .bi-insp-table td:nth-child(2)::before { content: 'الأستاذ: '; }
    .bi-insp-table td:nth-child(3), .bi-insp-table td:nth-child(4), .bi-insp-table td:nth-child(5) { grid-column: span 2; order: 2; text-align: center; background: var(--c-surface); border-radius: 10px; padding: 6px 2px !important; font-size: 11px; font-family: 'Tajawal', sans-serif; font-weight: 800; }
    .bi-insp-table td:nth-child(3)::before, .bi-insp-table td:nth-child(4)::before, .bi-insp-table td:nth-child(5)::before { display: block; font-size: 9px; color: #9ca3af; font-weight: 700; margin-bottom: 2px; font-family: 'Tajawal', sans-serif; }
    .bi-insp-table td:nth-child(3)::before { content: 'المتوقع'; }
    .bi-insp-table td:nth-child(4)::before { content: 'المدخل'; }
    .bi-insp-table td:nth-child(5)::before { content: 'الناقص'; }
    .bi-insp-table td:nth-child(7) { grid-column: span 6; order: 3; }
    .bi-insp-table td:nth-child(7) > div { justify-content: stretch; }
    .bi-insp-table td:nth-child(7) button { flex: 1; min-height: 36px; font-size: 11px; }

    /* تقارير الحلقات */
    .bi-rings-table td:nth-child(1) { grid-column: span 4; font-size: 13px; }
    .bi-rings-table td:nth-child(3) { grid-column: span 2; text-align: left; }
    .bi-rings-table td:nth-child(3) button { min-height: 34px; padding: 0 14px; }
    .bi-rings-table td:nth-child(2) { grid-column: span 6; order: 1; text-align: right !important; font-size: 11px; }

    /* الطلاب */
    .bi-students-scroll { max-height: 65vh; }
    .bi-students-table td:nth-child(1) { grid-column: span 4; font-size: 13px; }
    .bi-students-table td:nth-child(2) { grid-column: span 2; text-align: left; font-weight: 800; }
    .bi-students-table td:nth-child(3) { grid-column: span 4; font-size: 11px; }
    .bi-students-table td:nth-child(4) { grid-column: span 2; text-align: left; }
    .bi-students-table td:nth-child(4) button { min-height: 32px; width: 100%; background: rgba(16,185,129,0.12); color: #6ee7b7; border: 1px solid rgba(16,185,129,0.35); font-weight: 700; }
}

/* قائمة "تصفية حسب الحلقة" المشتركة */
select.ring-filter-select { min-height: 40px; font-size: 12px !important; font-weight: 700; color: var(--c-primary) !important; }

/* ==========================================
   الشريط السفلي: 3 صفحات رئيسية + "المزيد" على الموبايل، وسطر واحد على الشاشات الكبيرة
========================================== */
.nav-main-row { display: flex; justify-content: space-around; align-items: center; }
.nav-main-row > .nav-item, .nav-more-grid > .nav-item { min-width: 64px; }
.nav-more-backdrop { position: fixed; inset: 0; z-index: 89; background: rgba(0,0,0,0.5); backdrop-filter: blur(2px); }
.nav-more-sheet {
    position: absolute; left: 8px; right: 8px; bottom: calc(100% + 8px); padding: 12px;
    background: rgb(var(--c-container-rgb)); border: 1px solid rgba(255,255,255,0.08); border-radius: 20px;
    box-shadow: 0 -10px 40px rgba(0,0,0,0.5);
    opacity: 0; transform: translateY(12px); pointer-events: none; transition: opacity .18s, transform .18s;
}
.nav-more-sheet.open { opacity: 1; transform: none; pointer-events: auto; }
.nav-more-title { font-size: 11px; font-weight: 800; color: #9ca3af; margin: 0 4px 8px; }
.nav-more-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.nav-more-grid > button { padding: 10px 4px; border-radius: 14px; background: var(--c-surface); border: 1px solid rgba(255,255,255,0.05); }
.nav-more-grid > button.hidden { display: none; }
.nav-more-grid .icon-container .material-symbols-outlined { font-size: 22px; }
@media (min-width: 768px) {
    #bottom-nav { display: flex; justify-content: center; align-items: center; gap: 0; }
    .nav-more-sheet, .nav-more-grid { display: contents; opacity: 1; transform: none; pointer-events: auto; }
    .nav-more-grid > button { padding: 0; background: none; border: 0; border-radius: 0; }
    .nav-main-row { display: contents; }
    #bottom-nav .nav-item, #bottom-nav .nav-logout { margin: 0 18px; }
    #bottom-nav .nav-main-row > .nav-item { order: -1; }
    #bottom-nav .nav-logout { order: 10; }
}

/* أزرار الفحص التقنية مخفية عن المستخدمين؛ تظهر بإضافة ?dev=1 للرابط */
html:not(.dev-mode) .dev-only { display: none !important; }

/* مخطط التقدّم عبر الأيام */
.progress-quick { height: 36px; padding: 0 10px; border-radius: 10px; font-size: 11px; font-weight: 700; color: #d1d5db; background: var(--c-surface); border: 1px solid rgba(255,255,255,0.06); white-space: nowrap; }
.progress-quick:hover { color: var(--c-primary); }
.progress-chip { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 999px; background: var(--c-surface); border: 1px solid rgba(255,255,255,0.06); color: #d1d5db; }
.progress-key { display: inline-block; width: 14px; height: 3px; border-radius: 2px; margin-inline-start: 4px; }
.progress-main-wrap { position: relative; width: 100%; height: 340px; }
@media (min-width: 768px) { .progress-main-wrap { height: 440px; } }
.progress-multiples { display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 640px) { .progress-multiples { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1100px) { .progress-multiples { grid-template-columns: repeat(3, 1fr); } }
.progress-mini { background: var(--c-surface); border: 1px solid rgba(255,255,255,0.06); border-radius: 14px; padding: 10px; min-width: 0; }
.progress-mini-head { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; font-size: 13px; color: #fff; margin-bottom: 6px; }
.progress-mini-stats { display: flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.progress-mini-stat { display: inline-flex; align-items: center; gap: 3px; padding: 2px 8px; border-radius: 999px; background: rgb(var(--c-container-rgb)); }
.progress-mini-chart { position: relative; height: 210px; }
.progress-send-btn { width: 100%; margin-top: 8px; min-height: 38px; border-radius: 10px; font-size: 12px; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; gap: 6px; color: #6ee7b7; background: rgba(16,185,129,0.1); border: 1px solid rgba(16,185,129,0.3); }
.progress-send-btn .material-symbols-outlined { font-size: 17px; }
.progress-send-btn:active { transform: scale(0.98); }
.progress-trend { display: inline-flex; align-items: center; gap: 1px; font-size: 11px; font-weight: 800; direction: ltr; }
.progress-trend .material-symbols-outlined { font-size: 14px; }
.progress-trend.is-up { color: #34d399; }
.progress-trend.is-down { color: #f87171; }
.progress-trend.is-steady { color: #9ca3af; }
/* ملء الشاشة */
#progress-section.is-fullscreen { position: fixed; inset: 0; z-index: 300; margin: 0; border-radius: 0; overflow-y: auto; background: rgb(var(--c-container-rgb)); }
#progress-section.is-fullscreen .progress-main-wrap { height: calc(100dvh - 260px); min-height: 320px; }
#progress-section.is-fullscreen .progress-mini-chart { height: 210px; }
@media (min-width: 1400px) { #progress-section.is-fullscreen .progress-multiples { grid-template-columns: repeat(4, 1fr); } }

/* ==========================================
   يوم النشاط
========================================== */
.fd-toolbar { position: sticky; top: 0; z-index: 20; display: flex; gap: 8px; padding: 8px 0; background: var(--c-bg); }
.fd-search { flex: 1; display: flex; align-items: center; gap: 6px; background: var(--c-card); border: 1px solid rgb(255 255 255 / .06); border-radius: 14px; padding: 0 12px; }
.fd-search .material-symbols-outlined { color: var(--c-primary); font-size: 20px; }
.fd-search input { background: transparent !important; border: 0 !important; box-shadow: none !important; height: 46px; font-size: 15px; font-weight: 700; padding: 0 !important; }
.fd-screen-btn { display: flex; align-items: center; gap: 4px; padding: 0 14px; border-radius: 14px; font-weight: 800; font-size: 12px; color: #1a1300; background: linear-gradient(135deg, #fde68a, #f59e0b); box-shadow: 0 6px 20px rgb(245 158 11 / .25); white-space: nowrap; }
.fd-screen-btn .material-symbols-outlined { font-size: 20px; }
@media (max-width: 480px) { .fd-screen-btn span:last-child { display: none; } .fd-screen-btn { padding: 0 12px; } }
.fd-summary { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; font-size: 11px; color: #9ca3af; padding: 2px 4px 10px; }
.fd-summary b { color: #fff; font-size: 13px; }
.fd-sum-leader { display: inline-flex; align-items: center; gap: 3px; color: #fbbf24; font-weight: 800; }
.fd-sum-leader .material-symbols-outlined { font-size: 16px; }
.fd-live { display: inline-flex; align-items: center; gap: 5px; color: #34d399; font-weight: 800; }
.fd-live i { width: 8px; height: 8px; border-radius: 50%; background: #34d399; box-shadow: 0 0 0 0 rgb(52 211 153 / .7); animation: fdPulse 1.6s infinite; }
.fd-live.is-off { color: #f87171; } .fd-live.is-off i { background: #f87171; animation: none; }
@keyframes fdPulse { 0% { box-shadow: 0 0 0 0 rgb(52 211 153 / .7); } 70% { box-shadow: 0 0 0 8px rgb(52 211 153 / 0); } 100% { box-shadow: 0 0 0 0 rgb(52 211 153 / 0); } }

.fd-list { display: grid; gap: 8px; grid-template-columns: 1fr; padding-bottom: 90px; }
@media (min-width: 900px) { .fd-list { grid-template-columns: 1fr 1fr; } }
.fd-card { position: relative; background: var(--c-container); border: 1px solid rgb(255 255 255 / .05); border-radius: 18px; padding: 10px 12px 12px; will-change: transform; }
.fd-card.has-points { border-color: rgb(52 211 153 / .18); background: linear-gradient(135deg, rgb(52 211 153 / .07), transparent 60%), var(--c-container); }
.fd-card-head { display: flex; align-items: center; gap: 10px; }
.fd-rank { flex-shrink: 0; width: 34px; height: 34px; border-radius: 11px; display: flex; align-items: center; justify-content: center; font-weight: 900; font-size: 15px; background: var(--c-card); color: #d1d5db; font-family: ui-monospace, monospace; }
.fd-rank.is-zero { color: #4b5563; }
.fd-rank.is-gold { background: linear-gradient(135deg, #fde68a, #f59e0b); color: #3b2500; box-shadow: 0 4px 14px rgb(245 158 11 / .35); }
.fd-rank.is-silver { background: linear-gradient(135deg, #f3f4f6, #9ca3af); color: #1f2937; }
.fd-rank.is-bronze { background: linear-gradient(135deg, #fdba74, #c2410c); color: #2a0f00; }
.fd-name-wrap { flex: 1; min-width: 0; }
.fd-name { font-weight: 800; font-size: 15px; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fd-ring { font-size: 10px; color: #6b7280; margin-top: 1px; }
.fd-points { display: flex; flex-direction: column; align-items: center; line-height: 1; min-width: 44px; }
.fd-points-num { font-size: 24px; font-weight: 900; color: var(--c-primary); font-family: ui-monospace, monospace; }
.fd-points-lbl { font-size: 9px; color: #6b7280; margin-top: 2px; }
.fd-points.is-bump .fd-points-num { animation: fdBump .5s cubic-bezier(.3,1.6,.5,1); }
@keyframes fdBump { 0% { transform: scale(1); } 40% { transform: scale(1.6); color: #fde68a; } 100% { transform: scale(1); } }
.fd-plus { position: absolute; left: 22px; top: 6px; font-weight: 900; color: #fde68a; font-size: 18px; pointer-events: none; animation: fdPlus .9s ease-out forwards; }
@keyframes fdPlus { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(-28px); } }
.fd-games { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; margin-top: 10px; }
.fd-game { height: 44px; border-radius: 12px; font-weight: 900; font-size: 16px; color: #9ca3af; background: var(--c-card); border: 1px dashed rgb(255 255 255 / .1); display: flex; align-items: center; justify-content: center; -webkit-tap-highlight-color: transparent; transition: transform .1s, background-color .15s; }
.fd-game:active { transform: scale(.9); }
.fd-game.is-won { color: #052e1f; background: linear-gradient(135deg, #6ee7b7, #10b981); border: 1px solid #34d399; box-shadow: 0 4px 12px rgb(16 185 129 / .3); animation: fdWon .35s cubic-bezier(.3,1.6,.5,1); }
.fd-game.is-won .material-symbols-outlined { font-size: 22px; font-weight: 900; }
@keyframes fdWon { from { transform: scale(.7); } to { transform: scale(1); } }
.fd-empty { text-align: center; color: #6b7280; padding: 40px 10px; font-weight: 700; display: flex; flex-direction: column; align-items: center; gap: 6px; grid-column: 1 / -1; }
.fd-empty .material-symbols-outlined { font-size: 40px; }

/* ---- شاشة العرض ---- */
body.fd-screen-open { overflow: hidden; }
.fd-screen { position: fixed; inset: 0; z-index: 300; color: #fff; display: flex; flex-direction: column; padding: 1.4vh 2vw 1vh; overflow: hidden; font-family: 'Tajawal', sans-serif; background: #07090a; }
.fd-screen.hidden { display: none; }
.fd-scr-bg { position: absolute; inset: -20%; z-index: -1; background:
    radial-gradient(40% 40% at 20% 20%, rgb(16 185 129 / .22), transparent 70%),
    radial-gradient(35% 35% at 85% 15%, rgb(245 158 11 / .18), transparent 70%),
    radial-gradient(40% 40% at 60% 90%, rgb(168 85 247 / .16), transparent 70%);
    animation: fdBg 18s ease-in-out infinite alternate; }
@keyframes fdBg { from { transform: translate(0,0) rotate(0); } to { transform: translate(4%, -3%) rotate(8deg); } }
.fd-scr-head { display: flex; align-items: center; gap: 2vw; }
.fd-scr-title { display: flex; align-items: center; gap: .6vw; font-size: clamp(22px, 3.4vw, 56px); font-weight: 900; background: linear-gradient(90deg, #fde68a, #f59e0b, #34d399); -webkit-background-clip: text; background-clip: text; color: transparent; }
.fd-scr-title .material-symbols-outlined { color: #f97316; font-size: 1.1em; animation: fdFlame 1.2s ease-in-out infinite alternate; -webkit-text-fill-color: #f97316; }
@keyframes fdFlame { from { transform: scale(1) rotate(-6deg); } to { transform: scale(1.15) rotate(6deg); } }
.fd-scr-stats { flex: 1; display: flex; gap: 2vw; justify-content: flex-end; font-size: clamp(12px, 1.3vw, 22px); color: #9ca3af; }
.fd-scr-stats b { color: #fff; }
.fd-scr-close { width: 40px; height: 40px; border-radius: 50%; background: rgb(255 255 255 / .06); display: flex; align-items: center; justify-content: center; color: #9ca3af; opacity: .4; }
.fd-scr-close:hover { opacity: 1; }

.fd-podium { display: grid; grid-template-columns: 1fr 1.15fr 1fr; align-items: end; gap: 1.6vw; max-width: 1100px; width: 100%; margin: 1vh auto 1.4vh; }
.fd-pod { display: flex; flex-direction: column; align-items: center; min-width: 0; }
.fd-pod.is-pop { animation: fdPop .7s cubic-bezier(.3,1.5,.5,1); }
@keyframes fdPop { 0% { transform: scale(.8) translateY(20px); opacity: .3; } 100% { transform: none; opacity: 1; } }
.fd-pod-name { font-weight: 900; font-size: clamp(14px, 2vw, 34px); text-align: center; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 .4vw; }
.fd-pod-1 .fd-pod-name { font-size: clamp(16px, 2.5vw, 42px); color: #fde68a; text-shadow: 0 0 24px rgb(245 158 11 / .6); }
.fd-pod-pts { font-size: clamp(11px, 1.3vw, 22px); color: #d1d5db; margin: .3vh 0 .8vh; }
.fd-pod-pts b { font-size: 1.5em; color: #fff; }
.fd-pod-block { width: 100%; border-radius: 1.2vw 1.2vw .4vw .4vw; display: flex; align-items: flex-start; justify-content: center; padding-top: 1vh; font-weight: 900; font-size: clamp(22px, 3.6vw, 64px); }
.fd-pod-1 .fd-pod-block { height: 17vh; background: linear-gradient(180deg, #fbbf24, #b45309); color: #3b2500; box-shadow: 0 0 60px rgb(245 158 11 / .45); }
.fd-pod-2 .fd-pod-block { height: 12vh; background: linear-gradient(180deg, #e5e7eb, #6b7280); color: #1f2937; }
.fd-pod-3 .fd-pod-block { height: 9vh; background: linear-gradient(180deg, #fb923c, #9a3412); color: #2a0f00; }
.fd-pod.is-empty .fd-pod-block { opacity: .18; }
.fd-crown { color: #fbbf24; font-size: clamp(28px, 4vw, 70px) !important; filter: drop-shadow(0 0 14px rgb(245 158 11 / .7)); animation: fdCrown 2s ease-in-out infinite; }
@keyframes fdCrown { 0%,100% { transform: translateY(0) rotate(-4deg); } 50% { transform: translateY(-8px) rotate(4deg); } }

.fd-board-wrap { flex: 1; min-height: 0; overflow: hidden; border-radius: 1vw; mask-image: linear-gradient(180deg, transparent 0, #000 2%, #000 96%, transparent 100%); }
.fd-board { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: .6vh .8vw; padding: .5vh 0 2vh; }
.fd-b-row { display: flex; align-items: center; gap: .7vw; padding: .7vh .9vw; border-radius: .8vw; background: rgb(255 255 255 / .05); border: 1px solid rgb(255 255 255 / .06); font-size: clamp(12px, 1.25vw, 22px); will-change: transform; }
.fd-b-row.is-zero { opacity: .45; }
.fd-b-rank { width: 2.2em; text-align: center; font-weight: 900; color: #9ca3af; font-family: ui-monospace, monospace; }
.fd-b-name { flex: 1; min-width: 0; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fd-b-dots { display: flex; gap: 3px; }
.fd-b-dots i { width: .5em; height: .5em; border-radius: 50%; background: rgb(255 255 255 / .12); }
.fd-b-dots i.on { background: #34d399; box-shadow: 0 0 6px #34d399; }
.fd-b-pts { min-width: 1.8em; text-align: center; font-weight: 900; font-size: 1.3em; color: #34d399; font-family: ui-monospace, monospace; }
.fd-move { display: inline-flex; align-items: center; font-weight: 900; font-size: .8em; border-radius: 99px; padding: 0 .4em; animation: fdFade 4s forwards; }
.fd-move .material-symbols-outlined { font-size: 1.1em; }
.fd-move.is-up { color: #34d399; background: rgb(52 211 153 / .15); }
.fd-move.is-down { color: #f87171; background: rgb(248 113 113 / .15); }
@keyframes fdFade { 0%, 75% { opacity: 1; } 100% { opacity: 0; } }
.fd-b-row.flash-up { animation: fdFlashUp 1.8s ease-out; }
.fd-b-row.flash-down { animation: fdFlashDown 1.8s ease-out; }
@keyframes fdFlashUp { 0% { background: rgb(52 211 153 / .55); box-shadow: 0 0 30px rgb(52 211 153 / .6); transform: scale(1.05); } 100% { background: rgb(255 255 255 / .05); box-shadow: none; transform: none; } }
@keyframes fdFlashDown { 0% { background: rgb(248 113 113 / .35); } 100% { background: rgb(255 255 255 / .05); } }

.fd-toast-big { position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%) scale(.6); opacity: 0; pointer-events: none; padding: 2vh 3vw; border-radius: 2vw; font-size: clamp(22px, 4vw, 72px); font-weight: 900; white-space: nowrap; transition: opacity .3s, transform .4s cubic-bezier(.3,1.5,.5,1); backdrop-filter: blur(10px); }
.fd-toast-big.is-show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.fd-toast-big.is-gold { background: rgb(120 53 15 / .75); color: #fde68a; border: 2px solid #f59e0b; box-shadow: 0 0 80px rgb(245 158 11 / .5); }
.fd-toast-big.is-green { background: rgb(6 78 59 / .75); color: #a7f3d0; border: 2px solid #34d399; box-shadow: 0 0 80px rgb(52 211 153 / .45); }
.fd-confetti { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.fd-confetti i { position: absolute; top: -20px; width: 10px; height: 16px; border-radius: 2px; animation-name: fdConfetti; animation-timing-function: cubic-bezier(.3,.6,.6,1); animation-fill-mode: forwards; }
@keyframes fdConfetti { to { top: 105%; transform: translateX(60px) rotate(720deg); } }

/* يوم النشاط: نقطتان، ضيوف، إدارة */
.fd-game { position: relative; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: manipulation; }
.fd-game small { position: absolute; top: 2px; right: 5px; font-size: 9px; font-weight: 800; opacity: .55; }
.fd-game.is-pressing { animation: fdCharge .5s linear forwards; }
@keyframes fdCharge { from { box-shadow: inset 0 0 0 0 rgb(251 191 36 / .0); } to { box-shadow: inset 0 0 0 3px #fbbf24, 0 0 14px rgb(251 191 36 / .5); transform: scale(.94); } }
.fd-game.is-double { color: #3b2500; background: linear-gradient(135deg, #fde68a, #f59e0b); border-color: #fbbf24; box-shadow: 0 4px 14px rgb(245 158 11 / .4); }
.fd-game.is-double b { font-size: 17px; font-weight: 900; }
.fd-plus.is-double { color: #fbbf24; font-size: 24px; }
.fd-ring.is-guest { color: #a78bfa; font-weight: 700; }
.fd-manage-btn { width: 46px; flex-shrink: 0; border-radius: 14px; display: flex; align-items: center; justify-content: center; background: var(--c-card); border: 1px solid rgb(255 255 255 / .08); color: #d1d5db; }
.fd-manage-btn.hidden { display: none; }
.fd-add-guest { display: inline-flex; align-items: center; gap: 6px; margin-top: 10px; padding: 10px 16px; border-radius: 12px; font-weight: 800; font-size: 13px; color: #ede9fe; background: rgb(139 92 246 / .2); border: 1px solid rgb(167 139 250 / .4); }
.fd-add-guest .material-symbols-outlined { font-size: 20px; }
.fd-empty-hint { font-size: 11px; font-weight: 500; color: #6b7280; max-width: 280px; }
.fd-add-row { grid-column: 1 / -1; display: flex; flex-direction: column; align-items: center; padding: 10px; color: #6b7280; font-size: 12px; font-weight: 700; }
.fd-add-row .fd-add-guest { margin-top: 6px; }
.fd-b-guest { font-style: normal; font-size: .65em; color: #c4b5fd; background: rgb(139 92 246 / .2); padding: 0 .4em; border-radius: 99px; vertical-align: middle; }
.fd-b-dots i.on.x2 { background: #fbbf24; box-shadow: 0 0 8px #fbbf24; transform: scale(1.25); }
.fd-manage { position: fixed; inset: 0; z-index: 250; background: rgb(0 0 0 / .6); backdrop-filter: blur(4px); display: flex; align-items: flex-end; justify-content: center; }
.fd-manage.hidden { display: none; }
@media (min-width: 640px) { .fd-manage { align-items: center; } }
.fd-m-card { width: 100%; max-width: 440px; max-height: 85vh; overflow-y: auto; background: var(--c-container); border: 1px solid rgb(255 255 255 / .08); border-radius: 22px 22px 0 0; padding: 16px 16px 28px; }
@media (min-width: 640px) { .fd-m-card { border-radius: 22px; } }
.fd-m-head { display: flex; align-items: center; gap: 6px; font-weight: 900; font-size: 16px; color: #fff; margin-bottom: 14px; }
.fd-m-head .material-symbols-outlined { color: var(--c-primary); }
.fd-m-close { margin-right: auto; color: #9ca3af; }
.fd-m-label { font-size: 12px; font-weight: 800; color: #d1d5db; margin: 12px 0 6px; }
.fd-m-stepper { display: flex; align-items: center; justify-content: center; gap: 18px; background: var(--c-card); border-radius: 16px; padding: 8px; }
.fd-m-stepper button { width: 52px; height: 52px; border-radius: 14px; background: rgb(var(--c-primary-rgb) / .15); color: var(--c-primary); display: flex; align-items: center; justify-content: center; }
.fd-m-stepper button:active { transform: scale(.92); }
.fd-m-count { min-width: 60px; text-align: center; font-size: 34px; font-weight: 900; color: #fff; font-family: ui-monospace, monospace; }
.fd-m-note { font-size: 11px; color: #6b7280; margin-top: 6px; line-height: 1.6; }
.fd-m-guests { display: flex; flex-direction: column; gap: 6px; }
.fd-m-guest { display: flex; align-items: center; justify-content: space-between; background: var(--c-card); border-radius: 12px; padding: 8px 12px; font-weight: 700; font-size: 13px; }
.fd-m-guest button { color: #f87171; display: flex; }
.fd-m-none { font-size: 12px; color: #6b7280; padding: 6px 0; }

/* ===== مسابقة أدومها ===== */
.att-name-text { vertical-align: middle; }
.att-grade-select { margin-inline-start: 6px; padding: 1px 4px; font-size: 10px; font-weight: 700; border-radius: 8px;
    background: rgba(59,130,246,0.12); border: 1px solid rgba(59,130,246,0.35); color: #93c5fd; vertical-align: middle; cursor: pointer; }
.att-grade-select.is-empty { background: transparent; border-style: dashed; border-color: rgba(148,163,184,0.4); color: #94a3b8; }
.att-grade-select option { background: #1e293b; color: #fff; }
.adm-chip { display: inline-flex; align-items: center; gap: 2px; margin-inline-start: 6px; padding: 1px 6px; border-radius: 999px; font-size: 9px; font-weight: 800; line-height: 1.5; vertical-align: middle; white-space: nowrap; background: rgba(245,158,11,0.14); color: #fbbf24; border: 1px solid rgba(245,158,11,0.35); }
.adm-chip .adm-fire { font-size: 9px; }
.adm-chip.is-zero { background: transparent; color: #6b7280; border-color: var(--c-border); }
.adm-chip.is-zero .adm-fire { filter: grayscale(1); opacity: .6; }
.adm-rank { margin-inline-start: 3px; padding-inline-start: 4px; border-inline-start: 1px solid rgba(245,158,11,0.35); font-weight: 700; color: #fcd34d; }
.adm-chip.adm-r1 { background: rgba(250,204,21,0.2); border-color: #facc15; }
.adm-chip.adm-r2 { background: rgba(203,213,225,0.15); border-color: #cbd5e1; color: #e2e8f0; }
.adm-chip.adm-r3 { background: rgba(217,119,6,0.18); border-color: #d97706; }
.adm-chip.adm-r1 .adm-rank, .adm-chip.adm-r2 .adm-rank, .adm-chip.adm-r3 .adm-rank { border: 0; padding: 0; margin-inline-start: 2px; }

.adm-info { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; justify-content: space-between; }
.adm-info-text { font-size: 10px; color: #9ca3af; line-height: 1.7; flex: 1 1 260px; }
.adm-info-text b { color: #fbbf24; font-size: 12px; margin-inline-end: 6px; }
.adm-start { display: inline-block; margin-inline-start: 6px; padding: 0 6px; border-radius: 6px; background: var(--c-field); color: var(--c-text); font-family: monospace; }
.adm-bulk { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 10px; color: #d1d5db; font-weight: 700; }
.adm-bulk label { display: flex; align-items: center; gap: 4px; }
.adm-apply { padding: 6px 12px; border-radius: 10px; background: var(--c-primary); color: var(--c-bg); font-weight: 800; font-size: 11px; }
.adm-apply:disabled { opacity: .5; }
.adm-start-edit { display: flex; align-items: center; gap: 6px; font-size: 10px; color: #9ca3af; font-weight: 700; }
.adm-start-edit input { padding: 4px 6px; border-radius: 8px; font-size: 11px; font-family: monospace; }

.adm-stepper { display: inline-flex; align-items: center; gap: 2px; background: var(--c-field); border: 1px solid var(--c-border); border-radius: 10px; padding: 2px; }
.adm-step { width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; border-radius: 8px; color: var(--c-primary); }
.adm-step:hover:not(:disabled) { background: rgb(var(--c-primary-rgb) / 0.15); }
.adm-step:disabled { opacity: .35; cursor: not-allowed; }
.adm-step .material-symbols-outlined { font-size: 20px; }
.adm-step-val { min-width: 38px; text-align: center; font-weight: 900; font-size: 13px; color: var(--c-text); font-family: monospace; }
.adm-step-val small { font-size: 9px; color: #9ca3af; margin-inline-start: 2px; font-family: inherit; }
.adm-big { font-size: 15px; font-weight: 900; color: #fbbf24; }
.adm-big.is-zero { color: #6b7280; }
.adm-sub { font-size: 9px; color: #9ca3af; margin-top: 2px; }
.adm-today { font-size: 10px; font-weight: 700; color: #9ca3af; }
.adm-today.ok { color: #34d399; }

.adm-exam-row { display: flex; align-items: flex-start; gap: 10px; text-align: right; margin-bottom: 16px; padding: 10px 12px; border-radius: 14px; background: rgba(245,158,11,0.1); border: 1px solid rgba(245,158,11,0.35); cursor: pointer; }
.adm-exam-row.hidden { display: none; }
.adm-exam-row input { width: 18px; height: 18px; margin-top: 2px; accent-color: #f59e0b; flex-shrink: 0; }
.adm-exam-row b { display: block; font-size: 12px; color: #fbbf24; }
.adm-exam-row small { display: block; font-size: 10px; color: #9ca3af; margin-top: 2px; }

/* ===== جزء تبارك وعم بالسور في شبكة الحفظ ===== */
.hifz-juz-head { flex-basis: 100%; margin: 10px 0 4px; padding: 4px 0; font-size: 11px; font-weight: 800; color: #7dd3fc; border-top: 1px solid var(--c-border); scroll-margin-top: 4px; }
.part-btn.hifz-surah-btn { aspect-ratio: auto; min-width: 64px; height: 40px; padding: 2px 8px; flex-direction: column; gap: 0; line-height: 1.2; }
.hifz-surah-btn span { font-size: 11px; font-weight: 700; }
.hifz-surah-btn small { font-size: 8px; opacity: .7; font-family: monospace; }
.part-btn.hifz-surah-btn.partial { background: linear-gradient(to top, rgb(var(--c-primary-rgb) / 0.55) 50%, var(--c-field) 50%); border-color: var(--c-primary); }
.part-btn.hifz-surah-btn.partial small { opacity: 1; color: var(--c-text); font-weight: 700; }
.hifz-juz-jump { display: flex; gap: 6px; justify-content: center; }
.hifz-juz-jump button { padding: 4px 12px; border-radius: 999px; font-size: 10px; font-weight: 700; color: #7dd3fc; background: rgba(56,189,248,0.1); border: 1px solid rgba(56,189,248,0.3); }

/* أدومها على الموبايل: الاسم + النقاط + اليوم بالسطر الأول، وحدّا الحفظ والسرد بعرض نصف البطاقة لكل منهما */
@media (max-width: 767px) {
    #attendance-adoomha-grid tr.att-row td[data-cell="name"] { grid-column: span 12; }
    #attendance-adoomha-grid tr.att-row td[data-cell="detail"] { grid-column: span 9; order: 2; }
    #attendance-adoomha-grid tr.att-row td[data-cell="detail"]:nth-child(n+4) { grid-column: span 15; order: 4; }
    #attendance-adoomha-grid .adm-stepper { width: 100%; justify-content: space-between; }
    #attendance-adoomha-grid .adm-bulk { width: 100%; }
}

/* ===== ورشة تنظيم الحلقات ===== */
#ring-sort-page.active { animation: none; }
.rs-shell { width: calc(100vw - 16px); margin-inline: calc(50% - 50vw + 8px); display: flex; flex-direction: column; gap: 8px; }
.rs-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; background: var(--c-container); border: 1px solid rgba(255,255,255,0.06); border-radius: 16px; padding: 8px 12px; }
.rs-title { display: flex; align-items: center; gap: 8px; margin-inline-end: auto; }
.rs-title > .material-symbols-outlined { color: var(--c-primary); font-size: 26px; }
.rs-title h1 { font-size: 14px; font-weight: 800; color: #fff; line-height: 1.2; }
.rs-title p { font-size: 10px; color: #94a3b8; }
.rs-search { width: 160px; padding: 6px 10px; font-size: 11px; border-radius: 10px; background: var(--c-field); border: 1px solid var(--c-border); color: var(--c-text); }
.rs-zoom { display: flex; align-items: center; gap: 2px; background: var(--c-field); border: 1px solid var(--c-border); border-radius: 10px; padding: 2px; }
.rs-zoom button { width: 28px; height: 26px; display: flex; align-items: center; justify-content: center; border-radius: 8px; color: #cbd5e1; }
.rs-zoom button:hover { background: rgba(255,255,255,0.08); }
.rs-zoom .material-symbols-outlined { font-size: 17px; }
#rs-zoom-label { font-size: 10px; color: #94a3b8; min-width: 34px; text-align: center; font-variant-numeric: tabular-nums; }
.rs-btn-ghost, .rs-approve { display: inline-flex; align-items: center; gap: 4px; padding: 7px 12px; border-radius: 10px; font-size: 11px; font-weight: 700; }
.rs-btn-ghost { background: var(--c-field); border: 1px solid var(--c-border); color: #cbd5e1; }
.rs-btn-ghost:hover { background: rgba(255,255,255,0.08); }
.rs-approve { background: #10b981; color: #052e1f; box-shadow: 0 4px 14px rgba(16,185,129,0.25); }
.rs-approve:disabled { background: #2a3a33; color: #6b7f76; box-shadow: none; cursor: not-allowed; }
.rs-btn-ghost .material-symbols-outlined, .rs-approve .material-symbols-outlined { font-size: 16px; }

.rs-draftbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; background: var(--c-container); border: 1px solid rgba(255,255,255,0.06); border-radius: 12px; padding: 6px 10px; }
.rs-draft-icon { color: #93c5fd; font-size: 18px; }
.rs-draftbar label { font-size: 11px; font-weight: 700; color: #cbd5e1; }
.rs-draftbar select { width: auto !important; flex: 0 1 320px; min-width: 180px; max-width: 100%; padding: 5px 8px; font-size: 11px; font-weight: 700; border-radius: 9px; background: var(--c-field); border: 1px solid var(--c-border); color: var(--c-text); }
.rs-draftbar button { display: inline-flex; align-items: center; gap: 3px; font-size: 11px; font-weight: 700; padding: 5px 9px; border-radius: 9px; background: var(--c-field); border: 1px solid var(--c-border); color: #cbd5e1; }
.rs-draftbar button:hover:not(:disabled) { background: rgba(255,255,255,0.08); }
.rs-draftbar button:disabled { opacity: .4; cursor: not-allowed; }
.rs-draftbar button .material-symbols-outlined { font-size: 15px; }
.rs-save-state { margin-inline-start: auto; display: inline-flex; align-items: center; gap: 4px; font-size: 10.5px; font-weight: 700; }
.rs-save-state .material-symbols-outlined { font-size: 16px; }
.rs-save-state.is-saved { color: #34d399; }
.rs-save-state.is-pending { color: #fbbf24; }
.rs-save-state.is-error { color: #f87171; }

.rs-pass-overlay { position: fixed; inset: 0; z-index: 10000; background: rgba(0,0,0,0.6); backdrop-filter: blur(3px); display: flex; align-items: center; justify-content: center; padding: 16px; direction: rtl; }
.rs-pass-box { width: min(360px, 100%); background: var(--c-container); border: 1px solid var(--c-border); border-radius: 18px; padding: 18px; box-shadow: 0 20px 50px rgba(0,0,0,0.5); }
.rs-pass-title { display: flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 800; color: #fff; margin-bottom: 8px; }
.rs-pass-title .material-symbols-outlined { color: #fbbf24; }
.rs-pass-box p { font-size: 11px; color: #cbd5e1; line-height: 1.7; margin-bottom: 10px; }
.rs-pass-box input { width: 100%; padding: 9px 12px; font-size: 14px; letter-spacing: 3px; text-align: center; border-radius: 10px; background: var(--c-field); border: 1px solid var(--c-border); color: #fff; }
.rs-pass-err { min-height: 16px; margin-top: 4px; font-size: 10.5px; font-weight: 700; color: #f87171; text-align: center; }
.rs-pass-actions { display: flex; gap: 8px; margin-top: 8px; }
.rs-pass-actions button { flex: 1; justify-content: center; }

.rs-body { position: relative; display: flex; gap: 8px; }
.rs-viewport { flex: 1; direction: ltr; overflow: auto; height: calc(100dvh - 250px); min-height: 360px; border-radius: 16px; border: 1px solid rgba(255,255,255,0.06);
    background-color: #101315; background-image: radial-gradient(rgba(255,255,255,0.07) 1px, transparent 1px); background-size: 22px 22px; }
.rs-canvas-size { position: relative; }
.rs-canvas { position: absolute; top: 0; left: 0; transform-origin: 0 0; }
.rs-lines { position: absolute; inset: 0; pointer-events: none; z-index: 5; overflow: visible; }
.rs-lines path { fill: none; stroke-width: 2.2; stroke-dasharray: 6 4; opacity: .9; }

.rs-stack { position: absolute; width: 176px; direction: rtl; z-index: 2; filter: drop-shadow(0 4px 10px rgba(0,0,0,0.35)); transition: filter .15s; }
.rs-stack.is-lifted { z-index: 20; filter: drop-shadow(0 12px 24px rgba(0,0,0,0.55)); }
.rs-stack.is-target .rs-tail { background: color-mix(in srgb, var(--c) 35%, transparent); color: #fff; border-color: var(--c); }
.rs-stack.is-target { filter: drop-shadow(0 0 10px color-mix(in srgb, var(--c) 70%, transparent)); }
.rs-hat { display: flex; align-items: center; gap: 4px; height: 32px; padding: 0 6px 0 8px; background: var(--c); color: #fff; border-radius: 14px 14px 4px 4px;
    cursor: grab; touch-action: none; user-select: none; position: relative; }
.rs-hat:active { cursor: grabbing; }
.rs-hat .material-symbols-outlined { font-size: 16px; opacity: .75; }
.rs-hat-name { flex: 1; min-width: 0; font-size: 12px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rs-count { font-size: 10px; font-weight: 800; background: rgba(0,0,0,0.25); border-radius: 999px; padding: 1px 7px; }

/* بلوك الطالب: شكل قطعة متداخلة مثل البلوكات */
.rs-block { position: relative; display: flex; align-items: center; gap: 3px; height: 23px; margin-top: 2px; padding: 0 6px; border-radius: 4px;
    background: color-mix(in srgb, var(--c) 22%, #1c2024); border-inline-start: 3px solid var(--c); color: #f1f5f9;
    cursor: grab; touch-action: none; user-select: none; }
.rs-block::before { content: ''; position: absolute; top: -3px; right: 14px; width: 14px; height: 4px; border-radius: 0 0 4px 4px; background: inherit; }
.rs-block:hover { background: color-mix(in srgb, var(--c) 34%, #1c2024); }
.rs-block.is-moved { border-inline-start: 3px solid var(--from, #f59e0b); outline: 1.5px solid #f59e0b; outline-offset: -1.5px; }
.rs-block.is-hit { box-shadow: 0 0 0 2px #fde047; z-index: 3; }
.rs-block.is-dragging { opacity: .25; }
.rs-name { flex: 1; min-width: 0; font-size: 10.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rs-chip { flex: none; font-size: 9px; font-weight: 700; padding: 0 4px; line-height: 15px; border-radius: 4px; background: rgba(0,0,0,0.28); color: #bfdbfe; font-variant-numeric: tabular-nums; }
.rs-chip.is-empty { color: #64748b; }
/* لون مميز لكل صف دراسي */
.rs-chip.rs-grade.g1 { background: #ef4444; color: #0b0d0e; }
.rs-chip.rs-grade.g2 { background: #f97316; color: #0b0d0e; }
.rs-chip.rs-grade.g3 { background: #f59e0b; color: #0b0d0e; }
.rs-chip.rs-grade.g4 { background: #eab308; color: #0b0d0e; }
.rs-chip.rs-grade.g5 { background: #84cc16; color: #0b0d0e; }
.rs-chip.rs-grade.g6 { background: #22c55e; color: #0b0d0e; }
.rs-chip.rs-grade.g7 { background: #14b8a6; color: #0b0d0e; }
.rs-chip.rs-grade.g8 { background: #06b6d4; color: #0b0d0e; }
.rs-chip.rs-grade.g9 { background: #3b82f6; color: #0b0d0e; }
.rs-chip.rs-grade.g10 { background: #6366f1; color: #0b0d0e; }
.rs-chip.rs-grade.g11 { background: #a855f7; color: #0b0d0e; }
.rs-chip.rs-grade.g12 { background: #ec4899; color: #0b0d0e; }
.rs-chip.rs-page { color: #a7f3d0; }
.rs-tail { margin-top: 2px; height: 20px; display: flex; align-items: center; justify-content: center; font-size: 9px; color: #64748b;
    border: 1px dashed rgba(255,255,255,0.12); border-radius: 4px 4px 12px 12px; background: rgba(0,0,0,0.2); }
.rs-stack.is-none .rs-hat { cursor: grab; }

.rs-ghost { position: fixed; z-index: 9999; pointer-events: none; transform: rotate(-2deg) scale(1.04); box-shadow: 0 10px 24px rgba(0,0,0,0.5); opacity: .95; direction: rtl; }
body.rs-dragging, body.rs-dragging * { cursor: grabbing !important; user-select: none; }

.rs-side { display: none; width: 260px; flex: none; height: calc(100dvh - 250px); min-height: 360px; overflow: auto; background: var(--c-container); border: 1px solid rgba(255,255,255,0.06); border-radius: 16px; padding: 10px; }
.rs-side.open { display: block; }
.rs-side-title { font-size: 12px; font-weight: 800; color: #fff; margin-bottom: 8px; }
.rs-moves-empty { font-size: 10px; color: #94a3b8; }
.rs-move-row { display: grid; grid-template-columns: 1fr auto; gap: 0 6px; padding: 6px 0; border-bottom: 1px solid rgba(255,255,255,0.05); }
.rs-move-name { font-size: 11px; font-weight: 700; color: #f1f5f9; }
.rs-move-path { grid-row: 2; font-size: 9.5px; color: #fbbf24; }
.rs-move-row button { grid-row: 1 / span 2; grid-column: 2; align-self: center; color: #94a3b8; padding: 2px; border-radius: 6px; }
.rs-move-row button:hover { color: #fff; background: rgba(255,255,255,0.08); }
.rs-move-row .material-symbols-outlined { font-size: 16px; }

@media (max-width: 767px) {
    .rs-draftbar select { min-width: 0; flex: 1; }
    .rs-search { width: 100%; order: 5; }
    .rs-viewport { height: calc(100dvh - 330px); }
    .rs-side.open { position: absolute; inset: 0 auto 0 0; width: min(260px, 80vw); z-index: 30; }
}

.bi-kpi-note { margin-top: 2px; font-size: 9px; color: #6b7280; line-height: 1.3; }
