/* ============================================================
   نظام إدارة مسابقة أهل القرآن الكريم — ورقة الأنماط الرئيسية
   ------------------------------------------------------------
   1) المتغيرات والأساسيات
   2) الهيكل العام (الشريط الجانبي + الشريط العلوي)
   3) البطاقات والإحصاءات
   4) الجداول والشارات
   5) الأزرار والنماذج
   6) النوافذ (Modals) والتنبيهات (Toasts)
   7) المخططات وبطاقات الترتيب
   8) صفحة الدخول
   9) الاستجابة (Responsive)
   10) الطباعة (A6 Landscape)
   ============================================================ */

/* ---------------- 1) المتغيرات والأساسيات ---------------- */
:root {
    --pr: #1a4a2e;          /* الأخضر الداكن — اللون الرئيسي */
    --pr-mid: #2d7a4f;      /* الأخضر المتوسط */
    --pr-soft: #e8f1ec;     /* خلفية خضراء فاتحة */
    --gold: #c9a227;        /* الذهبي — للتميّز */
    --gold-lt: #f0c040;
    --gold-soft: #fdf6e3;
    --danger: #c0392b;
    --danger-soft: #fdecea;
    --info: #2b6cb0;
    --info-soft: #e8f0fa;

    --bg: #f4f6f5;
    --surface: #ffffff;
    --line: #dfe5e1;
    --text: #1f2a25;
    --muted: #6b7a72;

    --radius: 14px;
    --radius-sm: 9px;
    --shadow: 0 1px 2px rgba(16, 40, 28, .06), 0 8px 24px rgba(16, 40, 28, .06);
    --shadow-lg: 0 18px 50px rgba(16, 40, 28, .18);

    --sidebar-w: 262px;
    --topbar-h: 68px;

    --font: "Segoe UI", "Noto Naskh Arabic", "Cairo", Tahoma, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.65;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0 0 .4rem; line-height: 1.35; font-weight: 700; }
h1 { font-size: 1.4rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p  { margin: 0 0 .8rem; }
a  { color: var(--pr-mid); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
.ico { vertical-align: -3px; flex: 0 0 auto; }

::selection { background: var(--gold-lt); color: var(--pr); }

/* شريط تمرير أنيق */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: #eef2ef; }
::-webkit-scrollbar-thumb { background: #c3cfc8; border-radius: 20px; }
::-webkit-scrollbar-thumb:hover { background: #a8b8ae; }

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

.sidebar {
    width: var(--sidebar-w);
    flex: 0 0 var(--sidebar-w);
    background: linear-gradient(180deg, #16402a 0%, #123322 100%);
    color: #dfece4;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 40;
    transition: transform .25s ease;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: 1.05rem 1.1rem;
    border-bottom: 1px solid rgba(255, 255, 255, .09);
}
.sidebar-brand img,
.sidebar-brand .brand-logo {
    width: 32px;
    height: 32px;
    max-width: 32px;
    max-height: 32px;
    object-fit: contain;
    flex: 0 0 32px;
    align-self: center;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .3));
}
.sidebar-brand .b-title { font-weight: 700; font-size: .95rem; color: #fff; line-height: 1.3; }
.sidebar-brand .b-sub { font-size: .72rem; color: var(--gold-lt); letter-spacing: .3px; }

.sidebar-nav { padding: .8rem .7rem 1.4rem; overflow-y: auto; flex: 1; }
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.18); }

.nav-label {
    font-size: .68rem;
    letter-spacing: .8px;
    color: rgba(255, 255, 255, .42);
    padding: .9rem .6rem .35rem;
    text-transform: uppercase;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .62rem .75rem;
    border-radius: 10px;
    color: #cfe2d6;
    font-size: .92rem;
    margin-bottom: 2px;
    transition: background .15s, color .15s, transform .15s;
    text-decoration: none;
}
.nav-link:hover { background: rgba(255, 255, 255, .08); color: #fff; text-decoration: none; }
.nav-link.active {
    background: linear-gradient(90deg, rgba(201, 162, 39, .22), rgba(201, 162, 39, .05));
    color: #fff;
    box-shadow: inset 3px 0 0 var(--gold-lt);
}
.nav-link.active .ico { color: var(--gold-lt); }
.nav-link .count {
    margin-inline-start: auto;
    background: rgba(255, 255, 255, .13);
    color: #fff;
    font-size: .72rem;
    padding: .05rem .45rem;
    border-radius: 20px;
}

.sidebar-foot {
    padding: .8rem 1rem;
    border-top: 1px solid rgba(255, 255, 255, .09);
    font-size: .74rem;
    color: rgba(255, 255, 255, .5);
    text-align: center;
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar-logo {
    display: none;
    flex: 0 0 auto;
    margin-inline-end: .25rem;
}
.topbar-logo img {
    width: 26px;
    height: 26px;
    max-width: 26px;
    max-height: 26px;
    object-fit: contain;
    display: block;
}

.topbar {
    height: var(--topbar-h);
    background: rgba(255, 255, 255, .92);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    gap: .9rem;
    padding: 0 1.4rem;
    position: sticky;
    top: 0;
    z-index: 30;
}
.topbar h1 { font-size: 1.12rem; margin: 0; }
.topbar .crumb { font-size: .76rem; color: var(--muted); margin: 0; }

.topbar-actions { margin-inline-start: auto; display: flex; align-items: center; gap: .55rem; }

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px; height: 38px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--pr);
    cursor: pointer;
    transition: .15s;
}
.icon-btn:hover { background: var(--pr-soft); border-color: #cddbd3; }
.sidebar-toggle { display: none; }

.user-chip {
    display: flex;
    align-items: center;
    gap: .55rem;
    padding: .3rem .6rem .3rem .35rem;
    border: 1px solid var(--line);
    border-radius: 40px;
    background: #fff;
}
.avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--pr-mid), var(--pr));
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: .78rem;
    font-weight: 700;
    letter-spacing: .5px;
    flex: 0 0 auto;
}
.user-chip .u-name { font-size: .84rem; font-weight: 600; line-height: 1.2; }
.user-chip .u-role { font-size: .68rem; color: var(--muted); }

.content { padding: 1.4rem; flex: 1; }
.page-foot { padding: .6rem 1.4rem 1.4rem; color: var(--muted); font-size: .75rem; text-align: center; }

/* ---------------- 3) البطاقات والإحصاءات ---------------- */
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.card + .card { margin-top: 1rem; }
.card-head {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .95rem 1.15rem;
    border-bottom: 1px solid var(--line);
    background: #fbfcfb;
}
.card-head h2, .card-head h3 { margin: 0; font-size: .98rem; }
.card-head .spacer { margin-inline-start: auto; }
.card-body { padding: 1.15rem; }
.card-body.tight { padding: .6rem 0; }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.15rem;
}
/* شبكة إحصاءات متوازنة: 4 في الصف على الشاشات الكبيرة، و3 للبطاقات الست */
@media (min-width: 1100px) {
    .stats-grid { grid-template-columns: repeat(4, 1fr); }
    .stats-grid.six { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 1450px) {
    .stats-grid.six { grid-template-columns: repeat(6, 1fr); }
}
.stat {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1rem 1.1rem;
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: transform .18s, box-shadow .18s;
}
.stat::before {
    content: "";
    position: absolute;
    inset-inline: 0; top: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--pr), var(--pr-mid));
}
.stat.gold::before { background: linear-gradient(90deg, var(--gold), var(--gold-lt)); }
.stat.danger::before { background: linear-gradient(90deg, var(--danger), #e06b5e); }
.stat.info::before { background: linear-gradient(90deg, var(--info), #5b9bd5); }
.stat:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.stat .s-label { font-size: .78rem; color: var(--muted); display: flex; align-items: center; gap: .35rem; }
.stat .s-value { font-size: 1.75rem; font-weight: 800; color: var(--pr); line-height: 1.2; margin-top: .15rem; }
.stat .s-value small { font-size: .8rem; font-weight: 600; color: var(--muted); }
.stat .s-icon {
    position: absolute;
    inset-inline-end: .85rem;
    top: .8rem;
    color: #bed3c6;
    pointer-events: none;
    opacity: .95;
}
.stat.gold .s-icon { color: #e6d49c; }
.stat.danger .s-icon { color: #e7b7af; }
.stat.info .s-icon { color: #b8cfe8; }

.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
/* عمودان متوازنان على الشاشات الكبيرة */
@media (min-width: 900px) {
    .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }

.section-title {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: .9rem;
    font-weight: 700;
    color: var(--pr);
    margin: 1.4rem 0 .7rem;
}
.section-title::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* ---------------- 4) الجداول والشارات ---------------- */
.table-wrap { width: 100%; overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: .88rem; min-width: 640px; }
table.table th, table.table td { padding: .62rem .7rem; text-align: start; border-bottom: 1px solid #edf1ee; vertical-align: middle; }
table.table thead th {
    background: var(--pr);
    color: #fff;
    font-weight: 600;
    font-size: .8rem;
    white-space: nowrap;
    position: sticky;
    top: 0;
    border-bottom: none;
}
table.table tbody tr:hover { background: #f6faf7; }
table.table tbody tr:last-child td { border-bottom: none; }
table.table td.num, table.table th.num { text-align: center; white-space: nowrap; }
table.table td.actions { white-space: nowrap; text-align: end; }
.table-foot { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; padding: .8rem 1.1rem; border-top: 1px solid var(--line); background: #fbfcfb; }
.table-foot .info { font-size: .8rem; color: var(--muted); }

.mini-list { display: flex; flex-direction: column; }
.mini-row {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .6rem 1.1rem;
    border-bottom: 1px solid #eef2ef;
}
.mini-row:last-child { border-bottom: none; }
.mini-row:hover { background: #f7faf8; }
.mini-row .m-title { font-size: .87rem; font-weight: 600; }
.mini-row .m-sub { font-size: .74rem; color: var(--muted); }
.mini-row .m-end { margin-inline-start: auto; text-align: end; }

.badge {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    font-size: .72rem;
    font-weight: 600;
    padding: .16rem .55rem;
    border-radius: 30px;
    line-height: 1.6;
    white-space: nowrap;
    border: 1px solid transparent;
}
.badge-soft    { background: var(--pr-soft); color: var(--pr); border-color: #cfe2d7; }
.badge-gold    { background: var(--gold-soft); color: #8a6d00; border-color: #f0e0ae; }
.badge-success { background: #e7f7ee; color: #1c7a45; border-color: #c6ebd7; }
.badge-danger  { background: var(--danger-soft); color: var(--danger); border-color: #f6cdc7; }
.badge-info    { background: var(--info-soft); color: var(--info); border-color: #cfdff2; }
.badge-muted   { background: #f0f2f1; color: #61706a; border-color: #e0e5e2; }
.badge-dark    { background: var(--pr); color: #fff; }

/* التقديرات */
.grade { font-weight: 700; font-size: .78rem; padding: .18rem .6rem; border-radius: 30px; display: inline-block; }
.grade-a { background: #d8f3e3; color: #12683c; }
.grade-b { background: #dcecfb; color: #1b5e9e; }
.grade-c { background: #fff3d6; color: #8a6100; }
.grade-d { background: #fde8d7; color: #9a4b12; }
.grade-f { background: #fadbd8; color: #a5281b; }

.empty {
    text-align: center;
    padding: 2.6rem 1rem;
    color: var(--muted);
}
.empty .ico { color: #c9d6ce; margin-bottom: .5rem; }
.empty h3 { color: var(--text); font-size: .95rem; }
.empty p { font-size: .84rem; margin: 0; }

/* ---------------- 5) الأزرار والنماذج ---------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    padding: .52rem .95rem;
    font-family: inherit;
    font-size: .86rem;
    font-weight: 600;
    border-radius: 10px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: .16s;
    text-decoration: none;
    line-height: 1.5;
    white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn-primary { background: var(--pr); color: #fff; }
.btn-primary:hover { background: #143c24; color: #fff; }
.btn-gold { background: linear-gradient(135deg, var(--gold-lt), var(--gold)); color: #3d2f00; }
.btn-gold:hover { filter: brightness(1.04); color: #3d2f00; }
.btn-ghost { background: #fff; border-color: var(--line); color: var(--text); }
.btn-ghost:hover { background: #f4f7f5; border-color: #cfdbd4; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #a93226; color: #fff; }
.btn-soft { background: var(--pr-soft); color: var(--pr); }
.btn-soft:hover { background: #dcebe2; }
.btn-sm { padding: .32rem .62rem; font-size: .78rem; border-radius: 8px; }
.btn-icon { width: 32px; height: 32px; padding: 0; border-radius: 8px; }
.btn-block { width: 100%; }

.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: .6rem;
    padding: 1rem 1.1rem;
    border-bottom: 1px solid var(--line);
    background: #fbfcfb;
}
.toolbar .grow { flex: 1 1 220px; }

.field { display: flex; flex-direction: column; gap: .3rem; margin-bottom: .85rem; }
.field label { font-size: .82rem; font-weight: 600; color: #33443b; }
.field .req { color: var(--danger); }
.field .hint { font-size: .72rem; color: var(--muted); }
.field .err { font-size: .74rem; color: var(--danger); font-weight: 600; }

input[type="text"], input[type="password"], input[type="number"], input[type="date"],
input[type="email"], input[type="tel"], input[type="search"], input[type="file"], select, textarea {
    width: 100%;
    font-family: inherit;
    font-size: .88rem;
    color: var(--text);
    background: #fff;
    border: 1px solid #d5ded8;
    border-radius: var(--radius-sm);
    padding: .5rem .65rem;
    transition: border-color .15s, box-shadow .15s;
    min-height: 38px;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--pr-mid);
    box-shadow: 0 0 0 3px rgba(45, 122, 79, .13);
}
input.invalid, select.invalid, textarea.invalid { border-color: var(--danger); background: #fffafa; }
input:disabled, select:disabled, textarea:disabled {
    background: #eef6f0;
    color: #37624a;
    font-weight: 600;
    cursor: not-allowed;
    border-style: dashed;
}
textarea { min-height: 74px; resize: vertical; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 0 .9rem; }
.form-section {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1rem 1.05rem .35rem;
    margin-bottom: 1rem;
    background: #fff;
}
.form-section > .fs-title {
    display: flex;
    align-items: center;
    gap: .45rem;
    font-size: .88rem;
    font-weight: 700;
    color: var(--pr);
    margin: -.2rem 0 .9rem;
}
.form-section > .fs-title .badge { font-weight: 600; }
.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .6rem;
    padding-top: .4rem;
    position: sticky;
    bottom: 0;
    background: linear-gradient(180deg, rgba(244,246,245,0), var(--bg) 40%);
    padding-bottom: .6rem;
}

.switch { display: inline-flex; align-items: center; gap: .5rem; font-size: .84rem; cursor: pointer; }
.switch input { width: auto; min-height: auto; }

.check-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: .35rem .9rem; }
.check-item {
    display: flex;
    align-items: center;
    gap: .45rem;
    font-size: .82rem;
    padding: .3rem .45rem;
    border-radius: 8px;
    cursor: pointer;
}
.check-item:hover { background: #f4f8f5; }
.check-item input { width: auto; min-height: auto; accent-color: var(--pr-mid); }

/* مجموع الدرجات */
.score-summary {
    display: flex;
    flex-wrap: wrap;
    gap: .8rem;
    align-items: center;
    padding: .85rem 1rem;
    border-radius: var(--radius);
    background: linear-gradient(135deg, #f4faf6, #eef6f1);
    border: 1px dashed #bcd6c6;
}
.score-summary .pill {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 30px;
    padding: .3rem .8rem;
    font-size: .82rem;
    font-weight: 600;
    color: var(--pr);
}
.score-summary .pill strong { color: var(--pr); font-size: .95rem; }
.score-summary .total { margin-inline-start: auto; font-size: .9rem; color: var(--muted); }
.score-summary .total strong { font-size: 1.35rem; color: var(--pr); }

table.scores { min-width: 100%; table-layout: fixed; }
table.scores th, table.scores td { padding: .42rem .45rem; }
table.scores td:nth-child(1) { width: 46px; }
table.scores td:nth-child(3) { width: 110px; }
table.scores td:nth-child(4) { width: 130px; }
table.scores input, table.scores select { min-height: 34px; padding: .3rem .45rem; font-size: .82rem; }
table.scores tbody tr:nth-child(even) { background: #fafcfa; }
.row-no { color: var(--muted); font-weight: 700; font-size: .8rem; }

/* ---------------- 6) النوافذ والتنبيهات ---------------- */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(14, 34, 24, .5);
    backdrop-filter: blur(2px);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    z-index: 100;
}
.modal-backdrop.open { display: flex; animation: fade .18s ease; }
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }

.modal {
    background: #fff;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 560px;
    max-height: 92vh;
    display: flex;
    flex-direction: column;
    animation: pop .2s ease;
}
@keyframes pop { from { transform: translateY(12px) scale(.98); opacity: 0 } to { transform: none; opacity: 1 } }
.modal.lg { max-width: 860px; }
.modal-head {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: 1rem 1.15rem;
    border-bottom: 1px solid var(--line);
}
.modal-head h3 { margin: 0; font-size: 1rem; }
.modal-head .close { margin-inline-start: auto; }
.modal-body { padding: 1.15rem; overflow-y: auto; }
.modal-foot {
    display: flex;
    gap: .6rem;
    justify-content: flex-start;
    padding: .9rem 1.15rem;
    border-top: 1px solid var(--line);
    background: #fbfcfb;
    border-radius: 0 0 16px 16px;
}
.modal-foot .spacer { margin-inline-start: auto; }

.toast-host {
    position: fixed;
    inset-inline: 0;
    bottom: 1.2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .5rem;
    z-index: 200;
    pointer-events: none;
}
.toast {
    display: flex;
    align-items: center;
    gap: .55rem;
    background: #fff;
    border: 1px solid var(--line);
    border-inline-start: 4px solid var(--pr-mid);
    border-radius: 12px;
    padding: .65rem 1rem;
    box-shadow: var(--shadow-lg);
    font-size: .86rem;
    font-weight: 600;
    max-width: min(92vw, 480px);
    animation: slideUp .25s ease;
}
.toast.success { border-inline-start-color: var(--pr-mid); }
.toast.error   { border-inline-start-color: var(--danger); color: #8e2b20; }
.toast.info    { border-inline-start-color: var(--info); }
.toast.hide { opacity: 0; transform: translateY(8px); transition: .3s; }
@keyframes slideUp { from { transform: translateY(14px); opacity: 0 } to { transform: none; opacity: 1 } }

.alert {
    display: flex;
    gap: .6rem;
    align-items: flex-start;
    padding: .8rem .95rem;
    border-radius: var(--radius-sm);
    font-size: .85rem;
    margin-bottom: 1rem;
    border: 1px solid transparent;
}
.alert-info { background: var(--info-soft); color: #1e4e7f; border-color: #cfdff2; }
.alert-warn { background: var(--gold-soft); color: #7a5c00; border-color: #f0e0ae; }
.alert-danger { background: var(--danger-soft); color: #8e2b20; border-color: #f6cdc7; }

/* ---------------- 7) المخططات وبطاقات الترتيب ---------------- */
.chart-bars { display: flex; flex-direction: column; gap: .6rem; }
.bar-row { display: grid; grid-template-columns: 110px 1fr 46px; align-items: center; gap: .6rem; font-size: .8rem; }
.bar-track { background: #eef3ef; border-radius: 20px; height: 12px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 20px; transition: width .6s ease; }
.bar-row .bar-name { color: #3c4f45; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-row .bar-val { color: var(--muted); font-weight: 700; text-align: end; }

.rank-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: .8rem; }
.rank-card {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .7rem .85rem;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: #fff;
    transition: transform .16s, box-shadow .16s;
}
.rank-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.rank-card .medal {
    width: 34px; height: 34px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: .85rem;
    flex: 0 0 auto;
    color: #fff;
}
.rank-1 { background: linear-gradient(135deg, #f6d365, #c9a227); box-shadow: 0 0 0 3px #fdf3d3; }
.rank-2 { background: linear-gradient(135deg, #d7dde2, #9aa7b1); box-shadow: 0 0 0 3px #eef2f5; }
.rank-3 { background: linear-gradient(135deg, #e0a878, #b06c3a); box-shadow: 0 0 0 3px #fbeee3; }
.rank-n { background: #e8efe9; color: #4a5b50; box-shadow: none; }
.rank-card .r-name { font-weight: 700; font-size: .86rem; }
.rank-card .r-sub { font-size: .73rem; color: var(--muted); }
.rank-card .r-score {
    margin-inline-start: auto;
    font-weight: 800;
    color: var(--pr);
    font-size: .95rem;
    white-space: nowrap;
}

.level-block { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: #fff; }
.level-block-head {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .6rem .9rem;
    background: #f5f9f6;
    border-bottom: 1px solid var(--line);
    font-weight: 700;
    font-size: .86rem;
    color: var(--pr);
}
.level-block-head .badge { margin-inline-start: auto; }

.progress { height: 8px; border-radius: 20px; background: #edf2ee; overflow: hidden; }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--pr-mid), #58ac7b); }

.tabs { display: flex; flex-wrap: wrap; gap: .4rem; padding: .5rem; background: #f5f8f6; border-bottom: 1px solid var(--line); }
.tab {
    padding: .45rem .9rem;
    border-radius: 9px;
    font-size: .84rem;
    font-weight: 600;
    color: #4c5f54;
    background: transparent;
    border: 1px solid transparent;
}
.tab:hover { background: #fff; text-decoration: none; }
.tab.active { background: #fff; color: var(--pr); border-color: var(--line); box-shadow: 0 1px 3px rgba(0,0,0,.05); }

.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .7rem; }
.kv .kv-item { border: 1px solid var(--line); border-radius: 10px; padding: .55rem .7rem; background: #fbfcfb; }
.kv .kv-label { font-size: .72rem; color: var(--muted); }
.kv .kv-value { font-size: .88rem; font-weight: 600; }

/* ---------------- 8) صفحة الدخول ---------------- */
.guest-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.2rem;
    background:
        radial-gradient(1200px 600px at 80% -10%, rgba(201, 162, 39, .18), transparent 60%),
        radial-gradient(900px 500px at 0% 100%, rgba(45, 122, 79, .25), transparent 60%),
        linear-gradient(160deg, #123322 0%, #16402a 45%, #1a4a2e 100%);
}
.login-wrap { width: 100%; max-width: 940px; display: grid; grid-template-columns: 1.1fr .9fr; gap: 0; border-radius: 22px; overflow: hidden; box-shadow: var(--shadow-lg); background: #fff; }
.login-art {
    background: linear-gradient(160deg, #16402a, #1a4a2e 60%, #20583a);
    color: #eaf3ec;
    padding: 2.4rem 2rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
    overflow: hidden;
}
.login-art::after {
    content: "";
    position: absolute;
    inset: auto -60px -80px auto;
    width: 320px; height: 320px;
    background: radial-gradient(circle, rgba(240, 192, 64, .22), transparent 65%);
}
.login-art .logo-lg {
    width: 96px;
    height: 96px;
    max-width: 96px;
    max-height: 96px;
    object-fit: contain;
    margin-bottom: .8rem;
    filter: drop-shadow(0 4px 10px rgba(0, 0, 0, .3));
}
.login-art h2 { font-size: 1.5rem; color: #fff; margin-bottom: .4rem; }
.login-art p { color: #bcd4c4; font-size: .9rem; }
.login-art ul { list-style: none; padding: 0; margin: 1.2rem 0 0; display: grid; gap: .5rem; }
.login-art li { display: flex; align-items: center; gap: .5rem; font-size: .85rem; color: #d7e7dd; }
.login-art li .ico { color: var(--gold-lt); }

/* شعار شاشة التثبيت */
.install-logo {
    width: 46px;
    height: 46px;
    max-width: 46px;
    max-height: 46px;
    object-fit: contain;
    flex: 0 0 46px;
}

/* شعار صفحات الأخطاء */
.error-logo {
    width: 64px;
    height: 64px;
    max-width: 64px;
    max-height: 64px;
    object-fit: contain;
    margin-bottom: .4rem;
    opacity: .95;
}

.login-form { padding: 2.4rem 2rem; display: flex; flex-direction: column; justify-content: center; }
.login-form h1 { font-size: 1.25rem; color: var(--pr); }
.login-form .sub { color: var(--muted); font-size: .86rem; margin-bottom: 1.4rem; }
.login-form .field input { min-height: 44px; }
.login-hint { font-size: .76rem; color: var(--muted); margin-top: 1rem; background: #f6f9f7; border: 1px dashed #cfdcd4; padding: .55rem .7rem; border-radius: 9px; }

/* ---------------- 9) الاستجابة ---------------- */
@media (max-width: 1000px) {
    .login-wrap { grid-template-columns: 1fr; }
    .login-art { display: none; }
}

@media (max-width: 860px) {
    .sidebar {
        position: fixed;
        inset-block: 0;
        inset-inline-start: 0;
        transform: translateX(-105%);
        box-shadow: var(--shadow-lg);
    }
    html[dir="rtl"] .sidebar { transform: translateX(105%); }
    .sidebar.open { transform: none !important; }
    .sidebar-toggle { display: inline-flex; }
    .sidebar-backdrop {
        position: fixed; inset: 0;
        background: rgba(10, 26, 18, .45);
        z-index: 35;
        display: none;
    }
    .sidebar-backdrop.open { display: block; }
    .content { padding: 1rem; }
    .topbar { padding: 0 .9rem; }
    .topbar-logo { display: inline-flex; }
    /* عنوان الصفحة في سطر واحد على الموبايل حتى لا يكبر الشريط */
    .topbar > div { min-width: 0; flex: 1 1 auto; }
    .topbar h1 {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
    }
    .user-chip .u-name, .user-chip .u-role { display: none; }
    .stats-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .7rem; }
    .stat .s-value { font-size: 1.45rem; }
}

@media (max-width: 540px) {
    body { font-size: 14px; }
    .topbar { height: 60px; }
    .topbar .crumb { display: none; }
    .user-chip { padding: .25rem; border: none; background: transparent; }
    .topbar-actions { gap: .35rem; }
    .topbar h1 { font-size: 1rem; }
    .toolbar { padding: .8rem; }
    .toolbar .grow { flex: 1 1 100%; }
    .card-body { padding: .9rem; }
    .modal { max-height: 96vh; }
    .modal-foot { flex-wrap: wrap; }
    .modal-foot .btn { flex: 1 1 auto; }
    .form-actions .btn { flex: 1 1 45%; }
    .bar-row { grid-template-columns: 84px 1fr 38px; }
    .hide-sm { display: none !important; }
    .rank-card .r-score { font-size: .85rem; }
}


/* ============================================================
   11) المرفقات (سكانر / جهاز / كاميرا)
   ============================================================ */
.attach-box { border-style: dashed; border-color: #c9dcd1; background: #fcfffd; position: relative; }
.attach-actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: .7rem; }
/* حقول الملفات مخفية بصرياً لكنها تعمل (نُغلّب التخصيص على قاعدة .form-section input) */
.attach-box .attach-input {
    position: absolute;
    inset-block-start: 0;
    inset-inline-start: 0;
    width: 1px;
    height: 1px;
    padding: 0;
    border: 0;
    margin: 0;
    opacity: 0;
    overflow: hidden;
    pointer-events: none;
}

.attach-preview { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .6rem; }
.attach-item {
    position: relative;
    border: 1px solid var(--line);
    border-radius: 10px;
    overflow: hidden;
    background: #fff;
    display: flex;
    flex-direction: column;
}
.attach-item.invalid { border-color: var(--danger); background: #fff8f8; }
.attach-item img { width: 100%; height: 92px; object-fit: cover; display: block; background: #eef3ef; }
.attach-item .attach-file {
    height: 92px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--pr-soft);
    color: var(--pr);
    font-weight: 800;
    letter-spacing: 1px;
}
.attach-item .attach-meta {
    padding: .35rem .45rem;
    display: flex;
    flex-direction: column;
    gap: .1rem;
    min-width: 0;
}
.attach-item .attach-meta strong {
    font-size: .72rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.attach-item .attach-meta span { font-size: .68rem; color: var(--muted); }
.attach-item .attach-del {
    position: absolute;
    top: .3rem;
    inset-inline-end: .3rem;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: none;
    background: rgba(192, 57, 43, .9);
    color: #fff;
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
}
.attach-empty { margin: .5rem 0 0; font-size: .78rem; color: var(--muted); }

.attach-saved { display: flex; flex-direction: column; gap: .5rem; }
.saved-file {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .45rem .6rem;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
}
.saved-file .thumb {
    width: 46px;
    height: 46px;
    border-radius: 8px;
    overflow: hidden;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--pr-soft);
    color: var(--pr);
}
.saved-file .thumb img { width: 100%; height: 100%; object-fit: cover; }
.saved-file .sf-meta { min-width: 0; flex: 1; }
.saved-file .sf-name { font-size: .82rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.saved-file .sf-sub { font-size: .72rem; color: var(--muted); }
.saved-file .sf-actions { display: flex; gap: .3rem; }

/* ============================================================
   12) شاشة التسجيل + عدّاد المدة
   ============================================================ */
.reg-banner {
    display: flex;
    align-items: center;
    gap: .8rem;
    padding: .9rem 1.1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    border: 1px solid var(--line);
    background: #fff;
    box-shadow: var(--shadow);
}
.reg-banner .rb-icon {
    width: 42px; height: 42px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
}
.reg-banner.open { border-color: #c6ebd7; background: linear-gradient(135deg, #f2fbf6, #eaf7f0); }
.reg-banner.open .rb-icon { background: #d8f3e3; color: #12683c; }
.reg-banner.scheduled { border-color: #cfdff2; background: linear-gradient(135deg, #f4f9ff, #eaf2fb); }
.reg-banner.scheduled .rb-icon { background: #dcecfb; color: #1b5e9e; }
.reg-banner.closed, .reg-banner.invalid, .reg-banner.disabled {
    border-color: #f6cdc7; background: linear-gradient(135deg, #fff8f7, #fdeeec);
}
.reg-banner.closed .rb-icon, .reg-banner.invalid .rb-icon, .reg-banner.disabled .rb-icon {
    background: var(--danger-soft); color: var(--danger);
}
.reg-banner strong { font-size: .95rem; }
.reg-banner .rb-countdown { text-align: center; }
.countdown {
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--pr);
    letter-spacing: .3px;
    font-variant-numeric: tabular-nums;
    unicode-bidi: plaintext;   /* ترتيب طبيعي للأرقام داخل النص العربي */
    display: inline-block;
    line-height: 1.6;
}
.countdown b { font-weight: 800; }
.countdown.expired { color: var(--danger); }

.quick-range { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; margin-top: .2rem; }
.path-suggestions { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .5rem; }
.path-chip {
    text-align: start;
    border: 1px solid var(--line);
    background: #fbfcfb;
    border-radius: 10px;
    padding: .5rem .65rem;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: .1rem;
    font-family: inherit;
    transition: .15s;
}
.path-chip:hover { border-color: var(--pr-mid); background: var(--pr-soft); }
.path-chip strong { font-size: .8rem; color: var(--pr); }
.path-chip span { font-size: .72rem; color: #4a5b50; word-break: break-all; }
.path-chip small { font-size: .68rem; color: var(--muted); }

/* ============================================================
   13) تحسينات الموبايل والتابلت (لمس + مودالات + جداول)
   ============================================================ */
@media (max-width: 860px) {
    /* حقول أكبر للمس */
    input[type="text"], input[type="password"], input[type="number"], input[type="date"],
    input[type="email"], input[type="tel"], input[type="search"], input[type="datetime-local"],
    select, textarea { min-height: 44px; font-size: 16px; }  /* 16px يمنع تكبير iOS التلقائي */
    .btn { min-height: 40px; }
    .btn-sm { min-height: 34px; }
    .btn-icon { width: 38px; height: 38px; }

    /* المودالات تصبح ورقة سفلية */
    .modal-backdrop { align-items: flex-end; padding: 0; }
    .modal {
        max-width: 100%;
        max-height: 92vh;
        border-radius: 18px 18px 0 0;
        animation: sheetUp .25s ease;
    }
    .modal.lg { max-width: 100%; }
    .modal-foot { border-radius: 0; padding-bottom: max(.9rem, env(safe-area-inset-bottom)); }
    @keyframes sheetUp { from { transform: translateY(40px); opacity: .6 } to { transform: none; opacity: 1 } }

    /* بطاقة القبول تتصاغر لتناسب الشاشة */
    .card-sheet { width: 100%; max-width: 148mm; height: auto; min-height: 88mm; }
    .print-body { padding: .7rem; }
    .print-toolbar { max-width: 100%; flex-wrap: wrap; }

    /* ورقة التقرير */
    .sheet { width: 100%; padding: 6mm; min-height: auto; }

    /* التبويبات قابلة للتمرير */
    .tabs { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .tab { white-space: nowrap; }

    /* بطاقات الترتيب: عمود واحد */
    .rank-cards { grid-template-columns: 1fr; }

    /* الجداول: تمرير أفقي مع تلميح */
    .table-wrap { -webkit-overflow-scrolling: touch; }
    table.table { min-width: 560px; }

    /* الشريط السفلي للتذييل */
    .page-foot { font-size: .7rem; }
}

@media (max-width: 540px) {
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .form-grid { grid-template-columns: 1fr; }
    .attach-preview { grid-template-columns: repeat(2, 1fr); }
    .reg-banner { flex-wrap: wrap; }
    .reg-banner .rb-countdown { width: 100%; text-align: start; }
    .path-suggestions { grid-template-columns: 1fr; }
    .modal-body { padding: .9rem; }
    .score-summary { flex-direction: column; align-items: flex-start; }
    .score-summary .total { margin-inline-start: 0; }
    .kv { grid-template-columns: 1fr 1fr; }
    table.table { min-width: 480px; }
}

/* شاشات تابلت أفقية: عمودان */
@media (min-width: 700px) and (max-width: 1024px) {
    .grid-2 { grid-template-columns: 1fr 1fr; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

/* أجهزة لمس: إزالة تأثير hover المزعج */
@media (hover: none) {
    .stat:hover { transform: none; box-shadow: var(--shadow); }
    table.table tbody tr:hover { background: transparent; }
}


/* ============ 14) لوحة إدارة التسجيل (أزرار الفتح السريع) ============ */
.reg-admin-panel { border: 1px solid #d9e6df; box-shadow: 0 4px 14px rgba(16, 60, 40, .06); }
.quick-open {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem;
    padding: .7rem .8rem;
    background: #f7fbf8;
    border: 1px dashed #cfe0d7;
    border-radius: 10px;
}
.quick-open .qo-label {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    font-size: .85rem;
    font-weight: 700;
    color: var(--pr);
    margin-inline-end: .2rem;
}
.reg-admin-meta {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem 1.2rem;
    margin-top: .75rem;
    font-size: .82rem;
    color: var(--muted);
}
.reg-admin-meta strong { color: var(--text); font-weight: 700; }

/* الحقل غير المطلوب (متقدم جديد) */
.field.is-muted { opacity: .55; }
.field.is-muted select { cursor: not-allowed; }

/* شارة «معاينة» للمدير */
.badge-warn { background: #fdf3d9; color: #8a6100; border: 1px solid #f0dfae; }

@media (max-width: 640px) {
    html, body { overflow-x: hidden; }
    .quick-open { flex-direction: row; }
    .quick-open form { flex: 1 1 auto; }
    .quick-open form .btn { width: 100%; min-height: 40px; }
    .quick-open .qo-label { flex: 1 1 100%; }
}

@media print {
    .sidebar, .topbar, .page-foot, .no-print, .toast-host, .sidebar-backdrop { display: none !important; }
    .content { padding: 0; }
    .app-shell { display: block; }
    body { background: #fff; }
}

/* ---------------- 10) بطاقة القبول A6 (Landscape) ---------------- */
.print-body { background: #e9eeeb; margin: 0; padding: 1.2rem; font-family: var(--font); }

.print-toolbar {
    max-width: 148mm;
    margin: 0 auto 1rem;
    display: flex;
    flex-wrap: wrap;
    gap: .6rem;
    align-items: center;
    background: #fff;
    padding: .7rem .9rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
}

/* شريط أدوات أعرض عندما يحتوي أزراراً إضافية (بطاقة + نموذج اللجنة + رسالة القبول) */
.print-toolbar.is-wide { max-width: min(210mm, 100%); }
.print-note { max-width: min(210mm, 100%); margin: 0 auto 1rem; }
@media (max-width: 700px) {
    .print-toolbar.is-wide .btn { flex: 1 1 calc(50% - .6rem); justify-content: center; }
}

/* زر «إرسال رسالة قبول التسجيل» — ذهبي ليتميّز عن زر إرسال البطاقة */
.btn-wa.btn-accept {
    background: linear-gradient(135deg, var(--gold-lt), var(--gold));
    color: #3d2f00;
}
.btn-wa.btn-accept:hover { background: linear-gradient(135deg, #e9cd7f, #cfae55); color: #3d2f00; }

@page { size: A6 landscape; margin: 0; }

.card-sheet {
    width: 148mm;
    height: 105mm;
    margin: 0 auto;
    background: #fff;
    border-radius: 4mm;
    box-shadow: 0 10px 40px rgba(0, 0, 0, .14);
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
    border: 0.8mm solid var(--pr);
}

.card-head-band {
    background: linear-gradient(135deg, var(--pr), #20583a);
    color: #fff;
    padding: 3.2mm 5mm;
    display: flex;
    align-items: center;
    gap: 3mm;
    position: relative;
}
.card-head-band::after {
    content: "";
    position: absolute;
    inset-block: 0;
    inset-inline-start: 0;
    width: 1.6mm;
    background: linear-gradient(180deg, var(--gold-lt), var(--gold));
}
.card-head-band img,
.card-head-band .card-logo {
    width: 10mm;
    height: 10mm;
    max-width: 10mm;
    max-height: 10mm;
    object-fit: contain;
    flex: 0 0 10mm;
    align-self: center;
}
.card-head-band .c-title { font-size: 11pt; font-weight: 800; line-height: 1.25; }
.card-head-band .c-sub { font-size: 7pt; color: #d7e7dd; letter-spacing: .4px; }

.card-approved {
    text-align: center;
    font-size: 12pt;
    font-weight: 800;
    color: var(--gold);
    letter-spacing: 2px;
    padding: 1.6mm 0 1mm;
    background: #fffdf6;
    border-bottom: .35mm dashed #e5d9b0;
}
.card-approved .spark { font-size: 9pt; }

.card-main {
    flex: 1;
    display: flex;
    align-items: stretch;
    gap: 4mm;
    padding: 4mm 5mm;
    min-height: 0;
}

.card-fields { flex: 1; display: flex; flex-direction: column; justify-content: space-evenly; gap: 2mm; min-width: 0; }
.card-field { display: flex; align-items: baseline; gap: 1.8mm; font-size: 8.5pt; }
.card-field .cf-label { color: #5c6b62; font-size: 7.5pt; min-width: 20mm; flex: 0 0 auto; }
.card-field .cf-value { font-weight: 700; color: var(--pr); font-size: 10pt; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-field .cf-line { display: none; }

.card-qr { width: 26mm; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1mm; }
.card-qr .qr-box { width: 22mm; height: 22mm; padding: 1mm; border: .35mm solid #dbe4de; border-radius: 1.5mm; background: #fff; }
.card-qr .qr-box svg { width: 100%; height: 100%; display: block; }
.card-qr .qr-cap { font-size: 6pt; color: #7b8a81; letter-spacing: .3px; }

.card-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 3mm;
    padding: 2mm 5mm 2.6mm;
    border-top: .35mm solid #e8eeea;
    font-size: 7.5pt;
    color: #55655c;
}
.card-foot .cf-code { font-weight: 800; color: var(--pr); font-size: 9pt; letter-spacing: 1px; }
.card-foot .cf-sign { font-size: 7pt; color: #8a988f; }

@media print {
    .print-body { background: #fff; padding: 0; }
    .print-toolbar { display: none !important; }
    .card-sheet { box-shadow: none; border-radius: 0; margin: 0; width: 148mm; height: 105mm; page-break-after: always; }
}

/* ورقة تقرير للطباعة */
.sheet { width: 210mm; min-height: 297mm; margin: 0 auto; background: #fff; padding: 12mm; box-shadow: 0 10px 40px rgba(0,0,0,.12); }
.sheet-head { display: flex; align-items: center; gap: 4mm; border-bottom: .6mm double var(--pr); padding-bottom: 3mm; margin-bottom: 5mm; }
.sheet-head img,
.sheet-head .sheet-logo {
    width: 14mm;
    height: 14mm;
    max-width: 14mm;
    max-height: 14mm;
    object-fit: contain;
    flex: 0 0 14mm;
    align-self: center;
}
.sheet-head h1 { font-size: 15pt; color: var(--pr); margin: 0; }
.sheet-head .sub { font-size: 9pt; color: #5c6b62; }
.sheet table { width: 100%; border-collapse: collapse; font-size: 9pt; }
.sheet table th, .sheet table td { border: .25mm solid #c9d5cd; padding: 1.6mm 2mm; text-align: start; }
.sheet table th { background: #eef4f0; color: var(--pr); font-weight: 700; }
.sheet table tbody tr:nth-child(even) { background: #fbfdfb; }
.sheet-foot { margin-top: 8mm; display: flex; justify-content: space-between; font-size: 8.5pt; color: #65746b; }
@media print { .sheet { box-shadow: none; margin: 0; width: auto; min-height: auto; padding: 0; } }

/* ============================================================
   10) إرسال بطاقة القبول على واتساب
   ============================================================ */

/* زر واتساب الأخضر */
.btn-wa {
    background: linear-gradient(135deg, #25d366, #128c4b);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 6px 16px rgba(18, 140, 75, .22);
}
.btn-wa:hover { background: linear-gradient(135deg, #20bf5b, #0f7a41); color: #fff; }
.btn-wa:disabled { background: #c9d6cf; color: #66756c; box-shadow: none; }
.btn-wa.is-busy { opacity: .8; }
.btn-wa svg { flex: none; }

.wa-send-wrap {
    display: inline-flex;
    flex-direction: column;
    align-items: stretch;
    gap: .22rem;
    vertical-align: middle;
}
.wa-send-wrap.is-block { display: flex; width: 100%; }

.wa-status {
    font-size: .68rem;
    color: #6b7d72;
    text-align: center;
    line-height: 1.5;
}
.wa-status.is-warn {
    color: var(--danger);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .25rem;
    text-align: start;
}

/* رقم غير صالح: الزر يبقى قابلاً للضغط ويشرح المشكلة (لا يُعطَّل بصمت) */
.btn-wa.is-unusable {
    background: #e8eeea;
    color: #5d6f65;
    border: 1px dashed #b6c8bd;
    box-shadow: none;
}
.btn-wa.is-unusable:hover { background: #dfe8e2; color: #40544a; }

/* حاوية البطاقة المخفية التي تُحوَّل إلى PDF (مقاس A6 بالبكسل) */
.wa-card-stage {
    position: fixed;
    top: 0;
    left: -12000px;
    width: 560px;
    height: 397px;
    pointer-events: none;
    z-index: 0;
}
.wa-card-stage .card-sheet {
    width: 560px;
    height: 397px;
    margin: 0;
    box-shadow: none;
    border-radius: 6px;
}
/*
 * مهم: مكتبة تحويل الصفحة إلى صورة (html2canvas) ترسم الحروف
 * منفصلة عند وجود letter-spacing فتنكسر وصلات الحروف العربية.
 * لذا نُصفّره داخل بطاقة الواتساب فقط (النسخة الأصلية كما هي).
 */
.wa-card-stage .card-sheet,
.wa-card-stage .card-sheet * {
    letter-spacing: normal !important;
}

/* لا تظهر النسخة المخفية (المخصّصة لـPDF) في الطباعة */
@media print {
    .wa-card-stage { display: none !important; }
}

/* معاينة البطاقة داخل الصفحة */
.card-preview {
    overflow-x: auto;
    padding: .2rem 0 .6rem;
    display: flex;
    justify-content: center;
}

/* نافذة تعليمات الإرفاق */
.wa-head-icon { color: #128c4b; }
.wa-steps { display: grid; gap: .6rem; }
.wa-step { display: flex; gap: .6rem; align-items: flex-start; }
.wa-step-num {
    flex: none;
    width: 24px; height: 24px;
    border-radius: 50%;
    background: var(--pr-soft);
    color: var(--pr);
    font-weight: 800;
    font-size: .78rem;
    display: grid;
    place-items: center;
}
.wa-step strong { display: block; font-size: .86rem; }
/* الكلمات المؤكَّدة داخل الوصف تبقى في سياق السطر */
.wa-step p strong { display: inline; font-size: inherit; color: var(--text); font-weight: 700; }
.wa-step p { margin: .15rem 0 0; font-size: .76rem; color: var(--muted); }
.wa-clip { font-size: .95rem; }

/* ============================================================
   11) صفحة «تم التسجيل بنجاح»
   ============================================================ */
.done-wrap { display: grid; gap: 1rem; }

.done-hero {
    background: linear-gradient(135deg, #eaf7ef, #ffffff);
    border: 1px solid #cfe8d9;
    border-radius: 16px;
    padding: 1.3rem 1.1rem;
    text-align: center;
}
.done-hero h1 { margin: .5rem 0 .25rem; font-size: 1.25rem; color: var(--pr); }
.done-hero p { margin: 0; color: var(--muted); font-size: .9rem; }
.done-check {
    width: 64px; height: 64px;
    margin: 0 auto;
    border-radius: 50%;
    background: linear-gradient(135deg, #25d366, #128c4b);
    color: #fff;
    display: grid;
    place-items: center;
    box-shadow: 0 10px 22px rgba(18, 140, 75, .25);
}
.done-code {
    font-weight: 800;
    color: var(--pr);
    background: #fff;
    border: 1px dashed #b9d6c5;
    border-radius: 8px;
    padding: .05rem .45rem;
    display: inline-block;
}

.done-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.done-list { list-style: none; margin: 0; padding: 0; }
.done-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: .75rem;
    padding: .45rem 0;
    border-bottom: 1px dashed var(--line);
    font-size: .86rem;
}
.done-list li:last-child { border-bottom: 0; }
.done-list li > span { color: var(--muted); font-size: .8rem; }
.done-list li > strong { text-align: end; }

.done-actions { display: grid; gap: .5rem; margin-bottom: .8rem; }

.wa-msg-preview {
    border: 1px solid #d8ece0;
    background: #f6fbf8;
    border-radius: 12px;
    overflow: hidden;
}
.wa-msg-head {
    display: flex; align-items: center; gap: .35rem;
    padding: .45rem .7rem;
    font-size: .74rem;
    color: #128c4b;
    background: #eaf7ef;
    border-bottom: 1px solid #d8ece0;
}
.wa-msg-preview pre {
    margin: 0;
    padding: .7rem;
    font-family: inherit;
    font-size: .8rem;
    line-height: 1.75;
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--text);
    max-height: 190px;
    overflow: auto;
}

.done-foot { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center; }

@media (max-width: 900px) {
    .done-grid { grid-template-columns: 1fr; }
    /* على الجوال: زر الواتساب أولاً حتى لا يحتاج المستخدم للتمرير */
    .done-grid .done-send { order: -1; }
}
@media (max-width: 640px) {
    .done-hero h1 { font-size: 1.1rem; }
    .done-hero { padding: 1rem .8rem; }
    .done-foot .btn { flex: 1 1 auto; justify-content: center; }
    .card-preview { justify-content: flex-start; }
}


/* إخفاء أي عنصر يحمل hidden حتى لو كان له كلاس يعيّن display (مثل .alert) */
[hidden] { display: none !important; }

/* ============================================================
   12) شريط Excel (تصدير / استيراد) — يظهر في كل الشاشات
   ============================================================ */
.excel-bar {
    display: flex;
    align-items: center;
    gap: .6rem;
    flex-wrap: wrap;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: .5rem .7rem;
    margin-bottom: .85rem;
    box-shadow: 0 2px 10px rgba(15, 61, 38, .04);
}

.excel-bar .eb-label {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    font-size: .78rem;
    font-weight: 700;
    color: var(--pr);
    background: var(--pr-soft);
    border-radius: 8px;
    padding: .25rem .55rem;
    white-space: nowrap;
}

.excel-bar .eb-actions {
    display: flex;
    align-items: center;
    gap: .35rem;
    flex-wrap: wrap;
    margin-inline-start: auto;
}

@media (max-width: 640px) {
    .excel-bar { padding: .45rem .55rem; gap: .4rem; }
    .excel-bar .eb-actions { width: 100%; margin-inline-start: 0; }
    .excel-bar .eb-actions .btn { flex: 1 1 calc(50% - .35rem); justify-content: center; font-size: .74rem; }
    .excel-bar .eb-label { width: 100%; justify-content: center; }
}

/* رأس البطاقة على الشاشات الصغيرة: العنوان في سطر والأزرار في سطر تحته */
@media (max-width: 640px) {
    .card-head {
        flex-wrap: wrap;
        row-gap: .5rem;
        padding: .8rem .9rem;
    }
    .card-head h2, .card-head h3 {
        flex: 1 1 auto;
        min-width: 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .card-head .spacer {
        margin-inline-start: 0;
        width: 100%;
        justify-content: flex-end;
    }
    .card-head .spacer .btn { flex: 0 1 auto; }
}

/* ============================================================
   13) بطاقة «مستجد / مشترك سابق» في لوحة التحكم
   ============================================================ */
.attempt-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .7rem;
    margin-bottom: .9rem;
}
.split-item {
    border-radius: 12px;
    padding: .7rem .9rem;
    text-decoration: none;
    border: 1px solid transparent;
    transition: transform .12s ease, box-shadow .12s ease;
}
.split-item:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(15,61,38,.08); }
.split-item .si-value { font-size: 1.5rem; font-weight: 800; line-height: 1.1; }
.split-item .si-label { font-size: .78rem; color: var(--muted); margin-top: .15rem; }
.split-item.is-new { background: #eef7f1; border-color: #cfe8d9; }
.split-item.is-new .si-value { color: var(--pr); }
.split-item.is-ret { background: #fdf7e6; border-color: #f0e0b6; }
.split-item.is-ret .si-value { color: #8a6d00; }

.attempt-bars { display: grid; gap: .38rem; }
.ab-row {
    display: grid;
    grid-template-columns: 9rem 1fr 2.5rem;
    align-items: center;
    gap: .5rem;
    text-decoration: none;
    font-size: .78rem;
    color: var(--text);
}
.ab-label { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ab-track { height: 8px; background: #eef2ef; border-radius: 999px; overflow: hidden; }
.ab-fill { display: block; height: 100%; background: linear-gradient(90deg, var(--pr), #3d8b5f); border-radius: 999px; }
.ab-count { text-align: end; font-weight: 700; color: var(--pr); }

@media (max-width: 640px) {
    .attempt-split { grid-template-columns: 1fr; }
    .ab-row { grid-template-columns: 6.5rem 1fr 2rem; }
}

/* ============================================================
   14) اختيار قناة واتساب (ويب / تطبيق)
   ============================================================ */
.wa-channel-pick {
    border: 1px solid #d8ece0;
    background: #f6fbf8;
    border-radius: 12px;
    padding: .7rem .8rem;
    margin-top: .8rem;
}
.wa-channel-pick .wcp-title {
    font-size: .78rem;
    font-weight: 700;
    color: var(--pr);
    margin-bottom: .5rem;
}
.wa-channel-pick .wcp-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .5rem;
}
.wa-channel-pick .wcp-actions .btn {
    justify-content: center;
    flex-direction: column;
    gap: .1rem;
    padding: .5rem .6rem;
    line-height: 1.35;
}
.wa-channel-pick .wcp-actions .btn small {
    font-size: .64rem;
    font-weight: 500;
    opacity: .85;
}

.btn-wa-outline {
    background: #fff;
    color: #128c4b;
    border: 1.5px solid #128c4b;
}
.btn-wa-outline:hover { background: #eaf7ef; color: #0f7a41; }

@media (max-width: 480px) {
    .wa-channel-pick .wcp-actions { grid-template-columns: 1fr; }
}

/* ============================================================
   البحث عن متسابق سابق + أعوام الاشتراك  (1.5.0)
   ============================================================ */
.lookup-field { grid-column: 1 / -1; }
.seasons-bar {
    display: flex; flex-wrap: wrap; align-items: center; gap: 2mm;
    background: #f6faf7; border: .3mm solid var(--line);
    border-radius: 2mm; padding: 2mm 3mm; font-size: .86rem;
}
.seasons-value { font-weight: 700; color: var(--primary-dark, #143c24); letter-spacing: .3px; }
.seasons-bar .hint { margin: 0; }

.field { position: relative; }
.lookup-results {
    position: absolute; z-index: 40; inset-inline-start: 0; inset-inline-end: auto;
    top: 100%; min-width: 400px; max-width: 92vw;
    margin-top: 1mm; background: #fff; border: .3mm solid var(--line);
    border-radius: 2mm; box-shadow: 0 6mm 14mm rgba(15, 61, 38, .14);
    max-height: 92mm; overflow: auto; text-align: start;
}
.lookup-title {
    font-size: .74rem; font-weight: 700; color: var(--muted, #64756c);
    padding: 2mm 3mm; border-bottom: .2mm solid var(--line); background: #f8fbf9;
}
.lookup-empty { padding: 3mm; font-size: .84rem; color: var(--muted, #64756c); }
.lookup-item {
    display: flex; align-items: center; gap: 2mm; width: 100%;
    padding: 2mm 3mm; background: none; border: 0; border-bottom: .2mm solid #eef3f0;
    cursor: pointer; text-align: start; font: inherit;
}
.lookup-item:hover, .lookup-item:focus-visible { background: #eef6f1; }
.lookup-item .li-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .4mm; }
.lookup-item strong { font-size: .92rem; color: var(--primary-dark, #143c24); white-space: nowrap; }
.lookup-item small { font-size: .74rem; color: var(--muted, #64756c); }
.lookup-item .li-seasons { color: #8a6d00; }
.lookup-item .li-go {
    flex: none; font-size: .72rem; font-weight: 700; color: #fff;
    background: var(--primary, #1f5c3a); border-radius: 20mm; padding: 1mm 2.5mm;
    white-space: nowrap;
}
.lookup-item.is-dupe { background: #fdf6e3; }
.lookup-flag {
    flex: none; font-size: .7rem; font-weight: 700; color: #b3382c;
    background: #fdeceb; border-radius: 20mm; padding: .8mm 2.5mm;
}
.lookup-done {
    display: flex; flex-direction: column; gap: 1mm;
    padding: 3mm; background: #eef6f1; font-size: .84rem;
}
.lookup-done b { color: var(--primary-dark, #143c24); }
.lookup-done span { color: var(--muted, #64756c); }
.lookup-done .lookup-done-hint { color: var(--primary, #1f5c3a); font-weight: 600; }
.lookup-close {
    align-self: flex-start; margin-top: 1mm; font-size: .76rem;
    background: #fff; border: .3mm solid var(--line); border-radius: 20mm;
    padding: .8mm 3mm; cursor: pointer; color: var(--muted, #64756c);
}
@media (max-width: 640px) {
    .lookup-results { max-height: 64mm; }
    .lookup-item .li-go { display: none; }
}

/* ============================================================
   حدود السن لكل مستوى (1.6.0)
   ============================================================ */

/* نقطة لون المستوى في جدول الإعدادات */
.lvl-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-inline-end: .45rem;
    vertical-align: baseline;
}

/* سطر نتيجة فحص السن أسفل حقل المستوى (يضيفه app.js) */
.age-msg {
    margin-top: .4rem;
    padding: .45rem .7rem;
    border-radius: 9px;
    font-size: .78rem;
    line-height: 1.7;
    border: 1px solid transparent;
}

.age-msg.is-ok {
    background: #eef7f1;
    border-color: #cfe6d8;
    color: #1a4a2e;
}

.age-msg.is-error {
    background: #fdeaea;
    border-color: #f3c9c9;
    color: #8a1c1c;
    font-weight: 600;
}

select[aria-invalid="true"] {
    border-color: var(--danger, #b3261e);
    background: #fffafa;
}

/* ---------- حالات البحث عن متسابق سابق (1.6.1) ---------- */
.lookup-loading {
    padding: .55rem .8rem;
    font-size: .8rem;
    color: var(--muted, #6b7a70);
    background: #fff;
    border: 1px solid var(--line, #e3e9e5);
    border-radius: 10px;
}

.lookup-error {
    display: flex;
    align-items: center;
    gap: .6rem;
    flex-wrap: wrap;
    padding: .6rem .8rem;
    font-size: .8rem;
    line-height: 1.7;
    color: #8a1c1c;
    background: #fdeaea;
    border: 1px solid #f3c9c9;
    border-radius: 10px;
}

.lookup-error .le-msg { flex: 1 1 220px; }

.lookup-retry {
    border: 1px solid #d9a4a4;
    background: #fff;
    color: #8a1c1c;
    font: inherit;
    font-size: .78rem;
    padding: .3rem .7rem;
    border-radius: 8px;
    cursor: pointer;
    white-space: nowrap;
}

.lookup-retry:hover { background: #fff5f5; }

/* ============================================================
   13) لوحة تحميل دفاتر الطباعة PDF — حسب المستوى (1.12.0)
   ============================================================ */
.bulk-print {
    margin: 0 0 1rem;
    padding: .85rem 1rem;
    border: 1px dashed var(--line, #dbe4de);
    border-radius: 12px;
    background: linear-gradient(180deg, #f7faf8, #ffffff);
}
.bulk-print .bp-head {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-wrap: wrap;
    margin-bottom: .6rem;
    color: var(--pr);
}
.bulk-print .bp-row {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-wrap: wrap;
    padding: .32rem 0;
    border-top: .3mm solid #eef3f0;
}
.bulk-print .bp-row:first-of-type { border-top: 0; }
.bulk-print .bp-lvl {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    min-width: 12rem;
    font-size: .82rem;
    color: var(--ink, #21332a);
}
.bulk-print .bp-lvl b { color: var(--muted); font-weight: 600; }
.bulk-print .bp-all { font-weight: 700; color: var(--pr); }
.bulk-print .bp-dot { width: .55rem; height: .55rem; border-radius: 50%; display: inline-block; }
.bulk-print .bp-btn {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    font-size: .76rem;
    padding: .28rem .6rem;
    border-radius: 999px;
    border: 1px solid var(--line, #dbe4de);
    background: #fff;
    color: var(--pr);
    text-decoration: none;
    white-space: nowrap;
    transition: .15s ease;
}
.bulk-print .bp-btn:hover { background: var(--pr); color: #fff; border-color: var(--pr); }
@media (max-width: 640px) {
    .bulk-print .bp-lvl { min-width: 100%; }
}

/* ============================================================
   11) صفحة نتيجة الطلاب العامة (1.13.0)
   رابط يُنشر للمتسابقين — بلا قائمة جانبية
   ============================================================ */
.pub-body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-family: var(--font);
    color: var(--text);
    background:
        radial-gradient(900px 500px at 85% -8%, rgba(195, 155, 72, .20), transparent 62%),
        radial-gradient(700px 420px at 0% 100%, rgba(23, 112, 87, .22), transparent 60%),
        linear-gradient(165deg, #0B4A3A 0%, #115A45 48%, #177057 100%);
}

/* ترويسة */
.pub-head {
    padding: 1.6rem 1.1rem .4rem;
    color: #F6F1E2;
}
.pub-head-inner {
    max-width: 780px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: .85rem;
}
.pub-logo {
    width: 58px;
    height: 58px;
    max-width: 58px;
    max-height: 58px;
    object-fit: contain;
    filter: drop-shadow(0 3px 8px rgba(0, 0, 0, .28));
}
.pub-head h1 { margin: 0; font-size: 1.12rem; color: #FBF7EC; }
.pub-head p  { margin: .15rem 0 0; font-size: .82rem; color: #C9DBCF; }

/* الحاوية */
.pub-wrap {
    flex: 1;
    width: 100%;
    max-width: 780px;
    margin: 0 auto;
    padding: 1rem 1.1rem 2rem;
}

/* البطاقة الرئيسية */
.pub-card {
    background: #FBF7EC;
    border: 1px solid #E6DEC9;
    border-radius: 18px;
    box-shadow: 0 18px 44px rgba(6, 32, 24, .30);
    padding: 1.25rem 1.2rem 1.35rem;
}
.pub-card-head {
    display: flex;
    align-items: flex-start;
    gap: .6rem;
    margin-bottom: 1rem;
    padding-bottom: .8rem;
    border-bottom: 1px solid #E6DEC9;
}
.pub-card-head .ico { color: var(--gold); flex: 0 0 auto; margin-top: .15rem; }
.pub-card-head h2 { margin: 0; font-size: 1.05rem; color: #0B4A3A; }
.pub-card-head p  { margin: .2rem 0 0; font-size: .84rem; color: var(--muted); }

/* حقول الصفحة العامة (أكبر وأوضح) */
.pub-card .field { margin-bottom: .9rem; }
.pub-card label  { font-size: .9rem; font-weight: 700; color: #16241E; }
.pub-card input[type="text"],
.pub-card input[type="tel"] {
    min-height: 48px;
    font-size: 1.05rem;
    letter-spacing: .04em;
    text-align: center;
    background: #fff;
    border: 1px solid #DFD5BC;
    border-radius: 11px;
}
.pub-card input[type="text"]:focus,
.pub-card input[type="tel"]:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(195, 155, 72, .18); }
.pub-card .hint { font-size: .78rem; color: #7A8578; }
.pub-card .btn-lg { width: 100%; min-height: 48px; font-size: 1rem; }

.pub-hint {
    font-size: .8rem;
    color: #6C7A70;
    display: flex;
    align-items: center;
    gap: .35rem;
    line-height: 1.7;
}

/* خطوات الاستخدام */
.pub-steps {
    display: grid;
    gap: .5rem;
    margin-top: 1rem;
}
.pub-step {
    background: rgba(255, 255, 255, .10);
    border: 1px solid rgba(246, 241, 226, .22);
    border-radius: 11px;
    padding: .55rem .8rem;
    color: #EAF2EB;
    font-size: .84rem;
    display: flex;
    align-items: center;
    gap: .55rem;
}
.pub-step span {
    flex: 0 0 22px;
    height: 22px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--gold);
    color: #16241E;
    font-weight: 800;
    font-size: .78rem;
}

/* شريط نجاح التحقق */
.pub-note {
    background: rgba(255, 255, 255, .12);
    border: 1px solid rgba(246, 241, 226, .25);
    color: #EAF2EB;
    border-radius: 11px;
    padding: .55rem .8rem;
    font-size: .85rem;
    display: flex;
    align-items: center;
    gap: .45rem;
    margin-bottom: .8rem;
}

/* بطاقة النتيجة */
.result-card {
    background: #FBF7EC;
    border: 1px solid #E6DEC9;
    border-radius: 18px;
    box-shadow: 0 16px 40px rgba(6, 32, 24, .26);
    overflow: hidden;
    margin-bottom: 1rem;
}
.result-card.is-hidden { border-color: #E7B7AE; }

.result-head {
    display: flex;
    align-items: center;
    gap: .8rem;
    padding: 1rem 1.1rem;
    background: linear-gradient(165deg, #0B4A3A, #177057);
    color: #FBF7EC;
}
.result-avatar {
    flex: 0 0 48px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: rgba(246, 241, 226, .14);
    border: 2px solid var(--gold);
    color: #FBF7EC;
    font-weight: 800;
    font-size: 1rem;
}
.result-head h2 { margin: 0; font-size: 1.02rem; color: #fff; }
.result-meta { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .35rem; }
.result-meta .badge { font-size: .7rem; }

/* شريط الدرجة */
.score-band {
    display: flex;
    flex-wrap: wrap;
    gap: .6rem;
    padding: 1rem 1.1rem;
    background: #F6F1E2;
    border-bottom: 1px solid #E6DEC9;
}
.score-main, .score-grade, .score-side {
    flex: 1 1 150px;
    background: #fff;
    border: 1px solid #E6DEC9;
    border-radius: 13px;
    padding: .7rem .8rem;
    text-align: center;
}
.score-main { border-color: #C39B48; box-shadow: inset 0 0 0 1px rgba(195, 155, 72, .25); }
.score-label { font-size: .74rem; color: var(--muted); margin-bottom: .25rem; }
.score-value { font-size: 1.5rem; font-weight: 800; color: #0B4A3A; line-height: 1.2; }
.score-value small { font-size: .78rem; font-weight: 600; color: var(--muted); }
.score-grade .score-value { font-size: 1.15rem; }
.score-grade.grade-a { border-color: #A9DCC0; }
.score-grade.grade-b { border-color: #B6D4EE; }
.score-grade.grade-c { border-color: #EBD49A; }
.score-grade.grade-d { border-color: #F0C6A2; }
.score-grade.grade-f { border-color: #EDB3AC; }

.result-card .kv { padding: .9rem 1.1rem 0; }

/* تفصيل الأسئلة */
.result-details {
    margin: .9rem 1.1rem 0;
    border: 1px solid #E6DEC9;
    border-radius: 12px;
    background: #fff;
    overflow: hidden;
}
.result-details summary {
    cursor: pointer;
    padding: .6rem .8rem;
    font-size: .86rem;
    font-weight: 700;
    color: #0B4A3A;
    display: flex;
    align-items: center;
    gap: .4rem;
    list-style: none;
}
.result-details summary::-webkit-details-marker { display: none; }
.result-details[open] summary { border-bottom: 1px solid #E6DEC9; background: #F8F5EA; }
.detail-title { padding: .5rem .8rem .2rem; font-size: .78rem; font-weight: 700; color: var(--muted); }
.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: .35rem;
    padding: .2rem .8rem .7rem;
}
.detail-cell {
    display: flex;
    align-items: center;
    gap: .35rem;
    border: 1px solid #EDE6D6;
    border-radius: 9px;
    padding: .3rem .45rem;
    font-size: .78rem;
    background: #FDFBF4;
}
.detail-cell .d-pos { color: var(--gold); font-weight: 800; flex: 0 0 auto; }
.detail-cell .d-name { color: #40514A; flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.detail-cell .d-score { font-weight: 800; color: #0B4A3A; }

.result-foot {
    display: flex;
    gap: .4rem;
    align-items: flex-start;
    padding: .8rem 1.1rem;
    margin-top: .9rem;
    border-top: 1px solid #E6DEC9;
    background: #F8F5EA;
    font-size: .78rem;
    color: #6C7A70;
}
.result-foot .ico { flex: 0 0 auto; margin-top: .1rem; }

/* أزرار أسفل الصفحة */
.pub-actions {
    display: flex;
    gap: .6rem;
    flex-wrap: wrap;
    margin-top: .4rem;
}
.pub-actions .btn { flex: 1 1 160px; min-height: 44px; }

/* التذييل */
.pub-foot {
    max-width: 780px;
    margin: 0 auto;
    width: 100%;
    padding: 0 1.1rem 1.4rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: .5rem;
    flex-wrap: wrap;
    color: #B9CFC2;
    font-size: .78rem;
}
.pub-foot a { color: #E3C27C; text-decoration: none; }
.pub-foot a:hover { text-decoration: underline; }

/* صندوق الرابط في شاشة الإدارة */
.link-box {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-wrap: wrap;
    background: #F8F5EA;
    border: 1px dashed #C39B48;
    border-radius: 11px;
    padding: .55rem .7rem;
}
.link-box code {
    direction: ltr;
    text-align: left;
    flex: 1 1 auto;
    font-size: .82rem;
    color: #0B4A3A;
    word-break: break-all;
}

@media (max-width: 620px) {
    .pub-head { padding-top: 1.1rem; }
    .pub-logo { width: 46px; height: 46px; }
    .pub-head h1 { font-size: 1rem; }
    .pub-card { padding: 1rem .9rem 1.1rem; border-radius: 15px; }
    .score-main, .score-grade, .score-side { flex: 1 1 100%; }
    .score-value { font-size: 1.35rem; }
    .result-head h2 { font-size: .95rem; }
    .detail-grid { grid-template-columns: 1fr 1fr; }
}

/* طباعة نتيجة المتسابق */
@media print {
    .pub-body { background: #fff !important; }
    .pub-head { color: #000; padding: 0 0 .5rem; }
    .pub-head h1, .pub-head p { color: #000; }
    .pub-steps, .pub-actions, .pub-foot, .pub-note, .toast-host { display: none !important; }
    .result-card { box-shadow: none; border-color: #999; page-break-inside: avoid; }
    .result-head { background: #eee !important; color: #000 !important; -webkit-print-color-adjust: exact; }
    .result-head h2 { color: #000 !important; }
    .result-avatar { border-color: #666; color: #000; }
}
