/* Layout: right-hand sidebar on desktop, bottom tab bar on phones; content in a centred column */
:root {
  --bg: #f2f5f3;
  --surface: #ffffff;
  --surface-2: #eaf0ed;
  --ink: #13201c;
  --muted: #5b6b65;
  --line: #d9e2de;
  --primary: #0c6a5c;
  --primary-2: #0a5a4e;
  --on-primary: #ffffff;
  --accent: #e9a01b;
  --accent-soft: #fdf1d8;
  --ok: #1d8f4e;
  --ok-soft: #dff3e7;
  --bad: #c93b3b;
  --bad-soft: #fbe3e3;
  --warn: #b97700;
  --d1: #2f9e6e; --d2: #2d7fc1; --d3: #d0841a; --d4: #c0392b;
  --shadow: 0 1px 2px rgba(16, 40, 34, .06), 0 6px 20px rgba(16, 40, 34, .06);
  --radius: 14px;
  --f-display: 'Readex Pro', 'IBM Plex Sans Arabic', Tahoma, sans-serif;
  --f-body: 'IBM Plex Sans Arabic', 'Segoe UI', Tahoma, sans-serif;
  --f-mono: 'JetBrains Mono', ui-monospace, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1412; --surface: #151f1c; --surface-2: #1c2926; --ink: #e6efeb; --muted: #93a49e; --line: #283632;
    --primary: #3cbca4; --primary-2: #52cdb6; --on-primary: #06201b; --accent: #f2b440; --accent-soft: #3a2e14;
    --ok: #4cc782; --ok-soft: #173525; --bad: #ef6b6b; --bad-soft: #3d1c1c; --warn: #f0b13c;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.25); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1412; --surface: #151f1c; --surface-2: #1c2926; --ink: #e6efeb; --muted: #93a49e; --line: #283632;
  --primary: #3cbca4; --primary-2: #52cdb6; --on-primary: #06201b; --accent: #f2b440; --accent-soft: #3a2e14;
  --ok: #4cc782; --ok-soft: #173525; --bad: #ef6b6b; --bad-soft: #3d1c1c; --warn: #f0b13c;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.25); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font-family: var(--f-body); font-size: 15px; line-height: 1.6;
  -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { font-family: var(--f-display); font-weight: 600; line-height: 1.3; margin: 0; text-wrap: balance; }
h1 { font-size: 1.45rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
button, input, select, textarea { font: inherit; color: inherit; }
.mono, code { font-family: var(--f-mono); font-size: .92em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.tnum { font-variant-numeric: tabular-nums; }
bdi.code { direction: ltr; unicode-bidi: isolate; font-family: var(--f-mono); font-size: .92em; }

/* ---------- shell ---------- */
.app { display: grid; grid-template-columns: 1fr; min-height: 100%; }
.sidebar { display: none; }
.topbar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
  padding-block: 10px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  display: flex; align-items: center; gap: 10px; min-height: 56px;
}
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 30; background: var(--bg); }
.topbar .back { display: none; }
.topbar.has-back .back { display: inline-flex; }
.topbar h1 { font-size: 1.1rem; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 32px; height: 32px; border-radius: 9px; background: var(--primary); display: grid; place-items: center; color: var(--on-primary); flex: none; }
.main {
  padding-block: 18px 110px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  width: 100%; max-width: 1180px; margin: 0 auto; min-width: 0;
}
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40; background: var(--surface); border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding-bottom: env(safe-area-inset-bottom, 0px); padding-left: env(safe-area-inset-left, 0px); padding-right: env(safe-area-inset-right, 0px);
}
.tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 2px 9px; color: var(--muted); text-decoration: none; font-size: .72rem; font-weight: 500; }
.tabbar a.active { color: var(--primary); }
.tabbar a.scan-tab .ico-wrap { background: var(--primary); color: var(--on-primary); border-radius: 14px; width: 46px; height: 34px; display: grid; place-items: center; margin-top: -2px; }
.tabbar a.scan-tab.active { color: var(--primary); }
@media (min-width: 960px) {
  .app { grid-template-columns: 250px 1fr; }
  .sidebar {
    display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; padding: 20px 14px; border-left: 1px solid var(--line); background: var(--surface);
  }
  .sidebar .brand { padding: 6px 8px 18px; }
  .sidebar .brand b { font-family: var(--f-display); font-size: 1.05rem; }
  .sidebar a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: var(--muted); text-decoration: none; font-weight: 500; }
  .sidebar a:hover { background: var(--surface-2); color: var(--ink); }
  .sidebar a.active { background: color-mix(in srgb, var(--primary) 12%, transparent); color: var(--primary); }
  .sidebar .grow { flex: 1; }
  .tabbar { display: none; }
  .main { padding-block: 26px 60px; }
  .topbar .brand { display: none; }
}

/* ---------- primitives ---------- */
.ico { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  padding: 9px 14px; border-radius: 11px; cursor: pointer; font-weight: 600; font-size: .92rem; text-decoration: none; white-space: nowrap; transition: background .15s, transform .1s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(.98); }
.btn:focus-visible, .input:focus-visible, a:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn.primary:hover { background: var(--primary-2); }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #2a1a00; }
.btn.danger { color: var(--bad); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.sm { padding: 6px 10px; font-size: .84rem; border-radius: 9px; }
.btn.icon { padding: 8px; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.grid { display: grid; gap: 14px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); }
.grid.cards { grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; min-width: 0; }
.card.pad-lg { padding: 20px; }
.card.click { cursor: pointer; transition: border-color .15s, transform .15s; }
.card.click:hover { border-color: color-mix(in srgb, var(--primary) 45%, var(--line)); }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 22px 0 10px; flex-wrap: wrap; }
.section-title h2 { font-size: 1.05rem; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label, .label { font-size: .84rem; font-weight: 600; color: var(--muted); }
.input, select.input, textarea.input {
  width: 100%; border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 9px 12px; min-height: 42px;
}
textarea.input { min-height: 80px; resize: vertical; line-height: 1.6; }
.input:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent); }
.form-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr)); }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); }
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: .76rem; font-weight: 600; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.pill.d1 { background: color-mix(in srgb, var(--d1) 15%, transparent); color: var(--d1); }
.pill.d2 { background: color-mix(in srgb, var(--d2) 15%, transparent); color: var(--d2); }
.pill.d3 { background: color-mix(in srgb, var(--d3) 17%, transparent); color: var(--d3); }
.pill.d4 { background: color-mix(in srgb, var(--d4) 15%, transparent); color: var(--d4); }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.acc { background: var(--accent-soft); color: var(--warn); }
.empty { text-align: center; padding: 36px 16px; color: var(--muted); border: 1.5px dashed var(--line); border-radius: var(--radius); }
.divider { height: 1px; background: var(--line); margin: 6px 0; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 5px 12px; font-size: .84rem; cursor: pointer; font-weight: 500; }
.chip.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 11px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 9px; cursor: pointer; font-weight: 600; font-size: .86rem; color: var(--muted); }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

/* ---------- home ---------- */
.hero {
  border-radius: 18px; padding: 22px; background: var(--primary); color: var(--on-primary); position: relative; overflow: hidden;
  display: grid; gap: 14px;
}
.hero h1 { font-size: 1.5rem; }
.hero p { margin: 0; opacity: .88; max-width: 52ch; }
.hero .btn { background: var(--on-primary); color: var(--primary); border-color: transparent; }
.hero .btn.outline { background: transparent; color: var(--on-primary); border-color: color-mix(in srgb, var(--on-primary) 45%, transparent); }
.hero-bubbles { position: absolute; left: -10px; top: -10px; opacity: .16; pointer-events: none; }
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat b { font-family: var(--f-display); font-size: 1.6rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: .84rem; }

/* ---------- bank ---------- */
.lesson-card { display: flex; flex-direction: column; gap: 10px; }
.lesson-card .num { font-family: var(--f-mono); color: var(--muted); font-size: .8rem; }
.lesson-card h3 { font-size: 1rem; }
.diffbar { display: flex; height: 8px; border-radius: 6px; overflow: hidden; background: var(--surface-2); }
.diffbar i { display: block; height: 100%; }
.diffbar i.d1 { background: var(--d1); } .diffbar i.d2 { background: var(--d2); } .diffbar i.d3 { background: var(--d3); } .diffbar i.d4 { background: var(--d4); }
.qitem { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: start; padding: 14px 0; border-bottom: 1px solid var(--line); }
.qitem:last-child { border-bottom: 0; }
.qnum { font-family: var(--f-mono); font-size: .8rem; color: var(--muted); min-width: 2.2em; padding-top: 3px; }
.qtext { font-weight: 600; margin-bottom: 6px; overflow-wrap: anywhere; }
.opts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); gap: 4px 14px; }
.opt { display: flex; gap: 7px; align-items: baseline; font-size: .9rem; color: var(--muted); overflow-wrap: anywhere; min-width: 0; }
.opt .L { font-family: var(--f-mono); font-size: .78rem; font-weight: 700; flex: none; }
.opt.correct { color: var(--ok); font-weight: 600; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table.t { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.t th, table.t td { padding: 9px 12px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.t th { font-size: .78rem; color: var(--muted); font-weight: 600; background: var(--surface-2); position: sticky; top: 0; }
table.t tr:last-child td { border-bottom: 0; }
table.t tr.click { cursor: pointer; }
table.t tr.click:hover td { background: var(--surface-2); }
table.t input.input { min-height: 34px; padding: 4px 8px; width: 7.5em; font-family: var(--f-mono); }
table.t input.dup { border-color: var(--bad); background: var(--bad-soft); }

/* ---------- modal ---------- */
.modal-back { position: fixed; inset: 0; z-index: 100; background: rgba(8, 18, 15, .5); display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
.modal {
  background: var(--surface); width: 100%; max-width: 720px; max-height: 92vh; overflow: auto; border-radius: 18px 18px 0 0;
  padding: 18px; padding-bottom: calc(18px + env(safe-area-inset-bottom, 0px)); animation: up .2s ease-out;
}
.modal header { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.modal footer { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; position: sticky; bottom: -18px; background: var(--surface); padding-block: 10px; }
@media (min-width: 720px) { .modal-back { align-items: center; } .modal { border-radius: 18px; } }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(30px); opacity: .5; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
.optedit { display: grid; grid-template-columns: auto auto 1fr auto; gap: 8px; align-items: center; }
.optedit .L { font-family: var(--f-mono); font-weight: 700; color: var(--muted); width: 1.4em; text-align: center; }

/* ---------- toast ---------- */
.toast { position: fixed; z-index: 200; left: 50%; transform: translateX(-50%); bottom: calc(86px + env(safe-area-inset-bottom, 0px)); background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 12px; font-weight: 600; box-shadow: var(--shadow); max-width: calc(100% - 32px); }
@media (min-width: 960px) { .toast { bottom: 28px; } }

/* ---------- scanner ---------- */
.scan-wrap { position: fixed; inset: 0; z-index: 90; background: #000; display: flex; flex-direction: column; }
.scan-stage { position: relative; flex: 1; overflow: hidden; }
.scan-stage video, .scan-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.scan-frame { position: absolute; inset: 8% 9%; border: 2px dashed rgba(255,255,255,.35); border-radius: 18px; pointer-events: none; }
.scan-top {
  position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 8px; color: #fff; z-index: 3;
  padding: calc(10px + env(safe-area-inset-top, 0px)) max(12px, env(safe-area-inset-right, 0px)) 10px max(12px, env(safe-area-inset-left, 0px));
  background: linear-gradient(rgba(0,0,0,.6), transparent);
}
.scan-top .title { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scan-btn { background: rgba(255,255,255,.14); border: 0; color: #fff; width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; cursor: pointer; }
.scan-btn.on { background: #f2b440; color: #1c1300; }
.scan-status { position: absolute; top: calc(66px + env(safe-area-inset-top, 0px)); left: 50%; transform: translateX(-50%); background: rgba(0,0,0,.55); color: #fff; padding: 6px 14px; border-radius: 999px; font-size: .85rem; z-index: 3; white-space: nowrap; }
.scan-bottom {
  background: #0b0f0e; color: #fff; padding: 12px max(12px, env(safe-area-inset-right, 0px)) calc(12px + env(safe-area-inset-bottom, 0px)) max(12px, env(safe-area-inset-left, 0px));
  display: flex; flex-direction: column; gap: 10px;
}
.scan-result { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; background: #18201e; border-radius: 14px; padding: 10px 12px; }
.scan-result .score { font-family: var(--f-display); font-size: 1.5rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.scan-result .who { min-width: 0; }
.scan-result .who b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scan-result .who span { color: #9fb0aa; font-size: .82rem; }
.scan-result.err { background: #3a1a1a; }
.scan-flash { position: absolute; inset: 0; background: rgba(60, 220, 140, .25); z-index: 4; pointer-events: none; animation: fade .5s reverse forwards; }
.scan-thumb { width: 54px; height: 76px; object-fit: cover; border-radius: 6px; background: #fff; }
.counter { font-family: var(--f-mono); color: #9fb0aa; font-size: .82rem; }

/* review sheet */
.review { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 820px) { .review { grid-template-columns: 340px 1fr; } }
.review canvas { width: 100%; height: auto; border-radius: 10px; border: 1px solid var(--line); background: #fff; }
.ansgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.ansrow { display: flex; align-items: center; gap: 4px; padding: 4px 6px; border-radius: 9px; background: var(--surface-2); }
.ansrow.ok { background: var(--ok-soft); }
.ansrow.bad { background: var(--bad-soft); }
.ansrow .n { font-family: var(--f-mono); font-size: .76rem; width: 2em; color: var(--muted); }
.bub { width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--muted); font-size: .66rem; display: grid; place-items: center; cursor: pointer; background: transparent; font-family: var(--f-mono); padding: 0; color: var(--muted); }
.bub.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.bub.key { box-shadow: 0 0 0 2px var(--ok); }

/* bars */
.bars { display: flex; flex-direction: column; gap: 6px; }
.bar { display: grid; grid-template-columns: 3em 1fr 3.4em; gap: 8px; align-items: center; font-size: .82rem; }
.bar .track { height: 10px; background: var(--surface-2); border-radius: 6px; overflow: hidden; }
.bar .fill { height: 100%; border-radius: 6px; background: var(--primary); }
.bar .fill.low { background: var(--bad); }
.bar .fill.mid { background: var(--accent); }
.hist { display: flex; align-items: flex-end; gap: 4px; height: 120px; padding-top: 10px; }
.hist div { flex: 1; background: var(--primary); border-radius: 5px 5px 0 0; min-height: 2px; position: relative; }
.hist div span { position: absolute; top: -18px; left: 0; right: 0; text-align: center; font-size: .7rem; color: var(--muted); }
.hist-labels { display: flex; gap: 4px; font-size: .7rem; color: var(--muted); }
.hist-labels span { flex: 1; text-align: center; }

.sheet-preview { background: #fff; border-radius: 10px; border: 1px solid var(--line); overflow: hidden; max-width: 360px; }
.sheet-preview svg { width: 100%; height: auto; display: block; }

/* ---------- print ---------- */
#print-root { display: none; }
@media print {
  @page { size: A4; margin: 0; }
  html, body { background: #fff !important; color: #000 !important; height: auto; }
  body::before { display: none; }
  .app, .tabbar, .toast, .modal-back, .scan-wrap { display: none !important; }
  /* hide anything a host injects (Netlify drawer/badges, toolbars…) so only our pages print */
  body > *:not(#print-root), html > *:not(head):not(body) { display: none !important; }
  body > iframe, body > [style*="position: fixed"], body > [style*="position:fixed"] { display: none !important; }
  #print-root { display: block !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .p-page { width: 210mm; min-height: 297mm; page-break-after: always; break-after: page; position: relative; overflow: hidden; }
  .p-page:last-child { page-break-after: auto; break-after: auto; }
}
.p-page.sheet svg { display: block; width: 210mm; height: 297mm; }
.p-doc { padding: 10mm 12mm; font-family: var(--f-body); color: #000; direction: rtl; font-size: 10.5pt; line-height: 1.45; }
.p-head { border: 1.2px solid #000; border-radius: 6px; padding: 3mm 4mm; display: grid; gap: 1mm; }
.p-head .r { display: flex; justify-content: space-between; gap: 6mm; flex-wrap: wrap; }
.p-head .t { text-align: center; font-family: var(--f-display); font-size: 13pt; font-weight: 700; }
.p-ver { display: inline-block; border: 1.4px solid #000; border-radius: 4px; padding: 0 3mm; font-family: var(--f-mono); font-weight: 700; font-size: 13pt; }
.p-instr { margin: 2.5mm 0; font-size: 9.5pt; border-right: 3px solid #000; padding-right: 3mm; }
.p-qs { column-count: 2; column-gap: 7mm; column-rule: .6px solid #999; }
.p-q { break-inside: avoid; page-break-inside: avoid; margin-bottom: 2.6mm; }
.p-q .qt { font-weight: 700; }
.p-q .qt .n { display: inline-block; min-width: 6mm; }
.p-q ol { list-style: none; margin: .6mm 0 0; padding: 0 6mm 0 0; display: grid; gap: .2mm; }
.p-q ol li { display: flex; gap: 2mm; }
.p-q ol li b { font-family: var(--f-mono); min-width: 5mm; direction: ltr; unicode-bidi: isolate; text-align: right; }
.p-key { width: 100%; border-collapse: collapse; margin-top: 3mm; font-size: 10pt; }
.p-key td, .p-key th { border: .8px solid #000; padding: 1mm 2mm; text-align: center; }
.p-key th { background: #eee; }
.p-roster td, .p-roster th { text-align: right; }

/* paginated exam papers: fixed A4 pages with real margins on every page */
.p-page.paged { height: 296mm; min-height: 296mm; overflow: hidden; }
.p-inner { box-sizing: border-box; height: 296mm; padding: 12mm 12mm 14mm; position: relative; font-family: var(--f-body); color: #000; direction: rtl; line-height: 1.45; }
.p-inner .p-head { margin-bottom: 2mm; }
.p-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 0 7mm; align-items: start; }
.p-cols.one { grid-template-columns: 1fr; }
.p-cols:not(.one) { background: linear-gradient(#999, #999) center top / .6px 100% no-repeat; }
.p-col { min-width: 0; }
.p-foot { position: absolute; bottom: 6mm; left: 12mm; right: 12mm; display: flex; justify-content: space-between; font-size: 8pt; color: #444; }
.p-q ol li.ok { font-weight: 700; background: #dff3e6; border-radius: 3px; outline: 1.2px solid #1d8f4e; }
.p-q ol li.ok::after { content: "✔"; margin-inline-start: auto; padding-inline-end: 1.5mm; color: #1d8f4e; }
.p-keyhead { background: #eef7f1; }
.p-measure { position: absolute; left: -10000px; top: 0; visibility: hidden; }

/* scanner: result & questions shown in the middle of the camera view */
.scan-center { position: absolute; inset: 0; z-index: 5; display: grid; place-items: center; pointer-events: none; padding: 16px; }
.scan-card { pointer-events: auto; background: rgba(10, 16, 14, .62); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); color: #fff; border-radius: 22px; padding: 18px 22px; text-align: center; min-width: min(86vw, 320px); max-width: 92vw; box-shadow: 0 10px 40px rgba(0,0,0,.35); border: 1px solid rgba(255,255,255,.18); animation: pop .18s ease-out; }
.scan-card .nm { font-family: var(--f-display); font-size: 1.35rem; font-weight: 600; text-shadow: 0 1px 3px rgba(0,0,0,.5); }
.scan-card .sub { color: #d5e4df; font-size: .9rem; margin-top: 2px; }
.scan-card .big { font-family: var(--f-display); font-size: 3.4rem; font-weight: 700; line-height: 1.1; margin-top: 6px; font-variant-numeric: tabular-nums; text-shadow: 0 2px 8px rgba(0,0,0,.5); }
.scan-card .big small { font-size: .4em; opacity: .8; }
.scan-card.ok { border-color: rgba(76, 199, 130, .7); }
.scan-card.warn { border-color: rgba(242, 180, 64, .8); }
.scan-card img.name { max-width: 100%; height: 46px; background: #fff; border-radius: 6px; margin: 6px auto 0; display: block; }
@keyframes pop { from { transform: scale(.92); opacity: 0; } }
body.scanning .modal-back { align-items: center; background: rgba(0,0,0,.45); }
body.scanning .modal { border-radius: 18px; max-width: min(560px, 94vw); max-height: 86vh; }

/* review: clickable sheet + navigation */
.rv-nav { display: flex; align-items: center; gap: 8px; }
.rv-nav .pos { font-family: var(--f-mono); font-size: .85rem; color: var(--muted); }
.rv-side { position: fixed; top: 50%; transform: translateY(-50%); z-index: 110; width: 44px; height: 64px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); display: none; place-items: center; cursor: pointer; box-shadow: var(--shadow); }
.rv-side.next { left: max(10px, env(safe-area-inset-left, 0px)); }
.rv-side.prev { right: max(10px, env(safe-area-inset-right, 0px)); }
@media (min-width: 1000px) { .rv-side { display: grid; } }
.review canvas { cursor: pointer; touch-action: pan-y; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: .8rem; color: var(--muted); }
.legend i { display: inline-block; width: 11px; height: 11px; border-radius: 50%; border: 2.5px solid; vertical-align: -1px; margin-inline-end: 4px; }
.group-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.group-tabs a { text-decoration: none; }

/* ---------- إرسال النقاط إلى EVA ---------- */
.ev-send { border: 1px solid color-mix(in srgb, var(--primary) 30%, var(--line)); background: color-mix(in srgb, var(--primary) 6%, var(--surface)); border-radius: 14px; padding: 14px; }
.ev-big { width: 100%; justify-content: center; padding: 13px 16px; font-size: 1rem; font-weight: 700; }
.ev-send.is-locked { opacity: .65; }
.ev-send.is-locked .ev-big { filter: grayscale(.6); }
.ev-need { display: grid; gap: 4px; border: 1px solid color-mix(in srgb, var(--warn) 45%, var(--line)); background: var(--accent-soft); color: var(--ink); border-radius: 12px; padding: 12px 14px; font-size: .88rem; line-height: 1.8; }
.ev-need[hidden] { display: none; }
.ev-need b { color: var(--warn); }
.brand-img { background: none; padding: 0; object-fit: contain; box-shadow: 0 4px 10px -4px rgba(10,93,80,.55); }
