/**
 * نظام الجدول المدرسي الذكي
 * assets/css/app.css - التصميم العصري العربي الكامل RTL
 */

@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;500;600;700;800;900&display=swap');

/* ==========================================================================
   نظام التصميم (Design Tokens) — المرجع الوحيد للألوان والخطوط والمسافات
   التوثيق: docs/design-system.md — أي قيمة جديدة تُضاف هنا أولاً ثم تُستخدم بـ var()
   ========================================================================== */
:root {
    /* — الرمادي (Slate) — */
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;

    /* — اللون الأساسي (الأخضر الزمردي) — */
    --primary: #0f766e;
    --primary-hover: #0d9488;
    --primary-strong: #115e59;
    --primary-light: #ccfbf1;
    --primary-subtle: #f0fdfa;

    /* لون ثانوي للتمييز في الرسوم والمؤشرات فقط — لا يُستخدم للأزرار */
    --secondary: #4f46e5;
    --secondary-hover: #4338ca;

    /* — ألوان الحالة — */
    --success: #10b981;
    --success-light: #d1fae5;
    --success-dark: #065f46;
    --warning: #d97706;
    --warning-light: #fef3c7;
    --warning-dark: #92400e;
    --danger: #ef4444;
    --danger-light: #fee2e2;
    --danger-dark: #b91c1c;
    --info: #0284c7;
    --info-light: #e0f2fe;
    --info-dark: #0369a1;
    --accent: #f59e0b;
    --accent-light: #fef3c7;

    /* — لوحة التدرجات (للإبراز والوسوم والخلفيات الملونة؛ الأدوار الدلالية أعلاه أولى) — */
    --teal-200: #99f6e4;
    --teal-400: #2dd4bf;
    --teal-500: #14b8a6;
    --green-50: #f0fdf4;
    --green-100: #dcfce7;
    --green-200: #bbf7d0;
    --green-600: #16a34a;
    --green-700: #15803d;
    --green-800: #166534;
    --emerald-50: #ecfdf5;
    --emerald-200: #a7f3d0;
    --emerald-600: #059669;
    --emerald-700: #047857;
    --amber-50: #fffbeb;
    --amber-200: #fde68a;
    --amber-500: #f59e0b;
    --amber-700: #b45309;
    --red-50: #fef2f2;
    --red-200: #fecaca;
    --red-300: #fca5a5;
    --red-400: #f87171;
    --red-600: #dc2626;
    --red-800: #991b1b;
    --rose-50: #fff1f2;
    --rose-200: #fecdd3;
    --rose-600: #e11d48;
    --rose-700: #be123c;
    --rose-800: #9f1239;
    --blue-50: #eff6ff;
    --blue-200: #bfdbfe;
    --blue-500: #3b82f6;
    --blue-600: #2563eb;
    --blue-800: #1e40af;
    --sky-50: #f0f9ff;

    /* — الأدوار الدلالية — */
    --bg-body: var(--gray-50);
    --bg-subtle: var(--gray-100);
    --bg-card: #ffffff;
    --bg-sidebar: var(--gray-900);

    --text-main: var(--gray-900);
    --text-body: var(--gray-700);
    --text-muted: var(--gray-500);
    --text-light: var(--gray-400);
    --text-inverse: #ffffff;

    --border: var(--gray-200);
    --border-strong: var(--gray-300);
    --border-focus: var(--primary);
    --ring: 0 0 0 3px rgba(15, 118, 110, 0.15);

    /* — سلّم الخطوط — */
    --fs-2xs: 10px;
    --fs-xs: 11px;
    --fs-sm: 12px;
    --fs-base: 13px;
    --fs-md: 14px;
    --fs-lg: 16px;
    --fs-xl: 18px;
    --fs-2xl: 20px;
    --fs-3xl: 24px;
    --fs-4xl: 28px;

    --fw-regular: 400;
    --fw-medium: 600;
    --fw-bold: 700;
    --fw-heavy: 800;

    /* — المسافات (مضاعفات 4) — */
    --sp-1: 4px;
    --sp-2: 8px;
    --sp-3: 12px;
    --sp-4: 16px;
    --sp-5: 20px;
    --sp-6: 24px;
    --sp-8: 32px;

    /* — الاستدارات — */
    --radius-xs: 4px;
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-full: 9999px;

    /* — الظلال — */
    --shadow-sm: 0 1px 2px 0 rgba(15, 23, 42, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.07), 0 2px 4px -2px rgba(15, 23, 42, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.04);
    --shadow-xl: 0 20px 25px -5px rgba(15, 23, 42, 0.1), 0 8px 10px -6px rgba(15, 23, 42, 0.04);

    /* نقاط التجاوب المعتمدة (لا تعمل var() داخل @media؛ تُكتب القيم نفسها):
       الجوال ≤ 640px • اللوحي ≤ 1024px • الشاشات الصغيرة ≤ 1280px */

    /* متغيرات صفحة الإسناد */
    --alloc-success: #10b981;
    --alloc-danger: #ef4444;
    --alloc-warning: #f59e0b;
    --alloc-info: #0369a1;
    --alloc-primary: #0f766e;
    --alloc-bg-sidebar: #ffffff;
    --alloc-bg-stage: #ffffff;
    --alloc-border: #e2e8f0;
    --alloc-topbar-height: 106px;
}

/* ======================================================== */
/* فرض الأرقام الإنجليزية (0-9) مع خط Cairo الكامل           */
/* ======================================================== */
:root, html, body, *, *::before, *::after {
    font-feature-settings: "locl" 0 !important;
    -webkit-font-feature-settings: "locl" 0 !important;
    -moz-font-feature-settings: "locl" 0 !important;
    font-variant-numeric: normal tabular-nums !important;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Cairo', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-feature-settings: "locl" 0 !important;
    -webkit-font-feature-settings: "locl" 0 !important;
    -moz-font-feature-settings: "locl" 0 !important;
}

input, button, select, textarea {
    font-family: 'Cairo', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
    font-feature-settings: "locl" 0 !important;
    -webkit-font-feature-settings: "locl" 0 !important;
    -moz-font-feature-settings: "locl" 0 !important;
}

/* تنسيق موحد لكافة عناصر الأرقام لضمان ظهورها بالأرقام الإنجليزية 0-9 بخط Cairo */
.en-num, 
.number, 
input[type="number"], 
input[data-num], 
input[type="tel"], 
.subj-cell-input, 
.subj-new-quota-input, 
.table-inline-input.number,
.stat-card-value,
.badge,
.subj-total-cell,
.subj-footer-row td,
[data-col-total],
[data-row-total],
#subjGrandTotalCell,
.timetable-cell,
.period-badge,
.slot-pill,
.count,
.counter,
.stat-value,
.badge-count {
    font-family: 'Cairo', sans-serif !important;
    font-feature-settings: "locl" 0 !important;
    -webkit-font-feature-settings: "locl" 0 !important;
    -moz-font-feature-settings: "locl" 0 !important;
    font-variant-numeric: normal tabular-nums !important;
    direction: ltr !important;
    unicode-bidi: isolate !important;
}

body {
    background-color: var(--bg-body);
    color: var(--text-main);
    direction: rtl;
    text-align: right;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* التخطيط العام (App Layout) */
.app-container {
    display: flex;
    width: 100%;
    min-height: 100vh;
}

/* ======================================================== */
/* القائمة الجانبية الفاخرة (Modern Executive Sidebar)       */
/* ======================================================== */
.sidebar {
    width: 275px;
    background: linear-gradient(180deg, var(--gray-900) 0%, #0b1120 100%);
    color: var(--text-inverse);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: -8px 0 28px rgba(0, 0, 0, 0.3);
    border-left: 1px solid rgba(255, 255, 255, 0.07);
}

.sidebar-header {
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
    background: rgba(255, 255, 255, 0.015);
    flex-shrink: 0;
}

/* زر إغلاق القائمة الجانبية للشاشات الصغيرة */
.sidebar-close-btn {
    display: none;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: var(--gray-200);
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-md);
    align-items: center;
    justify-content: center;
    margin-right: auto;
    transition: all 0.18s ease;
    flex-shrink: 0;
}
.sidebar-close-btn:hover {
    background: rgba(239, 68, 68, 0.25);
    border-color: var(--danger);
    color: var(--red-300);
}

/* خلفية القائمة الجانبية المعتمة للجوال */
.sidebar-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 1500;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}
.sidebar-backdrop.active,
.sidebar-backdrop.show {
    opacity: 1;
    visibility: visible;
}

.brand-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--primary) 0%, var(--teal-500) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    box-shadow: 0 3px 12px rgba(20, 184, 166, 0.35);
    flex-shrink: 0;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.brand-icon svg {
    width: 20px;
    height: 20px;
}

.brand-info h2 {
    font-size: var(--fs-md);
    font-weight: 800;
    color: #ffffff;
    margin-bottom: 1px;
    letter-spacing: -0.2px;
    line-height: 1.2;
}

.brand-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: var(--fs-xs);
    font-weight: 600;
    color: var(--gray-400);
    line-height: 1.2;
}

.pulse-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: var(--success);
    box-shadow: 0 0 6px var(--success);
    display: inline-block;
    animation: pulseDot 2s infinite ease-in-out;
}

@keyframes pulseDot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.85); }
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
    padding: 6px 8px;
    display: flex;
    flex-direction: column;
    gap: 1.5px;
}

.sidebar-nav::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
    width: 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 5px 10px;
    border-radius: var(--radius-md);
    color: var(--gray-400);
    text-decoration: none;
    font-size: var(--fs-base);
    font-weight: 700;
    cursor: pointer;
    position: relative;
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
    border: 1px solid transparent;
}

.nav-icon-box {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gray-400);
    flex-shrink: 0;
    transition: all 0.15s ease;
}

.nav-icon-box svg {
    width: 17px;
    height: 17px;
}

.nav-title {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.35;
    font-size: var(--fs-base);
    font-weight: 700;
}

.nav-item:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--gray-50);
    transform: translateX(-2px);
    border-color: rgba(255, 255, 255, 0.05);
}

.nav-item:hover .nav-icon-box {
    background: rgba(20, 184, 166, 0.15);
    border-color: rgba(20, 184, 166, 0.3);
    color: var(--teal-400);
}

.nav-item.active {
    background: linear-gradient(90deg, rgba(15, 118, 110, 0.28) 0%, rgba(15, 118, 110, 0.08) 100%);
    border-right: 3.5px solid var(--teal-500);
    border-top: 1px solid rgba(20, 184, 166, 0.18);
    border-bottom: 1px solid rgba(20, 184, 166, 0.18);
    border-left: 1px solid rgba(20, 184, 166, 0.08);
    color: #ffffff;
    font-weight: 700;
    box-shadow: inset -2px 0 8px rgba(20, 184, 166, 0.12);
}

.nav-item.active .nav-icon-box {
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    border-color: var(--teal-500);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(15, 118, 110, 0.45);
}

.nav-badge-smart {
    font-size: var(--fs-2xs);
    font-weight: 800;
    padding: 1px 6px;
    border-radius: var(--radius-xs);
    background: rgba(16, 185, 129, 0.16);
    color: #34d399;
    border: 1px solid rgba(52, 211, 153, 0.3);
    margin-right: auto;
    letter-spacing: 0.2px;
}

.sidebar-footer {
    padding: 12px 14px;
    border-top: 1px solid rgba(255, 255, 255, 0.07);
    background: rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-shrink: 0;
}

.user-snippet {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 0;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--gray-800), var(--gray-700));
    border: 1.5px solid rgba(20, 184, 166, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: var(--fs-base);
    color: var(--teal-400);
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.user-meta {
    flex: 1;
    overflow: hidden;
}

.user-meta .name {
    font-size: var(--fs-sm);
    font-weight: 700;
    color: var(--gray-50);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
}

.user-meta .role {
    font-size: var(--fs-xs);
    color: var(--gray-400);
    margin-top: 1px;
    direction: ltr;
    text-align: right;
    line-height: 1.2;
}

.sidebar-logout-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--gray-300);
    font-size: var(--fs-sm);
    font-weight: 700;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
}

.sidebar-logout-btn:hover {
    background: rgba(239, 68, 68, 0.12);
    border-color: rgba(239, 68, 68, 0.35);
    color: var(--red-400);
    transform: translateY(-1px);
}

/* المحتوى الرئيسي (Main Content) */
.main-wrapper {
    flex: 1;
    margin-right: 275px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-right 0.3s ease;
}

/* الشريط العلوي (Top Navbar) */
.top-header {
    height: 70px;
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    position: sticky;
    top: 0;
    z-index: 99;
}

.header-left, .header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.feedback-header-btn {
    background: linear-gradient(135deg, var(--secondary) 0%, var(--secondary-hover) 100%) !important;
    color: #ffffff !important;
    border: 1px solid var(--secondary-hover) !important;
    font-weight: 800 !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 7px !important;
    padding: 7px 15px !important;
    border-radius: var(--radius-md) !important;
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.28) !important;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
    cursor: pointer !important;
    text-decoration: none !important;
}

.feedback-header-btn:hover {
    background: linear-gradient(135deg, var(--secondary-hover) 0%, #3730a3 100%) !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 4px 14px rgba(79, 70, 229, 0.42) !important;
    color: #ffffff !important;
}

.feedback-header-btn:active {
    transform: translateY(0) !important;
}

.menu-toggle-btn {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    color: var(--text-main);
}

.school-badge-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--primary-subtle);
    border: 1px solid var(--primary-light);
    color: var(--primary);
    padding: 6px 14px;
    border-radius: var(--radius-full);
    font-size: var(--fs-sm);
    font-weight: 700;
}

/* مساحة العمل الداخلية */
.content-area {
    flex: 1;
    padding: 32px;
    max-width: 1500px;
    margin: 0 auto;
    width: 100%;
}

/* بطاقات الإحصائيات (KPI Cards) */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}

.kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s, box-shadow 0.2s;
}

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

.kpi-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    flex-shrink: 0;
}

.kpi-icon.teal { background: linear-gradient(135deg, var(--primary), var(--teal-500)); }
.kpi-icon.indigo { background: linear-gradient(135deg, var(--secondary), #6366f1); }
.kpi-icon.amber { background: linear-gradient(135deg, var(--warning), var(--amber-500)); }
.kpi-icon.rose { background: linear-gradient(135deg, var(--rose-600), #f43f5e); }
.kpi-icon.purple { background: linear-gradient(135deg, #7c3aed, #a855f7); }

.kpi-data h3 {
    font-size: var(--fs-4xl);
    font-weight: 800;
    color: var(--text-main);
    line-height: 1.2;
}

.kpi-data p {
    font-size: var(--fs-base);
    font-weight: 600;
    color: var(--text-muted);
    margin-top: 4px;
}

/* شريط تقدم مسار التهيئة (Setup Checklist Card) */
.checklist-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 26px;
    margin-bottom: 30px;
    box-shadow: var(--shadow-sm);
}

.checklist-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.checklist-title h2 {
    font-size: var(--fs-xl);
    font-weight: 800;
    color: var(--text-main);
}

.checklist-title p {
    font-size: var(--fs-base);
    color: var(--text-muted);
}

.progress-bar-container {
    height: 10px;
    background: var(--gray-200);
    border-radius: var(--radius-full);
    overflow: hidden;
    margin-bottom: 24px;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--success));
    border-radius: var(--radius-full);
    transition: width 0.5s ease;
}

.steps-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
}

.step-item {
    background: var(--bg-body);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px;
    display: flex;
    gap: 14px;
    align-items: flex-start;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    color: inherit;
}

.step-item:hover {
    background: #fff;
    border-color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.step-item.done {
    border-color: var(--green-200);
    background: var(--green-50);
}

.step-status-icon {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: var(--gray-200);
    color: var(--gray-500);
    font-size: var(--fs-sm);
    font-weight: 700;
}

.step-item.done .step-status-icon {
    background: var(--success);
    color: #fff;
}

.step-body h4 {
    font-size: var(--fs-md);
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 3px;
}

.step-body p {
    font-size: var(--fs-sm);
    color: var(--text-muted);
    line-height: 1.4;
}

/* ======================================================== */
/* صفحة المراجعة: كل المحتوى في شاشة واحدة بلا تمرير           */
/* ======================================================== */
.review-hero {
    display: flex;
    align-items: center;
    gap: var(--sp-5);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: var(--sp-4) var(--sp-5);
    margin-bottom: var(--sp-4);
}

.review-ring {
    --pct: 0;
    width: 76px;
    height: 76px;
    flex-shrink: 0;
    border-radius: var(--radius-full);
    background: conic-gradient(var(--warning) calc(var(--pct) * 1%), var(--gray-200) 0);
    display: grid;
    place-items: center;
    position: relative;
}

.review-ring.is-ready {
    background: conic-gradient(var(--success) calc(var(--pct) * 1%), var(--gray-200) 0);
}

.review-ring::before {
    content: "";
    position: absolute;
    inset: 7px;
    border-radius: var(--radius-full);
    background: var(--bg-card);
}

.review-ring span {
    position: relative;
    font-size: var(--fs-xl);
    font-weight: var(--fw-heavy);
    color: var(--text-main);
}

.review-hero-text {
    flex: 1 1 220px;
    min-width: 0;
}

.review-hero-text h2 {
    font-size: var(--fs-lg);
    font-weight: var(--fw-heavy);
    color: var(--text-main);
    margin-bottom: 2px;
}

.review-hero-text p {
    font-size: var(--fs-base);
    color: var(--success-dark);
    font-weight: var(--fw-medium);
    line-height: 1.5;
}

.review-hero-text p.is-warning {
    color: var(--warning-dark);
}

.review-hero-text p.is-danger {
    color: var(--danger-dark);
}

/* الخطوات يميناً وفحص ما قبل التوليد يساراً؛ ارتفاع الصف تحدده الخطوات، وقائمة الفحص تتمرر داخلها */
.review-body {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: var(--sp-4);
}

.review-check {
    position: relative;
    padding: 0;
    margin-bottom: 0;
    min-height: 220px;
}

.review-check-inner {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    padding: var(--sp-4) var(--sp-5);
}

.review-check .checklist-header {
    margin-bottom: var(--sp-2);
}

.review-check-summary {
    font-size: var(--fs-base);
    font-weight: var(--fw-bold);
    color: var(--text-muted);
    padding: var(--sp-2) var(--sp-3);
    border-radius: var(--radius-md);
    background: var(--bg-subtle);
    margin-bottom: var(--sp-2);
}

.review-check-summary.is-ok { background: var(--success-light); color: var(--success-dark); }
.review-check-summary.is-warning { background: var(--warning-light); color: var(--warning-dark); }
.review-check-summary.is-danger { background: var(--danger-light); color: var(--danger-dark); }

.review-issues {
    list-style: none;
    margin: 0;
    padding: 0;
    flex: 1 1 0;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
}

.review-issue {
    display: flex;
    align-items: flex-start;
    gap: var(--sp-2);
    padding: var(--sp-2) var(--sp-3);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: var(--fs-sm);
    line-height: 1.6;
    color: var(--text-body);
}

.review-issue.is-danger { border-color: var(--danger-light); }
.review-issue.is-warning { border-color: var(--warning-light); }

.review-issue-dot {
    width: 8px;
    height: 8px;
    margin-top: 7px;
    border-radius: var(--radius-full);
    flex-shrink: 0;
    background: var(--warning);
}

.review-issue.is-danger .review-issue-dot { background: var(--danger); }

.review-issue-text {
    flex: 1;
    min-width: 0;
}

.review-issue .btn {
    flex-shrink: 0;
}

.review-issue-empty {
    font-size: var(--fs-sm);
    color: var(--text-muted);
    line-height: 1.6;
    padding: var(--sp-2) 0;
}

.review-kpis {
    flex: 0 1 auto;
    grid-template-columns: repeat(4, minmax(118px, 1fr));
    gap: var(--sp-2);
    margin-bottom: 0;
}

.review-kpis .kpi-card {
    padding: var(--sp-2) var(--sp-3);
    gap: var(--sp-2);
    box-shadow: none;
    background: var(--bg-subtle);
}

.review-kpis .kpi-card:hover {
    transform: none;
    box-shadow: none;
}

.review-kpis .kpi-data h3 {
    font-size: var(--fs-2xl);
}

.review-kpis .kpi-data p {
    font-size: var(--fs-xs);
    margin-top: 0;
    white-space: nowrap;
}

.review-kpis .kpi-icon {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-md);
}

.review-kpis .kpi-icon svg {
    width: 18px;
    height: 18px;
}

.review-checklist {
    padding: var(--sp-4) var(--sp-5);
    margin-bottom: 0;
}

.review-checklist .checklist-header {
    margin-bottom: var(--sp-3);
}

.review-hint {
    font-size: var(--fs-sm);
    color: var(--text-muted);
}

.review-checklist .steps-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--sp-2);
}

.review-checklist .step-item {
    padding: var(--sp-3);
    gap: var(--sp-2);
}

.review-checklist .step-body {
    min-width: 0;
}

.review-checklist .step-body h4 {
    font-size: var(--fs-base);
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
}

.review-checklist .step-body h4 .badge {
    font-size: var(--fs-2xs);
}

/* الوصف يظهر عند مرور الفأرة (title) حفاظاً على شاشة واحدة */
.review-checklist .step-body p {
    display: none;
}

.review-checklist .step-item {
    align-items: center;
}

@media (max-width: 1180px) {
    .review-hero { flex-wrap: wrap; }
    .review-kpis { flex-basis: 100%; }
}

@media (max-width: 1024px) {
    .review-body { grid-template-columns: 1fr; }
    .review-check { min-height: 0; }
    .review-check-inner { position: static; }
    .review-issues { flex: none; max-height: 360px; }
}

/* الجوال: سلّم خطوط واحد للصفحة — عنوان 16 • قسم 14 • نص 13 • ثانوي 12 • تسمية 11 */
@media (max-width: 640px) {
    .review-hero { gap: 12px; padding: 14px; }
    .review-ring { width: 60px; height: 60px; }
    .review-ring::before { inset: 6px; }
    .review-ring span { font-size: var(--fs-md); }
    .review-hero-text { flex: 1 1 0; }
    .review-hero-text h2 { font-size: var(--fs-lg); }
    .review-hero-text p { font-size: var(--fs-sm); line-height: 1.6; }

    .review-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 8px !important; }
    .review-kpis .kpi-card { min-width: 0; padding: 10px 12px !important; }
    .review-kpis .kpi-icon { display: none; }
    .review-kpis .kpi-data { min-width: 0; }
    .review-kpis .kpi-data h3 { font-size: var(--fs-2xl) !important; line-height: 1.2; }
    .review-kpis .kpi-data p { font-size: var(--fs-xs) !important; line-height: 1.4; }

    .review-checklist, .review-check-inner { padding: 14px !important; }
    .review-checklist .checklist-header,
    .review-check .checklist-header { flex-direction: row !important; align-items: center !important; justify-content: space-between; }
    .review-checklist .checklist-title h2,
    .review-check .checklist-title h2 { font-size: var(--fs-md); }
    .review-checklist .step-body h4 { font-size: var(--fs-base); }
    .review-check-summary { font-size: var(--fs-sm); }
    .review-issue-text { font-size: var(--fs-sm); }
    .review-checklist .steps-list { grid-template-columns: 1fr; }
    .review-hint { display: none; }
}

/* البطاقات العامة وجداول البيانات */
.panel-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    margin-bottom: 26px;
    overflow: hidden;
}

.panel-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.panel-title h3 {
    font-size: var(--fs-xl);
    font-weight: 800;
    color: var(--text-main);
}

.panel-title p {
    font-size: var(--fs-sm);
    color: var(--text-muted);
    margin-top: 2px;
}

.panel-body {
    padding: 24px;
}

/* ترويسة موحدة لتبويبات لوحة التحكم: العنوان يميناً والإجراءات يساراً */
.panel-header.tab-header {
    padding: 12px 18px;
    background: #ffffff;
    border-bottom: 1px solid var(--border);
}

.tab-header .panel-title h3 {
    margin: 0;
    font-size: var(--fs-lg);
    font-weight: 800;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 8px;
}

.tab-header-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.tab-header-badge {
    font-size: var(--fs-sm);
    font-weight: 800;
    color: var(--primary);
    background: var(--primary-subtle);
    border: 1px solid var(--teal-200);
    padding: 4px 10px;
    border-radius: var(--radius-md);
}

/* شريط تنبيه الميزات التي تتطلب اشتراكاً نشطاً */
.subscription-lock-banner {
    background: linear-gradient(135deg, var(--amber-50) 0%, var(--warning-light) 100%);
    border: 1.5px solid var(--amber-500);
    border-radius: var(--radius-lg);
    padding: 16px 20px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.1);
}

.subscription-lock-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.subscription-lock-icon {
    font-size: var(--fs-4xl);
}

.subscription-lock-banner h4 {
    margin: 0 0 4px 0;
    color: var(--warning-dark);
    font-size: var(--fs-lg);
    font-weight: 800;
}

.subscription-lock-banner p {
    margin: 0;
    color: var(--amber-700);
    font-size: var(--fs-base);
}

.subscription-lock-btn {
    background: linear-gradient(135deg, var(--warning), var(--amber-700));
    color: #ffffff;
    border: none;
    padding: 10px 22px;
    border-radius: var(--radius-md);
    font-weight: 800;
    font-size: var(--fs-base);
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(180, 83, 9, 0.3);
}

/* الأزرار (Buttons) */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 18px;
    border-radius: var(--radius-md);
    font-size: var(--fs-base);
    font-weight: 700;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.2s;
    text-decoration: none;
    line-height: 1;
}

.btn-sm {
    padding: 6px 12px;
    font-size: var(--fs-sm);
}

.btn-lg {
    padding: 12px 24px;
    font-size: var(--fs-lg);
}

.btn-primary {
    background-color: var(--primary);
    color: #fff;
}
.btn-primary:hover {
    background-color: var(--primary-hover);
    box-shadow: 0 4px 10px rgba(15, 118, 110, 0.25);
}

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

.btn-outline {
    background: transparent;
    border-color: var(--border);
    color: var(--text-main);
}
.btn-outline:hover {
    background: var(--bg-body);
    border-color: var(--gray-300);
}

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

/* إجراء خطِر ثانوي: هادئ حتى لا يكون أبرز من الإجراء الآمن بجانبه */
.btn-danger-outline {
    background: #fff;
    border-color: var(--red-200);
    color: var(--danger-dark);
}
.btn-danger-outline:hover {
    background: var(--danger-light);
    border-color: var(--red-300);
}

.btn-block {
    width: 100%;
}

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

/* الجداول (Data Tables) */
.table-responsive {
    width: 100%;
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: right;
    font-size: var(--fs-base);
}

.data-table th {
    background-color: var(--gray-50);
    color: var(--gray-600);
    font-weight: 700;
    padding: 14px 16px;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

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

.data-table tr:hover td {
    background-color: var(--gray-50);
}

/* شارات الحالة (Badges) */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: var(--fs-sm);
    font-weight: 700;
    white-space: nowrap;
}

.badge-success { background: var(--success-light); color: var(--success-dark); }
.badge-danger { background: var(--danger-light); color: var(--danger-dark); }
.badge-warning { background: var(--accent-light); color: var(--warning-dark); }
.badge-info { background: var(--info-light); color: var(--info-dark); }
.badge-neutral { background: var(--gray-100); color: var(--gray-600); }

/* النماذج وحقول الإدخال */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}

.form-group label {
    font-size: var(--fs-base);
    font-weight: 700;
    color: var(--text-main);
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background-color: #fff;
    color: var(--text-main);
    font-size: var(--fs-base);
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: var(--ring);
}

.form-hint {
    font-size: var(--fs-sm);
    color: var(--text-muted);
}

/* النوافذ المنبثقة (Modals) */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.25s ease;
}

.modal-backdrop.show {
    opacity: 1;
    visibility: visible;
}

.modal-dialog {
    background: #fff;
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-xl);
    transform: scale(0.95);
    transition: transform 0.25s ease;
    overflow: hidden;
}

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

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

.modal-header h3 {
    font-size: var(--fs-xl);
    font-weight: 800;
}

.modal-close-btn {
    background: none;
    border: none;
    font-size: var(--fs-2xl);
    cursor: pointer;
    color: var(--text-muted);
    padding: 4px;
}

/* ترويسة ملونة للنوافذ: يُحدَّد اللون عبر --hero-from و --hero-to */
.modal-header.modal-hero {
    background: linear-gradient(135deg, var(--hero-from, var(--primary)) 0%, var(--hero-to, var(--primary-strong)) 100%);
    color: #ffffff;
    padding: 18px 22px;
    border-bottom: none;
}
.modal-hero-lockup {
    display: flex;
    align-items: center;
    gap: 12px;
}
.modal-hero-icon {
    font-size: var(--fs-4xl);
    background: rgba(255, 255, 255, 0.2);
    width: 46px;
    height: 46px;
    flex-shrink: 0;
    border-radius: var(--radius-xl);
    display: flex;
    align-items: center;
    justify-content: center;
}
.modal-hero h3 {
    margin: 0;
    font-size: var(--fs-xl);
    font-weight: 900;
    color: #ffffff;
    line-height: 1.3;
}
.modal-hero p {
    margin: 3px 0 0 0;
    font-size: var(--fs-sm);
    color: rgba(255, 255, 255, 0.85);
}
.modal-hero-badge {
    display: inline-block;
    font-size: var(--fs-xs);
    font-weight: 800;
    background: rgba(255, 255, 255, 0.22);
    color: #ffffff;
    padding: 2px 10px;
    border-radius: var(--radius-full);
    margin-bottom: 4px;
    letter-spacing: 0.3px;
}
.modal-hero .modal-close-btn {
    color: #ffffff;
    font-size: var(--fs-3xl);
    opacity: 0.8;
    transition: opacity 0.2s;
}
.modal-hero .modal-close-btn:hover {
    opacity: 1;
}

/* بطاقات نافذة تخصيص المظهر: يُحدَّد اللون عبر --hub-color و --hub-soft و --hub-line */
.hub-card {
    background: #ffffff;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 16px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    transition: border-color 0.2s;
}
.hub-card:hover {
    border-color: var(--hub-color, var(--primary));
}
.hub-card-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: var(--fs-3xl);
}
.hub-card-tag {
    background: var(--hub-soft, var(--primary-subtle));
    color: var(--hub-color, var(--primary));
    border: 1px solid var(--hub-line, var(--teal-200));
    font-size: var(--fs-xs);
    font-weight: 800;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
}
.hub-card h4 {
    margin: 0 0 4px 0;
    font-size: var(--fs-lg);
    color: var(--gray-900);
    font-weight: 800;
}
.hub-card p {
    margin: 0 0 14px 0;
    font-size: var(--fs-sm);
    color: var(--gray-500);
    line-height: 1.4;
}
.hub-card-actions {
    display: flex;
    gap: 6px;
}
.hub-card-actions .btn-primary {
    flex: 1;
    justify-content: center;
    font-weight: 800;
}
.hub-card-actions .btn-outline {
    padding: 6px 10px;
}

/* قائمة خيارات الاختيار المتعددة (مثل نافذة إعادة ضبط البيانات) */
.check-option {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: var(--fs-base);
    font-weight: 700;
    color: var(--gray-800);
}
.check-option input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    flex-shrink: 0;
}
.check-option-note {
    font-weight: 500;
    color: var(--gray-500);
    font-size: var(--fs-sm);
}

/* بطاقة حقل في صفحة الإعدادات */
.settings-field-card {
    background: var(--gray-50);
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius-md);
    padding: 16px;
}
.settings-field-card label {
    font-size: var(--fs-sm);
    font-weight: 800;
    color: var(--gray-800);
    display: block;
    margin-bottom: 6px;
}
.settings-field-card .form-control {
    font-size: var(--fs-base);
    font-weight: 700;
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    background: var(--gray-50);
}

/* جدول الحصص الشبكي (Timetable Grid) */
.timetable-matrix {
    width: 100%;
    border-collapse: separate;
    border-spacing: 4px;
}

.timetable-matrix th {
    background: var(--gray-100);
    padding: 6px 4px;
    text-align: center;
    font-size: var(--fs-sm);
    font-weight: 800;
    border-radius: var(--radius-sm);
    color: var(--gray-700);
}

.timetable-matrix td {
    vertical-align: top;
    padding: 0;
    height: 56px;
    min-width: 105px;
}

.tt-day-col {
    background: var(--gray-200) !important;
    color: var(--primary) !important;
    font-weight: 900 !important;
    width: 95px;
}

.slot-card {
    height: 100%;
    min-height: 52px;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 4px 6px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    cursor: grab;
    transition: all 0.2s;
    user-select: none;
    position: relative;
}

.slot-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.slot-card.dragging {
    opacity: 0.4;
    transform: scale(0.95);
}

.is-dragging-slot .slot-card:not(.dragging) {
    pointer-events: none;
}

.drag-valid-target-row {
    background-color: var(--green-50) !important;
}
.drag-valid-target-row .tt-day-col {
    background-color: var(--green-100) !important;
    border-right: 4px solid var(--green-600) !important;
}
.drag-valid-target-row td {
    border-top: 1.5px dashed var(--green-600) !important;
    border-bottom: 1.5px dashed var(--green-600) !important;
}

.timetable-matrix td.drag-hover {
    background-color: var(--green-200) !important;
    outline: 2px dashed var(--green-700) !important;
}

.slot-card.is-reserved {
    background-color: var(--rose-50);
    border: 1px dashed #f43f5e;
    cursor: not-allowed;
}

.slot-card.is-reserved .slot-subject {
    color: var(--rose-700);
    font-weight: 800;
}

/* المعلم انصرف بحسب موعد مجموعته (ليست تفريغاً) */
.slot-card.is-departed {
    background: repeating-linear-gradient(135deg, var(--gray-50) 0 6px, var(--gray-100) 6px 12px);
    border: 1px solid var(--gray-300);
    cursor: pointer;
}
.slot-card.is-departed .slot-subject { color: var(--gray-600); font-weight: 800; }
.slot-card.is-departed .slot-detail { color: var(--gray-500); }

/* تمييز الحصص المتكررة باللون الأحمر في نفس اليوم لنفس المادة والفصل والمعلم */
.slot-card.is-duplicate {
    background-color: #fff5f5 !important;
    border: 1.5px solid var(--danger) !important;
    border-right: 5px solid var(--red-600) !important;
    box-shadow: 0 2px 6px rgba(220, 38, 38, 0.15);
}

.slot-card.is-duplicate:hover {
    border-color: var(--danger-dark) !important;
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.25);
}

.slot-card.is-duplicate .slot-subject {
    color: var(--red-800) !important;
    font-weight: 900 !important;
}

.slot-card.is-duplicate .slot-detail {
    color: var(--danger-dark) !important;
    font-weight: 700 !important;
}

.slot-duplicate-tag {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: var(--fs-2xs);
    font-weight: 800;
    color: var(--red-600);
    background: var(--danger-light);
    padding: 1px 5px;
    border-radius: var(--radius-xs);
    border: 1px solid var(--red-300);
    margin-top: 3px;
    width: fit-content;
    white-space: nowrap;
}

/* عند تعطيل تمييز التكرار */
.hide-duplicate-highlights .slot-card.is-duplicate {
    background-color: #ffffff !important;
    border: 1px solid var(--border) !important;
    box-shadow: none !important;
}
.hide-duplicate-highlights .slot-card.is-duplicate .slot-subject {
    color: var(--gray-900) !important;
}
.hide-duplicate-highlights .slot-card.is-duplicate .slot-duplicate-tag {
    display: none !important;
}

/* تصميم زر وشارة تثبيت الحصة 📌 */
/* أزرار الأيقونات داخل بطاقات الحصص — مقاس موحد في جدول المعلمين والفصول والعام والتسكين اليدوي */
.slot-pin-btn,
.builder-slot-btn,
.builder-remove-btn {
    width: 22px;
    height: 22px;
    min-width: 22px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    line-height: 1;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

.slot-pin-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all 0.15s ease;
    opacity: 0.45;
}

.builder-slot-btn {
    background: rgba(15, 118, 110, 0.12);
    color: var(--primary);
    border: none;
    cursor: pointer;
    transition: all 0.15s ease;
}

.slot-card:hover .slot-pin-btn {
    opacity: 1;
}

.slot-pin-btn.is-active {
    opacity: 1;
    background: var(--warning-light);
    border: 1px solid var(--amber-200);
    box-shadow: 0 1px 3px rgba(217, 119, 6, 0.2);
}

.slot-pin-btn:hover {
    transform: scale(1.18);
    opacity: 1;
}

.slot-card.is-pinned-slot {
    background-color: #fffdf5 !important;
    border-color: var(--amber-500) !important;
    box-shadow: 0 1px 4px rgba(245, 158, 11, 0.15);
}

.slot-pinned-tag {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    font-size: var(--fs-2xs);
    font-weight: 800;
    color: var(--amber-700);
    background: var(--warning-light);
    padding: 1px 5px;
    border-radius: var(--radius-xs);
    border: 1px solid var(--amber-200);
    margin-top: 3px;
    width: fit-content;
    white-space: nowrap;
}

.slot-card.is-empty {
    border: 1px dashed var(--gray-300);
    background: var(--gray-50);
    cursor: pointer;
    align-items: center;
    justify-content: center;
}

.slot-card.is-empty:hover {
    background: var(--gray-100);
    border-color: var(--primary);
}

.slot-subject {
    font-size: var(--fs-sm);
    font-weight: 800;
    color: var(--gray-900);
    line-height: 1.2;
}

.slot-detail {
    font-size: var(--fs-2xs);
    color: var(--gray-600);
    font-weight: 600;
    line-height: 1.2;
}

/* ===================================================
   تحسينات التصميم الاحترافي للجدول المدرسي (Timetable Pro UI)
   =================================================== */

/* شريحة النسخة النشطة في رأس الجدول */
.tt-active-version-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--green-50);
    border: 1px solid var(--green-200);
    padding: 6px 12px;
    border-radius: var(--radius-full);
    font-size: var(--fs-sm);
    color: var(--green-800);
    cursor: pointer;
    transition: all 0.2s ease;
}

.tt-active-version-chip:hover {
    background: var(--green-100);
    border-color: #86efac;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(22, 101, 52, 0.12);
}

.tt-active-version-chip .pulse-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--green-600);
    box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.7);
    animation: pulseDot 2s infinite;
}

@keyframes pulseDot {
    0% { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.7); }
    70% { box-shadow: 0 0 0 6px rgba(22, 163, 74, 0); }
    100% { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0); }
}

.tt-active-version-chip .chip-link {
    font-size: var(--fs-xs);
    color: var(--emerald-600);
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* شريط التحكم المقطعي (Segmented Control) لعروض الجدول */
.tt-segmented-control {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--gray-100);
    padding: 4px;
    border-radius: var(--radius-md);
    border: 1px solid var(--gray-200);
}

.tt-seg-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--gray-600);
    font-size: var(--fs-base);
    font-weight: 700;
    cursor: pointer;
    transition: all 0.18s ease;
    user-select: none;
}

.tt-seg-btn:hover {
    color: var(--gray-900);
    background: rgba(255, 255, 255, 0.6);
}

.tt-seg-btn.active {
    background: #ffffff;
    color: var(--primary);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
    font-weight: 800;
}

/* شريط تحكم وتصفية الجدول */
.tt-toolbar-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 14px;
    background: #fafafa;
    border-bottom: 1px solid var(--border);
}

/* رأس بطاقة اليوم في الجدول العام - تصميم مدمج ومريح للرؤية */
.tt-day-card {
    margin-bottom: 14px;
    background: #ffffff;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.02);
    transition: box-shadow 0.2s ease;
}

.tt-day-card:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.tt-day-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 12px;
    background: linear-gradient(to left, var(--gray-50), var(--gray-100));
    border-bottom: 1px solid var(--gray-200);
}

.tt-day-title {
    display: flex;
    align-items: center;
    gap: 8px;
}

.tt-day-title h4 {
    margin: 0;
    font-size: var(--fs-base);
    font-weight: 800;
    color: var(--gray-900);
}

.tt-day-bullet {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary);
}

.tt-day-badge {
    background: #ffffff;
    color: var(--gray-600);
    font-size: var(--fs-xs);
    font-weight: 700;
    padding: 2px 8px;
    border-radius: var(--radius-xs);
    border: 1px solid var(--gray-300);
}

/* تزيين الخلية الشاغرة بأناقة مدمجة */
.slot-card.is-empty {
    border: 1px dashed var(--gray-300);
    background: #fbfcfe;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    min-height: 48px !important;
}

.slot-card.is-empty:hover {
    background: var(--primary-subtle);
    border-color: var(--teal-500);
    transform: scale(1.01);
}

/* «شاغرة» تظهر عند المرور فقط، فلا تمتلئ الشبكة بنص مكرر */
.slot-card.is-empty .empty-slot-text {
    font-size: var(--fs-2xs);
    font-weight: 700;
    color: var(--gray-400);
    opacity: 0;
    transition: opacity 0.15s, color 0.2s;
}

.slot-card.is-empty:hover .empty-slot-text,
.slot-card.is-empty:focus-within .empty-slot-text,
.drag-over .slot-card.is-empty .empty-slot-text {
    opacity: 1;
    color: var(--primary-hover);
}

@media (hover: none) {
    .slot-card.is-empty .empty-slot-text { opacity: 0.6; }
}

/* ===================================================
   صفحة النسخ الاحتياطي والنماذج (Backup & Versions Page)
   =================================================== */

/* شبكة المؤشرات العلوية للنسخ */
.backup-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.backup-stat-card {
    background: #ffffff;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 16px 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.03);
}

.backup-stat-card.active-card {
    border: 1.5px solid var(--success);
    background: linear-gradient(135deg, #ffffff 60%, var(--green-50) 100%);
}

.backup-stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    background: var(--gray-100);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--fs-2xl);
    flex-shrink: 0;
}

.backup-stat-card.active-card .stat-icon {
    background: var(--green-100);
}

.backup-stat-card .stat-info {
    display: flex;
    flex-direction: column;
}

.backup-stat-card .stat-label {
    font-size: var(--fs-sm);
    font-weight: 700;
    color: var(--gray-500);
    margin-bottom: 2px;
}

.backup-stat-card .stat-val {
    font-size: var(--fs-lg);
    font-weight: 800;
    color: var(--gray-900);
    line-height: 1.2;
}

.backup-stat-card .stat-sub {
    font-size: var(--fs-sm);
    color: var(--gray-400);
    margin-top: 2px;
}

/* بطاقة الحفظ السريع للنسخة */
.backup-quick-create-card {
    background: linear-gradient(to left, var(--gray-50), var(--blue-50));
    border: 1.5px solid var(--blue-200);
    border-radius: var(--radius-lg);
    padding: 16px 20px;
    margin-bottom: 26px;
}

/* شبكة بطاقات النسخ الاحتياطية */
.backup-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}

.backup-version-card {
    background: #ffffff;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 18px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 14px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
    transition: all 0.22s ease;
    position: relative;
}

.backup-version-card:hover {
    border-color: var(--gray-300);
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
}

.backup-version-card.is-active {
    border-color: var(--success);
    box-shadow: 0 4px 16px rgba(16, 185, 129, 0.12);
    background: linear-gradient(to bottom, #ffffff, #fbfdfc);
}

.backup-version-card .card-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
}

.backup-version-card .version-name {
    font-size: var(--fs-lg);
    font-weight: 800;
    color: var(--gray-900);
    line-height: 1.3;
}

.backup-version-card .meta-row {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: var(--fs-sm);
    color: var(--gray-500);
    margin-top: 6px;
    flex-wrap: wrap;
}

.backup-version-card .notes-text {
    font-size: var(--fs-sm);
    color: var(--gray-600);
    background: var(--gray-50);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    border-right: 3px solid var(--gray-300);
    margin-top: 8px;
    font-style: italic;
    line-height: 1.4;
}

.backup-version-card .card-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding-top: 12px;
    border-top: 1px solid var(--gray-100);
    margin-top: auto;
    flex-wrap: wrap;
}

/* التنبيهات المنبثقة (Toast Notifications) */
#toast-container {
    position: fixed;
    bottom: 24px;
    left: 24px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 380px;
}

.toast-msg {
    background: var(--gray-800);
    color: #fff;
    border-radius: var(--radius-md);
    padding: 14px 18px;
    font-size: var(--fs-base);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: var(--shadow-lg);
    animation: toastSlideIn 0.3s ease;
}

.toast-msg.success { background: var(--success-dark); border-right: 4px solid #34d399; }
.toast-msg.error { background: #881337; border-right: 4px solid #fb7185; }
.toast-msg.warning { background: #78350f; border-right: 4px solid #fbbf24; }

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

/* شاشة تسجيل الدخول */
.login-body {
    background: linear-gradient(135deg, var(--gray-900) 0%, var(--primary) 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-card {
    background: #ffffff;
    border-radius: var(--radius-lg);
    padding: 36px;
    width: 100%;
    max-width: 440px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

.login-header {
    text-align: center;
    margin-bottom: 28px;
}

.login-header .logo-badge {
    width: 60px;
    height: 60px;
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 14px;
    box-shadow: 0 8px 16px rgba(15, 118, 110, 0.25);
}

.login-header h1 {
    font-size: var(--fs-2xl);
    font-weight: 800;
    color: var(--text-main);
    margin-bottom: 4px;
}

.login-header p {
    font-size: var(--fs-base);
    color: var(--text-muted);
}

.wasender-notice-box {
    background-color: var(--primary-subtle);
    border: 1px solid var(--teal-200);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    margin-bottom: 20px;
    font-size: var(--fs-sm);
    color: var(--primary-strong);
    display: flex;
    gap: 10px;
    align-items: center;
}

/* ======================================================== */
/* استجابة الجوال المتقدمة لكافة شاشات التطبيق (320px - 992px) */
/* ======================================================== */

/* 1. الشاشات اللوحية والمتوسطة (أقل من 992px) */
@media (max-width: 992px) {
    .sidebar {
        position: fixed !important;
        top: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 285px !important;
        max-width: 86vw !important;
        transform: translateX(100%) !important;
        z-index: 2000 !important;
        box-shadow: -10px 0 35px rgba(0, 0, 0, 0.5) !important;
        transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1) !important;
    }
    
    .sidebar.open {
        transform: translateX(0) !important;
    }
    
    .sidebar-close-btn {
        display: inline-flex !important;
    }
    
    .main-wrapper {
        margin-right: 0 !important;
        width: 100% !important;
        min-width: 0 !important;
    }
    
    .menu-toggle-btn {
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        width: 42px !important;
        height: 42px !important;
        border-radius: var(--radius-sm) !important;
        background: var(--bg-body) !important;
        border: 1.5px solid var(--border) !important;
        color: var(--primary) !important;
        cursor: pointer !important;
        flex-shrink: 0 !important;
    }
    .menu-toggle-btn:hover {
        background: var(--primary-subtle) !important;
        border-color: var(--primary) !important;
    }
    
    .top-header {
        height: auto !important;
        min-height: 60px !important;
        padding: 10px 16px !important;
        gap: 12px !important;
        flex-wrap: wrap !important;
    }
    
    .content-area {
        padding: 16px 12px !important;
    }
    
    .kpi-grid {
        grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)) !important;
        gap: 10px !important;
    }
    
    .kpi-card {
        padding: 14px 12px !important;
    }
    .kpi-data h3 {
        font-size: var(--fs-2xl) !important;
    }
    .kpi-data p {
        font-size: var(--fs-sm) !important;
    }
    .kpi-icon {
        width: 38px !important;
        height: 38px !important;
    }
    .kpi-icon svg {
        width: 20px !important;
        height: 20px !important;
    }
    
    /* حاويات الجداول مع التمرير الأفقي السلس */
    .table-responsive,
    .timetable-container,
    .matrix-wrapper,
    .table-container {
        width: 100% !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        position: relative !important;
        border-radius: var(--radius-md) !important;
    }
    
    /* تثبيت عمود اليوم في جدول الحصص الذكي */
    .timetable-matrix th.tt-day-col,
    .timetable-matrix td.tt-day-col {
        position: sticky !important;
        right: 0 !important;
        z-index: 5 !important;
        background: var(--gray-200) !important;
        box-shadow: -3px 0 8px rgba(0, 0, 0, 0.08) !important;
    }
    
    .timetable-matrix {
        min-width: 740px !important;
    }
    
    .standby-matrix-table {
        min-width: 680px !important;
    }
    
    .data-table {
        min-width: 600px !important;
    }
}

/* 2. الشاشات الصغيرة والهواتف (أقل من 768px) */
@media (max-width: 768px) {
    .header-right {
        width: 100% !important;
        justify-content: flex-start !important;
        overflow-x: auto !important;
        padding-bottom: 2px !important;
    }
    
    .school-badge-pill {
        max-width: 180px !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
        font-size: var(--fs-sm) !important;
        padding: 5px 10px !important;
    }
    
    .checklist-card {
        padding: 16px 14px !important;
    }
    .checklist-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 8px !important;
    }
    .steps-list {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
    }
    
    /* شريط أدوات الجدول والحصص */
    .timetable-toolbar,
    .panel-header,
    .card-header-actions,
    .actions-bar {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 10px !important;
    }
    
    .timetable-toolbar .btn,
    .actions-bar .btn,
    .panel-header .btn {
        width: 100% !important;
        justify-content: center !important;
    }
    
    /* النوافذ المنبثقة التفاعلية */
    .modal-dialog {
        max-width: calc(100vw - 16px) !important;
        margin: 8px auto !important;
        max-height: 94vh !important;
        border-radius: var(--radius-md) !important;
    }
    .modal-header {
        padding: 14px 16px !important;
    }
    .modal-header h3 {
        font-size: var(--fs-lg) !important;
    }
    .modal-body {
        padding: 16px 14px !important;
        max-height: calc(94vh - 125px) !important;
    }
    .modal-footer {
        padding: 12px 14px !important;
        flex-direction: column-reverse !important;
        gap: 8px !important;
    }
    .modal-footer .btn {
        width: 100% !important;
        justify-content: center !important;
        min-height: 42px !important;
    }
    
    /* مركز الطباعة والتصدير */
    .print-grid,
    .export-options-grid {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }
    
    /* شاشة تسجيل الدخول */
    .login-card {
        padding: 24px 18px !important;
        border-radius: var(--radius-md) !important;
    }
    .login-header h1 {
        font-size: var(--fs-2xl) !important;
    }
}

/* 3. الشاشات فائقة الصغر (أقل من 480px وحتى 320px) */
@media (max-width: 480px) {
    /* منع التكبير التلقائي المزعج في متصفحات iOS Safari */
    input[type="text"],
    input[type="number"],
    input[data-num],
    input[type="tel"],
    input[type="password"],
    select,
    textarea {
        font-size: var(--fs-lg) !important;
    }
    
    .top-header {
        padding: 8px 10px !important;
    }
    .content-area {
        padding: 12px 8px !important;
    }
    
    .kpi-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px !important;
    }
    .kpi-data h3 {
        font-size: var(--fs-2xl) !important;
    }
    
    .preset-chip {
        padding: 6px 10px !important;
        font-size: var(--fs-sm) !important;
    }
    
    .btn {
        min-height: 40px !important;
    }
    
    .app-dialog-card {
        max-width: calc(100vw - 16px) !important;
        margin: 8px !important;
        border-radius: var(--radius-xl) !important;
    }
    .app-dialog-body {
        padding: 14px 12px !important;
    }
    .app-dialog-title {
        font-size: var(--fs-lg) !important;
    }
    .app-dialog-message {
        font-size: var(--fs-base) !important;
    }
    
    #app-toast-container {
        right: 8px !important;
        left: 8px !important;
        bottom: 12px !important;
    }
    .app-toast-card {
        max-width: 100% !important;
        padding: 10px 12px !important;
    }
}

/* ====================================================
   تأثيرات السحب والإفلات والتبديل بخطوة أو خطوتين
   ==================================================== */
.timetable-matrix td.drag-hover {
    background: var(--emerald-50) !important;
    outline: 2px dashed var(--emerald-600) !important;
    outline-offset: -2px;
    border-radius: var(--radius-sm);
    transition: background 0.15s ease;
}

.slot-card.dragging {
    opacity: 0.45;
    transform: scale(0.96);
    border: 2px dashed var(--primary);
}

/* خيارات الاختيار السريع للمراحل والصفوف والفصول */
.preset-chips-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 6px;
    margin-bottom: 12px;
}

.preset-chip {
    background: var(--gray-50);
    color: var(--gray-700);
    border: 1.5px solid var(--gray-300);
    border-radius: var(--radius-md);
    padding: 7px 14px;
    font-size: var(--fs-base);
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    user-select: none;
}

.preset-chip:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-subtle);
    transform: translateY(-1px);
}

.preset-chip.active {
    background: var(--primary) !important;
    color: #ffffff !important;
    border-color: var(--primary) !important;
    box-shadow: 0 2px 8px rgba(15, 118, 110, 0.3);
}

.preset-chip-number {
    min-width: 48px;
    height: 42px;
    padding: 0 14px;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    font-size: var(--fs-xl);
    font-weight: 800;
    border-radius: var(--radius-md);
}

/* بطاقات وقوائم الصفوف والفصول الديناميكية عند إضافة مرحلة */
.stage-grade-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: #ffffff;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius-md);
    padding: 10px 14px;
    margin-bottom: 8px;
    transition: all 0.2s ease;
}

.stage-grade-row:hover {
    border-color: var(--gray-300);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.03);
}

.stage-grade-row.active {
    border-color: var(--teal-200);
    background: var(--primary-subtle);
}

.stage-grade-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.stage-grade-name {
    font-weight: 800;
    font-size: var(--fs-base);
    color: var(--gray-800);
    white-space: nowrap;
}

.stage-grade-classes-ctrl {
    display: flex;
    align-items: center;
    gap: 8px;
}

.stage-grade-classes-label {
    font-size: var(--fs-sm);
    font-weight: 700;
    color: var(--gray-500);
    white-space: nowrap;
}

.stage-num-stepper {
    display: inline-flex;
    align-items: center;
    background: #ffffff;
    border: 1.5px solid var(--gray-300);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.stage-num-stepper button {
    background: var(--gray-50);
    border: none;
    width: 32px;
    height: 32px;
    font-weight: 800;
    font-size: var(--fs-lg);
    color: var(--gray-700);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease;
    user-select: none;
}

.stage-num-stepper button:hover {
    background: var(--gray-200);
    color: var(--gray-900);
}

.stage-num-stepper input {
    width: 44px;
    height: 32px;
    border: none;
    border-left: 1px solid var(--gray-200);
    border-right: 1px solid var(--gray-200);
    text-align: center;
    font-weight: 800;
    font-size: var(--fs-md);
    color: var(--primary);
    outline: none;
    -moz-appearance: textfield;
}

.stage-num-stepper input::-webkit-outer-spin-button,
.stage-num-stepper input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* منطقة سحب وإفلات ورفع ملفات الإكسل */
.upload-dropzone {
    border: 2px dashed var(--primary-hover);
    background: var(--primary-subtle);
    border-radius: var(--radius-lg);
    padding: 30px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.25s ease;
    margin-bottom: 16px;
    position: relative;
}

.upload-dropzone:hover,
.upload-dropzone.dragover {
    background: var(--primary-light);
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(15, 118, 110, 0.15);
}

.upload-dropzone-icon {
    font-size: 40px;
    margin-bottom: 8px;
    color: var(--primary);
}

.upload-dropzone-title {
    font-weight: 800;
    font-size: var(--fs-lg);
    color: #134e4a;
    margin-bottom: 4px;
}

.upload-dropzone-desc {
    font-size: var(--fs-sm);
    color: var(--primary-strong);
}

.excel-preview-container {
    max-height: 280px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin-top: 12px;
    background: #fff;
}

/* مدخلات التعديل المباشر في الجداول (Inline Editable Table) */
.table-inline-input {
    width: 100%;
    border: 1.5px solid transparent;
    background: transparent;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    font-family: 'Cairo', sans-serif;
    font-size: var(--fs-base);
    font-weight: 600;
    color: var(--text-main);
    transition: all 0.2s ease;
    outline: none;
}

.table-inline-input:hover {
    background: var(--gray-50);
    border-color: var(--gray-300);
}

.table-inline-input:focus {
    background: #ffffff;
    border-color: var(--primary);
    box-shadow: var(--ring);
}

.table-inline-input.number {
    text-align: center;
    font-weight: 800;
}

.inline-save-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: var(--fs-sm);
    padding: 3px 7px;
    border-radius: var(--radius-xs);
    transition: opacity 0.3s ease;
    white-space: nowrap;
}

.inline-save-indicator.saving {
    color: var(--info);
    background: var(--info-light);
}

.inline-save-indicator.saved {
    color: var(--green-700);
    background: var(--green-100);
}

.inline-save-indicator.error {
    color: var(--danger-dark);
    background: var(--danger-light);
}

.table-inline-input.is-saving {
    border-color: #38bdf8 !important;
    background: var(--sky-50) !important;
}

.table-inline-input.is-saved {
    border-color: #22c55e !important;
    background: var(--green-50) !important;
}

/* مصفوفة الإسناد على شكل إكسل (المواد في الصفوف والفصول في الأعمدة) */
.alloc-matrix-wrapper {
    margin-bottom: 12px;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    overflow-x: auto;
}

.alloc-matrix-header-bar {
    padding: 6px 12px;
    background: var(--gray-50);
    border-bottom: 1.5px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.alloc-matrix-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--fs-sm);
    min-width: 600px;
}

.alloc-matrix-table th,
.alloc-matrix-table td {
    border: 1px solid var(--gray-200);
    padding: 3px 6px;
    vertical-align: middle;
}

.alloc-matrix-table thead th {
    background: var(--gray-100);
    color: var(--gray-800);
    font-weight: 800;
    text-align: center;
    padding: 5px 6px;
}

.alloc-matrix-table thead th.subject-col-header {
    text-align: right;
    width: 200px;
    min-width: 180px;
    background: var(--gray-200);
    color: var(--primary);
    font-size: var(--fs-sm);
}

.alloc-matrix-table tbody td.subject-name-cell {
    background: var(--gray-50);
    font-weight: 700;
    color: var(--text-main);
    border-left: 2px solid var(--gray-300);
    padding: 3px 6px;
}

.alloc-matrix-cell {
    min-width: 160px;
    background: #ffffff;
    transition: background 0.2s, border-color 0.2s;
    text-align: center;
    padding: 3px 5px !important;
}

.alloc-matrix-cell:hover {
    background: var(--primary-subtle);
}

/* الخلية غير المسندة - تمييز باللون الأحمر الفاتح */
.alloc-matrix-cell.is-unassigned-cell {
    background-color: var(--rose-50) !important;
    border: 1.5px solid var(--rose-200) !important;
}

.alloc-matrix-cell.is-unassigned-cell:hover {
    background-color: #ffe4e6 !important;
}

/* الخلية المسندة */
.alloc-matrix-cell.is-assigned-cell {
    background-color: #ffffff;
}

.alloc-cell-select {
    width: 100%;
    padding: 2px 5px;
    font-family: 'Cairo', sans-serif;
    font-size: var(--fs-xs); /* خلية كثيفة بارتفاع ثابت 27px */
    font-weight: 600;
    border: 1.5px solid var(--gray-300);
    border-radius: var(--radius-xs);
    background: #ffffff;
    color: var(--gray-700);
    outline: none;
    cursor: pointer;
    height: 27px;
    transition: all 0.2s ease;
}

.alloc-cell-select:focus {
    border-color: var(--primary);
    box-shadow: var(--ring);
}

.alloc-cell-select.is-assigned {
    border-color: var(--success);
    background: var(--green-50);
    color: var(--success-dark);
    font-weight: 700;
}

/* القائمة المنسدلة غير المسندة */
.alloc-cell-select.is-unassigned {
    border-color: var(--red-400);
    background: #fffafa;
    color: var(--red-800);
    font-weight: 700;
}

.alloc-cell-select.is-unassigned:focus {
    border-color: var(--red-600);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2);
}

.alloc-cell-badge {
    font-size: var(--fs-2xs);
    margin-top: 1px;
    display: inline-block;
    padding: 0;
    line-height: 1.1;
}

.alloc-badge-unassigned {
    background: var(--danger-light);
    color: var(--danger-dark);
    font-weight: 700;
    border: 1px solid var(--red-300);
    padding: 1px 5px;
    border-radius: var(--radius-xs);
    font-size: var(--fs-2xs);
    display: inline-block;
}

.alloc-badge-assigned {
    background: var(--green-100);
    color: var(--green-700);
    font-weight: 700;
    border: 1px solid var(--green-200);
    padding: 1px 5px;
    border-radius: var(--radius-xs);
    font-size: var(--fs-2xs);
    display: inline-block;
}

.alloc-cell-flash {
    animation: allocFlashGreen 1.2s ease;
}

@keyframes allocFlashGreen {
    0% { background-color: #86efac; }
    100% { background-color: transparent; }
}

/* ======================================================== */
/* مساحة العمل التفاعلية للإسناد الذكي (Workspace Mode)     */
/* ======================================================== */

/* الترويسة المدمجة النحيفة لمنع أي هدر رأسي وجعل مساحة العمل واضحة بالكامل */
/* ================================================================ */
/* صفحة الإسناد — التصميم المطوّر v3 (رؤية واضحة + تجربة سلسة) */
/* ================================================================ */

.alloc-unified-panel {
    border-radius: var(--radius-xl);
    overflow: hidden;
}

/* -------------------------------------------------- */
/* الشريط العلوي النحيف الموحّد */
/* -------------------------------------------------- */
.alloc-topbar {
    background: #ffffff;
    border-bottom: 1.5px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 0;
    gap: 0;
}

.alloc-topbar-row-1 {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 5px 14px;
    border-bottom: 1px solid var(--gray-100);
    min-height: 36px;
    width: 100%;
    box-sizing: border-box;
}

.alloc-topbar-row-2 {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 14px;
    background: var(--gray-50);
    min-height: 32px;
    width: 100%;
    flex-wrap: wrap;
    box-sizing: border-box;
}

.alloc-topbar-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.alloc-topbar-icon {
    width: 30px;
    height: 30px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--primary), var(--success));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--fs-lg);
    flex-shrink: 0;
}

.alloc-topbar-title {
    font-size: var(--fs-md);
    font-weight: 800;
    color: var(--gray-900);
    white-space: nowrap;
}

.alloc-topbar-divider {
    width: 1px;
    height: 28px;
    background: var(--gray-200);
    flex-shrink: 0;
}

/* شريط التقدم المدمج */
.alloc-progress-compact {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 180px;
}

.alloc-progress-labels-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.alloc-progress-pct {
    font-size: var(--fs-sm);
    font-weight: 800;
    color: var(--primary);
    white-space: nowrap;
}

.alloc-progress-pills {
    display: flex;
    gap: 6px;
}

.alloc-pill {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 1px 6px;
    border-radius: var(--radius-md);
    font-size: var(--fs-xs);
    font-weight: 700;
}

.alloc-pill.unassigned {
    background: var(--rose-50);
    color: var(--rose-700);
    border: 1px solid var(--rose-200);
}

.alloc-pill.assigned {
    background: var(--green-50);
    color: var(--green-700);
    border: 1px solid var(--green-200);
}

.alloc-pill .dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
}

.alloc-pill.unassigned .dot { background: var(--rose-600); }
.alloc-pill.assigned .dot   { background: var(--success); }

/* فلاتر مدمجة */
.alloc-topbar-filters {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.alloc-filter-group {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.alloc-filter-group label {
    font-size: var(--fs-sm);
    font-weight: 700;
    color: var(--gray-500);
    margin: 0;
    white-space: nowrap;
}

.alloc-filter-select {
    padding: 2px 8px !important;
    font-size: var(--fs-sm) !important;
    height: 29px !important;
    border-radius: var(--radius-sm) !important;
    border: 1px solid var(--gray-300) !important;
    background: var(--gray-50) !important;
    font-weight: 600 !important;
    color: var(--gray-800) !important;
    cursor: pointer;
    outline: none;
}

.alloc-filter-select:focus {
    border-color: var(--primary-hover) !important;
    box-shadow: 0 0 0 2px rgba(13,148,136,0.15);
}

/* أزرار التبديل والأدوات */
.alloc-topbar-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-right: auto;
    flex-wrap: wrap;
}

.alloc-view-switcher {
    display: flex;
    background: var(--gray-100);
    border-radius: var(--radius-md);
    padding: 2px;
    gap: 2px;
}

.alloc-view-tab-btn {
    padding: 4px 10px;
    font-size: var(--fs-sm);
    font-weight: 700;
    border: none;
    background: transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--gray-500);
    transition: all 0.18s;
    white-space: nowrap;
}

.alloc-view-tab-btn.active {
    background: #ffffff;
    color: var(--primary);
    box-shadow: 0 1px 4px rgba(0,0,0,0.10);
}

/* (تم توحيد أنماط مساحة العمل وقوائم المهام في قسم واجهة الإسناد الحديثة بالأسفل) */

/* (تم نقل أنماط شريط التراجع إلى القسم الموحد بالأسفل) */

/* شريط التقدم وزر الأدوات الموحّد */
.alloc-progress-track {
    height: 7px;
    background: var(--gray-200);
    border-radius: var(--radius-full);
    overflow: hidden;
    position: relative;
}

.alloc-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-hover) 0%, var(--success) 100%);
    border-radius: var(--radius-full);
    transition: width 0.4s ease;
}

.alloc-tool-btn {
    font-weight: 700 !important;
    padding: 5px 10px !important;
    font-size: var(--fs-sm) !important;
    border-radius: var(--radius-sm) !important;
}

/* ======================================================== */
/* مصفوفة المواد والأنصبة بنمط إكسل (المواد صفوف والصفوف أعمدة) */
/* ======================================================== */
/* مصفوفة المواد والأنصبة بنمط إكسل المفتوح */
/* ======================================================== */
.subj-unified-panel {
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-lg);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
    overflow: hidden;
    background: #ffffff;
}

.subj-unified-panel .panel-body {
    padding: 0 !important;
}

.subj-matrix-wrapper {
    margin-bottom: 0;
    background: #ffffff;
    border: none;
    border-radius: 0;
    box-shadow: none;
    overflow: auto;
    position: relative;
    scrollbar-width: thin;
    scrollbar-color: var(--gray-300) var(--gray-50);
}

.subj-matrix-wrapper::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.subj-matrix-wrapper::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: var(--radius-xs);
}

.subj-matrix-wrapper::-webkit-scrollbar-thumb:hover {
    background: var(--gray-400);
}

.subj-matrix-header-bar {
    padding: 12px 18px;
    background: var(--gray-50);
    border-bottom: 1.5px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.subj-matrix-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: var(--fs-base);
    min-width: 750px;
}

.subj-matrix-table th,
.subj-matrix-table td {
    border: 1px solid var(--gray-200);
    padding: 6px 8px;
    vertical-align: middle;
}

.subj-matrix-table thead {
    position: sticky;
    top: 0;
    z-index: 20;
}

.subj-matrix-table thead th {
    position: sticky;
    top: 0;
    z-index: 20;
    background: var(--gray-100);
    color: var(--gray-800);
    font-weight: 800;
    text-align: center;
    border-bottom: 2px solid var(--gray-300);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.subj-matrix-table thead th.subj-col-header {
    position: sticky;
    top: 0;
    right: 0;
    z-index: 25;
    text-align: right;
    width: 220px;
    min-width: 200px;
    background: var(--gray-200);
    color: var(--primary);
    border-bottom: 2px solid var(--gray-300);
}

.subj-matrix-table tbody td.subj-name-cell {
    position: sticky;
    right: 0;
    z-index: 10;
    background: #ffffff;
    font-weight: 700;
    color: var(--text-main);
    border-left: 2px solid var(--gray-300);
    box-shadow: -2px 0 4px rgba(0, 0, 0, 0.04);
}

.subj-new-row td.subj-name-cell {
    position: sticky;
    right: 0;
    z-index: 10;
    background: var(--primary-subtle) !important;
    border-left: 2px solid var(--gray-300);
}

.subj-matrix-table tfoot td:first-child {
    position: sticky;
    right: 0;
    z-index: 10;
    background: var(--gray-50);
    border-left: 2px solid var(--gray-300);
}

.subj-name-input {
    width: 100%;
    border: 1px solid transparent;
    background: transparent;
    font-family: 'Cairo', sans-serif;
    font-weight: 700;
    font-size: var(--fs-base);
    color: var(--gray-800);
    padding: 4px 6px;
    border-radius: var(--radius-xs);
    outline: none;
    transition: all 0.2s;
}

.subj-name-input:focus,
.subj-name-input:hover {
    border-color: var(--gray-300);
    background: #ffffff;
}

.subj-matrix-cell {
    text-align: center;
    background: #ffffff;
    padding: 4px !important;
}

.subj-cell-input {
    width: 52px;
    height: 34px;
    text-align: center;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, 'Cairo', sans-serif !important;
    font-feature-settings: "locl" 0 !important;
    -webkit-font-feature-settings: "locl" 0 !important;
    -moz-font-feature-settings: "locl" 0 !important;
    font-variant-numeric: normal tabular-nums !important;
    direction: ltr !important;
    unicode-bidi: isolate !important;
    font-size: var(--fs-md);
    font-weight: 800;
    border: 1.5px solid var(--gray-300);
    border-radius: var(--radius-sm);
    background: var(--gray-50);
    color: var(--gray-900);
    outline: none;
    transition: all 0.2s ease;
    margin: 0 auto;
    display: block;
}

.subj-cell-input:focus {
    border-color: var(--primary);
    background: #ffffff;
    color: var(--gray-900);
    box-shadow: var(--ring);
}

.subj-cell-input.has-quota {
    border-color: var(--success);
    background: var(--green-50);
    color: var(--success-dark);
    font-weight: 800;
}

.subj-cell-flash {
    animation: subjFlashGreen 1.2s ease;
}

@keyframes subjFlashGreen {
    0% { background-color: #86efac; }
    100% { background-color: transparent; }
}

/* سطر إضافة سجل مادة جديد تحت السجلات الحالية كإكسل */
.subj-new-row {
    background: var(--primary-subtle) !important;
    border-top: 2px solid var(--primary-hover) !important;
}

.subj-new-row td {
    background: var(--primary-subtle) !important;
    padding: 8px 6px !important;
}

.subj-new-input-name {
    width: 100%;
    padding: 6px 10px;
    font-family: 'Cairo', sans-serif;
    font-size: var(--fs-base);
    font-weight: 700;
    border: 1.5px solid var(--primary-hover);
    border-radius: var(--radius-sm);
    background: #ffffff;
    color: var(--gray-900);
    outline: none;
}

.subj-new-input-name:focus {
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.2);
}

.subj-new-quota-input {
    width: 52px;
    height: 34px;
    text-align: center;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, 'Cairo', sans-serif !important;
    font-feature-settings: "locl" 0 !important;
    -webkit-font-feature-settings: "locl" 0 !important;
    -moz-font-feature-settings: "locl" 0 !important;
    font-variant-numeric: normal tabular-nums !important;
    direction: ltr !important;
    unicode-bidi: isolate !important;
    font-size: var(--fs-md);
    font-weight: 800;
    border: 1.5px dashed var(--primary-hover);
    border-radius: var(--radius-sm);
    background: #ffffff;
    color: var(--gray-900);
    outline: none;
    margin: 0 auto;
    display: block;
}

.subj-new-quota-input:focus {
    border-style: solid;
    border-color: var(--primary-hover);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.2);
}

.subj-total-cell {
    text-align: center;
    font-weight: 800;
    color: var(--primary);
    background: var(--gray-50);
}

.subj-footer-row {
    background: var(--gray-100) !important;
    font-weight: 800;
}

.subj-footer-row td {
    background: var(--gray-100) !important;
    border-top: 2px solid var(--gray-300) !important;
    color: var(--gray-800);
}

/* ======================================================== */
/* مصفوفة تفريغات وحجوزات المعلمين التفاعلية (✓ و ✕)        */
/* ======================================================== */
.resv-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.resv-teacher-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #ffffff;
    padding: 8px 14px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    flex-wrap: wrap;
    gap: 8px;
}

.resv-teacher-select-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
}

.resv-teacher-select-wrapper label {
    font-weight: 800;
    font-size: var(--fs-base);
    color: var(--gray-800);
    white-space: nowrap;
}

.resv-teacher-select {
    min-width: 220px;
    font-weight: 700;
    font-size: var(--fs-base);
    color: var(--primary);
    border: 1.5px solid var(--primary);
    background: var(--primary-subtle);
    border-radius: var(--radius-sm);
    padding: 5px 12px;
    outline: none;
    cursor: pointer;
}

.resv-stats-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.resv-stat-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 12px;
    border-radius: var(--radius-full);
    font-size: var(--fs-sm);
    font-weight: 700;
}

.resv-stat-pill.available {
    background: var(--emerald-50);
    border: 1px solid #6ee7b7;
    color: var(--success-dark);
}

.resv-stat-pill.reserved {
    background: var(--rose-50);
    border: 1px solid var(--red-300);
    color: var(--rose-800);
}

.resv-matrix-wrapper {
    background: #ffffff;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    overflow-x: auto;
}

.resv-matrix-table {
    width: 100%;
    border-collapse: collapse;
    text-align: center;
    min-width: 680px;
}

.resv-matrix-table th,
.resv-matrix-table td {
    border: 1px solid var(--gray-200);
    padding: 3px 4px;
    vertical-align: middle;
}

.resv-matrix-table th {
    background: var(--gray-50);
    color: var(--gray-800);
    font-weight: 800;
    font-size: var(--fs-sm);
    padding: 6px 4px;
}

.resv-matrix-day-cell {
    background: var(--gray-50);
    font-weight: 800;
    color: var(--primary);
    font-size: var(--fs-sm);
    width: 90px;
    padding: 3px 6px;
    white-space: nowrap;
}

/* بطاقة / زر الحصة التفاعلي المضغوط */
.resv-cell-btn {
    width: 100%;
    min-height: 36px;
    font-size: var(--fs-base); /* بدل حجم الأزرار الافتراضي في المتصفح (13.33px) */
    border: 1.5px solid transparent;
    border-radius: var(--radius-sm);
    background: #ffffff;
    cursor: pointer;
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 4px;
    padding: 3px 6px;
    transition: all 0.15s ease-in-out;
    user-select: none;
    position: relative;
}

.resv-cell-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}

.resv-cell-btn:active {
    transform: translateY(0);
}

/* حالة الحصة: متاحة (الافتراضي) — خانة هادئة بلا نص حتى تبرز التفريغات وحدها */
.resv-cell-btn.is-available {
    background: #ffffff;
    border: 1px dashed var(--gray-200);
    color: var(--gray-400);
}

.resv-cell-btn.is-available:hover {
    background: var(--rose-50);
    border-color: var(--rose-200);
    box-shadow: none;
}

/* النص يبقى لقارئات الشاشة ويُخفى بصرياً */
.resv-cell-btn.is-available .resv-icon,
.resv-cell-btn.is-available .resv-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.resv-cell-btn.is-available::after {
    content: '＋ تفريغ';
    font-size: var(--fs-xs);
    font-weight: 700;
    color: var(--rose-600);
    opacity: 0;
    transition: opacity 0.12s ease;
}

.resv-cell-btn.is-available:hover::after,
.resv-cell-btn.is-available:focus-visible::after {
    opacity: 0.8;
}

.resv-cell-btn.is-available:has(.resv-slot-busy-tag)::after {
    content: none;
}

/* حالة الحصة: محجوزة / مفرغة (✕) */
.resv-cell-btn.is-reserved {
    background: var(--rose-50);
    border-color: var(--red-300);
    color: var(--rose-700);
    animation: resvPop 0.18s ease-out;
}

.resv-cell-btn.is-reserved:hover {
    background: #ffe4e6;
    border-color: var(--red-400);
}

.resv-cell-btn.is-reserved .resv-icon {
    font-size: var(--fs-md);
    font-weight: 900;
    line-height: 1;
    color: var(--rose-600);
}

.resv-cell-btn.is-reserved .resv-label {
    font-size: var(--fs-xs);
    font-weight: 800;
    color: var(--rose-800);
}

/* مؤشر حصة مجدولة في الجدول */
.resv-slot-busy-tag {
    font-size: var(--fs-2xs);
    font-weight: 700;
    background: rgba(15, 118, 110, 0.12);
    color: var(--primary);
    border-radius: var(--radius-xs);
    padding: 1px 3px;
    white-space: nowrap;
    max-width: 95%;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
    text-align: center;
}

@keyframes resvPop {
    0% { transform: scale(0.95); }
    50% { transform: scale(1.03); }
    100% { transform: scale(1); }
}

.resv-day-action-btn {
    padding: 2px 6px;
    font-size: var(--fs-2xs);
    font-weight: 700;
    border-radius: var(--radius-xs);
    border: 1px solid var(--gray-300);
    background: #ffffff;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.resv-day-action-btn:hover {
    background: var(--gray-100);
}

/* ==========================================================================
   نظام التنبيهات والرسائل المتطورة بنفس هوية الموقع (AppDialog & AppToast)
   ========================================================================== */

#app-dialog-backdrop {
    position: fixed;
    inset: 0;
    z-index: 100000;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: appDialogFadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

#app-dialog-backdrop.closing {
    animation: appDialogFadeOut 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.app-dialog-card {
    background: #ffffff;
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 440px;
    box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.25), 0 0 0 1px rgba(226, 232, 240, 0.9);
    overflow: hidden;
    animation: appDialogPopIn 0.26s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    display: flex;
    flex-direction: column;
    direction: rtl;
    text-align: right;
    font-family: 'Cairo', sans-serif;
}

#app-dialog-backdrop.closing .app-dialog-card {
    animation: appDialogPopOut 0.18s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.app-dialog-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 18px;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-100);
}

.app-dialog-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: var(--fs-base);
    font-weight: 800;
    color: var(--gray-900);
}

.app-dialog-brand-badge {
    background: rgba(15, 118, 110, 0.1);
    color: var(--primary);
    font-size: var(--fs-xs);
    font-weight: 700;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    border: 1px solid rgba(15, 118, 110, 0.2);
}

.app-dialog-close {
    background: transparent;
    border: none;
    color: var(--gray-400);
    width: 28px;
    height: 28px;
    border-radius: var(--radius-md);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
    font-size: var(--fs-xl);
    line-height: 1;
}

.app-dialog-close:hover {
    background: var(--gray-200);
    color: var(--gray-900);
}

.app-dialog-body {
    padding: 24px 22px 18px 22px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.app-dialog-icon-wrapper {
    width: 64px;
    height: 64px;
    border-radius: var(--radius-xl);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 14px;
    position: relative;
    box-shadow: 0 8px 16px -4px rgba(0, 0, 0, 0.06);
}

.app-dialog-icon-wrapper svg {
    width: 32px;
    height: 32px;
}

/* سمات الحالات */
.app-dialog-icon-wrapper.info {
    background: var(--primary-subtle);
    color: var(--primary);
    border: 2px solid var(--primary-light);
}
.app-dialog-icon-wrapper.success {
    background: var(--emerald-50);
    color: var(--emerald-600);
    border: 2px solid var(--emerald-200);
}
.app-dialog-icon-wrapper.warning {
    background: var(--amber-50);
    color: var(--warning);
    border: 2px solid var(--amber-200);
}
.app-dialog-icon-wrapper.error {
    background: var(--red-50);
    color: var(--red-600);
    border: 2px solid var(--red-200);
}
.app-dialog-icon-wrapper.confirm {
    background: #eef2ff;
    color: var(--secondary);
    border: 2px solid #c7d2fe;
}

.app-dialog-title {
    font-size: var(--fs-xl);
    font-weight: 800;
    color: var(--gray-900);
    margin: 0 0 8px 0;
    line-height: 1.4;
}

.app-dialog-message {
    font-size: var(--fs-md);
    font-weight: 500;
    color: var(--gray-600);
    line-height: 1.65;
    margin: 0;
    white-space: pre-line;
    word-break: break-word;
    max-height: 240px;
    overflow-y: auto;
    padding: 0 4px;
}

.app-dialog-footer {
    padding: 14px 22px 22px 22px;
    display: flex;
    gap: 12px;
    justify-content: center;
    border-top: 1px solid var(--gray-50);
}

.app-dialog-btn {
    font-family: 'Cairo', sans-serif;
    font-size: var(--fs-md);
    font-weight: 700;
    padding: 10px 24px;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all 0.18s ease;
    min-width: 110px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    outline: none;
    border: 1px solid transparent;
}

.app-dialog-btn:focus-visible {
    box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.35);
}

.app-dialog-btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(15, 118, 110, 0.25);
}
.app-dialog-btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-strong), var(--primary));
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(15, 118, 110, 0.35);
}
.app-dialog-btn-primary:active {
    transform: translateY(0);
}

.app-dialog-btn-danger {
    background: linear-gradient(135deg, var(--danger), var(--red-600));
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.25);
}
.app-dialog-btn-danger:hover {
    background: linear-gradient(135deg, var(--red-600), var(--danger-dark));
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(239, 68, 68, 0.35);
}

.app-dialog-btn-secondary {
    background: var(--gray-100);
    color: var(--gray-600);
    border: 1px solid var(--gray-300);
}
.app-dialog-btn-secondary:hover {
    background: var(--gray-200);
    color: var(--gray-900);
}

/* حاوية التنبيهات السريعة (Toasts) */
#app-toast-container {
    position: fixed;
    top: 24px;
    left: 24px;
    z-index: 100001;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 400px;
    width: calc(100% - 48px);
    pointer-events: none;
    direction: rtl;
    font-family: 'Cairo', sans-serif;
}

.app-toast-card {
    pointer-events: auto;
    background: #ffffff;
    border-radius: var(--radius-xl);
    padding: 12px 16px;
    box-shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.15), 0 0 0 1px rgba(226, 232, 240, 0.9);
    display: flex;
    align-items: flex-start;
    gap: 12px;
    border-right: 4px solid var(--primary);
    animation: appToastSlideDown 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    position: relative;
    overflow: hidden;
    transition: all 0.25s ease;
}

.app-toast-card.closing {
    opacity: 0;
    transform: translateY(-12px) scale(0.95);
}

.app-toast-card.success { border-right-color: var(--success); }
.app-toast-card.error { border-right-color: var(--danger); }
.app-toast-card.warning { border-right-color: var(--amber-500); }
.app-toast-card.info { border-right-color: var(--primary); }

.app-toast-icon {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    margin-top: 2px;
}
.app-toast-card.success .app-toast-icon { color: var(--success); }
.app-toast-card.error .app-toast-icon { color: var(--danger); }
.app-toast-card.warning .app-toast-icon { color: var(--amber-500); }
.app-toast-card.info .app-toast-icon { color: var(--primary); }

.app-toast-content {
    flex: 1;
    min-width: 0;
}
.app-toast-title {
    font-size: var(--fs-base);
    font-weight: 800;
    color: var(--gray-900);
    margin-bottom: 2px;
}
.app-toast-message {
    font-size: var(--fs-base);
    font-weight: 500;
    color: var(--gray-500);
    line-height: 1.45;
    word-break: break-word;
}

.app-toast-close {
    background: none;
    border: none;
    color: var(--gray-400);
    font-size: var(--fs-lg);
    cursor: pointer;
    padding: 0;
    margin-top: 1px;
    transition: color 0.15s;
    line-height: 1;
}
.app-toast-close:hover {
    color: var(--gray-900);
}

/* Keyframe Animations */
@keyframes appDialogFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes appDialogFadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}
@keyframes appDialogPopIn {
    from { opacity: 0; transform: scale(0.88) translateY(12px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes appDialogPopOut {
    from { opacity: 1; transform: scale(1) translateY(0); }
    to { opacity: 0; transform: scale(0.92) translateY(8px); }
}
@keyframes appToastSlideDown {
    from { opacity: 0; transform: translateY(-16px) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ===================================================
   مركز الطباعة والتصدير المدرسي الذكي (Smart Print Hub)
   =================================================== */

/* شريط الحالة المدمج والموجز */
.print-status-strip {
    background: linear-gradient(135deg, var(--green-50) 0%, #ffffff 100%);
    border: 1px solid var(--green-200);
    border-radius: var(--radius-lg);
    padding: 12px 18px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.print-status-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.print-status-pill {
    background: var(--green-100);
    color: var(--green-700);
    font-size: var(--fs-sm);
    font-weight: 800;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.print-status-meta {
    font-size: var(--fs-base);
    font-weight: 700;
    color: var(--gray-800);
    display: flex;
    align-items: center;
    gap: 8px;
}

.print-status-meta span.sep {
    color: var(--gray-300);
}

.print-status-meta span.num {
    color: var(--primary);
    font-weight: 800;
}

/* شريط التبويب الفئوي المقطعي (Category Navigation Tabs) */
.print-category-nav {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--gray-100);
    padding: 5px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--gray-200);
    margin-bottom: 22px;
    overflow-x: auto;
}

.print-category-pill {
    flex: 1;
    min-width: 160px;
    text-align: center;
    padding: 10px 16px;
    font-size: var(--fs-base);
    font-weight: 800;
    color: var(--gray-600);
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    white-space: nowrap;
}

.print-category-pill:hover {
    color: var(--gray-900);
    background: rgba(255, 255, 255, 0.6);
}

.print-category-pill.active {
    background: #ffffff;
    color: var(--primary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* حاوية محتوى الفئات */
.print-category-section {
    display: none;
    animation: fadeInPrint 0.2s ease-in-out;
}

.print-category-section.active {
    display: block;
}

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

/* شبكة البطاقات المدمجة العصرية */
.compact-print-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 18px;
}

.compact-print-card {
    background: #ffffff;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius-xl);
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 14px;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.03);
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.compact-print-card:hover {
    border-color: var(--gray-400);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.07);
}

.compact-print-card.featured {
    border-color: var(--teal-200);
    background: linear-gradient(to bottom, #ffffff 60%, var(--primary-subtle) 100%);
    box-shadow: 0 4px 14px rgba(15, 118, 110, 0.08);
}

.card-top-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.card-title-lockup {
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-icon-avatar {
    width: 42px;
    height: 42px;
    border-radius: var(--radius-md);
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--fs-2xl);
    flex-shrink: 0;
}

.compact-print-card.featured .card-icon-avatar {
    background: var(--primary-light);
    border-color: var(--teal-200);
    color: var(--primary);
}

.card-headings h4 {
    margin: 0;
    font-size: var(--fs-lg);
    font-weight: 800;
    color: var(--gray-900);
    line-height: 1.3;
}

.card-headings span {
    font-size: var(--fs-sm);
    color: var(--gray-500);
    font-weight: 600;
    display: block;
    margin-top: 1px;
}

.card-tag-badge {
    font-size: var(--fs-xs);
    font-weight: 800;
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    white-space: nowrap;
}

.tag-single-page {
    background: var(--primary-light);
    color: var(--primary);
    border: 1px solid var(--teal-200);
}

.tag-multi-page {
    background: #e0e7ff;
    color: #3730a3;
    border: 1px solid #c7d2fe;
}

.tag-excel {
    background: var(--green-100);
    color: var(--green-700);
    border: 1px solid var(--green-200);
}

/* تبديل نطاق الطباعة الفردية/الجماعية */
.scope-switch-bar {
    display: flex;
    background: var(--gray-100);
    padding: 3px;
    border-radius: var(--radius-md);
    gap: 3px;
    margin-top: 4px;
}

.scope-btn {
    flex: 1;
    padding: 5px 8px;
    font-size: var(--fs-sm);
    font-weight: 700;
    border: none;
    background: transparent;
    color: var(--gray-500);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s ease;
}

.scope-btn.active {
    background: #ffffff;
    color: var(--primary);
    font-weight: 800;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.scope-select-wrap {
    margin-top: 8px;
}

.compact-select {
    width: 100%;
    padding: 7px 10px;
    font-size: var(--fs-sm);
    font-weight: 700;
    color: var(--gray-800);
    background: var(--gray-50);
    border: 1.5px solid var(--gray-300);
    border-radius: var(--radius-sm);
    outline: none;
    transition: all 0.15s ease;
}

.compact-select:focus {
    border-color: var(--primary);
    background: #ffffff;
    box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.15);
}

/* منطقة الإجراءات للبطاقة */
.card-single-action {
    margin-top: 6px;
}

.card-double-action {
    margin-top: 6px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.card-triple-action {
    margin-top: 6px;
    display: grid;
    grid-template-columns: 1.2fr 1.05fr 1fr;
    gap: 6px;
}

@media (max-width: 576px) {
    .card-triple-action {
        grid-template-columns: 1fr;
    }
}

.btn-print-action {
    width: 100%;
    padding: 9px 12px;
    font-size: var(--fs-sm);
    font-weight: 800;
    border-radius: var(--radius-md);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    cursor: pointer;
    border: none;
    transition: all 0.18s ease;
    text-decoration: none;
}

.btn-print-action.primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(15, 118, 110, 0.22);
}

.btn-print-action.primary:hover {
    background: linear-gradient(135deg, var(--primary-strong), var(--primary));
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(15, 118, 110, 0.3);
}

.btn-print-action.indigo {
    background: linear-gradient(135deg, var(--secondary-hover), var(--secondary));
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(67, 56, 202, 0.22);
}

.btn-print-action.indigo:hover {
    background: linear-gradient(135deg, #3730a3, var(--secondary-hover));
    transform: translateY(-1px);
}

.btn-print-action.blue {
    background: linear-gradient(135deg, var(--blue-600), var(--blue-500));
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.22);
}

.btn-print-action.blue:hover {
    background: linear-gradient(135deg, #1d4ed8, var(--blue-600));
    transform: translateY(-1px);
}

/* تصدير Excel إجراء ثانوي: زر هادئ حتى يبقى «طباعة / PDF» هو الإجراء الأبرز في البطاقة */
.btn-print-action.emerald {
    background: #ffffff;
    color: var(--emerald-700);
    border: 1.5px solid var(--emerald-200);
    box-shadow: none;
}

.btn-print-action.emerald:hover {
    background: var(--emerald-50);
    border-color: var(--emerald-600);
    transform: translateY(-1px);
}

.btn-print-action.customizer {
    background: var(--primary-subtle);
    color: var(--primary);
    border: 1.5px solid var(--teal-200);
    box-shadow: 0 1px 4px rgba(15, 118, 110, 0.08);
}

.btn-print-action.customizer:hover {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
    transform: translateY(-1px);
}


/* ======================================================== */
/* معايير وقواعد الطباعة الرسمية للوحة التحكم                */
/* ======================================================== */
@media print {
    /* إخفاء القوائم والأشرطة الجانبية والأزرار والنوافذ */
    .sidebar,
    .top-header,
    .header-bar,
    .panel-header,
    .btn,
    .nav-tabs,
    .modal-backdrop,
    .toast-container,
    .app-toast,
    #standbyTeacherFilter,
    .no-print {
        display: none !important;
    }

    body, html {
        background: #ffffff !important;
        margin: 0 !important;
        padding: 0 !important;
        color: #000000 !important;
        font-family: 'Cairo', sans-serif !important;
    }

    .app-layout {
        display: block !important;
        margin: 0 !important;
        padding: 0 !important;
    }

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

    .panel-card {
        box-shadow: none !important;
        border: none !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    /* طباعة الألوان بدقة */
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
}

/* ====================================================
   نظام التسكين والبناء اليدوي: بنك الحصص يميناً والجدول يساراً
   ==================================================== */
.builder-layout-row {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    width: 100%;
}

.builder-bank-col {
    width: 320px;
    min-width: 290px;
    max-width: 330px;
    flex-shrink: 0;
    position: sticky;
    top: 15px;
    max-height: calc(100vh - 120px);
    display: flex;
    flex-direction: column;
    background: #ffffff;
    border: 1.5px solid var(--gray-300);
    border-radius: var(--radius-md);
    padding: 12px;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.04);
}

.builder-bank-header {
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--gray-100);
}

.builder-alloc-list {
    display: flex;
    flex-direction: column;
    gap: 7px;
    overflow-y: auto;
    padding-left: 3px;
    padding-right: 1px;
    flex: 1;
    min-height: 200px;
    max-height: calc(100vh - 270px);
}

.builder-alloc-card {
    background: var(--gray-50);
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    transition: all 0.15s ease;
    cursor: grab;
    user-select: none;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 50px;
}

.builder-alloc-card:hover:not(.is-completed) {
    border-color: var(--primary);
    background: var(--primary-subtle);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
    transform: translateY(-1px);
}

.builder-alloc-card.is-completed {
    opacity: 0.45;
    background: var(--gray-100);
    cursor: not-allowed;
    border-style: dotted;
}

.builder-alloc-card.is-dragging {
    opacity: 0.35;
    transform: scale(0.96);
}

.builder-alloc-badge {
    font-size: var(--fs-xs);
    font-weight: 800;
    padding: 1px 6px;
    border-radius: var(--radius-md);
    display: inline-block;
    white-space: nowrap;
}

.builder-alloc-badge.badge-remaining {
    background: #e0e7ff;
    color: #3730a3;
}

.builder-alloc-badge.badge-done {
    background: var(--green-100);
    color: var(--green-800);
}

.builder-unassign-zone {
    background: var(--red-50);
    border: 1.5px dashed var(--red-400);
    border-radius: var(--radius-sm);
    padding: 7px 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: var(--fs-sm);
    font-weight: 700;
    color: var(--red-800);
    transition: all 0.15s ease;
    cursor: default;
    user-select: none;
    margin-bottom: 8px;
    width: 100%;
}

.builder-unassign-zone.drag-over {
    background: var(--danger-light);
    border-color: var(--red-600);
    transform: scale(1.02);
}

.builder-table-col {
    flex: 1;
    min-width: 0;
    background: #ffffff;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius-md);
    padding: 12px;
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.03);
}

@media (max-width: 1024px) {
    .builder-layout-row {
        flex-direction: column;
    }
    .builder-bank-col {
        width: 100%;
        max-width: 100%;
        position: static;
        max-height: 380px;
    }
    .builder-alloc-list {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
        max-height: 240px;
    }
}

/* شبكة الجدول المضغوطة بالكامل بدون أي تمدد أو خروج لليسار */
.builder-matrix-table {
    table-layout: fixed !important;
    width: 100% !important;
    border-collapse: separate !important;
    border-spacing: 4px !important;
    margin: 0 !important;
}

.builder-matrix-table th {
    background: var(--gray-100);
    padding: 7px 4px !important;
    text-align: center;
    font-size: var(--fs-sm) !important;
    font-weight: 800;
    border-radius: var(--radius-xs);
    color: var(--gray-700);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.builder-matrix-table td {
    vertical-align: top;
    padding: 0 !important;
    height: auto !important;
    min-width: 0 !important;
}

.builder-matrix-table th.tt-day-col,
.builder-matrix-table td.tt-day-col {
    width: 80px !important;
    min-width: 80px !important;
    max-width: 80px !important;
    background: var(--gray-200) !important;
    color: var(--primary) !important;
    font-weight: 900 !important;
    font-size: var(--fs-sm) !important;
    text-align: center;
    vertical-align: middle;
    padding: 4px !important;
    border-radius: var(--radius-xs);
}

.builder-matrix-table td.builder-cell-free {
    background: var(--green-50) !important;
    outline: 2px dashed #22c55e !important;
    outline-offset: -2px;
    border-radius: var(--radius-sm);
}

.builder-matrix-table td.builder-cell-busy {
    background: var(--rose-50) !important;
    opacity: 0.45;
    cursor: not-allowed !important;
}

/* بطاقة الحصة المضغوطة */
.builder-slot-card {
    height: 100%;
    min-height: 52px;
    background: #ffffff;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    padding: 4px 6px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    cursor: grab;
    user-select: none;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
    transition: all 0.15s ease;
}

.builder-slot-card:hover {
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.builder-slot-card.is-empty {
    background: var(--gray-50);
    border: 1.5px dashed var(--gray-300);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    opacity: 0.85;
}

.builder-slot-card.is-empty:hover {
    background: var(--primary-subtle);
    border-color: var(--primary);
    opacity: 1;
}

.builder-slot-subject {
    padding-inline-end: 48px; /* مساحة زرّي المناقلة والإلغاء في الزاوية */
    font-size: var(--fs-sm);
    font-weight: 800;
    color: var(--gray-900);
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-bottom: 2px;
}

.builder-slot-teacher {
    font-size: var(--fs-xs);
    color: var(--gray-600);
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.builder-remove-btn {
    /* يجلس بجانب زر المناقلة داخل حاويتهما المرنة، لا فوقه */
    position: static;
    background: rgba(220, 38, 38, 0.12);
    color: var(--red-600);
    border: none;
    display: none;
    font-size: 15px;
    font-weight: 900;
    cursor: pointer;
    transition: all 0.15s ease;
    z-index: 5;
}

.builder-slot-card:hover .builder-remove-btn {
    display: flex;
}

.builder-remove-btn:hover {
    background: var(--red-600);
    color: #ffffff;
}

/* ======================================================== */
/* شارة تبديل حالة الانتظار (مشمول / معفى) في جدول المعلمين */
/* ======================================================== */
.badge-standby-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: var(--fs-sm);
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    border-width: 1px;
    border-style: solid;
    user-select: none;
    line-height: 1.4;
    white-space: nowrap;
}

.badge-standby-toggle:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.08);
}

.badge-standby-toggle:active {
    transform: translateY(0);
}

.badge-standby-included {
    background: var(--emerald-50);
    border-color: var(--emerald-200);
    color: var(--emerald-700);
}

.badge-standby-included:hover {
    background: var(--success-light);
    border-color: #6ee7b7;
    color: var(--success-dark);
}

.badge-standby-exempt {
    background: #fff7ed;
    border-color: #fed7aa;
    color: #c2410c;
}

.badge-standby-exempt:hover {
    background: #ffedd5;
    border-color: #fdba74;
    color: #9a3412;
}

/* ========================================================
   أنماط السحب والإفلات للفصول الدراسية (Class Drag & Drop)
   ======================================================== */
.classes-dnd-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    min-height: 42px;
    padding: 4px 2px;
}

.class-chip-item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--primary-subtle);
    border: 1.5px solid var(--teal-200);
    padding: 6px 14px;
    border-radius: var(--radius-md);
    box-shadow: 0 1px 3px rgba(15, 118, 110, 0.08);
    cursor: grab;
    user-select: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.class-chip-item:hover {
    border-color: var(--teal-400);
    background: #ffffff;
    box-shadow: 0 4px 10px rgba(15, 118, 110, 0.14);
    transform: translateY(-1px);
}

.class-chip-item:active {
    cursor: grabbing;
}

.class-chip-item.is-dragging {
    opacity: 0.35;
    transform: scale(0.96);
    border: 2px dashed var(--primary-hover) !important;
    background: #e6fffa !important;
    box-shadow: none !important;
}

.class-chip-item.drag-over {
    border-color: var(--primary) !important;
    background: var(--primary-light) !important;
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 0 0 2.5px rgba(15, 118, 110, 0.35) !important;
}

.class-chip-drag-handle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-hover);
    font-size: var(--fs-md);
    cursor: grab;
    opacity: 0.75;
    padding: 0 2px;
    transition: opacity 0.15s ease, transform 0.15s ease;
    line-height: 1;
}

.class-chip-item:hover .class-chip-drag-handle {
    opacity: 1;
    color: var(--primary);
}

.class-chip-name {
    font-weight: 800;
    font-size: var(--fs-base);
    color: var(--primary);
    letter-spacing: 0.2px;
}

.class-chip-btn {
    background: transparent;
    border: none;
    padding: 2px 4px;
    border-radius: var(--radius-xs);
    cursor: pointer;
    font-size: var(--fs-base);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    line-height: 1;
}

.class-chip-btn-edit {
    color: var(--primary-hover);
}

.class-chip-btn-edit:hover {
    background: var(--primary-light);
    color: var(--primary);
    transform: scale(1.15);
}

.class-chip-btn-delete {
    color: var(--danger);
    font-size: var(--fs-lg);
    font-weight: bold;
}

.class-chip-btn-delete:hover {
    background: var(--danger-light);
    color: var(--red-600);
    transform: scale(1.15);
}

/* ========================================================
   أزرار حفظ التغييرات الاحترافية وشريط الحفظ العائم
   ======================================================== */
.btn-save-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%) !important;
    color: #ffffff !important;
    border: none !important;
    font-weight: 800 !important;
    font-size: var(--fs-base) !important;
    padding: 7px 18px !important;
    border-radius: var(--radius-md) !important;
    box-shadow: 0 2px 8px rgba(15, 118, 110, 0.25) !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 7px !important;
    cursor: pointer !important;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
    user-select: none !important;
}

.btn-save-header:hover {
    background: linear-gradient(135deg, var(--primary-strong) 0%, var(--primary) 100%) !important;
    box-shadow: 0 4px 14px rgba(15, 118, 110, 0.38) !important;
    transform: translateY(-1px) !important;
}

.btn-save-header:active {
    transform: translateY(0) !important;
}

.btn-save-header svg, .btn-save-header span.icon {
    flex-shrink: 0;
}

/* شريط الحفظ العائم الذكي (Floating Save Bar) */
.floating-save-bar {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(120px);
    opacity: 0;
    pointer-events: none;
    z-index: 9999;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1.5px solid rgba(45, 212, 191, 0.35);
    border-radius: var(--radius-xl);
    padding: 10px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 10px 35px rgba(0, 0, 0, 0.3), 0 0 20px rgba(15, 118, 110, 0.2);
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
    color: #ffffff;
    max-width: 90vw;
}

.floating-save-bar.visible {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    pointer-events: auto;
}

.floating-save-bar-text {
    font-size: var(--fs-base);
    font-weight: 700;
    color: var(--gray-100);
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.floating-save-bar-btn {
    background: linear-gradient(135deg, var(--primary-hover) 0%, var(--emerald-600) 100%);
    color: #ffffff;
    border: none;
    border-radius: var(--radius-md);
    padding: 7px 18px;
    font-size: var(--fs-base);
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(5, 150, 105, 0.4);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.floating-save-bar-btn:hover {
    background: linear-gradient(135deg, var(--primary) 0%, var(--emerald-700) 100%);
    box-shadow: 0 4px 15px rgba(5, 150, 105, 0.6);
    transform: translateY(-1px);
}

.floating-save-bar-dismiss {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--gray-300);
    border-radius: var(--radius-md);
    padding: 6px 12px;
    font-size: var(--fs-sm);
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.floating-save-bar-dismiss:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

/* ====================================================
   واجهة مناقلة الحصص الذكية ملء الشاشة (Smart Transfer Canvas)
   ==================================================== */
.transfer-canvas-modal {
    position: fixed;
    inset: 0;
    z-index: 999999;
    background: var(--bg-body);
    color: var(--text-main);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: transferFadeIn 0.2s ease-out;
}

@keyframes transferFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* الرأس: عنوان + إجراءات */
.transfer-canvas-header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: var(--sp-3) var(--sp-5);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--sp-4);
    flex-shrink: 0;
}

.tc-title-wrap {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    min-width: 0;
}

.tc-title-icon {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    border-radius: var(--radius-md);
    background: var(--primary-subtle);
    color: var(--primary);
    display: grid;
    place-items: center;
    font-size: var(--fs-xl);
}

.tc-title-text { min-width: 0; }

.tc-title {
    margin: 0;
    font-size: var(--fs-lg);
    font-weight: var(--fw-heavy);
    color: var(--text-main);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tc-accent { color: var(--primary); }

.tc-sub {
    font-size: var(--fs-sm);
    color: var(--text-muted);
    margin-top: 2px;
}

.tc-sub strong { color: var(--text-main); }

.transfer-canvas-actions {
    display: flex;
    gap: var(--sp-2);
    flex-shrink: 0;
}

/* شريط الاختيار ومفتاح الألوان */
.transfer-canvas-filter-bar {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: var(--sp-2) var(--sp-5);
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    flex-wrap: wrap;
    flex-shrink: 0;
}

.transfer-canvas-filter-item {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    flex: 1 1 200px;
    min-width: 0;
}

.transfer-canvas-filter-item label { white-space: nowrap; }

.transfer-canvas-filter-item.is-wide { flex: 1.5 1 240px; }

.transfer-canvas-filter-item label {
    font-size: var(--fs-xs);
    font-weight: var(--fw-bold);
    color: var(--text-muted);
    margin: 0;
}

.tc-select {
    width: 100%;
    background: var(--bg-card);
    color: var(--text-main);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    padding: 7px 10px;
    font-size: var(--fs-base);
    font-weight: var(--fw-medium);
    outline: none;
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.tc-select:focus {
    border-color: var(--primary);
    box-shadow: var(--ring);
}

.transfer-legend {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    margin-inline-start: auto;
}

.transfer-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: var(--fs-sm);
    font-weight: var(--fw-bold);
    color: var(--text-body);
    padding: 4px 10px;
    border-radius: var(--radius-full);
    background: var(--bg-subtle);
    white-space: nowrap;
}

.transfer-legend-item i {
    width: 10px;
    height: 10px;
    border-radius: var(--radius-full);
    background: var(--tc-c, var(--gray-300));
}

.transfer-legend-item strong { color: var(--text-muted); font-weight: var(--fw-bold); }

.transfer-legend-green { --tc-c: var(--success); }
.transfer-legend-orange { --tc-c: var(--amber-500); }
.transfer-legend-blue { --tc-c: var(--blue-500); }
.transfer-legend-blocked { --tc-c: var(--gray-300); }

/* الجسم: الجدول يملأ المساحة المتبقية والصفوف تتقاسم الارتفاع فلا يلزم تمرير */
.transfer-canvas-body {
    flex: 1;
    min-height: 0;
    overflow: auto;
    padding: var(--sp-3) var(--sp-5) var(--sp-4);
    display: flex;
    flex-direction: column;
}

.tc-state {
    margin: auto;
    text-align: center;
    color: var(--text-muted);
    font-size: var(--fs-md);
    font-weight: var(--fw-bold);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-8);
}

.tc-state small {
    font-size: var(--fs-sm);
    font-weight: var(--fw-regular);
}

.tc-state.is-error { color: var(--danger-dark); }

.transfer-matrix-table {
    width: 100%;
    height: 100%;
    border-collapse: separate;
    border-spacing: 6px;
    table-layout: fixed;
}

.transfer-matrix-table th {
    background: var(--gray-100);
    color: var(--text-body);
    padding: 6px 4px;
    height: 32px;
    text-align: center;
    font-size: var(--fs-sm);
    font-weight: var(--fw-heavy);
    border-radius: var(--radius-sm);
}

.transfer-matrix-table td {
    vertical-align: stretch;
    padding: 0;
    min-width: 0;
    height: 1px; /* يسمح للبطاقة بملء الخلية بنسبة 100% */
}

.transfer-matrix-table th.transfer-day-col,
.transfer-matrix-table td.transfer-day-col {
    width: 84px;
    background: var(--primary-subtle);
    color: var(--primary-strong);
    font-size: var(--fs-base);
    font-weight: var(--fw-heavy);
    text-align: center;
    vertical-align: middle;
    border-radius: var(--radius-sm);
}

.transfer-matrix-table thead th.transfer-day-col {
    background: var(--gray-100);
    color: var(--text-muted);
    font-size: var(--fs-xs);
}

/* شبكة المناقلة: عمود الأيام + أعمدة الحصص، والصفوف تتقاسم الارتفاع المتاح (minmax(0,1fr)) */
.transfer-grid {
    flex: 1 1 auto;
    min-height: 0;
    display: grid;
    grid-template-columns: 84px repeat(var(--tc-periods, 7), minmax(0, 1fr));
    grid-template-rows: 30px repeat(var(--tc-days, 5), minmax(0, 1fr));
    gap: 6px;
}

.transfer-grid-head {
    background: var(--gray-100);
    color: var(--text-body);
    border-radius: var(--radius-sm);
    display: grid;
    place-items: center;
    font-size: var(--fs-sm);
    font-weight: var(--fw-heavy);
}

.transfer-grid > .transfer-day-col {
    background: var(--primary-subtle);
    color: var(--primary-strong);
    border-radius: var(--radius-sm);
    display: grid;
    place-items: center;
    font-size: var(--fs-base);
    font-weight: var(--fw-heavy);
}

.transfer-grid > .transfer-grid-head.transfer-day-col {
    background: var(--gray-100);
    color: var(--text-muted);
    font-size: var(--fs-xs);
}

/* بطاقة الخانة: تتكيف مع ارتفاعها — يُخفى السطر الوصفي ثم العنوان عند ضيق المساحة */
.transfer-cell-card {
    height: 100%;
    min-height: 0;
    overflow: hidden;
    container-type: size;
    border-radius: var(--radius-md);
    padding: 6px 8px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 4px;
    position: relative;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
    user-select: none;
    text-align: right;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-inline-start: 4px solid var(--tc-c, var(--gray-300));
}

.transfer-cell-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 4px;
    min-width: 0;
}

.transfer-cell-period {
    font-size: var(--fs-2xs);
    font-weight: var(--fw-bold);
    color: var(--text-light);
    flex-shrink: 0;
}

.transfer-cell-green { --tc-c: var(--success); background: var(--green-50); border-color: var(--green-200); }
.transfer-cell-orange { --tc-c: var(--amber-500); background: var(--amber-50); border-color: var(--amber-200); }
.transfer-cell-blue { --tc-c: var(--blue-500); background: var(--blue-50); border-color: var(--blue-200); }

.transfer-cell-green:hover,
.transfer-cell-orange:hover,
.transfer-cell-blue:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
    border-color: var(--tc-c);
    z-index: 2;
}

/* الخانة الحالية للحصة */
.transfer-cell-current {
    --tc-c: var(--primary);
    background: var(--primary-subtle);
    border: 1.5px dashed var(--primary);
    border-inline-start: 4px solid var(--primary);
    cursor: default;
}

/* الخانة غير المتاحة: هادئة حتى تبرز البدائل وحدها */
.transfer-cell-blocked {
    background: var(--bg-subtle);
    border-color: transparent;
    cursor: not-allowed;
}

.transfer-cell-blocked .transfer-cell-title,
.transfer-cell-blocked .transfer-cell-desc { color: var(--text-light); }

.transfer-badge {
    font-size: var(--fs-2xs);
    font-weight: var(--fw-heavy);
    padding: 1px 6px;
    border-radius: var(--radius-xs);
    display: inline-block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}
.transfer-badge-green { background: var(--success); color: #ffffff; }
.transfer-badge-orange { background: var(--amber-500); color: #ffffff; }
.transfer-badge-blue { background: var(--blue-600); color: #ffffff; }
.transfer-badge-current { background: var(--primary); color: #ffffff; }
.transfer-badge-blocked { background: var(--gray-200); color: var(--text-muted); }

.transfer-cell-title {
    font-size: var(--fs-sm);
    font-weight: var(--fw-heavy);
    color: var(--text-main);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.transfer-cell-desc {
    font-size: var(--fs-xs);
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.transfer-cell-body { min-width: 0; }

@container (max-height: 66px) {
    .transfer-cell-desc { display: none; }
}

@container (max-height: 44px) {
    .transfer-cell-body { display: none; }
}

/* الخانة المحددة للمناقلة */
.transfer-cell-card.transfer-cell-selected {
    border-color: var(--primary) !important;
    transform: translateY(-1px);
    animation: cellPulse 1.4s infinite alternate ease-in-out;
    z-index: 3;
}

@keyframes cellPulse {
    from { box-shadow: 0 0 0 2px var(--primary-light), var(--shadow-sm); }
    to { box-shadow: 0 0 0 5px var(--primary-light), var(--shadow-md); }
}

@media (max-width: 900px) {
    .transfer-canvas-header { flex-wrap: wrap; padding: var(--sp-3); }
    .transfer-canvas-actions { width: 100%; }
    .transfer-canvas-actions .btn { flex: 1; justify-content: center; }
    .transfer-canvas-filter-bar { padding: var(--sp-2) var(--sp-3) var(--sp-3); }
    .transfer-legend { margin-inline-start: 0; }
    .tc-title { white-space: normal; }
}

/* ====================================================
   استوديو صفحة خارطة المناقلة الاحترافية داخل الجدول (Transfer Map Studio)
   ==================================================== */
.tm-studio-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
    animation: tmFadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

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

/* شريط كروت الاختيار الثلاثي (المعلم - الصف - الحصة) */
.tm-selectors-card {
    background: linear-gradient(135deg, #ffffff, var(--gray-50));
    border: 1.5px solid var(--gray-300);
    border-radius: var(--radius-lg);
    padding: 16px 20px;
    box-shadow: 0 4px 16px rgba(15, 23, 42, 0.05);
}

.tm-selectors-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 14px;
    align-items: flex-end;
}

.tm-selector-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.tm-selector-label {
    font-size: var(--fs-base);
    font-weight: 800;
    color: var(--gray-800);
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0;
}

.tm-selector-label .tm-icon {
    font-size: var(--fs-lg);
}

.tm-selector-label .tm-count-tag {
    font-size: var(--fs-xs);
    font-weight: 700;
    background: var(--gray-200);
    color: var(--gray-600);
    padding: 1px 7px;
    border-radius: var(--radius-lg);
}

.tm-select-input {
    width: 100%;
    padding: 9px 12px;
    font-size: var(--fs-base);
    font-weight: 700;
    color: var(--gray-900);
    background: #ffffff;
    border: 1.5px solid var(--gray-300);
    border-radius: var(--radius-md);
    outline: none;
    transition: all 0.2s ease;
    cursor: pointer;
}

.tm-select-input:focus {
    border-color: var(--info);
    box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

/* بطاقة ملخص الحصة المستهدفة وإحصائيات البدائل */
.tm-slot-hero {
    background: #090e1a;
    color: var(--gray-50);
    border-radius: var(--radius-lg);
    padding: 16px 22px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
    border: 1.5px solid var(--gray-800);
}

.tm-slot-hero-info {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.tm-teacher-avatar-badge {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, var(--info), var(--primary));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--fs-2xl);
    box-shadow: 0 4px 12px rgba(2, 132, 199, 0.35);
    flex-shrink: 0;
}

.tm-slot-meta-title {
    font-size: var(--fs-lg);
    font-weight: 900;
    color: #ffffff;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.tm-slot-meta-sub {
    font-size: var(--fs-sm);
    color: var(--gray-400);
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

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

.tm-stat-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: var(--radius-md);
    font-size: var(--fs-sm);
    font-weight: 800;
    border: 1px solid transparent;
    transition: all 0.2s ease;
}

.tm-stat-green {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    border-color: var(--success);
}

.tm-stat-orange {
    background: rgba(249, 115, 22, 0.15);
    color: #fb923c;
    border-color: #f97316;
}

.tm-stat-blue {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
    border-color: var(--blue-500);
}

.tm-stat-blocked {
    background: rgba(148, 163, 184, 0.12);
    color: var(--gray-400);
    border-color: var(--gray-700);
}

/* شبكة خارطة المناقلة داخل الصفحة */
.tm-matrix-canvas {
    background: #090e1a;
    border: 1.5px solid var(--gray-800);
    border-radius: var(--radius-lg);
    padding: 18px 20px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
    overflow-x: auto;
}

/* الحالة الترحيبية الفارغة قبل الاختيار */
.tm-empty-state {
    text-align: center;
    padding: 60px 24px;
    background: linear-gradient(135deg, var(--gray-50), var(--gray-100));
    border: 2px dashed var(--gray-300);
    border-radius: var(--radius-xl);
    color: var(--gray-500);
}

.tm-empty-state .tm-empty-icon {
    font-size: 48px;
    margin-bottom: 14px;
    display: inline-block;
    filter: drop-shadow(0 4px 12px rgba(2, 132, 199, 0.2));
}

.tm-empty-state h3 {
    font-size: var(--fs-xl);
    font-weight: 900;
    color: var(--gray-900);
    margin-bottom: 8px;
}

.tm-empty-state p {
    font-size: var(--fs-base);
    color: var(--gray-600);
    max-width: 580px;
    margin: 0 auto 20px;
    line-height: 1.7;
}

.tm-guide-steps {
    display: flex;
    justify-content: center;
    gap: 16px;
    flex-wrap: wrap;
    margin-top: 14px;
}

.tm-guide-step-pill {
    background: #ffffff;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius-md);
    padding: 8px 16px;
    font-size: var(--fs-sm);
    font-weight: 800;
    color: var(--gray-700);
    box-shadow: 0 2px 6px rgba(0,0,0,0.04);
}

/* ======================================================== */
/* 7.4 مجموعات المعلمين (teacher-groups.js)                  */
/* بطاقة واحدة بترويسة التبويبات الموحدة، ثم «تخصيص متقدم».   */
/* ======================================================== */
.tg-container { display: flex; flex-direction: column; gap: 16px; width: 100%; min-width: 0; }
.tg-container .panel-card { margin-bottom: 0; }

/* لون كل مجموعة متغير واحد تستخدمه النقاط والبطاقات والخانات */
.tg-container [data-g="1"]  { --group-accent: #6366f1; }
.tg-container [data-g="2"]  { --group-accent: #06b6d4; }
.tg-container [data-g="3"]  { --group-accent: var(--success); }
.tg-container [data-g="4"]  { --group-accent: var(--amber-500); }
.tg-container [data-g="5"]  { --group-accent: #f43f5e; }
.tg-container [data-g="6"]  { --group-accent: #8b5cf6; }
.tg-container [data-g="7"]  { --group-accent: #0ea5e9; }
.tg-container [data-g="8"]  { --group-accent: #84cc16; }
.tg-container [data-g="9"]  { --group-accent: #d946ef; }
.tg-container [data-g="10"] { --group-accent: #78716c; }
.tg-container [data-g="x"]  { --group-accent: var(--gray-400); }

/* الترويسة */
.tg-panel .panel-title p { margin: 2px 0 0; }
.tg-status-pill {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 10px; border-radius: var(--radius-full);
    font-size: var(--fs-sm); font-weight: var(--fw-bold); white-space: nowrap;
    background: var(--gray-100); color: var(--gray-600);
}
.tg-status-pill::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.tg-status-pill.active { background: var(--success-light); color: var(--success-dark); }
.tg-status-pill.unsaved { background: var(--warning-light); color: var(--warning-dark); }

/* الجسم والتذييل */
.tg-body { padding: var(--sp-4) 18px; display: flex; flex-direction: column; gap: var(--sp-4); min-width: 0; }
.tg-section { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.tg-section + .tg-section { padding-top: var(--sp-4); border-top: 1px solid var(--gray-100); }
.tg-section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px 16px; flex-wrap: wrap; }
.tg-section-head h4 { margin: 0; font-size: var(--fs-md); font-weight: var(--fw-bold); color: var(--text-main); }
.tg-summary-line { margin: 0; font-size: var(--fs-sm); color: var(--text-muted); }
.tg-summary-line strong { color: var(--text-main); }
.tg-help { margin: 0; font-size: var(--fs-xs); color: var(--text-muted); line-height: 1.7; }
.tg-footer {
    display: flex; align-items: center; gap: 8px 12px; flex-wrap: wrap;
    padding: 12px 18px; border-top: 1px solid var(--border); background: var(--bg-subtle);
}
.tg-footer .tg-help { flex: 1; min-width: 200px; }
.tg-footer-end { margin-inline-start: auto; }
.tg-danger { color: var(--danger-dark); border-color: var(--red-200); }
.tg-danger:hover { background: var(--danger-light); color: var(--danger-dark); border-color: var(--danger); }
.tg-link { background: none; border: 0; padding: 0; color: var(--primary); font: inherit; font-weight: var(--fw-bold); text-decoration: underline; cursor: pointer; }

/* الإعداد: حقلان متجاوران */
.tg-questions { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 320px)); gap: var(--sp-4) var(--sp-8); }
.tg-question { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.tg-question > label { margin: 0; font-size: var(--fs-sm); font-weight: var(--fw-bold); color: var(--gray-700); }
.tg-select-input {
    width: 100%; max-width: 100%; height: 36px; box-sizing: border-box;
    border: 1px solid var(--border-strong); border-radius: var(--radius-md);
    padding: 0 10px; background: var(--bg-card); color: var(--text-main);
    font: inherit; font-size: var(--fs-base); font-weight: var(--fw-medium);
    transition: border-color .15s, box-shadow .15s;
}
.tg-select-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }
.tg-question .tg-help .ui-ic { color: var(--success); }

/* شريط المؤشرات */
.tg-kpis { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.tg-kpi {
    display: flex; align-items: center; gap: 10px; min-width: 0;
    padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--bg-card);
}
.tg-kpi-icon {
    width: 32px; height: 32px; flex-shrink: 0; border-radius: var(--radius-md);
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--primary-subtle); color: var(--primary);
}
.tg-kpi-icon .ui-ic { width: 16px; height: 16px; }
.tg-kpi-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.5; }
.tg-kpi-text span { font-size: var(--fs-xs); color: var(--text-muted); }
.tg-kpi-text strong { font-size: var(--fs-base); font-weight: var(--fw-bold); color: var(--text-main); }

/* لافتة النتيجة */
.tg-result {
    display: flex; align-items: flex-start; gap: 12px;
    padding: 12px 14px; border-radius: var(--radius-md);
    border: 1px solid var(--border); border-inline-start: 4px solid var(--gray-300); background: var(--bg-subtle);
}
.tg-result.ok { border-color: var(--green-200); border-inline-start-color: var(--success); background: var(--success-light); }
.tg-result.warn { border-color: var(--amber-200); border-inline-start-color: var(--amber-500); background: var(--amber-50); }
.tg-result-icon { flex-shrink: 0; display: inline-flex; margin-top: 2px; }
.tg-result-icon .ui-ic { width: 20px; height: 20px; }
.tg-result.ok .tg-result-icon { color: var(--success-dark); }
.tg-result.warn .tg-result-icon { color: var(--warning-dark); }
.tg-result h3 { margin: 0; font-size: var(--fs-md); font-weight: var(--fw-bold); color: var(--text-main); }
.tg-result p { margin: 2px 0 0; font-size: var(--fs-sm); color: var(--gray-700); }

/* تنبيه داخل الصفحة */
.tg-alert {
    display: flex; align-items: center; gap: 8px 12px; flex-wrap: wrap;
    padding: 10px 14px; border-radius: var(--radius-md);
    border: 1px solid var(--amber-200); background: var(--amber-50); color: var(--warning-dark);
    font-size: var(--fs-sm);
}
.tg-alert.info { border-color: var(--blue-200); background: var(--blue-50); color: var(--blue-800); }
.tg-alert strong { font-weight: var(--fw-bold); }
.tg-alert span { flex: 1; min-width: 200px; }

/* البدائل المجرّبة */
.tg-alternatives { display: flex; flex-direction: column; gap: 8px; }
.tg-alt {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--bg-card);
}
.tg-alt:hover { border-color: var(--primary); }
.tg-alt-badge {
    width: 28px; height: 28px; flex-shrink: 0; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--primary-subtle); color: var(--primary); font-size: var(--fs-sm); font-weight: var(--fw-bold);
}
.tg-alt-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.tg-alt-body strong { font-size: var(--fs-base); font-weight: var(--fw-bold); }
.tg-alt-body span { font-size: var(--fs-xs); color: var(--text-muted); }

/* مراحل التجهيز */
.tg-progress { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.tg-progress li { display: flex; align-items: center; gap: 10px; font-size: var(--fs-base); color: var(--text-body); }
.tg-progress li.running { font-weight: var(--fw-bold); color: var(--text-main); }
.tg-progress li.done .ui-ic { color: var(--success); }
.tg-progress li.fail { color: var(--text-muted); }
.tg-progress-icon { width: 20px; display: inline-flex; justify-content: center; }
.tg-spinner { width: 16px; height: 16px; border: 2px solid var(--gray-300); border-top-color: var(--primary); border-radius: 50%; animation: app-spin .8s linear infinite; }

/* ترقيم خطوات الإعداد */
.tg-step-num {
    display: inline-flex; align-items: center; justify-content: center;
    width: 20px; height: 20px; margin-inline-end: 8px; vertical-align: 1px;
    border-radius: 50%; background: var(--primary-subtle); color: var(--primary);
    font-size: var(--fs-xs); font-weight: var(--fw-bold);
}
.tg-section-aside { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tg-group-dot { width: 8px; height: 8px; flex-shrink: 0; display: inline-block; border-radius: 50%; background: var(--group-accent, var(--primary)); }

/* طريقة التوزيع: بطاقتا اختيار */
.tg-methods { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 10px; }
.tg-method {
    position: relative; display: flex; align-items: flex-start; gap: 12px; margin: 0; cursor: pointer;
    padding: 14px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--bg-card);
    transition: border-color .15s, box-shadow .15s, background .15s;
}
.tg-method:hover { border-color: var(--border-strong); background: var(--gray-50); }
.tg-method input { position: absolute; opacity: 0; pointer-events: none; }
.tg-method:has(input:focus-visible) { box-shadow: 0 0 0 3px var(--ring); }
.tg-method.active { border-color: var(--primary); background: var(--primary-subtle); box-shadow: 0 0 0 1px var(--primary); }
.tg-method-icon {
    width: 36px; height: 36px; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center;
    border-radius: var(--radius-md); background: var(--gray-100); color: var(--gray-600);
}
.tg-method.active .tg-method-icon { background: var(--primary); color: #fff; }
.tg-method-icon .ui-ic { width: 18px; height: 18px; }
.tg-method-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tg-method-text strong { font-size: var(--fs-md); font-weight: var(--fw-bold); color: var(--text-main); }
.tg-method-text span { font-size: var(--fs-sm); color: var(--text-muted); line-height: 1.7; }
.tg-method-check {
    position: absolute; top: 10px; inset-inline-end: 10px; width: 18px; height: 18px;
    display: inline-flex; align-items: center; justify-content: center; border-radius: 50%;
    border: 1px solid var(--border-strong); color: transparent; background: var(--bg-card);
}
.tg-method-check .ui-ic { width: 12px; height: 12px; }
.tg-method.active .tg-method-check { border-color: var(--primary); background: var(--primary); color: #fff; }

/* لوحة الأعضاء */
.tg-board { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.tg-board-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px 16px; flex-wrap: wrap; }
.tg-board-progress { display: flex; align-items: center; gap: 10px; font-size: var(--fs-sm); color: var(--text-muted); }
.tg-board-progress strong { color: var(--text-main); font-weight: var(--fw-bold); }
.tg-meter { width: 120px; height: 6px; border-radius: var(--radius-full); background: var(--gray-100); overflow: hidden; }
.tg-meter > span { display: block; height: 100%; width: var(--p, 0%); background: var(--primary); border-radius: inherit; transition: width .25s; }
.tg-board-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.tg-board-grid { display: grid; grid-template-columns: minmax(250px, 300px) minmax(0, 1fr); gap: 12px; align-items: start; }

.tg-pool {
    position: sticky; top: 8px; display: flex; flex-direction: column; gap: 8px; min-width: 0;
    padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--bg-subtle);
    transition: border-color .15s, background .15s;
}
.tg-pool-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.tg-pool-head strong { display: block; font-size: var(--fs-md); font-weight: var(--fw-bold); color: var(--text-main); }
.tg-pool-tools { display: flex; justify-content: flex-end; font-size: var(--fs-xs); }
.tg-pool-list { display: flex; flex-direction: column; gap: 6px; max-height: 440px; overflow-y: auto; margin-inline: -4px; padding-inline: 4px; }
.tg-pool-empty { margin: 0; padding: 20px 8px; text-align: center; font-size: var(--fs-sm); color: var(--text-muted); }
.tg-pool-empty .ui-ic { color: var(--success); }
.tg-pool-bulk {
    display: flex; flex-direction: column; gap: 6px; padding: 10px; border-radius: var(--radius-md);
    background: var(--primary); color: #fff; font-size: var(--fs-sm); font-weight: var(--fw-bold);
}
.tg-pool-bulk .tg-quick-btn { background: #fff; }

.tg-person {
    display: flex; align-items: center; gap: 8px; padding: 6px 8px; cursor: grab;
    border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--bg-card);
    transition: border-color .15s, box-shadow .15s;
}
.tg-person:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.tg-person.is-selected { border-color: var(--primary); background: var(--primary-subtle); }
.tg-person-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; margin: 0; cursor: pointer; }
.tg-person-main input { width: 15px; height: 15px; flex-shrink: 0; accent-color: var(--primary); margin: 0; }
.tg-person-text, .tg-chip-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.5; }
.tg-person-name, .tg-chip-name { font-size: var(--fs-sm); font-weight: var(--fw-bold); color: var(--text-main); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tg-person-sub, .tg-chip-sub { font-size: var(--fs-xs); color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tg-person-load, .tg-chip-load {
    flex-shrink: 0; min-width: 24px; padding: 1px 6px; text-align: center; border-radius: var(--radius-full);
    background: var(--gray-100); color: var(--gray-600); font-size: var(--fs-xs); font-weight: var(--fw-bold);
}
.tg-quick { display: flex; gap: 3px; flex-wrap: wrap; justify-content: flex-end; max-width: 110px; }
.tg-pool-bulk .tg-quick { max-width: none; justify-content: flex-start; }
.tg-quick-btn {
    width: 22px; height: 22px; padding: 0; cursor: pointer; border-radius: 50%;
    border: 1.5px solid var(--group-accent, var(--primary)); background: var(--bg-card);
    color: var(--text-main); font: inherit; font-size: var(--fs-xs); font-weight: var(--fw-bold); line-height: 1;
    transition: background .15s, color .15s, transform .1s;
}
.tg-quick-btn:hover { background: var(--group-accent, var(--primary)); color: #fff; }
.tg-quick-btn:active { transform: scale(.92); }
.tg-quick-btn:focus-visible, .tg-chip-x:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }

.tg-lanes { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; min-width: 0; }
.tg-lane {
    position: relative; display: flex; flex-direction: column; gap: 6px; min-width: 0; min-height: 150px;
    padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--bg-card);
    border-top: 3px solid var(--group-accent, var(--primary));
    transition: border-color .15s, background .15s, box-shadow .15s;
}
.tg-lane.is-outside { border-top-color: var(--gray-300); border-style: dashed; border-top-style: solid; background: var(--bg-subtle); }
.tg-lane-head { display: flex; align-items: center; gap: 6px; }
.tg-lane-head strong { font-size: var(--fs-md); font-weight: var(--fw-bold); color: var(--text-main); }
.tg-lane-count {
    margin-inline-start: auto; min-width: 22px; padding: 1px 7px; text-align: center; border-radius: var(--radius-full);
    background: color-mix(in srgb, var(--group-accent, var(--primary)) 14%, #fff); color: var(--text-main);
    font-size: var(--fs-xs); font-weight: var(--fw-bold);
}
.tg-lane-meta { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; font-size: var(--fs-xs); color: var(--text-muted); }
.tg-lane-bar { height: 4px; border-radius: var(--radius-full); background: var(--gray-100); overflow: hidden; }
.tg-lane-bar > span { display: block; height: 100%; width: var(--p, 0%); background: var(--group-accent, var(--primary)); border-radius: inherit; transition: width .25s; }
.tg-lane-body { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); align-content: start; gap: 6px; flex: 1; }
.tg-lane-body > .tg-lane-empty { grid-column: 1 / -1; }
.tg-lane-empty {
    flex: 1; margin: 0; display: flex; align-items: center; justify-content: center; text-align: center;
    padding: 16px 10px; border: 1.5px dashed var(--gray-200); border-radius: var(--radius-md);
    font-size: var(--fs-xs); color: var(--text-light); line-height: 1.7;
}
.tg-chip {
    display: flex; align-items: center; gap: 8px; padding: 6px 8px;
    border: 1px solid var(--gray-200); border-radius: var(--radius-md); background: var(--bg-card);
    border-inline-start: 3px solid var(--group-accent, var(--primary));
}
.tg-lane.is-outside .tg-chip { border-inline-start-color: var(--gray-300); }
.tg-chip[draggable="true"] { cursor: grab; }
.tg-chip[draggable="true"]:hover { box-shadow: var(--shadow-sm); border-color: var(--border-strong); }
.tg-chip-text { flex: 1; }
.tg-chip-x {
    width: 22px; height: 22px; flex-shrink: 0; padding: 0; cursor: pointer; border: 0; border-radius: 50%;
    background: transparent; color: var(--gray-400); font-size: var(--fs-lg); line-height: 1;
}
.tg-chip-x:hover { background: var(--danger-light); color: var(--danger-dark); }

/* السحب والإفلات */
.tg-board.is-dragging [data-drop] { border-style: dashed; }
.tg-board.is-dragging .tg-lane[data-drop] { border-top-style: solid; }
[data-drop].is-over { background: color-mix(in srgb, var(--group-accent, var(--primary)) 8%, #fff); border-color: var(--group-accent, var(--primary)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--group-accent, var(--primary)) 20%, transparent); }
.tg-pool.is-over { --group-accent: var(--gray-500); }
.tg-person.is-dragging, .tg-chip.is-dragging { opacity: .45; }

/* اللوحة للقراءة فقط */
.tg-board.is-readonly .tg-lane { min-height: 0; }

/* الجداول */
.tg-table-wrapper { width: 100%; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--border); border-radius: var(--radius-md); }
.tg-table { width: 100%; min-width: 480px; border-collapse: collapse; }
.tg-table th {
    padding: 8px 10px; background: var(--gray-50); border-bottom: 1px solid var(--border);
    font-size: var(--fs-xs); font-weight: var(--fw-bold); color: var(--gray-600); text-align: right; white-space: nowrap;
}
.tg-table td { padding: 7px 10px; border-bottom: 1px solid var(--gray-100); font-size: var(--fs-sm); color: var(--text-main); vertical-align: middle; }
.tg-table tbody tr:last-child > * { border-bottom: 0; }
.tg-table tbody tr:hover td { background: var(--gray-50); }
.tg-table tbody th { background: var(--bg-card); font-size: var(--fs-sm); color: var(--text-main); }
.tg-row-label { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.tg-week-table th, .tg-week-table td { text-align: center; }
.tg-week-table tbody th, .tg-week-table thead th:first-child { text-align: right; }
.tg-leave {
    display: inline-block; padding: 2px 10px; border-radius: var(--radius-full); white-space: nowrap;
    font-size: var(--fs-xs); font-weight: var(--fw-bold); color: var(--text-main);
    border: 1px solid var(--group-accent, var(--primary));
    background: color-mix(in srgb, var(--group-accent, var(--primary)) 14%, #ffffff);
}
.tg-stay { color: var(--gray-300); }
.tg-legend { display: flex; align-items: center; gap: 6px 16px; flex-wrap: wrap; font-size: var(--fs-xs); color: var(--text-muted); }
.tg-legend-leave { padding: 0 8px; border: 1px solid var(--gray-400); border-radius: var(--radius-full); background: var(--gray-100); color: var(--text-main); font-weight: var(--fw-bold); }

/* تخصيص متقدم */
.tg-advanced > summary {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
    padding: 12px 18px; cursor: pointer; list-style: none; user-select: none;
}
.tg-advanced > summary::-webkit-details-marker { display: none; }
.tg-advanced > summary:hover { background: var(--gray-50); }
.tg-advanced > summary strong { font-size: var(--fs-md); font-weight: var(--fw-bold); color: var(--text-main); }
.tg-advanced > summary .ui-ic { color: var(--primary); }
.tg-advanced > summary .tg-help { flex: 1; min-width: 180px; }
.tg-chevron { margin-inline-start: auto; color: var(--gray-400); transition: transform .2s; font-size: var(--fs-sm); }
.tg-advanced[open] > summary { border-bottom: 1px solid var(--border); }
.tg-advanced[open] .tg-chevron { transform: rotate(180deg); }

.tg-columns { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--sp-4); align-items: start; }
.tg-col { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.tg-col-teachers { position: sticky; top: 8px; max-height: calc(100vh - 160px); }
.tg-col-teachers .tg-teachers-scroll { flex: 1; min-height: 0; overflow-y: auto; }
.tg-teachers-table thead th { position: sticky; top: 0; z-index: 1; }
.tg-table.tg-cutoffs-table, .tg-table.tg-teachers-table { min-width: 0; }
.tg-cutoffs-table th, .tg-cutoffs-table td { text-align: center; padding: 5px 4px; }
.tg-cutoffs-table tbody th, .tg-cutoffs-table thead th:first-child { text-align: right; padding-inline: 10px; }
.tg-cutoff-select {
    width: 100%; min-width: 46px; height: 30px; padding: 0 4px; text-align: center; cursor: pointer;
    border: 1px solid var(--gray-300); border-radius: var(--radius-sm); background: var(--bg-card);
    font: inherit; font-size: var(--fs-sm); font-weight: var(--fw-medium); color: var(--text-main);
}
.tg-cutoff-select.is-early {
    border-color: var(--group-accent, var(--primary)); font-weight: var(--fw-bold);
    background: color-mix(in srgb, var(--group-accent, var(--primary)) 14%, #ffffff);
}
.tg-cutoff-select:focus, .tg-group-select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px var(--ring); }

.tg-search-input {
    width: 100%; height: 34px; box-sizing: border-box; padding: 0 12px;
    border: 1px solid var(--border-strong); border-radius: var(--radius-md);
    font: inherit; font-size: var(--fs-base);
}
.tg-search-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }
.tg-filter-bar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tg-filter-btn {
    display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; cursor: pointer;
    border: 1px solid var(--border); border-radius: var(--radius-full); background: var(--bg-card);
    font: inherit; font-size: var(--fs-xs); font-weight: var(--fw-bold); color: var(--text-muted);
    transition: background .15s, color .15s;
}
.tg-filter-btn:hover { background: var(--gray-50); color: var(--text-main); }
.tg-filter-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.tg-count-badge { font-size: var(--fs-xs); font-weight: var(--fw-bold); color: var(--gray-600); background: var(--gray-100); padding: 2px 8px; border-radius: var(--radius-full); }

.tg-teacher-name { font-weight: var(--fw-bold); }
.tg-teacher-subjects { margin-top: 3px; display: flex; flex-wrap: wrap; gap: 3px; }
.tg-subj-tag { padding: 1px 6px; border-radius: var(--radius-xs); background: var(--gray-100); color: var(--gray-600); font-size: var(--fs-xs); }
.tg-load { font-size: var(--fs-xs); }
.tg-group-select {
    width: 100%; max-width: 140px; height: 30px; padding: 0 8px; cursor: pointer;
    border: 1px solid var(--gray-300); border-radius: var(--radius-sm); background: var(--bg-card);
    font: inherit; font-size: var(--fs-sm); font-weight: var(--fw-medium); color: var(--text-main);
}
.tg-group-select[data-val]:not([data-val=""]) {
    border-color: var(--group-accent, var(--gray-300));
    border-inline-start-width: 3px;
}
.tg-group-select[data-val="x"] { border-style: dashed; color: var(--gray-600); background: var(--gray-50); }
tr.tg-excluded-row td { background: var(--gray-50); color: var(--text-muted); }
.tg-empty { text-align: center; padding: 20px; color: var(--text-muted); }

/* نتيجة الفحص */
.tg-issue-group { border: 1px solid var(--amber-200); background: var(--amber-50); border-radius: var(--radius-md); padding: 8px 12px; font-size: var(--fs-sm); }
.tg-issue-group.minor { border-color: var(--gray-200); background: var(--gray-50); }
.tg-issue-group summary { cursor: pointer; font-weight: var(--fw-bold); color: var(--warning-dark); }
.tg-issue-group.minor summary { color: var(--gray-600); }
.tg-issue-count { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: var(--radius-full); background: var(--amber-200); color: var(--warning-dark); text-align: center; font-size: var(--fs-xs); }
.tg-issue-group.minor .tg-issue-count { background: var(--gray-200); color: var(--gray-600); }
.tg-issue-hint { margin: 6px 0; color: var(--gray-600); }
.tg-issue-group ul { margin: 4px 0 0; padding-inline-start: 18px; line-height: 1.8; }
.tg-issues { display: flex; flex-direction: column; gap: 8px; }

.slot-card.is-departed:focus-visible { outline: 2px solid var(--primary); }

@media (max-width: 1100px) {
    .tg-columns { grid-template-columns: minmax(0, 1fr); }
    .tg-col-teachers { position: static; max-height: none; }
    .tg-col-teachers .tg-teachers-scroll { overflow-y: visible; }
    .tg-board-grid { grid-template-columns: minmax(0, 1fr); }
    .tg-pool { position: static; }
    .tg-pool-list { max-height: 320px; }
}
@media (max-width: 640px) {
    .tg-body { padding: 12px; }
    .tg-footer { padding: 12px; }
    .tg-footer .btn { flex: 1 1 auto; }
    .tg-footer-end { margin-inline-start: 0; }
    .tg-advanced > summary { padding: 12px; }
    .tg-questions { grid-template-columns: minmax(0, 1fr); }
    .tg-select-input { height: 40px; font-size: 16px; }
    .tg-search-input { font-size: 16px; }
    .tg-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
    .tg-kpi { padding: 8px 10px; gap: 8px; }
    .tg-kpi-icon { width: 28px; height: 28px; }
    .tg-methods { grid-template-columns: minmax(0, 1fr); }
    .tg-method { padding: 12px; }
    .tg-lanes { grid-template-columns: minmax(0, 1fr); }
    .tg-lane { min-height: 0; }
    .tg-board-actions .btn { flex: 1 1 auto; }
    .tg-quick-btn { width: 30px; height: 30px; font-size: var(--fs-sm); }
    .tg-quick { max-width: 140px; }
    .tg-chip-x { width: 30px; height: 30px; }
    .tg-person-main input { width: 18px; height: 18px; }
    .tg-alt { flex-wrap: wrap; }
    .tg-alt .btn { width: 100%; }
}

/* ==========================================================================
   الغياب اليومي: جدول تغطية حصص الغائبين (standby.js ← renderDailyAbsenceTabContent)
   ========================================================================== */
.panel-card.is-daily .sb-grid-only { display: none !important; }

.sb-daily { display: flex; flex-direction: column; gap: 14px; }
.sb-daily-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.sb-daily-head h4 { margin: 0 0 2px; font-size: var(--fs-lg); font-weight: 900; color: var(--text-main); }
.sb-daily-head p { margin: 0; font-size: var(--fs-base); color: var(--text-muted); }

.sb-daily-controls {
    display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 12px;
    background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 14px;
}
.sb-field { display: flex; flex-direction: column; gap: 6px; margin: 0; min-width: 0; }
.sb-field > span { font-size: var(--fs-sm); font-weight: 800; color: var(--gray-600); }
.sb-field .form-control { font-weight: 700; font-size: var(--fs-base); padding: 8px 12px; }

.sb-chips { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.sb-chips-label { font-size: var(--fs-sm); font-weight: 800; color: var(--gray-600); }
.sb-chip {
    display: inline-flex; align-items: center; gap: 6px;
    background: var(--rose-50); color: var(--rose-800); border: 1px solid var(--rose-200);
    border-radius: var(--radius-full); padding: 4px 6px 4px 12px; font-size: var(--fs-sm); font-weight: 800;
}
.sb-chip button {
    width: 20px; height: 20px; border-radius: 50%; border: none; cursor: pointer;
    background: var(--rose-200); color: var(--rose-800); font-size: var(--fs-md); line-height: 1; display: inline-flex; align-items: center; justify-content: center;
}
.sb-chip button:hover { background: var(--rose-600); color: #fff; }
.sb-chips-clear { background: none; border: none; color: var(--text-muted); font-size: var(--fs-sm); font-weight: 700; cursor: pointer; text-decoration: underline; }

.sb-daily-empty {
    text-align: center; padding: 36px 16px; font-size: var(--fs-base); font-weight: 700; color: var(--text-muted);
    background: var(--bg-card); border: 1.5px dashed var(--gray-300); border-radius: var(--radius-md);
}
.sb-daily-empty.is-ok { color: var(--green-800); background: var(--green-50); border: 1px solid var(--green-200); }
.sb-daily-empty.is-error { color: var(--danger-dark); background: var(--rose-50); border: 1px solid var(--rose-200); }

.sb-cover { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; }
.sb-cover-bar {
    display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap;
    padding: 12px 14px; border-bottom: 1px solid var(--border);
}
.sb-cover-stats { display: flex; flex-wrap: wrap; gap: 6px; }
.sb-cover-stats span {
    font-size: var(--fs-sm); font-weight: 800; color: var(--gray-600); background: var(--gray-100);
    border-radius: var(--radius-full); padding: 3px 10px;
}
.sb-cover-stats span b { color: var(--text-main); }
.sb-cover-stats .ok { background: var(--success-light); color: var(--success-dark); }
.sb-cover-stats .warn { background: var(--danger-light); color: var(--danger-dark); }
.sb-cover-actions { display: flex; gap: 8px; }
.sb-cover-actions .btn { font-weight: 800; }
.sb-btn-wa { background: #25d366; border: 1px solid #25d366; color: #fff; }
.sb-btn-wa:hover { background: #1fb855; border-color: #1fb855; color: #fff; }

.sb-cover-table { min-width: 560px; }
.sb-cover-table th { padding: 10px 14px; font-size: var(--fs-sm); }
.sb-cover-table td { padding: 8px 14px; }
.sb-cover-table tr:hover td { background: transparent; }
.sb-cover-table tr.sb-band td { background: var(--gray-50); }
.sb-cover-table .sb-col-period { width: 70px; text-align: center; border-left: 1px solid var(--border); }
.sb-cover-table td.sb-col-period span {
    display: inline-flex; align-items: center; justify-content: center;
    width: 30px; height: 30px; border-radius: var(--radius-md); background: var(--primary); color: #fff; font-weight: 900;
}
.sb-col-class { font-weight: 800; color: var(--text-main); white-space: nowrap; }
.sb-col-subject { color: var(--gray-600); }
.sb-col-absent { color: var(--rose-800); font-weight: 700; white-space: nowrap; }
.sb-col-assign { min-width: 220px; }
.sb-assign {
    width: 100%; max-width: 280px; padding: 6px 10px; font-size: var(--fs-base); font-weight: 800;
    color: var(--success-dark); background: var(--emerald-50); border: 1px solid var(--emerald-200); border-radius: var(--radius-md); cursor: pointer;
}
.sb-assign:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
tr.is-vacant .sb-assign, tr.is-conflict .sb-assign { color: var(--danger-dark); background: var(--rose-50); border-color: var(--rose-200); }
.sb-vacant-note { font-size: var(--fs-sm); font-weight: 800; color: var(--danger-dark); }
.sb-row-note { margin-top: 4px; font-size: var(--fs-sm); font-weight: 800; color: var(--danger-dark); }

@media (max-width: 640px) {
    .sb-daily-controls { grid-template-columns: minmax(0, 1fr); }
    .sb-cover-actions { width: 100%; }
    .sb-cover-actions .btn { flex: 1; justify-content: center; }
}

/* ==========================================================================
   مشرفو حصة النشاط في خطوة الإسناد (app.js ← renderActivitySupervisorsSection)
   ========================================================================== */
.alloc-activity { border-color: var(--emerald-200); }
.alloc-activity .alloc-matrix-header-bar { background: var(--green-50); border-bottom-color: var(--green-200); }
.alloc-activity-hint { padding: 8px 12px; font-size: var(--fs-sm); color: var(--gray-600); border-bottom: 1px solid var(--border); }
.alloc-activity-off { padding: 10px 12px; font-size: var(--fs-sm); font-weight: 700; color: var(--warning-dark); background: var(--amber-50); }
.alloc-activity-table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); min-width: 560px; }
.alloc-activity-table th {
    background: var(--gray-50); color: var(--gray-600); font-weight: 800; font-size: var(--fs-sm);
    padding: 6px 10px; text-align: right; border-bottom: 1.5px solid var(--border);
}
.alloc-activity-table td { padding: 5px 10px; border-bottom: 1px solid var(--gray-100); vertical-align: middle; }
.alloc-activity-table tr:last-child td { border-bottom: none; }
.alloc-activity-table th:nth-child(1) { width: 30%; }
.alloc-activity-table th:nth-child(3) { width: 30%; }
.alloc-activity-class { font-weight: 800; color: var(--text-main); white-space: nowrap; }
.alloc-activity-group {
    width: 100%; height: 27px; padding: 2px 8px; font-family: 'Cairo', sans-serif; font-size: var(--fs-sm); font-weight: 600;
    border: 1.5px solid var(--gray-300); border-radius: var(--radius-xs); background: #fff; color: var(--gray-700);
}
.alloc-activity-group:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
.alloc-activity-group:disabled { background: var(--gray-50); color: var(--gray-400); cursor: not-allowed; }

/* ==========================================================================
   نافذة اختيار المعلم في الإسناد (app.js ← openTeacherPicker)
   ========================================================================== */
.tpick { position: relative; cursor: pointer; border-radius: var(--radius-sm); outline: none; }
.tpick select { pointer-events: none; }
.tpick:focus-visible { box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.35); }
.tpick[aria-expanded="true"] select { border-color: var(--primary); box-shadow: var(--ring); }

.tpick-panel {
    position: fixed; z-index: 3000;
    display: flex; flex-direction: column;
    max-height: min(70vh, 560px);
    background: #fff; border: 1px solid var(--gray-300); border-radius: var(--radius-lg);
    box-shadow: 0 18px 40px -8px rgba(15, 23, 42, 0.25), 0 4px 12px rgba(15, 23, 42, 0.08);
    font-family: 'Cairo', sans-serif; direction: rtl; overflow: hidden;
}
.tpick-panel.is-sheet {
    left: 0 !important; right: 0; bottom: 0; top: auto !important; width: auto !important;
    max-height: 82vh; border-radius: 16px 16px 0 0;
}
.tpick-head {
    display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center;
    padding: 10px 12px; border-bottom: 1px solid var(--border); background: var(--gray-50);
}
.tpick-title { font-size: var(--fs-base); font-weight: 800; color: var(--text-main); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tpick-close {
    width: 28px; height: 28px; border: none; border-radius: var(--radius-md); background: transparent;
    font-size: var(--fs-2xl); line-height: 1; color: var(--gray-500); cursor: pointer;
}
.tpick-close:hover { background: var(--gray-200); color: var(--text-main); }
.tpick-search {
    grid-column: 1 / -1; width: 100%; height: 36px; padding: 0 12px;
    font-family: inherit; font-size: var(--fs-base); font-weight: 600;
    border: 1.5px solid var(--gray-300); border-radius: var(--radius-md); outline: none; background: #fff;
}
.tpick-search:focus { border-color: var(--primary); box-shadow: var(--ring); }

.tpick-body { overflow-y: auto; padding: 8px 12px 12px; overscroll-behavior: contain; }
.tpick-group { margin-top: 6px; }
.tpick-group-title { font-size: var(--fs-sm); font-weight: 800; color: var(--gray-500); padding: 4px 2px; }
.tpick-group-title span { font-weight: 600; color: var(--gray-400); }
.tpick-suggested { background: var(--green-50); border: 1px solid var(--green-200); border-radius: var(--radius-md); padding: 4px 8px 8px; margin-top: 0; }
.tpick-suggested .tpick-group-title { color: var(--emerald-700); }
.tpick-panel.is-searching .tpick-suggested { display: none; }
.tpick-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }

.tpick-item {
    display: flex; align-items: center; gap: 6px; min-width: 0; min-height: 34px;
    padding: 5px 8px; text-align: right; cursor: pointer;
    font-family: inherit; font-size: var(--fs-sm); font-weight: 700; color: var(--text-main);
    background: #fff; border: 1px solid var(--gray-200); border-radius: var(--radius-md);
    transition: background 0.12s ease, border-color 0.12s ease;
}
.tpick-item:hover, .tpick-item:focus { background: var(--primary-subtle); border-color: #5eead4; outline: none; }
.tpick-item:focus-visible { box-shadow: 0 0 0 2px var(--primary); }
.tpick-item.is-current { background: var(--emerald-50); border-color: var(--success); }
.tpick-item.is-full { opacity: 0.55; }
.tpick-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tpick-tag { flex-shrink: 0; font-size: var(--fs-2xs); font-weight: 800; color: var(--info-dark); background: var(--info-light); border-radius: var(--radius-xs); padding: 0 5px; }
.tpick-rem {
    flex-shrink: 0; min-width: 24px; text-align: center; font-size: var(--fs-xs); font-weight: 800;
    border-radius: var(--radius-full); padding: 1px 6px;
}
.tpick-rem.ok { background: var(--success-light); color: var(--success-dark); }
.tpick-rem.no { background: var(--danger-light); color: var(--danger-dark); }
.tpick-empty { padding: 24px 8px; text-align: center; font-size: var(--fs-base); font-weight: 700; color: var(--text-muted); }

.tpick-foot {
    display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap;
    padding: 8px 12px; border-top: 1px solid var(--border); background: var(--gray-50);
}
.tpick-legend { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-xs); font-weight: 700; color: var(--gray-500); }
.tpick-legend i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.tpick-legend i.ok { background: var(--success); }
.tpick-legend i.no { background: var(--danger); margin-right: 6px; }
.tpick-clear {
    border: 1px solid var(--rose-200); background: var(--rose-50); color: var(--rose-700); border-radius: var(--radius-md);
    padding: 4px 12px; font-family: inherit; font-size: var(--fs-sm); font-weight: 800; cursor: pointer;
}
.tpick-clear:hover { background: #ffe4e6; }

@media (max-width: 900px) { .tpick-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 420px) { .tpick-grid { grid-template-columns: minmax(0, 1fr); } }
.tpick-panel [hidden] { display: none !important; }

/* ==========================================================================
   بطاقة إجراء (عنوان + وصف + زر في الأسفل) — النسخ الاحتياطي وما يشبهه
   ========================================================================== */
.action-card {
    display: flex; flex-direction: column; justify-content: space-between; gap: 16px;
    padding: 20px; background: var(--bg-card);
    border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
}
.action-card-title { display: flex; align-items: center; gap: 8px; margin: 0 0 6px; font-size: var(--fs-lg); font-weight: 800; color: var(--text-main); }
.action-card-title span:first-child { font-size: var(--fs-xl); }
.action-card p { margin: 0; font-size: var(--fs-base); line-height: 1.7; color: var(--text-muted); }
.action-card-tag {
    display: inline-block; margin-top: 8px; padding: 2px 10px; border-radius: var(--radius-full);
    font-size: var(--fs-sm); font-weight: 800; background: var(--primary-subtle); color: var(--primary);
}
.action-card.is-recommended { border-color: var(--teal-200); box-shadow: 0 0 0 3px var(--primary-subtle); }

/* ==========================================================================
   مؤشر التحميل العام (.spinner مستخدم في مواضع كثيرة ولم يكن له تنسيق)
   ========================================================================== */
.spinner {
    width: 28px; height: 28px;
    border: 3px solid var(--primary-light); border-top-color: var(--primary);
    border-radius: 50%;
    animation: app-spin 0.8s linear infinite;
}
@keyframes app-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } }

/* شاشة التحميل الأولى قبل فتح أول خطوة */
.app-boot-loader {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
    min-height: 50vh; font-size: var(--fs-base); font-weight: 700; color: var(--text-muted);
}

/* ==========================================================================
   جداول تتحول إلى بطاقات على الجوال (App.enableMobileCards يضيف .mobile-cards وdata-label)
   ========================================================================== */
@media (max-width: 640px) {
    .table-responsive:has(> table.mobile-cards) { overflow-x: visible; }
    table.mobile-cards,
    table.mobile-cards tbody,
    table.mobile-cards tr,
    table.mobile-cards td { display: block; width: 100%; }
    table.mobile-cards { min-width: 0 !important; }
    table.mobile-cards thead { display: none; }

    table.mobile-cards tr {
        position: relative;
        margin: 0 0 var(--sp-3);
        padding: var(--sp-2) var(--sp-3);
        background: var(--bg-card);
        border: 1px solid var(--border);
        border-radius: var(--radius-lg);
        box-shadow: var(--shadow-sm);
    }
    table.mobile-cards tr:hover td { background: transparent; }

    table.mobile-cards td {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: var(--sp-3);
        min-height: 40px;
        padding: var(--sp-1) 0 !important;
        border: none !important;
        border-bottom: 1px dashed var(--gray-100) !important;
        text-align: right !important;
        width: 100% !important;
    }
    table.mobile-cards td:last-child { border-bottom: none !important; }
    table.mobile-cards td::before {
        content: attr(data-label);
        flex-shrink: 0;
        max-width: 42%;
        font-size: var(--fs-xs);
        font-weight: var(--fw-heavy);
        color: var(--text-muted);
    }
    table.mobile-cards td[data-label=""]::before { content: none; }
    table.mobile-cards td > input,
    table.mobile-cards td > select { flex: 1; min-width: 0; max-width: 62%; }
    table.mobile-cards td[colspan] { display: block; text-align: center !important; }
    table.mobile-cards td[colspan]::before { content: none; }

    /* — جدول المعلمين: الاسم عنوان البطاقة، والرقم التسلسلي شارة صغيرة في الزاوية — */
    #teachersUnifiedTable td:nth-child(1) {
        position: absolute; top: var(--sp-2); left: var(--sp-3);
        width: auto !important; min-height: 0; padding: 0 !important; border: none !important;
        font-size: var(--fs-xs); color: var(--text-light) !important;
    }
    #teachersUnifiedTable td:nth-child(1)::before { content: none; }
    #teachersUnifiedTable td:nth-child(2) { padding-left: 32px !important; }
    #teachersUnifiedTable td:nth-child(2)::before { content: none; }
    #teachersUnifiedTable td:nth-child(2) > input {
        max-width: none;
        font-size: var(--fs-lg) !important;
        font-weight: var(--fw-heavy);
    }
    #teachersUnifiedTable td:nth-child(5) > div { flex: 1; justify-content: flex-end; }
    #teachersUnifiedTable td:nth-child(9) > div { justify-content: flex-end !important; }
    #teachersUnifiedTable tr.teacher-new-row,
    #teachersUnifiedTable tr.teacher-extra-new-row {
        border: 1.5px dashed var(--primary-hover) !important;
        background: var(--primary-subtle) !important;
    }
    #teachersUnifiedTable tr.teacher-new-row td:nth-child(5),
    #teachersUnifiedTable tr.teacher-new-row td:nth-child(6) { display: none; }
    #teachersUnifiedTable tr.teacher-new-row td:nth-child(1) { color: var(--primary-hover) !important; font-size: var(--fs-lg); }
    #teachersUnifiedTable tr.teacher-new-row td:nth-child(9) > .btn { width: 100%; }
}

/* ==========================================================================
   أيقونات الواجهة (assets/js/ui-icons.js) — تأخذ لون النص وحجمه
   ========================================================================== */
.ui-ic {
    display: inline-block;
    width: 1.15em;
    height: 1.15em;
    vertical-align: -0.2em;
    flex-shrink: 0;
    stroke-width: 2;
}
.btn .ui-ic, button .ui-ic { width: 1.1em; height: 1.1em; }
h3 .ui-ic, h4 .ui-ic { color: var(--primary); }
.btn-primary .ui-ic, .btn-danger .ui-ic { color: inherit; }
.empty-state .ui-ic { color: var(--primary); }
.empty-state > div:first-child > .ui-ic { opacity: 0.35; stroke-width: 1.5; }
.empty-state .btn .ui-ic, .empty-state button .ui-ic { color: inherit; opacity: 1; }
/* عنوان الحالة الفارغة كان يأخذ حجم المتصفح الافتراضي (18.72px) */
.empty-state h3 { font-size: var(--fs-lg); font-weight: var(--fw-heavy); color: var(--text-main); }
.empty-state p { font-size: var(--fs-base); }

/* شبكة حقلين متساويين (بيانات المدرسة) — عمود واحد على الجوال */
.settings-grid-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--sp-4);
    margin-bottom: var(--sp-4);
}
@media (max-width: 640px) {
    .settings-grid-2 { grid-template-columns: minmax(0, 1fr); }
}
.settings-hint {
    margin: 0;
    font-size: var(--fs-sm);
    color: var(--text-muted);
}
/* زر بشكل رابط لإجراء ثانوي داخل نص */
.link-btn {
    padding: 0;
    border: none;
    background: none;
    font: inherit;
    font-weight: var(--fw-bold);
    color: var(--primary);
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer;
}
.link-btn:hover { color: var(--primary-strong); }

/* أزرار رأس الخطوة على الجوال: صف واحد بعروض متساوية بدل أعمدة متفاوتة */
@media (max-width: 640px) {
    .tab-header-actions { width: 100%; }
    .tab-header-actions > .btn,
    .tab-header-actions > .btn-save-header { flex: 1 1 140px; justify-content: center; }
    .tab-header-actions > .tab-header-badge,
    .tab-header-actions > .badge { flex-basis: 100%; text-align: center; justify-content: center; }
}
/* اسم الصف فوق اسم الفصل في جدول تغطية الغياب */
.sb-col-class .sb-grade { display: block; font-size: var(--fs-xs); font-weight: var(--fw-bold); color: var(--text-muted); line-height: 1.3; }
