/* =========================================================
   هوية "فخامة" — مركز شيخ الإسلام ابن تيمية الوقفي
   كحلي عميق (من الخلفية الزخرفية)، أزرق الهوية، ولمسة ذهبية (من الشعار).
   مبنية فوق Bootstrap 5 RTL: تعيد تلوين مكوناته دون تغيير طريقة عملها.
   ========================================================= */

:root {
    /* الأدوار الثلاثة */
    --navy: #0b1d33;
    --navy-2: #13304f;
    --blue: #1f5585;
    --blue-deep: #184569;
    --blue-light: #4f86b8;
    --blue-tint: #e8f0f8;
    --gold: #d3a46b;
    --gold-deep: #b38549;
    --gold-light: #ebd2a6;
    --gold-tint: #faf3e7;

    /* نفس الألوان بصيغة R, G, B للظلال والتدرجات الشفافة */
    --navy-rgb: 11, 29, 51;
    --blue-rgb: 31, 85, 133;
    --blue-light-rgb: 79, 134, 184;
    --gold-rgb: 211, 164, 107;

    --ink: #142235;
    --muted: #5b6b7c;
    --faint: #8d99a6;
    --line: #e3e9ef;
    --bg: #ffffff;
    --bg-soft: #f3f6fa;
    --success: #2e8b6a;
    --success-tint: #e2f3ec;
    --danger: #b8433f;
    --danger-tint: #f9e6e5;
    --warn: #8d6418;

    --shadow-sm: 0 2px 6px rgba(var(--navy-rgb), 0.05);
    --shadow: 0 2px 6px rgba(var(--navy-rgb), 0.04), 0 18px 40px -20px rgba(var(--navy-rgb), 0.22);
    --shadow-lg: 0 4px 10px rgba(var(--navy-rgb), 0.05), 0 36px 70px -30px rgba(var(--navy-rgb), 0.4);

    --radius-sm: 12px;
    --radius: 18px;
    --radius-lg: 26px;

    --font-display: 'El Messiri', 'Tajawal', sans-serif;
    --font-body: 'Tajawal', 'El Messiri', sans-serif;
    --ease: cubic-bezier(0.22, 0.8, 0.26, 1);
    --sidebar-w: 270px;

    /* ربط ألوان Bootstrap بالهوية */
    --bs-body-font-family: var(--font-body);
    --bs-body-color: var(--ink);
    --bs-body-bg: var(--bg-soft);
    --bs-primary: var(--blue);
    --bs-primary-rgb: 31, 85, 133;
    --bs-link-color: var(--blue);
    --bs-link-hover-color: var(--blue-deep);
    --bs-border-color: var(--line);
    --bs-border-radius: var(--radius-sm);
    --bs-success-rgb: 46, 139, 106;
    --bs-danger-rgb: 184, 67, 63;
}

/* ---------- الأساسيات ---------- */
html { -webkit-text-size-adjust: 100%; }
body {
    font-family: var(--font-body);
    color: var(--ink);
    background: var(--bg-soft);
    direction: rtl;
    text-align: right;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}
h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 { font-family: var(--font-display); font-weight: 700; color: inherit; text-wrap: balance; }
a { color: var(--blue); }
code { color: var(--blue-deep); background: var(--blue-tint); padding: 1px 6px; border-radius: 6px; direction: ltr; unicode-bidi: embed; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.ltr-num { direction: ltr; unicode-bidi: embed; font-variant-numeric: tabular-nums; }

/* ---------- الأزرار (مع لمعة تمرّ عند المرور) ---------- */
.btn {
    position: relative;
    overflow: hidden;
    isolation: isolate;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: 999px;
    font-weight: 700;
    white-space: nowrap;
    padding: 0.55rem 1.4rem;
    transition: transform 0.35s var(--ease), box-shadow 0.35s var(--ease), background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}
.btn::after {
    content: '';
    position: absolute;
    z-index: -1;
    top: 0;
    bottom: 0;
    width: 40%;
    right: -60%;
    background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.35), transparent);
    transform: skewX(-20deg);
    transition: right 0.7s var(--ease);
    pointer-events: none;
}
.btn:hover::after { right: 120%; }
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn.disabled { transform: none; }
.btn-sm { padding: 0.35rem 0.95rem; font-size: 0.86rem; }
.btn-lg { padding: 0.75rem 1.8rem; }

.btn-primary {
    --bs-btn-bg: var(--blue);
    --bs-btn-border-color: var(--blue);
    --bs-btn-hover-bg: var(--blue-deep);
    --bs-btn-hover-border-color: var(--blue-deep);
    --bs-btn-active-bg: var(--blue-deep);
    --bs-btn-active-border-color: var(--blue-deep);
    --bs-btn-disabled-bg: var(--blue);
    --bs-btn-disabled-border-color: var(--blue);
    background-image: linear-gradient(135deg, var(--blue), var(--navy-2));
    border: 0;
    box-shadow: 0 12px 24px -14px rgba(var(--navy-rgb), 0.9);
}
.btn-gold, .btn-warning {
    --bs-btn-color: var(--navy);
    --bs-btn-bg: var(--gold);
    --bs-btn-border-color: var(--gold);
    --bs-btn-hover-color: var(--navy);
    --bs-btn-hover-bg: var(--gold-light);
    --bs-btn-hover-border-color: var(--gold-light);
    --bs-btn-active-color: var(--navy);
    --bs-btn-active-bg: var(--gold);
    --bs-btn-disabled-color: var(--navy);
    --bs-btn-disabled-bg: var(--gold);
    background-image: linear-gradient(135deg, var(--gold-light), var(--gold));
    border: 0;
    color: var(--navy);
    box-shadow: 0 12px 24px -14px rgba(var(--gold-rgb), 1);
}
.btn-success {
    --bs-btn-bg: var(--success);
    --bs-btn-border-color: var(--success);
    --bs-btn-hover-bg: #26755a;
    --bs-btn-hover-border-color: #26755a;
    --bs-btn-active-bg: #26755a;
    --bs-btn-disabled-bg: var(--success);
    --bs-btn-disabled-border-color: var(--success);
}
.btn-danger {
    --bs-btn-bg: var(--danger);
    --bs-btn-border-color: var(--danger);
    --bs-btn-hover-bg: #9c3835;
    --bs-btn-hover-border-color: #9c3835;
    --bs-btn-active-bg: #9c3835;
    --bs-btn-disabled-bg: var(--danger);
    --bs-btn-disabled-border-color: var(--danger);
}
.btn-secondary, .btn-light, .btn-outline-secondary {
    --bs-btn-color: var(--ink);
    --bs-btn-bg: #fff;
    --bs-btn-border-color: var(--line);
    --bs-btn-hover-color: var(--blue);
    --bs-btn-hover-bg: #fff;
    --bs-btn-hover-border-color: var(--blue);
    --bs-btn-active-color: var(--blue);
    --bs-btn-active-bg: var(--blue-tint);
    --bs-btn-active-border-color: var(--blue);
}
.btn-outline-primary {
    --bs-btn-color: var(--blue);
    --bs-btn-border-color: rgba(var(--blue-rgb), 0.35);
    --bs-btn-hover-bg: var(--blue);
    --bs-btn-hover-border-color: var(--blue);
    --bs-btn-active-bg: var(--blue-deep);
}
.btn-outline-danger {
    --bs-btn-color: var(--danger);
    --bs-btn-border-color: rgba(184, 67, 63, 0.35);
    --bs-btn-hover-bg: var(--danger);
    --bs-btn-hover-border-color: var(--danger);
    --bs-btn-active-bg: #9c3835;
}

/* ---------- البطاقات ---------- */
.card {
    --bs-card-border-color: var(--line);
    --bs-card-border-radius: var(--radius-lg);
    --bs-card-inner-border-radius: calc(var(--radius-lg) - 1px);
    --bs-card-cap-bg: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    background: #fff;
    margin-bottom: 1.5rem;
}
.card-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 1.1rem 1.4rem;
    background: #fff;
    border-bottom: 1px solid var(--line);
    color: var(--ink);
}
.card-header h2, .card-header h3, .card-header h4, .card-header h5 { font-size: 1.12rem; margin: 0; display: flex; align-items: center; gap: 8px; }
.card-header h2 > i, .card-header h3 > i, .card-header h4 > i, .card-header h5 > i { color: var(--gold); }
.card-body { padding: 1.4rem; }

/* ---------- الجداول ---------- */
.table {
    --bs-table-bg: transparent;
    --bs-table-hover-bg: #f6f9fc;
    --bs-table-border-color: var(--line);
    margin-bottom: 0;
}
.table > :not(caption) > * > * { padding: 0.8rem 0.9rem; }
.table thead th {
    font-family: var(--font-body);
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--faint);
    background: #f8fafc;
    border-bottom-width: 1px;
    white-space: nowrap;
}
.table td { vertical-align: middle; }
/* الأرقام والتواريخ لا تنكسر على سطرين */
.table td.ltr-num, .table td[dir="ltr"] { white-space: nowrap; }
.table-bordered > :not(caption) > * > * { border-color: var(--line); }

/* ---------- الشارات ---------- */
.badge { font-weight: 700; border-radius: 999px; padding: 0.42em 0.8em; letter-spacing: 0; }
.badge.bg-success { background: var(--success-tint) !important; color: var(--success); }
.badge.bg-danger { background: var(--danger-tint) !important; color: var(--danger); }
.badge.bg-secondary { background: #eef1f4 !important; color: var(--muted); }
.badge.bg-warning { background: var(--gold-tint) !important; color: var(--warn) !important; }
.badge.bg-info { background: var(--blue-tint) !important; color: var(--blue); }
.badge.bg-primary { background: linear-gradient(135deg, var(--blue), var(--navy-2)) !important; color: #fff; }
.badge.bg-light { background: rgba(255, 255, 255, 0.9) !important; color: var(--ink) !important; }

/* ---------- النماذج ---------- */
.form-label { font-weight: 700; font-size: 0.93rem; color: var(--ink); }
.form-control, .form-select {
    min-height: 46px;
    border-radius: 14px;
    border-color: var(--line);
    color: var(--ink);
    transition: border-color 0.25s ease, box-shadow 0.25s ease;
}
textarea.form-control { min-height: 96px; }
.form-control:focus, .form-select:focus { border-color: var(--gold); box-shadow: 0 0 0 4px rgba(var(--gold-rgb), 0.18); }
.form-check-input:checked { background-color: var(--blue); border-color: var(--blue); }
.form-check-input:focus { border-color: var(--gold); box-shadow: 0 0 0 4px rgba(var(--gold-rgb), 0.18); }
.form-switch .form-check-input:checked { background-color: var(--success); border-color: var(--success); }
.input-group > .form-control { border-radius: 14px; }
.form-text { color: var(--muted); }

/* ---------- التنبيهات والرسائل العائمة ---------- */
.alert { border: 0; border-radius: var(--radius); padding: 0.95rem 1.15rem; }
.alert-success { background: var(--success-tint); color: #1f6b50; }
.alert-danger { background: var(--danger-tint); color: #7f2d2a; }
.alert-warning { background: var(--gold-tint); color: #6e4d10; }
.alert-info { background: var(--blue-tint); color: var(--blue-deep); }
.alert-secondary, .alert-light { background: #f1f4f7; color: var(--muted); }
.toast-stack {
    position: fixed;
    top: 1rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1100;
    width: min(560px, calc(100% - 2rem));
}
.toast-stack .alert {
    background: #fff;
    border-inline-start: 4px solid currentColor;
    box-shadow: var(--shadow-lg);
    animation: toast-in 0.5s var(--ease) both;
}
.toast-stack .alert-success { color: var(--success); }
.toast-stack .alert-danger { color: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-16px); } }

/* ---------- النوافذ ---------- */
.modal-content { border: 0; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); overflow: hidden; }
.modal-header { border-bottom: 1px solid var(--line); }
.modal-header .modal-title { font-size: 1.15rem; }
.modal-footer { border-top: 1px solid var(--line); }
.modal-backdrop.show { opacity: 1; background: rgba(var(--navy-rgb), 0.55); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }

/* =========================================================
   هيكل صفحات الإدارة: قائمة جانبية كحلية + محتوى
   ========================================================= */
.admin-body { background: var(--bg-soft); }
.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 22px 16px;
    overflow-y: auto;
    color: #fff;
    background:
        linear-gradient(rgba(var(--navy-rgb), 0.9), rgba(var(--navy-rgb), 0.96)),
        url('../images/backgraund.jpeg') center / cover;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}
.side-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 2px 8px 20px;
    margin-bottom: 14px;
    color: #fff;
    text-decoration: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.side-brand img { width: 48px; height: 48px; object-fit: contain; filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.35)); }
.side-brand strong { display: block; font-family: var(--font-display); font-size: 1.12rem; line-height: 1.3; }
.side-brand span { display: block; font-size: 0.78rem; color: var(--gold-light); }
.nav-group { margin-bottom: 14px; }
.nav-group-label { font-size: 0.74rem; font-weight: 700; color: rgba(255, 255, 255, 0.42); padding: 0 14px 6px; }
.side-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    color: rgba(255, 255, 255, 0.78);
    text-decoration: none;
    font-weight: 500;
    transition: background 0.3s ease, color 0.3s ease, padding 0.35s var(--ease);
}
.side-link i { width: 20px; text-align: center; color: rgba(255, 255, 255, 0.5); transition: color 0.3s ease; }
.side-link .ext { margin-inline-start: auto; width: auto; font-size: 0.72rem; opacity: 0.6; }
.side-link:hover { background: rgba(255, 255, 255, 0.07); color: #fff; padding-inline-start: 18px; }
.side-link.active { background: rgba(var(--gold-rgb), 0.15); color: #fff; font-weight: 700; }
.side-link.active i { color: var(--gold); }
.side-link.active::before { content: ''; position: absolute; top: 9px; bottom: 9px; right: 0; width: 3px; border-radius: 3px; background: var(--gold); }
.sidebar-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid rgba(255, 255, 255, 0.1); }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 8px; margin-bottom: 6px; }
.avatar { flex: none; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-family: var(--font-display); font-weight: 700; color: var(--navy); background: linear-gradient(135deg, var(--gold-light), var(--gold)); }
.user-chip strong { display: block; font-size: 0.92rem; line-height: 1.3; }
.user-chip span { font-size: 0.78rem; color: rgba(255, 255, 255, 0.55); }

.main { min-width: 0; padding: 18px 32px 28px; display: flex; flex-direction: column; min-height: 100vh; }
.topbar {
    position: sticky;
    top: 12px;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 18px;
    margin-bottom: 24px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-sm);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
}
.topbar-title { font-weight: 700; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-date { margin-inline-start: auto; font-size: 0.85rem; color: var(--muted); white-space: nowrap; }
.menu-toggle { display: none; width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: #fff; color: var(--ink); font-size: 1.2rem; place-items: center; cursor: pointer; flex: none; }
.scrim { display: none; }
.admin-footer { margin-top: auto; padding-top: 28px; text-align: center; font-size: 0.82rem; color: var(--faint); }

/* رأس الصفحة: عنوان بخط ذهبي يرتسم */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.page-head h1 { font-size: clamp(1.45rem, 2.6vw, 1.95rem); margin: 0; }
.page-head h1::after { content: ''; display: block; width: 56px; height: 3px; margin-top: 10px; border-radius: 3px; background: linear-gradient(to left, var(--gold), var(--gold-light)); transform-origin: right; animation: line-draw 1s var(--ease) 0.25s both; }
.page-head p { color: var(--muted); margin: 8px 0 0; max-width: 64ch; }
.page-actions { display: flex; flex-wrap: wrap; gap: 10px; }
@keyframes line-draw { from { transform: scaleX(0); } }

/* ظهور متتابع لمكونات الصفحة عند فتحها */
@keyframes rise { from { opacity: 0; transform: translateY(16px); } }
.main > .page-head, .main > .card, .main > .stat-grid, .main > .row, .main > .notice, .main > form, .main > section { animation: rise 0.7s var(--ease) both; }
.main > :nth-child(4) { animation-delay: 0.06s; }
.main > :nth-child(5) { animation-delay: 0.12s; }
.main > :nth-child(6) { animation-delay: 0.18s; }
.main > :nth-child(7) { animation-delay: 0.24s; }
.main > :nth-child(n + 8) { animation-delay: 0.3s; }

/* بطاقات الأرقام */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 18px; margin-bottom: 24px; }
/* توزيع متوازن بلا مربع وحيد في سطر: الثلاثة في صف، والأربعة في صف أو صفين متساويين */
.stat-grid:has(> :nth-child(3):last-child) { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stat-grid:has(> :nth-child(4):last-child) { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1219.98px) {
    .stat-grid:has(> :nth-child(4):last-child) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.stat-tile {
    position: relative;
    overflow: hidden;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 16px;
    padding: 20px;
    border-radius: var(--radius-lg);
    background: #fff;
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    color: var(--ink);
    text-decoration: none;
    transition: transform 0.4s var(--ease), box-shadow 0.4s var(--ease);
}
.stat-tile:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); color: var(--ink); }
/* حين يضيق المربع ينزل النص تحت الأيقونة بدل أن ينكسر على ثلاثة أسطر */
.stat-tile > div { flex: 1 1 120px; min-width: 0; }
.stat-icon { flex: none; width: 54px; height: 54px; border-radius: 16px; display: grid; place-items: center; font-size: 1.3rem; color: #fff; background: linear-gradient(135deg, var(--blue-light), var(--blue-deep)); box-shadow: 0 10px 20px -12px rgba(var(--blue-rgb), 0.9); transition: transform 0.5s var(--ease); }
.stat-tile.gold .stat-icon { color: var(--navy); background: linear-gradient(135deg, var(--gold-light), var(--gold)); box-shadow: 0 10px 20px -12px rgba(var(--gold-rgb), 0.9); }
.stat-tile.navy .stat-icon { background: linear-gradient(135deg, var(--navy-2), var(--navy)); }
.stat-tile:hover .stat-icon { transform: rotate(-8deg) scale(1.06); }
.stat-tile strong { display: block; font-family: var(--font-display); font-size: 1.85rem; line-height: 1.15; font-variant-numeric: tabular-nums; }
.stat-tile span { font-size: 0.9rem; color: var(--muted); }

/* روابط سريعة */
.quick { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.quick a { display: flex; align-items: center; gap: 12px; padding: 16px; border-radius: var(--radius); background: #fff; border: 1px solid var(--line); color: var(--ink); text-decoration: none; font-weight: 700; transition: all 0.35s var(--ease); }
.quick a small { display: block; font-weight: 500; color: var(--muted); font-size: 0.82rem; }
.quick a:hover { border-color: var(--gold); transform: translateY(-3px); box-shadow: var(--shadow); }
.quick a > i { flex: none; width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; font-size: 1.1rem; color: var(--blue); background: var(--blue-tint); transition: all 0.35s var(--ease); }
.quick a:hover > i { color: var(--navy); background: linear-gradient(135deg, var(--gold-light), var(--gold)); }

/* شريط تنبيه داخل الصفحة */
.notice { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; margin-bottom: 22px; border-radius: var(--radius); background: var(--gold-tint); color: #6e4d10; border: 1px solid rgba(var(--gold-rgb), 0.35); }

/* صورة مصغرة دائرية */
.avatar-sm { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; border: 2px solid #fff; box-shadow: var(--shadow-sm); }

/* حالة فارغة */
.empty { text-align: center; padding: 42px 20px; color: var(--muted); }
.empty > i { display: inline-grid; place-items: center; width: 64px; height: 64px; margin-bottom: 12px; border-radius: 50%; font-size: 1.6rem; color: var(--gold-deep); background: var(--gold-tint); }

/* بطاقات العرض على الجوال (بديل الجداول) */
.visitor-mobile-card .visitor-name { font-weight: 700; color: var(--ink); }
.visitor-mobile-card .visitor-detail { font-size: 0.85rem; color: var(--muted); }
.visitor-mobile-card img { border: 2px solid #fff; box-shadow: var(--shadow-sm); }
.mobile-card, .visitor-mobile-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px; box-shadow: var(--shadow-sm); }

/* ---------- الرسوم البيانية ---------- */
.chart-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 22px; }
.chart-grid .span-full { grid-column: 1 / -1; }
.chart-grid .span-2 { grid-column: span 2; }
.chart-card .card-header { padding-block: 0.95rem; }
.chart-card .card-header h2 { font-size: 1.02rem; }
.scope { font-size: 0.8rem; color: var(--faint); background: var(--bg-soft); border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; white-space: nowrap; }
.chart-box { position: relative; height: 240px; }
.span-full .chart-box { height: 280px; }
.chart-print { display: none; }
.chart-legend { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 8px; }
.chart-legend li { display: grid; grid-template-columns: 12px minmax(0, 1fr) auto 52px; grid-template-areas: "dot name val pc" "bar bar bar bar"; align-items: center; gap: 4px 10px; font-size: 0.88rem; }
.chart-legend .dot { grid-area: dot; width: 12px; height: 12px; border-radius: 4px; }
.chart-legend .name { grid-area: name; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chart-legend .val { grid-area: val; font-family: var(--font-display); font-weight: 700; font-variant-numeric: tabular-nums; }
.chart-legend .pc { grid-area: pc; text-align: left; color: var(--muted); font-variant-numeric: tabular-nums; direction: ltr; }
.chart-legend .bar { grid-area: bar; height: 5px; border-radius: 5px; background: var(--bg-soft); overflow: hidden; }
.chart-legend .bar span { display: block; height: 100%; border-radius: 5px; transform-origin: right; animation: line-draw 1.1s var(--ease) 0.3s both; }
.ratio-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 28px; }
.ratio-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 6px; font-size: 0.93rem; }
.ratio-top strong { font-family: var(--font-display); font-variant-numeric: tabular-nums; }
.ratio-top small { color: var(--muted); font-family: var(--font-body); font-weight: 500; }
.ratio-bar { height: 10px; border-radius: 10px; background: var(--bg-soft); border: 1px solid var(--line); overflow: hidden; }
.ratio-bar span { display: block; height: 100%; border-radius: 10px; transform-origin: right; animation: line-draw 1.2s var(--ease) 0.3s both; }
.tone-success .ratio-bar span { background: linear-gradient(to left, #3fae86, var(--success)); }
.tone-danger .ratio-bar span { background: linear-gradient(to left, #d36a66, var(--danger)); }
.tone-blue .ratio-bar span { background: linear-gradient(to left, var(--blue-light), var(--blue)); }
.tone-gold .ratio-bar span { background: linear-gradient(to left, var(--gold-light), var(--gold)); }
.tone-navy .ratio-bar span { background: linear-gradient(to left, var(--navy-2), var(--navy)); }
.tone-slate .ratio-bar span { background: linear-gradient(to left, #b3bdc7, var(--faint)); }
.suggestions { position: absolute; z-index: 30; inset-inline: 0; top: 100%; margin-top: 6px; border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); overflow: hidden; }
.suggestions:empty { display: none; }

/* ---------- البحث ---------- */
.search-bar { position: relative; display: flex; gap: 10px; }
.search-bar > i { position: absolute; top: 50%; right: 18px; transform: translateY(-50%); color: var(--gold); pointer-events: none; z-index: 5; }
.search-bar .form-control { min-height: 52px; padding-right: 46px; border-radius: 999px; }
.search-bar .btn { min-width: 110px; }

/* ---------- نموذج الزائر ---------- */
.form-card { max-width: 980px; }
.required-field::after { content: ' *'; color: var(--danger); font-weight: 700; }
input[type="number"], input[type="tel"], input[type="date"], input#id_number, input#age, input#membership_duration { direction: ltr; text-align: left; font-variant-numeric: tabular-nums; }
.renewal-card { border: 1px solid rgba(var(--gold-rgb), 0.4); border-radius: var(--radius); background: var(--gold-tint); overflow: hidden; }
.renewal-card.border-success { border-color: rgba(46, 139, 106, 0.45) !important; }
.renewal-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; }
.renewal-head > div:first-child i { color: var(--gold-deep); }
.renewal-body { padding: 4px 16px 6px; border-top: 1px dashed rgba(var(--gold-rgb), 0.45); }
.expiry-preview { padding: 12px; text-align: center; font-family: var(--font-display); font-size: 1.4rem; font-weight: 700; letter-spacing: 2px; color: var(--success); background: #fff; border: 1px solid var(--line); border-radius: 14px; }
.photo-preview { width: 180px; height: 180px; margin: 6px 0; overflow: hidden; border-radius: var(--radius); border: 1px solid var(--line); box-shadow: var(--shadow-sm); background: var(--bg-soft); }
.photo-preview img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- إدارة المستخدمين ---------- */
.role-badge { display: inline-flex; align-items: center; gap: 4px; padding: 4px 12px; border-radius: 999px; font-size: 0.8rem; font-weight: 700; white-space: nowrap; }
.role-admin { background: var(--gold-tint); color: var(--gold-deep); border: 1px solid rgba(var(--gold-rgb), 0.35); }
.role-moderator { background: var(--blue-tint); color: var(--blue); border: 1px solid rgba(var(--blue-rgb), 0.2); }
.role-viewer { background: #eef1f4; color: var(--muted); border: 1px solid var(--line); }
.password-toggle { cursor: pointer; position: absolute; left: 14px; top: 23px; transform: translateY(-50%); color: var(--faint); z-index: 5; }
.user-mobile-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px; box-shadow: var(--shadow-sm); }
.user-mobile-card .user-name { font-weight: 700; }
.user-mobile-card .user-username { font-size: 0.85rem; color: var(--faint); direction: ltr; text-align: right; }
.roles-help { padding: 14px; border-radius: var(--radius); background: var(--bg-soft); border: 1px solid var(--line); font-size: 0.84rem; }
.roles-help div + div { margin-top: 6px; }

/* =========================================================
   الصفحات العامة: خلفية سينمائية (فيديو واجهة المركز)
   ========================================================= */
.cinema {
    position: relative;
    min-height: 100vh;
    min-height: 100svh;
    color: #fff;
    background: var(--navy);
    /* منع التمرير الأفقي فقط؛ التمرير العمودي يبقى متاحاً حتى لا يُقص المحتوى على الشاشات القصيرة */
    overflow-x: hidden;
    overflow-y: auto;
    isolation: isolate;
}
.cinema-media { position: fixed; inset: 0; z-index: -2; background: var(--navy) url('../images/hero-poster.jpg') center / cover no-repeat; }
.cinema-media video, .cinema-media img { width: 100%; height: 100%; object-fit: cover; }
.cinema::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: -1;
    background:
        radial-gradient(ellipse at 50% 35%, rgba(var(--navy-rgb), 0.45), rgba(var(--navy-rgb), 0.86) 70%),
        linear-gradient(to bottom, rgba(var(--navy-rgb), 0.6), rgba(var(--navy-rgb), 0.35) 35%, rgba(var(--navy-rgb), 0.95));
}
/* إضاءتان ذهبية وزرقاء تطفوان ببطء */
.cinema .glow { position: fixed; z-index: -1; border-radius: 50%; pointer-events: none; }
.cinema .glow.one { width: 520px; height: 520px; top: -220px; right: -140px; background: radial-gradient(circle, rgba(var(--gold-rgb), 0.28), transparent 70%); animation: float 14s ease-in-out infinite; }
.cinema .glow.two { width: 480px; height: 480px; bottom: -220px; left: -140px; background: radial-gradient(circle, rgba(var(--blue-light-rgb), 0.35), transparent 70%); animation: float 16s ease-in-out infinite reverse; }
@keyframes float { 0%, 100% { transform: translate(0, 0); } 50% { transform: translate(-40px, 30px); } }

/* ظهور متتابع عند التحميل */
.intro > * { opacity: 0; transform: translateY(22px); animation: intro-rise 1s var(--ease) forwards; }
.intro > :nth-child(1) { animation-delay: 0.1s; }
.intro > :nth-child(2) { animation-delay: 0.25s; }
.intro > :nth-child(3) { animation-delay: 0.4s; }
.intro > :nth-child(4) { animation-delay: 0.55s; }
.intro > :nth-child(5) { animation-delay: 0.7s; }
.intro > :nth-child(n + 6) { animation-delay: 0.85s; }
@keyframes intro-rise { to { opacity: 1; transform: none; } }

.gold-text {
    background: linear-gradient(90deg, var(--gold-light), var(--gold), var(--gold-light));
    background-size: 200% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    animation: shimmer 6s ease-in-out infinite;
}
@keyframes shimmer { 0%, 100% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } }

.chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 16px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.22);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    font-size: 0.92rem;
    color: var(--gold-light);
}

/* بطاقة زجاجية داكنة */
.glass-card {
    position: relative;
    border-radius: 28px;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.14);
    -webkit-backdrop-filter: blur(18px);
    backdrop-filter: blur(18px);
    box-shadow: 0 40px 80px -30px rgba(0, 0, 0, 0.6);
}
.glass-card .form-label { color: rgba(255, 255, 255, 0.85); }
.glass-card .form-control {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.18);
    color: #fff;
}
.glass-card .form-control::placeholder { color: rgba(255, 255, 255, 0.45); }
.glass-card .form-control:focus { background: rgba(255, 255, 255, 0.12); color: #fff; }
.glass-card .invalid-feedback { color: #ffb4ae; }

/* ---------- صفحات الدخول ---------- */
.auth { min-height: 100vh; min-height: 100svh; display: grid; place-items: center; padding: 28px 16px; }
.auth-card { width: min(430px, 100%); padding: 36px 30px 28px; text-align: center; }
.auth-card .auth-logo { width: 96px; height: 96px; object-fit: contain; margin: 0 auto 12px; filter: drop-shadow(0 10px 22px rgba(0, 0, 0, 0.4)); }
.auth-card h1 { font-size: 1.6rem; margin: 6px 0 4px; }
.auth-card .sub { color: rgba(255, 255, 255, 0.65); margin-bottom: 22px; font-size: 0.95rem; }
.auth-card form { text-align: right; display: flex; flex-direction: column; gap: 16px; }
.field-icon { position: relative; }
.field-icon > i { position: absolute; top: 26px; right: 16px; transform: translateY(-50%); color: var(--gold); pointer-events: none; z-index: 5; }
.field-icon .form-control { padding-right: 44px; min-height: 52px; }
.auth-card .btn-gold { min-height: 52px; font-size: 1.05rem; margin-top: 4px; }
.auth-foot { margin-top: 18px; font-size: 0.9rem; text-wrap: balance; }
.auth-foot a { color: var(--gold-light); text-decoration: none; }
.auth-foot a:hover { color: #fff; }
.auth-copy { position: fixed; bottom: 12px; inset-inline: 0; text-align: center; font-size: 0.8rem; color: rgba(255, 255, 255, 0.45); }

/* ---------- شاشة تسجيل الزوار ---------- */
.kiosk { min-height: 100vh; min-height: 100svh; display: flex; flex-direction: column; }
.kiosk-main { flex: 1; display: grid; place-items: center; padding: 28px 18px 16px; }
.kiosk-grid { width: min(1080px, 100%); display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 0.9fr); gap: 26px; align-items: stretch; }
.kiosk-panel { padding: clamp(24px, 4vw, 44px); text-align: center; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.kiosk-logo { width: clamp(96px, 12vw, 140px); height: auto; filter: drop-shadow(0 12px 26px rgba(0, 0, 0, 0.45)); }
.kiosk-panel h1 { font-size: clamp(1.6rem, 3.6vw, 2.6rem); line-height: 1.35; margin: 14px 0 6px; text-shadow: 0 4px 30px rgba(0, 0, 0, 0.35); }
.kiosk-panel h1 .gold-text { display: block; }
.kiosk-clock { margin: 6px 0 18px; }
.kiosk-hint { color: rgba(255, 255, 255, 0.8); margin-bottom: 14px; font-size: 1.05rem; }
.kiosk-hint i { color: var(--gold); }
.scan-form { width: min(460px, 100%); display: flex; flex-direction: column; gap: 12px; }
/* معرّف #id_number يتغلب على قاعدة محاذاة حقول الهوية العامة، فيبقى النص في المنتصف */
.scan-form #id_number.scan-input {
    min-height: 64px !important;
    text-align: center;
    font-size: 1.6rem !important;
    font-weight: 800;
    letter-spacing: 4px;
    direction: ltr;
    border-radius: 18px !important;
}
.scan-form .btn-gold { min-height: 58px; font-size: 1.15rem; }
.qr-panel { padding: clamp(22px, 3vw, 34px); text-align: center; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; }
.qr-panel h2 { font-size: 1.3rem; margin: 0; }
.qr-panel p { color: rgba(255, 255, 255, 0.72); margin: 0; }
.qr-frame { display: block; width: min(220px, 70%); padding: 14px; border-radius: 22px; background: #fff; box-shadow: 0 0 0 6px rgba(var(--gold-rgb), 0.25), 0 24px 50px -20px rgba(0, 0, 0, 0.6); transition: transform 0.45s var(--ease), box-shadow 0.45s var(--ease); }
.qr-frame:hover { transform: translateY(-4px) scale(1.02); box-shadow: 0 0 0 8px rgba(var(--gold-rgb), 0.35), 0 30px 60px -20px rgba(0, 0, 0, 0.6); }
.qr-frame img { width: 100%; height: auto; border-radius: 10px; }
.kiosk-foot { display: flex; justify-content: center; align-items: center; gap: 12px; padding: 10px 16px 16px; font-size: 0.82rem; color: rgba(255, 255, 255, 0.5); }
.kiosk-foot a { color: rgba(255, 255, 255, 0.55); text-decoration: none; border: 1px solid rgba(255, 255, 255, 0.2); border-radius: 999px; padding: 2px 12px; transition: all 0.3s ease; }
.kiosk-foot a:hover { color: #fff; border-color: var(--gold); }

/* نافذة النتيجة العائمة في شاشة التسجيل */
.result-overlay {
    position: fixed;
    inset: 0;
    z-index: 1050;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(var(--navy-rgb), 0.72);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    cursor: pointer;
}
.result-overlay.show { opacity: 1; visibility: visible; }
.result-panel { width: 100%; max-width: 560px; max-height: calc(100vh - 2rem); overflow-y: auto; transform: scale(0.94); transition: transform 0.45s var(--ease); }
.result-overlay.show .result-panel { transform: none; }
.visitor-card {
    display: none;
    color: var(--ink);
    background: #fff;
    border-radius: 28px;
    overflow: hidden;
    box-shadow: 0 40px 80px -30px rgba(0, 0, 0, 0.6);
    text-align: center;
}
.visitor-card-top { position: relative; padding: 30px 24px 22px; color: #fff; background: radial-gradient(ellipse at top, var(--navy-2), var(--navy) 75%); }
.visitor-card-top::after { content: ''; position: absolute; inset-inline: 0; bottom: 0; height: 4px; background: linear-gradient(to left, var(--navy-2), var(--blue), var(--gold)); }
.visitor-photo { width: 132px; height: 132px; margin: 0 auto 14px; border-radius: 50%; object-fit: cover; background: #fff; border: 4px solid var(--gold); box-shadow: 0 0 0 8px rgba(var(--gold-rgb), 0.18); }
.visitor-card h2 { font-size: 1.7rem; margin: 0 0 4px; }
.visitor-card .welcome { color: rgba(255, 255, 255, 0.78); margin: 0 0 12px; }
.expiry-label { display: inline-flex; align-items: center; gap: 6px; padding: 5px 16px; border-radius: 999px; font-weight: 700; font-size: 0.95rem; }
.expiry-valid { background: rgba(46, 139, 106, 0.2); color: #8fe0bf; }
.expiry-warning { background: rgba(var(--gold-rgb), 0.22); color: var(--gold-light); }
.visitor-info { padding: 10px 26px 4px; text-align: right; }
.visitor-info-item { display: flex; justify-content: space-between; gap: 12px; padding: 11px 0; border-bottom: 1px dashed var(--line); }
.visitor-info-item:last-child { border-bottom: 0; }
.visitor-info-item span:first-child { color: var(--muted); }
.visitor-info-item span:last-child { font-weight: 700; }
.visitor-ok { padding: 16px 20px 22px; }
.visitor-ok h5 { color: var(--success); margin: 0 0 2px; }
.visitor-ok p { color: var(--muted); margin: 0; }
.message-error {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 24px;
    border-radius: 24px;
    background: #fff;
    color: var(--danger);
    text-align: right;
    box-shadow: 0 40px 80px -30px rgba(0, 0, 0, 0.6);
    border-top: 4px solid var(--danger);
}
.message-error .icon-box { flex: none; width: 60px; height: 60px; border-radius: 50%; display: grid; place-items: center; font-size: 1.6rem; background: var(--danger-tint); }
.message-error h5 { color: var(--ink); margin: 0 0 4px; }
.message-error p { color: var(--muted); }

/* ---------- صفحة التسجيل الذاتي ---------- */
.reg-hero { position: relative; padding: 46px 18px 120px; text-align: center; }
.reg-hero .reg-logo { display: block; width: 92px; height: auto; margin: 0 auto 12px; filter: drop-shadow(0 10px 22px rgba(0, 0, 0, 0.45)); }
.reg-hero h1 { font-size: clamp(1.7rem, 4.5vw, 2.7rem); margin: 10px 0 8px; }
.reg-hero p { color: rgba(255, 255, 255, 0.8); max-width: 560px; margin: 0 auto; text-wrap: balance; }
.reg-wrap { position: relative; width: min(820px, calc(100% - 28px)); margin: -84px auto 40px; }
.reg-card { background: #fff; color: var(--ink); border-radius: 28px; box-shadow: var(--shadow-lg); overflow: hidden; }
.reg-card::before { content: ''; display: block; height: 4px; background: linear-gradient(to left, var(--navy-2), var(--blue), var(--gold)); }
.reg-card .reg-body { padding: clamp(22px, 4vw, 40px); }
.reg-section-head { text-align: center; margin-bottom: 22px; }
.kicker { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 0.92rem; color: var(--gold-deep); }
.reg-section-head h2 { font-size: clamp(1.35rem, 3vw, 1.75rem); margin: 6px 0 0; }
.divider { display: block; width: 64px; height: 3px; margin: 14px auto 0; border-radius: 3px; background: linear-gradient(to left, var(--gold), var(--gold-light)); animation: line-draw 1s var(--ease) 0.6s both; }
.gender-options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.gender-options input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.gender-options label { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; border-radius: 14px; border: 1px solid var(--line); cursor: pointer; font-weight: 700; color: var(--muted); transition: all 0.3s var(--ease); }
.gender-options input:checked + label { color: #fff; border-color: transparent; background: linear-gradient(135deg, var(--blue), var(--navy-2)); box-shadow: 0 10px 20px -12px rgba(var(--navy-rgb), 0.8); }
.gender-options input:focus-visible + label { outline: 2px solid var(--gold); outline-offset: 2px; }
.was-validated .gender-options input:invalid + label { border-color: var(--danger); }
/* حقل عليه خطأ من السكربت (is-invalid) يبقى أحمر حتى بعد محاولة الإرسال، ولو كان صالحاً عند المتصفح (مثل حقل الصورة الاختياري) */
.was-validated .form-control.is-invalid:valid {
    border-color: var(--bs-form-invalid-border-color);
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' width='12' height='12' fill='none' stroke='%23dc3545'%3e%3ccircle cx='6' cy='6' r='4.5'/%3e%3cpath stroke-linejoin='round' d='M5.8 3.6h.4L6 6.5z'/%3e%3ccircle cx='6' cy='8.2' r='.6' fill='%23dc3545' stroke='none'/%3e%3c/svg%3e");
}
.was-validated .form-control.is-invalid:valid:focus { border-color: var(--bs-form-invalid-border-color); box-shadow: 0 0 0 0.25rem rgba(var(--bs-danger-rgb), 0.25); }
.upload-box { display: flex; align-items: center; gap: 16px; padding: 14px; border-radius: var(--radius); border: 1.5px dashed #c9d6e2; background: #f8fbfd; transition: border-color 0.3s ease, background 0.3s ease; }
.upload-box:hover { border-color: var(--gold); background: #fffcf7; }
.upload-box .preview { flex: none; width: 84px; height: 84px; border-radius: 16px; background: #fff; display: grid; place-items: center; color: var(--faint); font-size: 1.8rem; overflow: hidden; box-shadow: var(--shadow-sm); }
.upload-box .preview img { width: 100%; height: 100%; object-fit: cover; }
.upload-box .form-control { min-height: 42px; }
.reg-success { text-align: center; padding: 10px 0 4px; }
.reg-success > i { display: inline-grid; place-items: center; width: 76px; height: 76px; margin-bottom: 12px; border-radius: 50%; font-size: 2rem; color: #fff; background: linear-gradient(135deg, #3fae86, var(--success)); box-shadow: 0 0 0 10px var(--success-tint); }
.reg-foot { text-align: center; color: rgba(255, 255, 255, 0.55); font-size: 0.82rem; padding: 0 16px 24px; }

/* ---------- شاشة المراقبة ---------- */
.live-counter {
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 24px 28px;
    margin-bottom: 24px;
    border-radius: var(--radius-lg);
    color: #fff;
    background:
        linear-gradient(120deg, rgba(var(--navy-rgb), 0.94), rgba(var(--blue-rgb), 0.88)),
        url('../images/backgraund.jpeg') center / cover;
    box-shadow: var(--shadow-lg);
}
.live-counter h2 { font-size: 1.15rem; margin: 0 0 4px; color: var(--gold-light); }
.live-counter p { margin: 0; color: rgba(255, 255, 255, 0.7); font-size: 0.9rem; }
.live-dot { display: inline-block; width: 9px; height: 9px; margin-inline-end: 6px; border-radius: 50%; background: #4ade80; box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.6); animation: live-pulse 2.2s ease-out infinite; vertical-align: middle; }
@keyframes live-pulse { 0% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.6); } 80%, 100% { box-shadow: 0 0 0 10px rgba(74, 222, 128, 0); } }
#todayVisitorCount { font-family: var(--font-display); font-size: clamp(2.6rem, 6vw, 3.6rem); font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; transition: transform 0.4s var(--ease); }
.count-updated-effect { animation: count-pop 0.6s var(--ease); }
@keyframes count-pop { 50% { transform: scale(1.15); color: var(--gold-light); } }
.latest-attempt-container { padding: 1.4rem; }
@media (min-width: 768px) {
    .latest-attempt-container { min-height: 300px; }
    #latest-attempt-container { min-height: 260px; }
}

/* =========================================================
   الشاشات المتوسطة والصغيرة
   ========================================================= */
@media (max-width: 991.98px) {
    .app { grid-template-columns: minmax(0, 1fr); }
    .sidebar {
        position: fixed;
        z-index: 1060;
        top: 0;
        right: 0;
        bottom: 0;
        height: auto;
        width: min(290px, calc(100vw - 40px));
        transform: translateX(105%);
        transition: transform 0.45s var(--ease);
    }
    body.nav-open .sidebar { transform: none; }
    .scrim { display: block; position: fixed; inset: 0; z-index: 1055; background: rgba(var(--navy-rgb), 0.5); opacity: 0; pointer-events: none; transition: opacity 0.3s ease; }
    body.nav-open .scrim { opacity: 1; pointer-events: auto; }
    body.nav-open { overflow: hidden; }
    .menu-toggle { display: inline-grid; }
    .main { padding: 10px 14px 20px; }
    .topbar { top: 8px; margin-bottom: 18px; padding: 7px 10px 7px 14px; }
    .kiosk-grid { grid-template-columns: minmax(0, 1fr); }
    .qr-frame { width: min(180px, 60%); }
}
@media (max-width: 575.98px) {
    .card-header, .card-body { padding: 1rem; }
    .stat-grid, .stat-grid:has(> :nth-child(3):last-child) { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
    .stat-grid > :last-child:nth-child(odd) { grid-column: 1 / -1; }
    .stat-tile { flex-direction: column; align-items: flex-start; gap: 10px; padding: 16px; }
    .stat-tile > div { flex: none; }
    .stat-tile strong { font-size: 1.55rem; }
    .stat-icon { width: 44px; height: 44px; font-size: 1.1rem; border-radius: 13px; }
    .page-actions, .page-actions .btn { width: 100%; }
    .topbar-date { display: none; }
    .live-counter { padding: 20px; }
    .auth-card { padding: 28px 20px 24px; }
    .scan-input { font-size: 1.3rem !important; letter-spacing: 2px; }
    .visitor-photo { width: 108px; height: 108px; }
    .visitor-info { padding: 8px 18px 2px; }
    .message-error { flex-direction: column; text-align: center; }
    .upload-box { flex-direction: column; align-items: stretch; text-align: center; }
    .upload-box .preview { margin: 0 auto; }
}

@media (max-width: 1199.98px) {
    .chart-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .chart-grid .span-2 { grid-column: 1 / -1; }
}
@media (max-width: 767.98px) {
    .chart-grid, .ratio-grid { grid-template-columns: minmax(0, 1fr); }
    .chart-box { height: 220px; }
    .search-bar .btn { min-width: 0; }
}

/* الجداول العريضة تتحول إلى بطاقات تحت 1400px (لا تتسع بجانب القائمة الجانبية، وبلا سحب جانبي):
   كل خلية تأخذ عنوانها من data-label، والبطاقات تصطف في شبكة على الشاشات المتوسطة */
@media screen and (max-width: 1399.98px) {
    .table-cards thead { display: none; }
    .table-cards, .table-cards tr, .table-cards td { display: block; width: 100%; }
    .table-cards tbody { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); gap: 12px; }
    .table-cards tr { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 16px; box-shadow: var(--shadow-sm); }
    .table-cards > :not(caption) > * > * { padding: 9px 0; border: 0; border-bottom: 1px dashed var(--line); }
    .table-cards td:last-child { border-bottom: 0; }
    .table-cards td[data-label] { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
    .table-cards td[data-label]::before { content: attr(data-label); flex: none; font-size: 0.8rem; font-weight: 700; color: var(--faint); }
    /* خلايا الأرقام اتجاهها ltr: يُعكس الترتيب ليبقى العنوان يميناً */
    .table-cards td.ltr-num[data-label], .table-cards td[dir="ltr"][data-label] { flex-direction: row-reverse; }
    .table-cards td.cell-primary { font-size: 1.02rem; }
    .table-cards td.cell-index { display: none; }
}

.print-header { display: none; }

/* =========================================================
   الطباعة على A4: ترويسة رسمية، بلا قوائم أو أزرار، جداول كاملة،
   ورسوم تتسع للصفحة دون قص (تُحوَّل إلى صور قبل الطباعة)
   ========================================================= */
@page { size: A4; margin: 12mm 10mm 14mm; }
@media print {
    * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    *, *::before, *::after { animation: none !important; transition: none !important; }
    html, body { background: #fff !important; }
    body { font-size: 10.5pt; color: #000; overflow: visible; }

    .sidebar, .scrim, .topbar, .toast-stack, .no-print, .page-actions, .menu-toggle,
    .modal, .btn, .quick, .suggestions, .admin-footer, video, .glow, audio,
    .d-lg-none, .d-md-none, .d-xxl-none, .result-overlay, .kiosk-foot, .auth-foot, .auth-copy { display: none !important; }
    .d-none.d-lg-block, .d-none.d-md-block, .d-none.d-xxl-block { display: block !important; }

    .app { display: block; }
    .main { display: block; padding: 0; min-height: 0; }
    .print-header {
        display: flex;
        align-items: center;
        gap: 12px;
        padding-bottom: 8px;
        margin-bottom: 14px;
        border-bottom: 2px solid var(--gold);
    }
    .print-header img { width: 54px; height: auto; border-radius: 8px; }
    .print-header strong { display: block; font-family: var(--font-display); font-size: 14pt; color: var(--navy); }
    .print-header span { color: #444; font-size: 10pt; }
    .print-header .print-date { margin-inline-start: auto; font-size: 9pt; }

    .page-head { margin-bottom: 10px; }
    .page-head h1 { font-size: 16pt; }
    .page-head h1::after { display: none; }
    .page-head p { color: #333; }

    .card { box-shadow: none !important; border: 1px solid #cfd6dd; border-radius: 10px; margin-bottom: 10px; break-inside: avoid; page-break-inside: avoid; }
    .card:has(table) { break-inside: auto; page-break-inside: auto; }
    .card-header { padding: 6px 10px; background: #f4f6f9 !important; break-after: avoid; page-break-after: avoid; }
    .card-header h2 { font-size: 11pt; }
    .card-body { padding: 8px 10px; }

    .stat-grid { grid-template-columns: repeat(4, minmax(0, 1fr)) !important; gap: 8px; margin-bottom: 10px; }
    .stat-tile { padding: 8px 10px; gap: 8px; box-shadow: none; border-radius: 10px; flex-direction: row; align-items: center; }
    .stat-icon { width: 30px; height: 30px; font-size: 0.85rem; border-radius: 8px; box-shadow: none; }
    .stat-tile strong { font-size: 14pt; }
    .stat-tile span { font-size: 8.5pt; }
    .live-counter { padding: 10px 16px; box-shadow: none; }

    /* الجداول: كاملة بلا تمرير، ورأس الجدول يتكرر في كل صفحة */
    .table-responsive { overflow: visible !important; }
    .table { font-size: 8.5pt; width: 100% !important; }
    .table > :not(caption) > * > * { padding: 4px 6px; }
    .table thead { display: table-header-group; }
    .table tr { break-inside: avoid; page-break-inside: avoid; }
    .table th, .table td { white-space: normal !important; }
    .avatar-sm { width: 22px; height: 22px; border: 0; }
    .badge { border: 1px solid currentColor; }

    /* الرسوم: صورة بعرض البطاقة وارتفاع محدود */
    .chart-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 0 10px; }
    .chart-grid .span-full, .chart-grid .span-2 { grid-column: 1 / -1; }
    .chart-box { height: 62mm !important; }
    .span-full .chart-box { height: 70mm !important; }
    .chart-box.has-print { height: auto !important; }
    .chart-box.has-print canvas { display: none !important; }
    .chart-box.has-print .chart-print { display: block; width: 100%; height: auto; max-height: 62mm; object-fit: contain; margin: 0 auto; }
    .span-full .chart-box.has-print .chart-print { max-height: 70mm; }
    .chart-legend { margin-top: 6px; gap: 3px; }
    .chart-legend li { font-size: 8.5pt; }
    .ratio-grid { gap: 8px 18px; }
    .keep-together { break-inside: avoid; page-break-inside: avoid; }

    /* الصفحات العامة عند طباعتها */
    .cinema { background: #fff !important; color: #000; min-height: 0; }
    .cinema::before, .cinema-media { display: none !important; }
    .glass-card { background: #fff !important; border: 1px solid #cfd6dd; box-shadow: none !important; -webkit-backdrop-filter: none; backdrop-filter: none; color: #000; }
    .glass-card .form-control { background: #fff; color: #000; border-color: #999; }
    .glass-card .form-label, .auth-card .sub, .kiosk-hint, .qr-panel p { color: #333 !important; }
    .gold-text { color: var(--gold-deep) !important; background: none; -webkit-text-fill-color: currentColor; }
    .chip { color: #333; border-color: #999; background: none; }
    .kiosk-logo, .auth-logo, .reg-logo { filter: none; background: var(--navy); border-radius: 12px; padding: 6px; }
    .reg-hero { padding: 0 0 10px; color: #000; }
    .reg-hero p { color: #333; }
    .reg-wrap { margin: 0 auto; width: 100%; }
    .reg-card { box-shadow: none; border: 1px solid #cfd6dd; }
    .intro > * { opacity: 1 !important; transform: none !important; }
}

/* احترام إعداد تقليل الحركة في الجهاز */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
    .cinema-media video { display: none; }
}
