/* ملكاوي ماث: ألوان المنصة ونظام التصميم */
:root {
  --navy: #141414;
  --navy-2: #262626;
  --blue: #c8102e;
  --blue-soft: #fbe8eb;
  --accent: #c8102e;
  --accent-ink: #ffffff;
  --gray: #9e9e9e;
  --on-dark: #d4d4d4;
  --bg: #f6f6f6;
  --card: #ffffff;
  --ink: #1a1a1a;
  --muted: #5f5f5f;
  --line: #e2e2e2;
  --ok: #187a4a;
  --ok-soft: #e2f4ea;
  --bad: #c0352b;
  --bad-soft: #fbe8e6;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 4px 16px rgba(0, 0, 0, .05);
  --f-body: "IBM Plex Sans Arabic", system-ui, "Segoe UI", Tahoma, sans-serif;
  --f-display: "Readex Pro", "IBM Plex Sans Arabic", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--f-body); font-size: 16px; line-height: 1.7; }
img { max-width: 100%; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-family: var(--f-display); line-height: 1.3; margin: 0 0 .5em; text-wrap: balance; }
h1 { font-size: clamp(1.6rem, 3.5vw, 2.3rem); }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.08rem; }
p { margin: 0 0 1em; }
.katex { direction: ltr; unicode-bidi: isolate; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
input, select, textarea, button { font: inherit; color: inherit; }

.container { max-width: 1180px; margin: 0 auto; padding-inline: 16px; }
.narrow { max-width: 780px; }
.section { padding-block: 40px; }
.center { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.mb { margin-bottom: 28px; }
.mt { margin-top: 24px; }
.inline { display: inline; }
.grow { flex: 1 1 240px; }
.ok-text { color: var(--ok); }
.bad-text { color: var(--bad); }
.accent-text { color: var(--blue); font-weight: 600; }
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 24px; align-items: start; }
.eyebrow { font-size: .8rem; font-weight: 600; letter-spacing: .02em; color: var(--blue); }
.eyebrow.light { color: #ff6b7f; }
.lead { font-size: 1.1rem; color: var(--muted); max-width: 62ch; }
.empty { background: var(--card); border: 1px dashed var(--line); border-radius: var(--radius); padding: 24px; text-align: center; color: var(--muted); }

/* أزرار */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid transparent; border-radius: 10px; padding: 9px 18px; font-weight: 600; cursor: pointer; background: var(--card); color: var(--ink); text-decoration: none !important; transition: background .15s, border-color .15s; white-space: nowrap; }
.btn-sm { padding: 5px 12px; font-size: .875rem; border-radius: 8px; }
.btn-lg { padding: 13px 26px; font-size: 1.05rem; }
.btn-block { width: 100%; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: #a50d26; }
.btn-accent { background: var(--accent); color: var(--accent-ink); }
.btn-accent:hover { background: #a50d26; }
.btn-ghost { background: transparent; border-color: var(--line); }
.btn-ghost:hover { background: var(--blue-soft); }
.btn-outline { background: transparent; border-color: var(--blue); color: var(--blue); }
.btn-outline-light { background: transparent; border-color: rgba(255,255,255,.5); color: #fff; }
.btn-outline-light:hover { background: rgba(255,255,255,.1); }
.btn-success { background: var(--ok); color: #fff; }
.btn-danger-ghost { background: transparent; color: var(--bad); border-color: transparent; }
.btn-danger-ghost:hover { background: var(--bad-soft); }
.btn-link { background: none; border: 0; color: var(--muted); padding-inline: 6px; }

.chip { display: inline-block; font-size: .78rem; font-weight: 600; padding: 2px 10px; border-radius: 999px; background: var(--blue-soft); color: var(--blue); white-space: nowrap; }
.chip-free { background: #fff3d6; color: #8a5a00; }
.chip-ok, .status-paid { background: var(--ok-soft); color: var(--ok); }
.chip-bad, .status-rejected { background: var(--bad-soft); color: var(--bad); }
.chip-muted, .status-cancelled { background: #efefef; color: var(--muted); }
.chip-dark { background: rgba(0,0,0,.75); color: #fff; }
.status-awaiting_review { background: #fff3d6; color: #8a5a00; }
.status-pending { background: #eeeeee; color: #3a3a3a; }
.diff-easy { background: var(--ok-soft); color: var(--ok); }
.diff-medium { background: #fff3d6; color: #8a5a00; }
.diff-hard { background: var(--bad-soft); color: var(--bad); }
.badge { background: var(--accent); color: var(--accent-ink); border-radius: 999px; font-size: .75rem; padding: 0 8px; margin-inline-start: 6px; font-weight: 700; }

.alert { border-radius: 10px; padding: 12px 16px; margin-bottom: 12px; border: 1px solid; }
.alert-success { background: var(--ok-soft); border-color: #b8e2ca; color: #0f5a35; }
.alert-error { background: var(--bad-soft); border-color: #f1c2bd; color: #8d231b; }
.alert-info { background: #f0f0f0; border-color: #dcdcdc; color: #2b2b2b; }
.flashes { padding-top: 16px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.progress { height: 8px; background: #e8e8e8; border-radius: 99px; overflow: hidden; margin: 8px 0 4px; }
.progress i { display: block; height: 100%; background: var(--ok); border-radius: 99px; transition: width .3s; }

/* الهيدر */
.site-header { background: var(--navy); color: #fff; position: sticky; top: 0; z-index: 20; }
.nav { display: flex; align-items: center; gap: 20px; min-height: 64px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-family: var(--f-display); font-weight: 700; font-size: 1.25rem; color: inherit; text-decoration: none !important; }
.brand-mark { display: inline-block; width: 38px; height: 38px; border-radius: 9px; background: #fff; padding: 3px; flex-shrink: 0; }
.brand-mark img { display: block; width: 100%; height: 100%; }
.brand-logo { display: block; width: 180px; max-width: 100%; height: auto; }
.nav-links { display: flex; align-items: center; gap: 6px; flex: 1; }
.nav-links > a:not(.btn) { color: var(--on-dark); padding: 6px 12px; border-radius: 8px; }
.nav-links > a:not(.btn):hover, .nav-links > a.active { color: #fff; background: rgba(255,255,255,.08); text-decoration: none; }
.nav-links .btn-ghost { color: #fff; border-color: rgba(255,255,255,.25); }
.nav-links .btn-ghost:hover { background: rgba(255,255,255,.08); }
.nav-links .btn-link { color: var(--on-dark); }
.nav-spacer { flex: 1; }
.nav-toggle { display: none; background: none; border: 0; color: #fff; font-size: 1.5rem; margin-inline-start: auto; cursor: pointer; }
@media (max-width: 860px) {
  .nav-toggle { display: block; }
  .nav-links { display: none; position: absolute; top: 64px; inset-inline: 0; background: var(--navy); flex-direction: column; align-items: stretch; padding: 12px 16px 16px; }
  .nav-links.open { display: flex; }
  .nav-spacer { display: none; }
}

/* الهيرو */
.hero { background: radial-gradient(1200px 400px at 85% -10%, rgba(200,16,46,.35) 0%, transparent 60%), var(--navy); color: #fff; padding-block: 56px 0; }
.hero-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 40px; align-items: center; }
.hero h1 { font-size: clamp(1.9rem, 4.6vw, 3rem); }
.hero .lead { color: var(--on-dark); }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 8px; }
.hero-board { background: #1f1f1f; border: 1px solid rgba(255,255,255,.08); border-radius: 16px; padding: 24px; display: grid; gap: 14px; font-size: 1.15rem; direction: ltr; box-shadow: inset 0 0 0 6px rgba(255,255,255,.02); }
.board-line { color: #f5f5f5; padding: 6px 0; border-bottom: 1px dashed rgba(255,255,255,.12); overflow-x: auto; }
.board-line:last-child { border-bottom: 0; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: rgba(255,255,255,.1); border-radius: 14px 14px 0 0; overflow: hidden; margin-top: 48px; }
.stats div { background: var(--navy-2); padding: 18px; text-align: center; }
.stats b { display: block; font-family: var(--f-display); font-size: 1.7rem; font-variant-numeric: tabular-nums; }
.stats span { color: var(--on-dark); font-size: .9rem; }
@media (max-width: 860px) { .hero-grid { grid-template-columns: 1fr; } .hero-board { display: none; } .stats { grid-template-columns: repeat(2, 1fr); } }

.section-title { font-size: 1.4rem; margin-bottom: 16px; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.program-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.program-card { display: flex; flex-direction: column; gap: 6px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; color: var(--ink); text-decoration: none !important; transition: border-color .15s, transform .15s; }
.program-card:hover { border-color: var(--blue); transform: translateY(-2px); }
.program-icon { font-size: 1.8rem; line-height: 1; }
.program-name { font-family: var(--f-display); font-weight: 600; font-size: 1.15rem; }

.course-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 20px; }
.course-card { display: flex; flex-direction: column; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; color: var(--ink); text-decoration: none !important; box-shadow: var(--shadow); transition: transform .15s; }
.course-card:hover { transform: translateY(-3px); }
.course-cover { position: relative; aspect-ratio: 16 / 8; max-width: 100%; background: linear-gradient(135deg, var(--navy-2), var(--blue)); background-size: cover; background-position: center; display: grid; place-items: center; }
.cover-sym { font-size: 3.4rem; color: rgba(255,255,255,.85); font-family: var(--f-display); }
.course-cover .chip { position: absolute; top: 10px; inset-inline-start: 10px; }
.course-body { padding: 16px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.course-body h3 { margin: 0; }
.course-meta { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; font-size: .875rem; color: var(--muted); margin-top: auto; padding-top: 8px; }
.course-meta.light { color: var(--on-dark); }
.price { margin-inline-start: auto; font-weight: 700; color: var(--ink); font-size: 1rem; }
.price.free { color: var(--ok); }

.band { background: var(--card); border-block: 1px solid var(--line); }
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 28px; padding-block: 40px; }
.features p { color: var(--muted); margin: 0; }
.feature-icon { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; background: var(--blue-soft); color: var(--blue); font-weight: 700; margin-bottom: 10px; }

.exam-list { display: grid; gap: 10px; }
.exam-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; color: var(--ink); text-decoration: none !important; }
.exam-row:hover { border-color: var(--blue); }

.teacher-strip { display: flex; gap: 28px; align-items: center; flex-wrap: wrap; }
.teacher-strip > div:last-child { flex: 1 1 320px; min-width: 0; }
.teacher-photo { width: 140px; height: 140px; border-radius: 50%; overflow: hidden; background: var(--navy); display: grid; place-items: center; color: #ff6b7f; font-family: var(--f-display); font-size: 3rem; flex-shrink: 0; }
.teacher-photo.lg { width: 180px; height: 180px; }
.teacher-photo img { width: 100%; height: 100%; object-fit: cover; }

.page-head { background: var(--navy); color: #fff; padding-block: 36px; }
.page-head .lead { color: var(--on-dark); }
.page-head a { color: #fff; }
.crumbs { font-size: .875rem; color: var(--muted); margin-bottom: 8px; }
.page-head .crumbs { color: var(--gray); }
.light-link { color: #ff6b7f !important; }

/* صفحة الكورس */
.course-head-grid { display: grid; grid-template-columns: 1fr 320px; gap: 32px; align-items: start; }
.buy-box { background: var(--card); color: var(--ink); border-radius: var(--radius); padding: 20px; display: grid; gap: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.18); }
.buy-price { font-family: var(--f-display); font-size: 2rem; font-weight: 700; }
.buy-state { font-weight: 700; color: var(--ok); }
@media (max-width: 860px) { .course-head-grid { grid-template-columns: 1fr; } }
.course-layout { display: grid; grid-template-columns: 1fr 300px; gap: 32px; align-items: start; }
.course-layout > div { min-width: 0; }
@media (max-width: 860px) { .course-layout { grid-template-columns: 1fr; } }
.prose { max-width: 70ch; }
.syllabus { display: grid; gap: 10px; }
.unit { background: var(--card); border: 1px solid var(--line); border-radius: 10px; }
.unit summary { display: flex; justify-content: space-between; gap: 12px; padding: 14px 16px; cursor: pointer; font-weight: 600; list-style: none; }
.unit summary::-webkit-details-marker { display: none; }
.unit summary::before { content: "‹"; transform: rotate(-90deg); transition: transform .15s; color: var(--muted); }
.unit[open] summary::before { transform: rotate(90deg); }
.unit summary span:first-of-type { flex: 1; }
.lesson-list { list-style: none; margin: 0; padding: 0 0 8px; }
.lesson-list li > a, .lesson-list li { display: flex; align-items: center; gap: 10px; padding: 8px 16px; color: var(--ink); }
.lesson-list li > a { padding: 0; flex: 1; text-decoration: none; }
.lesson-list li:hover { background: var(--bg); }
.lesson-title { flex: 1; min-width: 0; }
.lesson-icon { color: var(--blue); width: 20px; text-align: center; }

/* صفحة الدرس */
.learn { display: grid; grid-template-columns: 300px 1fr; min-height: calc(100vh - 64px); }
.learn-side { background: var(--card); border-inline-end: 1px solid var(--line); padding: 20px; overflow-y: auto; max-height: calc(100vh - 64px); position: sticky; top: 64px; }
.learn-side h2 { font-size: 1.05rem; margin-top: 8px; }
.side-unit { font-weight: 700; font-size: .85rem; color: var(--muted); margin: 16px 0 6px; }
.side-lessons { list-style: none; margin: 0; padding: 0; }
.side-lessons a, .side-lessons .locked { display: flex; gap: 8px; align-items: baseline; padding: 6px 8px; border-radius: 8px; color: var(--ink); font-size: .92rem; text-decoration: none; }
.side-lessons .locked { color: var(--muted); }
.side-lessons a:hover { background: var(--bg); }
.side-lessons .current a { background: var(--blue-soft); color: var(--blue); font-weight: 600; }
.side-lessons .dot { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--line); flex-shrink: 0; transform: translateY(1px); }
.side-lessons .done .dot { background: var(--ok); border-color: var(--ok); }
.learn-main { padding: 28px clamp(16px, 4vw, 48px); min-width: 0; }
.player { position: relative; aspect-ratio: 16 / 9; max-width: 100%; background: #000; border-radius: var(--radius); overflow: hidden; }
.player iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.learn-actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }
.locked-box { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); text-align: center; padding: 48px 20px; }
.lock-big { font-size: 2.5rem; }
.files { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 6px; }
@media (max-width: 860px) { .learn { grid-template-columns: 1fr; } .learn-side { position: static; max-height: none; order: 2; border-inline-end: 0; border-top: 1px solid var(--line); } }

/* النماذج */
.auth { display: grid; place-items: center; padding-block: 48px; }
.auth .card { width: 100%; max-width: 520px; }
.form { display: grid; gap: 14px; }
.form label { display: grid; gap: 4px; font-weight: 500; font-size: .95rem; min-width: 0; }
.form-row { display: flex; gap: 14px; flex-wrap: wrap; }
.form-row > label { flex: 1 1 160px; }
.form-row.checks { align-items: center; gap: 20px; }
.form .check, label.check { display: inline-flex; flex-direction: row; align-items: center; gap: 8px; font-weight: 400; }
input:not([type=checkbox]):not([type=radio]):not([type=file]), select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 9px 12px; background: #fff; min-width: 0; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); outline: none; box-shadow: 0 0 0 3px var(--blue-soft); }
input:disabled { background: var(--bg); color: var(--muted); }
fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; display: grid; gap: 10px; margin: 0; }
legend { font-weight: 600; padding: 0 6px; }
.inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline-form input:not([type=checkbox]):not([type=radio]) { width: auto; flex: 1 1 180px; }
.inline-form input.w-num, .w-num { width: 84px !important; flex: 0 0 84px !important; }
.strong { font-weight: 700; }

/* الطلب والدفع */
.steps { display: flex; gap: 8px; margin: 16px 0 20px; flex-wrap: wrap; }
.step { flex: 1 1 140px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; color: var(--muted); display: flex; gap: 8px; align-items: center; }
.step b { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--bg); }
.step.active { border-color: var(--blue); color: var(--ink); }
.step.active b { background: var(--blue); color: #fff; }
.step.done { color: var(--ok); }
.step.done b { background: var(--ok); color: #fff; }
.cliq { margin-bottom: 20px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 20px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.kv .big { font-family: var(--f-display); font-size: 1.4rem; font-weight: 700; }
.copy { cursor: pointer; border-bottom: 1px dashed var(--blue); }
.copy.copied::after { content: " ✓ نُسخ"; color: var(--ok); font-size: .8rem; }
@media (max-width: 520px) { .kv { grid-template-columns: 1fr; } .kv dd { margin-bottom: 6px; } }

/* الامتحانات */
.facts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 20px 0; }
.facts div { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px; text-align: center; }
.facts b { display: block; font-family: var(--f-display); font-size: 1.4rem; }
.facts span { color: var(--muted); font-size: .85rem; }
@media (max-width: 520px) { .facts { grid-template-columns: repeat(2, 1fr); } }
.exam-bar { position: sticky; top: 64px; z-index: 10; background: var(--card); border-bottom: 1px solid var(--line); }
.exam-bar-inner { display: flex; gap: 16px; align-items: center; min-height: 54px; flex-wrap: wrap; }
.exam-bar-inner b { flex: 1; min-width: 0; }
.timer { font-family: var(--f-display); font-variant-numeric: tabular-nums; font-size: 1.2rem; font-weight: 700; background: var(--navy); color: #fff; padding: 2px 14px; border-radius: 8px; direction: ltr; }
.timer.low { background: var(--bad); }
.question { margin-bottom: 16px; }
.q-head { display: flex; gap: 12px; align-items: center; margin-bottom: 10px; }
.q-num { font-weight: 700; color: var(--blue); }
.save-state { margin-inline-start: auto; color: var(--muted); }
.save-state.ok { color: var(--ok); }
.save-state.err { color: var(--bad); }
.q-body { font-size: 1.05rem; margin-bottom: 12px; overflow-x: auto; }
.q-img { border-radius: 8px; margin-bottom: 12px; }
.options { display: grid; gap: 8px; }
.option { display: flex; gap: 10px; align-items: center; border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; cursor: pointer; }
.option:has(input:checked) { border-color: var(--blue); background: var(--blue-soft); }
.options.review .option { cursor: default; }
.option.correct { border-color: var(--ok); background: var(--ok-soft); }
.option.wrong { border-color: var(--bad); background: var(--bad-soft); }
.numeric-input { max-width: 260px; font-size: 1.1rem !important; text-align: center; }
.question.is-correct { border-inline-start: 4px solid var(--ok); }
.question.is-wrong { border-inline-start: 4px solid var(--bad); }
.explain { background: var(--bg); border-radius: 8px; padding: 10px 14px; margin-top: 12px; }
.result-hero { display: flex; gap: 20px; align-items: center; border-radius: var(--radius); padding: 20px 24px; margin: 16px 0 24px; flex-wrap: wrap; }
.result-hero.pass { background: var(--ok-soft); color: #0f5a35; }
.result-hero.fail { background: var(--bad-soft); color: #8d231b; }
.result-score { font-family: var(--f-display); font-size: 3rem; font-weight: 700; line-height: 1; }

/* الجداول */
.table-wrap { padding: 0; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: start; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { font-size: .82rem; color: var(--muted); font-weight: 600; background: var(--bg); }
.table tr:last-child td { border-bottom: 0; }
.table tr.dim td { opacity: .55; }
.card .table th, .card .table td { padding-inline: 10px; }
.q-cell { max-width: 520px; }
.my-courses { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.my-course { color: var(--ink); text-decoration: none !important; }
.error-code { font-family: var(--f-display); font-size: 5rem; color: var(--line); font-weight: 700; }

.site-footer { background: var(--navy); color: var(--on-dark); margin-top: 40px; }
.site-footer .brand { color: #fff; }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 24px; padding-block: 32px; }
.footer-links { display: grid; gap: 6px; align-content: start; }
.footer-links a { color: var(--on-dark); }
.copyright { border-top: 1px solid rgba(255,255,255,.08); padding-block: 14px; font-size: .85rem; }
@media (max-width: 720px) { .footer-grid { grid-template-columns: 1fr; } }

/* لوحة الأدمن */
body.admin { background: var(--bg); }
.admin-shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.admin-side { background: var(--navy); color: #fff; padding: 20px 14px; display: flex; flex-direction: column; gap: 20px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.admin-side nav { display: grid; gap: 2px; }
.admin-side nav a { color: var(--on-dark); padding: 8px 12px; border-radius: 8px; display: flex; align-items: center; }
.admin-side nav a:hover, .admin-side nav a.active { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; }
.admin-side-foot { margin-top: auto; display: grid; gap: 6px; }
.admin-side-foot a, .admin-side-foot .btn-link { color: var(--on-dark); text-align: start; padding: 0 12px; }
.admin-main { padding: 28px clamp(16px, 3vw, 40px); min-width: 0; }
.admin-main h1 { font-size: 1.6rem; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; margin-bottom: 24px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; color: var(--ink); text-decoration: none !important; }
.kpi b { display: block; font-family: var(--f-display); font-size: 1.7rem; font-variant-numeric: tabular-nums; }
.kpi span { color: var(--muted); font-size: .88rem; }
.kpi.attn { border-color: var(--accent); background: #fdf1f3; }
.sticky { position: sticky; top: 20px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tabs a { padding: 8px 14px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.active { color: var(--ink); border-color: var(--blue); font-weight: 600; text-decoration: none; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.filters select, .filters input { width: auto !important; flex: 1 1 180px; }
.pager { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 16px; }
.pager a { padding: 4px 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--card); }
.pager a.active { background: var(--blue); color: #fff; border-color: var(--blue); }
.unit-admin { position: relative; }
.unit-title-form { margin-bottom: 10px; padding-inline-end: 120px; }
.unit-del { position: absolute; top: 20px; inset-inline-end: 20px; }
.lesson-admin { border: 1px solid var(--line); border-radius: 10px; margin-top: 8px; }
.lesson-admin summary { display: flex; justify-content: space-between; gap: 12px; padding: 10px 14px; cursor: pointer; }
.lesson-admin.add summary { color: var(--blue); font-weight: 600; }
.lesson-form { padding: 4px 14px 14px; }
.option-edit { display: flex; gap: 10px; align-items: center; }
.preview { background: var(--bg); border-radius: 8px; padding: 10px 14px; min-height: 44px; overflow-x: auto; }
.bank-list { display: grid; gap: 6px; max-height: 520px; overflow-y: auto; }
.bank-item { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.bank-item .muted { grid-column: 2; }
.bank-item:has(input:checked) { border-color: var(--blue); background: var(--blue-soft); }
.receipt { border: 1px solid var(--line); border-radius: 8px; max-height: 640px; object-fit: contain; }
@media (max-width: 860px) {
  .admin-shell { grid-template-columns: 1fr; }
  .admin-side { position: static; height: auto; }
  .admin-side nav { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .unit-title-form { padding-inline-end: 0; }
  .unit-del { position: static; margin-bottom: 8px; }
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
.auth-logo { width: 140px; height: auto; margin: 0 auto 8px; }
.site-footer .muted { color: var(--gray); }

/* علامة مائية متحركة باسم الطالب ورقمه فوق الفيديو (بتردع تصوير الشاشة ونشر الفيديو) */
.watermark { position: absolute; z-index: 2; pointer-events: none; user-select: none; color: rgba(255, 255, 255, .38); font-size: clamp(.7rem, 1.6vw, .95rem); font-weight: 700; text-shadow: 0 1px 2px rgba(0, 0, 0, .6); white-space: nowrap; transition: top 1.2s ease, left 1.2s ease; top: 12%; left: 10%; }

/* ── حقول الحماية والدخول ── */
.hp { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; opacity: 0; pointer-events: none; }
.hidden { display: none !important; }
.label-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.pw-field { position: relative; display: block; }
.pw-field input { padding-inline-end: 44px; width: 100%; }
.pw-toggle { position: absolute; inset-inline-end: 6px; top: 50%; transform: translateY(-50%); border: 0; background: none; cursor: pointer; font-size: 1.05rem; padding: 6px; line-height: 1; opacity: .7; }
.pw-toggle:hover { opacity: 1; }
.pw-meter { display: block; height: 5px; border-radius: 5px; background: rgba(127, 127, 127, .25); overflow: hidden; margin-top: 6px; }
.pw-meter i { display: block; height: 100%; width: 0; border-radius: inherit; background: #c8102e; transition: width .3s, background .3s; }
.pw-meter[data-level="2"] i { background: #e0a100; }
.pw-meter[data-level="3"] i, .pw-meter[data-level="4"] i { background: #1fa463; }
.code-input { font: 700 1.6rem/1.2 ui-monospace, monospace; letter-spacing: .5em; text-align: center; }
.auth-icon { font-size: 2.6rem; text-align: center; }
.auth-card h1 { text-align: center; }
.center { text-align: center; }
.stars-admin { color: #e0a100; letter-spacing: 1px; }
.media-prev { display: flex; align-items: center; gap: 12px; margin-top: -4px; }
.media-prev img { width: 64px; height: 64px; object-fit: contain; background: #fff; border: 1px solid #ddd; border-radius: 10px; padding: 4px; }
.media-prev.wide img { width: 140px; object-fit: cover; padding: 0; }
.admin-uni-logo { width: 32px; height: 32px; object-fit: contain; vertical-align: middle; margin-inline-end: 8px; }

/* ── تحليل الأداء (الأدمن) ── */
.an-filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin-bottom: 18px; }
.an-filters label { display: grid; gap: 4px; font-weight: 600; min-width: 220px; }
.an-alert { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 14px 16px; margin-bottom: 18px; border-radius: 12px; background: #fdf1f3; border: 1px solid #f3c2cc; }
.an-alert.warn { background: #fff8ec; border-color: #f5d9a8; }
.an-pill { padding: 3px 10px; border-radius: 999px; font-size: .85rem; font-weight: 700; background: #fff; border: 1px solid currentColor; }
.an-grid { margin-bottom: 18px; align-items: start; }
.an-bars { display: grid; gap: 12px; }
.an-bar-row { display: grid; grid-template-columns: minmax(120px, 1.2fr) 2fr 52px; align-items: center; gap: 12px; }
.an-bar-label { display: grid; line-height: 1.35; }
.an-bar, .an-mini { height: 12px; border-radius: 999px; background: #eee; overflow: hidden; }
.an-mini { height: 6px; width: 90px; display: inline-block; vertical-align: middle; margin-inline-end: 6px; }
.an-bar i, .an-mini i { display: block; height: 100%; border-radius: inherit; }
i.ok { background: #2e9e5b; } i.warn { background: #e8961e; } i.bad { background: #c8102e; }
.an-pct { font-variant-numeric: tabular-nums; }
.an-pct.ok { color: #23804a; } .an-pct.warn { color: #b86e00; } .an-pct.bad { color: #c8102e; }
.an-pill.ok { color: #23804a; } .an-pill.warn { color: #b86e00; } .an-pill.bad { color: #c8102e; }
.an-hist { display: grid; grid-template-columns: repeat(10, 1fr); gap: 6px; align-items: end; height: 170px; padding-top: 18px; direction: ltr; }
.an-col { position: relative; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; }
.an-col i { width: 100%; min-height: 2px; border-radius: 6px 6px 0 0; }
.an-col-n { font-size: .78rem; font-weight: 700; margin-bottom: 2px; }
.an-col-x { font-size: .72rem; color: #888; margin-top: 4px; }
.an-qtable td { vertical-align: top; }
.an-qbody { max-width: 380px; }
.an-surprise { background: #fffaf0; }
@media (max-width: 700px) { .an-bar-row { grid-template-columns: 1fr 52px; } .an-bar { grid-column: 1 / -1; order: 3; } }

/* أسئلة الطلاب، الباقات، الملفات (أدمن) */
.sq-list { display: grid; gap: 14px; }
.sq-item.dim { opacity: .6; }
.sq-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.sq-head h2 { margin: 0; font-size: 1.1rem; }
.sq-body { background: var(--bg); border-radius: 10px; padding: 12px 14px; margin-bottom: 10px; line-height: 1.9; }
.sq-answer textarea { width: 100%; }
.sq-actions { margin-top: 6px; }
.bundle-admin { margin-bottom: 14px; }
.bundle-admin ul { margin: 6px 0; padding-inline-start: 20px; }
.bundle-pick { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; max-height: 280px; overflow: auto; display: grid; gap: 4px; }
.bundle-pick legend { font-weight: 600; font-size: .9rem; padding: 0 6px; }
.bundle-pick-group { margin-top: 6px; font-weight: 600; }

/* صور الأسئلة والرسائل */
.img-field { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 8px 0; }
.img-pick { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 10px; border: 1px dashed var(--line); cursor: pointer; font-weight: 600; font-size: .9rem; background: var(--card); }
.img-pick:hover { border-color: var(--blue); }
.img-preview { position: relative; display: inline-block; }
.img-preview img { max-height: 90px; max-width: 160px; border-radius: 8px; border: 1px solid var(--line); display: block; }
.img-clear { position: absolute; top: -8px; inset-inline-end: -8px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: #C8102E; color: #fff; font-size: .7rem; cursor: pointer; }
.q-image-box { border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; margin: 10px 0; }
.q-image-current { display: flex; align-items: center; gap: 14px; margin: 8px 0; }
.q-image-current img { max-height: 120px; border-radius: 8px; border: 1px solid var(--line); }
.q-img { max-width: 100%; height: auto; display: block; }
.thread { display: grid; gap: 10px; margin: 10px 0 14px; }
.msg { padding: 10px 14px; border-radius: 12px; background: var(--bg); border: 1px solid var(--line); max-width: 100%; }
.msg-teacher { background: #fff2f4; border-color: #f3c3cc; }
.msg-meta { font-size: .8rem; color: var(--muted); margin-bottom: 4px; }
.msg-body { white-space: pre-line; line-height: 1.9; overflow-wrap: anywhere; }
.msg-img { display: inline-block; margin-top: 8px; }
.msg-img img { max-width: min(100%, 420px); max-height: 360px; border-radius: 10px; border: 1px solid var(--line); display: block; }
.img-preview[hidden] { display: none !important; }
.form .img-field .img-pick, label.img-pick { display: inline-flex; flex-direction: row; align-items: center; width: auto; margin: 0; }

/* لوحة الرموز الرياضية */
.math-bar { border: 1px solid var(--line); border-bottom: 0; border-radius: 10px 10px 0 0; background: var(--bg); margin-top: 6px; }
.math-bar + textarea, .math-bar + input { border-top-left-radius: 0; border-top-right-radius: 0; }
.math-tabs { display: flex; gap: 2px; flex-wrap: wrap; align-items: center; padding: 4px 6px 0; border-bottom: 1px solid var(--line); }
.math-tabs button { border: 0; background: none; padding: 6px 10px; font: inherit; font-size: .82rem; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.math-tabs button.on { color: var(--ink); font-weight: 700; border-color: #C8102E; }
.math-hint { margin-inline-start: auto; font-size: .75rem; color: var(--muted); padding: 0 6px; }
.math-pad { display: flex; flex-wrap: wrap; gap: 4px; padding: 6px; }
.math-pad[hidden] { display: none; }
.math-pad button { min-width: 38px; height: 34px; padding: 0 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); font: 600 1rem/1 "Cambria Math", "STIX Two Math", "Times New Roman", serif; color: var(--ink); cursor: pointer; direction: ltr; }
.math-pad button:hover { border-color: #C8102E; background: #fff2f4; }
.math-preview { margin-top: 6px; padding: 10px 12px; border: 1px dashed var(--line); border-radius: 10px; background: var(--card); line-height: 2; white-space: pre-line; overflow-x: auto; }
.math-preview::before { content: "معاينة: "; color: var(--muted); font-size: .8rem; }
html[dir="ltr"] .math-preview::before { content: "Preview: "; }
@media (max-width: 600px) { .math-hint { display: none; } .math-pad button { min-width: 34px; height: 32px; } }
/* تحقّق أنك إنسان */
.captcha { display: grid; gap: .4rem; margin: .25rem 0 .5rem; }
.captcha-label { font-weight: 600; }
.captcha-row { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; direction: ltr; }
.captcha-row img { border-radius: 10px; border: 1px solid rgba(128,128,128,.35); background: #f4f1f1; max-width: 100%; height: auto; }
.captcha-row .captcha-new { padding: .45rem .75rem; font-size: 1.1rem; line-height: 1; }
.captcha .captcha-row input { width: 7rem !important; flex: 0 0 auto; text-align: center; font-size: 1.15rem; margin: 0; }
@media (max-width: 420px) { .captcha-row img { width: 150px; } .captcha .captcha-row input { width: 5.5rem !important; } }
