/* مُصحِّح — واجهة لوحة التحكم (RTL) */
@font-face { font-family: "Plex Arabic"; font-weight: 400; font-display: swap; src: url("../fonts/ibm-plex-sans-arabic-arabic-400-normal.woff2") format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF; }
@font-face { font-family: "Plex Arabic"; font-weight: 500; font-display: swap; src: url("../fonts/ibm-plex-sans-arabic-arabic-500-normal.woff2") format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF; }
@font-face { font-family: "Plex Arabic"; font-weight: 600; font-display: swap; src: url("../fonts/ibm-plex-sans-arabic-arabic-600-normal.woff2") format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF; }
@font-face { font-family: "Plex Arabic"; font-weight: 700; font-display: swap; src: url("../fonts/ibm-plex-sans-arabic-arabic-700-normal.woff2") format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF; }
@font-face { font-family: "Plex Arabic"; font-weight: 400; font-display: swap; src: url("../fonts/ibm-plex-sans-arabic-latin-400-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2212; }
@font-face { font-family: "Plex Arabic"; font-weight: 500; font-display: swap; src: url("../fonts/ibm-plex-sans-arabic-latin-500-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2212; }
@font-face { font-family: "Plex Arabic"; font-weight: 600; font-display: swap; src: url("../fonts/ibm-plex-sans-arabic-latin-600-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2212; }
@font-face { font-family: "Plex Arabic"; font-weight: 700; font-display: swap; src: url("../fonts/ibm-plex-sans-arabic-latin-700-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2212; }

:root {
  --paper: #f6f4ef;
  --surface: #ffffff;
  --surface-2: #faf9f6;
  --ink: #1d2433;
  --ink-2: #4a5263;
  --muted: #7b8291;
  --line: #e4e1d9;
  --line-2: #d4d0c6;
  --brand: #1f5f5b;          /* أخضر حبري */
  --brand-2: #2b7c76;
  --brand-soft: #e3efed;
  --accent: #e8a33d;         /* لون قلم التحديد */
  --accent-soft: #fbefd9;
  --ok: #24804a;   --ok-soft: #e1f2e7;
  --warn: #a8670c; --warn-soft: #fbefd6;
  --bad: #b3362f;  --bad-soft: #f8e1df;
  --info: #2d5fa8; --info-soft: #e3ecf8;
  --side: #17222b;
  --side-ink: #c9d3d8;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(29, 36, 51, .05), 0 4px 16px rgba(29, 36, 51, .04);
  --font: "Plex Arabic", "Segoe UI", Tahoma, "Noto Sans Arabic", system-ui, sans-serif;
}

* { 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(--ink); background: var(--paper);
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.35; font-weight: 700; }
h1 { font-size: 1.55rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1.05rem; }
p { margin: 0 0 1em; }
small, .small { font-size: .85em; }
.muted { color: var(--muted); }
.ltr { direction: ltr; unicode-bidi: isolate; display: inline-block; }
.num { font-variant-numeric: tabular-nums; }
code, .mono { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: .9em; direction: ltr; unicode-bidi: isolate; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1.2rem 0; }

/* ---------- الهيكل ---------- */
.app { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--side); color: var(--side-ink); padding: 18px 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 4px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; color: #fff; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 9px; background: var(--accent); display: grid; place-items: center; flex: none;
}
.brand-mark svg { width: 22px; height: 22px; }
.brand b { display: block; font-size: 1.1rem; }
.brand span { font-size: .78rem; color: #8fa1ab; display: block; line-height: 1.3; }
.nav-label { font-size: .72rem; color: #6f8590; padding: 14px 10px 4px; letter-spacing: .02em; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--side-ink); font-weight: 500;
}
.nav a svg { width: 18px; height: 18px; opacity: .8; flex: none; }
.nav a:hover { background: rgba(255, 255, 255, .06); text-decoration: none; color: #fff; }
.nav a.active { background: rgba(232, 163, 61, .14); color: #fff; box-shadow: inset -3px 0 0 var(--accent); }
.sidebar-foot { margin-top: auto; padding: 14px 10px 0; border-top: 1px solid rgba(255, 255, 255, .08); font-size: .85rem; }
.sidebar-foot a { color: #9fb2bb; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 14px 28px; border-bottom: 1px solid var(--line); background: var(--surface);
  position: sticky; top: 0; z-index: 20;
}
.topbar .menu-btn { display: none; }
.topbar .title { font-weight: 700; font-size: 1.05rem; }
.topbar .spacer { flex: 1; }
.user-chip { display: flex; align-items: center; gap: 8px; color: var(--ink-2); font-size: .9rem; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-weight: 700; }
.content { padding: 26px 28px 60px; max-width: 1280px; width: 100%; }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { margin: 0; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.crumbs { font-size: .85rem; color: var(--muted); margin-bottom: 6px; }
.crumbs a { color: var(--muted); }

/* ---------- البطاقات ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.card-head h2, .card-head h3 { margin: 0; font-size: 1rem; }
.card-body { padding: 18px; }
.card + .card { margin-top: 18px; }
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.stack > * + * { margin-top: 18px; }

.stat { padding: 16px 18px; }
.stat .k { color: var(--muted); font-size: .85rem; display: flex; align-items: center; gap: 6px; }
.stat .v { font-size: 1.75rem; font-weight: 700; line-height: 1.2; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .s { font-size: .82rem; color: var(--muted); }
.stat.hero { background: var(--brand); color: #fff; border-color: var(--brand); display: block; padding: 16px 18px; }
.stat.hero .k, .stat.hero .s { color: #cfe3e0; }

/* ---------- الأزرار ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 15px; border-radius: 8px;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); font: inherit; font-weight: 600; font-size: .9rem;
  cursor: pointer; text-decoration: none; white-space: nowrap; line-height: 1.4; transition: background .12s, border-color .12s, transform .05s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; border-color: var(--muted); }
.btn:active { transform: translateY(1px); }
.btn svg { width: 17px; height: 17px; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-2); border-color: var(--brand-2); }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #2b1d05; }
.btn-accent:hover { background: #f0b155; border-color: #f0b155; }
.btn-danger { color: var(--bad); border-color: #e6c1be; }
.btn-danger:hover { background: var(--bad-soft); border-color: var(--bad); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: rgba(29, 36, 51, .05); border-color: transparent; }
.btn-sm { padding: 4px 10px; font-size: .82rem; border-radius: 7px; }
.btn-lg { padding: 11px 20px; font-size: 1rem; }
.btn-block { width: 100%; }
.btn[disabled], .btn.disabled { opacity: .5; pointer-events: none; }
.inline { display: inline; }

/* ---------- النماذج ---------- */
.field { margin-bottom: 14px; }
.field > label, .label { display: block; font-weight: 600; font-size: .88rem; margin-bottom: 5px; color: var(--ink-2); }
.hint { font-size: .8rem; color: var(--muted); margin-top: 4px; }
.input, select.input, textarea.input {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line-2); border-radius: 8px; background: #fff; font: inherit; color: var(--ink);
  transition: border-color .12s, box-shadow .12s;
}
textarea.input { min-height: 90px; resize: vertical; line-height: 1.7; }
.input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(31, 95, 91, .15); }
.input-sm { padding: 5px 9px; font-size: .88rem; }
.form-row { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; cursor: pointer; margin-bottom: 8px; }
.check input { width: 17px; height: 17px; accent-color: var(--brand); }
.radio-cards { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.radio-card { border: 1.5px solid var(--line-2); border-radius: 10px; padding: 12px 14px; cursor: pointer; display: block; }
.radio-card input { accent-color: var(--brand); }
.radio-card b { display: block; }
.radio-card span { font-size: .82rem; color: var(--muted); }
.radio-card:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.form-actions { display: flex; gap: 10px; align-items: center; margin-top: 18px; flex-wrap: wrap; }

/* ---------- الجداول ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { padding: 10px 14px; text-align: right; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { font-weight: 600; color: var(--muted); font-size: .8rem; background: var(--surface-2); white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fcfbf8; }
.table .actions { white-space: nowrap; text-align: left; }
.table td.c, .table th.c { text-align: center; }

/* ---------- الشارات ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 99px; font-size: .78rem; font-weight: 600; background: #eeece6; color: var(--ink-2); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.brand { background: var(--brand-soft); color: var(--brand); }

/* ---------- التنبيهات ---------- */
.alert { padding: 12px 16px; border-radius: 9px; margin-bottom: 16px; border: 1px solid; display: flex; gap: 10px; align-items: flex-start; }
.alert.success { background: var(--ok-soft); border-color: #b9dfc6; color: #17552f; }
.alert.error { background: var(--bad-soft); border-color: #eec2be; color: #7e231e; }
.alert.warn { background: var(--warn-soft); border-color: #efd7a7; color: #6e4508; }
.alert.info { background: var(--info-soft); border-color: #c4d5ef; color: #1f437a; }

.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty svg { width: 46px; height: 46px; opacity: .45; margin-bottom: 8px; }
.empty b { display: block; color: var(--ink-2); font-size: 1.05rem; margin-bottom: 4px; }

/* ---------- التبويبات ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs a { padding: 9px 14px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.active { color: var(--brand); border-color: var(--brand); }

/* ---------- نافذة منبثقة ---------- */
dialog.modal { border: 0; border-radius: 14px; padding: 0; width: min(560px, 94vw); box-shadow: 0 20px 60px rgba(0, 0, 0, .25); color: var(--ink); }
dialog.modal::backdrop { background: rgba(23, 34, 43, .45); }
dialog.modal .card-head { border-radius: 14px 14px 0 0; }

/* ---------- عناصر متنوعة ---------- */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; font-size: .92rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; }
.progress { height: 8px; background: #ece9e1; border-radius: 99px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--brand); border-radius: 99px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--muted); }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--accent); } .dot.bad { background: var(--bad); }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar .grow { flex: 1; }
.search { max-width: 260px; }
.pill-list { display: flex; gap: 6px; flex-wrap: wrap; }
.chart-bars { display: flex; align-items: flex-end; gap: 10px; height: 170px; padding-top: 10px; }
.chart-bars .bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; min-width: 0; }
.chart-bars .bar i { display: block; width: 100%; max-width: 46px; background: var(--brand); border-radius: 6px 6px 2px 2px; min-height: 2px; }
.chart-bars .bar small { color: var(--muted); font-size: .72rem; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.chart-bars .bar b { font-size: .78rem; }

/* ---------- محرر الأسئلة ---------- */
.q-list { display: flex; flex-direction: column; gap: 10px; }
.q-item { display: grid; grid-template-columns: 42px 1fr auto; gap: 14px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 10px; background: #fff; align-items: start; }
.q-num { width: 34px; height: 34px; border-radius: 8px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-weight: 700; }
.q-body { min-width: 0; }
.q-body .rich { margin-bottom: 6px; }
.q-opts { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 4px 16px; font-size: .92rem; }
.q-opts .opt { display: flex; gap: 6px; align-items: baseline; }
.q-opts .opt.correct { color: var(--ok); font-weight: 600; }
.q-opts .opt .l { font-weight: 700; color: var(--muted); }
.q-opts .opt.correct .l { color: var(--ok); }
.q-meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.q-actions { display: flex; gap: 4px; }
.q-img { max-width: 260px; max-height: 160px; border-radius: 8px; border: 1px solid var(--line); margin: 6px 0; }
.rich { overflow-wrap: anywhere; }
.rich .katex { font-size: 1.08em; }
.rich .katex-display { margin: .5em 0; overflow-x: auto; overflow-y: hidden; }

.math-toolbar { display: flex; flex-wrap: wrap; gap: 4px; padding: 6px; border: 1px solid var(--line-2); border-bottom: 0; border-radius: 8px 8px 0 0; background: var(--surface-2); }
.math-toolbar button {
  font: inherit; font-size: .85rem; padding: 3px 8px; border: 1px solid var(--line); border-radius: 6px; background: #fff; cursor: pointer; min-width: 32px; line-height: 1.5;
}
.math-toolbar button:hover { border-color: var(--brand); color: var(--brand); }
.math-toolbar .sep { width: 1px; background: var(--line-2); margin: 2px 4px; }
.math-toolbar .grp-label { font-size: .72rem; color: var(--muted); align-self: center; padding: 0 4px; }
.math-toolbar + textarea.input, .math-toolbar + .input { border-radius: 0 0 8px 8px; }
.preview-box { border: 1px dashed var(--line-2); border-radius: 8px; padding: 10px 14px; min-height: 44px; background: var(--surface-2); margin-top: 6px; }
.preview-box:empty::before { content: "المعاينة تظهر هنا"; color: var(--muted); font-size: .85rem; }
.opt-row { display: grid; grid-template-columns: 34px 1fr 40px; gap: 8px; align-items: start; margin-bottom: 8px; }
.opt-row .letter { height: 40px; display: grid; place-items: center; font-weight: 700; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--line); }
.opt-row.is-correct .letter { background: var(--ok); color: #fff; border-color: var(--ok); }
.opt-row .opt-preview { grid-column: 2; font-size: .88rem; color: var(--ink-2); }
.opt-row .opt-preview:empty { display: none; }

/* ---------- المسح ---------- */
.scan-layout { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.camera-box { position: relative; background: #0d1418; border-radius: 12px; overflow: hidden; aspect-ratio: 3 / 4; max-height: 72vh; margin: 0 auto; }
.camera-box video, .camera-box canvas.overlay { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.camera-box .cam-msg { position: absolute; inset: auto 0 0 0; padding: 10px 14px; background: linear-gradient(transparent, rgba(0, 0, 0, .7)); color: #fff; font-weight: 600; text-align: center; }
.camera-box .cam-off { position: absolute; inset: 0; display: grid; place-items: center; color: #9fb2bb; text-align: center; padding: 20px; }
.camera-box .cam-off > div > svg { width: 54px; height: 54px; }
.camera-box.flash::after { content: ""; position: absolute; inset: 0; background: rgba(255, 255, 255, .55); animation: flash .35s ease-out forwards; }
@keyframes flash { to { opacity: 0; } }
.dropzone { border: 2px dashed var(--line-2); border-radius: 12px; padding: 30px; text-align: center; color: var(--muted); cursor: pointer; transition: .15s; }
.dropzone.drag, .dropzone:hover { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }
.dropzone svg { width: 40px; height: 40px; }
.scan-feed { display: flex; flex-direction: column; gap: 10px; max-height: 76vh; overflow-y: auto; }
.scan-card { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; background: #fff; display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; animation: slidein .25s ease-out; }
.scan-card.ok { border-inline-start: 4px solid var(--ok); }
.scan-card.warn { border-inline-start: 4px solid var(--accent); }
.scan-card.bad { border-inline-start: 4px solid var(--bad); }
.scan-card .score { font-size: 1.35rem; font-weight: 700; font-variant-numeric: tabular-nums; text-align: left; }
.scan-card .meta { font-size: .82rem; color: var(--muted); }
.scan-card .flags { grid-column: 1 / -1; display: flex; gap: 4px; flex-wrap: wrap; }
.scan-card .fix { grid-column: 1 / -1; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 6px; }
@keyframes slidein { from { opacity: 0; transform: translateY(-6px); } }
.scan-stats { display: flex; gap: 14px; font-size: .9rem; flex-wrap: wrap; }
.scan-stats b { font-variant-numeric: tabular-nums; }

/* ---------- تفاصيل النتيجة ---------- */
.fills { display: inline-flex; gap: 3px; vertical-align: middle; }
.fills i { width: 16px; height: 16px; border-radius: 50%; border: 1.5px solid #9aa1ab; display: inline-grid; place-items: center; font-style: normal; font-size: 9px; color: #6b7280; position: relative; overflow: hidden; }
.fills i::before { content: ""; position: absolute; inset: 0; background: var(--ink); opacity: var(--f, 0); }
.fills i span { position: relative; mix-blend-mode: difference; color: #fff; }
.sheet-thumb { max-width: 100%; border-radius: 8px; border: 1px solid var(--line); }
.hist { display: flex; align-items: flex-end; gap: 4px; height: 120px; }
.hist div { flex: 1; background: var(--brand-2); border-radius: 4px 4px 0 0; position: relative; min-height: 1px; }
.hist-labels { display: flex; gap: 4px; font-size: .7rem; color: var(--muted); }
.hist-labels span { flex: 1; text-align: center; }
.cell-good { background: var(--ok-soft) !important; }
.cell-mid { background: var(--warn-soft) !important; }
.cell-bad { background: var(--bad-soft) !important; }

/* ---------- صفحة الدخول ---------- */
.auth-page { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-art { background: var(--side); color: #dbe4e8; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.auth-art h2 { color: #fff; font-size: 2rem; line-height: 1.4; max-width: 440px; }
.auth-art p { color: #9fb2bb; max-width: 420px; }
.auth-art .sheet-art { position: absolute; left: -40px; bottom: -40px; width: 360px; opacity: .9; transform: rotate(-8deg); }
.auth-form { display: grid; place-items: center; padding: 40px 24px; }
.auth-form .card { width: min(400px, 100%); }

/* ---------- الاستجابة للشاشات ---------- */
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .scan-layout { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 0 0 auto; width: 270px; z-index: 50; transform: translateX(100%); transition: transform .2s; }
  body.nav-open .sidebar { transform: none; box-shadow: -20px 0 50px rgba(0, 0, 0, .3); }
  body.nav-open::after { content: ""; position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 40; }
  .topbar { padding: 10px 16px; }
  .topbar .menu-btn { display: inline-flex; }
  .user-chip span { display: none; }
  .content { padding: 18px 16px 50px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .auth-page { grid-template-columns: 1fr; }
  .auth-art { display: none; }
  .q-item { grid-template-columns: 1fr; }
  .q-actions { justify-content: flex-start; }
  .table th, .table td { padding: 8px 10px; }
}
@media (max-width: 520px) {
  .grid-4 { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat .v { font-size: 1.4rem; }
  .page-head .actions { width: 100%; }
}
@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  .app { display: block; }
  .content { padding: 0; }
  body { background: #fff; }
  .card { box-shadow: none; }
}
.badge svg { width: 13px; height: 13px; }
.q-num svg { width: 18px; height: 18px; }
.card-head h2 svg { width: 18px; height: 18px; vertical-align: -3px; }
.sidebar-foot svg { width: 14px; height: 14px; vertical-align: -2px; }
.tabs a svg { width: 16px; height: 16px; vertical-align: -3px; margin-left: 4px; }
.scan-card .title { display: block; }
.camera-box .cam-off p { margin: 10px 0 16px; }
label.dropzone { display: block; }
.dropzone > svg { display: block; margin: 0 auto 10px; }
/* أيقونات: حجم افتراضي يتبع حجم الخط */
.ic { width: 1.15em; height: 1.15em; vertical-align: -0.2em; flex: none; }
.alert > .ic { width: 20px; height: 20px; margin-top: 2px; }
.stat .k .ic { width: 16px; height: 16px; }
/* المعادلات تُكتب دائماً من اليسار لليمين داخل النص العربي */
.katex, .katex-display { direction: ltr; unicode-bidi: isolate; }
.katex { display: inline-block; text-indent: 0; }
.katex-display > .katex { display: block; text-align: center; }
textarea.input { unicode-bidi: plaintext; }
input[type=file].input { padding: 6px; font-size: .88rem; }
[hidden] { display: none !important; }
