/* ===== Admin: tabs, results table ===== */
.tabs { display: flex; gap: 6px; background: var(--paper); border: 1px solid var(--line); border-radius: 999px; padding: 5px; width: max-content; margin: 0 0 26px; }
.tab { border: 0; background: transparent; padding: 9px 18px; border-radius: 999px; font-weight: 800; font-size: 14px; color: var(--ink-2); font-family: inherit; }
.tab.active { background: var(--ink); color: #fff; }
.badge { display: inline-block; min-width: 22px; padding: 0 7px; border-radius: 999px; background: var(--orange); color: #fff; font-size: 11px; line-height: 20px; margin-inline-start: 4px; }
.filters { display: grid; grid-template-columns: 2fr 1fr 1.4fr 1.2fr; gap: 10px; margin: 18px 0 14px; }
.filters input, .filters select { padding: 11px 14px; border-radius: 12px; border: 2px solid var(--line); background: var(--paper); font: inherit; font-size: 14px; }
.filters input:focus, .filters select:focus { outline: none; border-color: var(--orange); }
.table-wrap { background: var(--paper); border: 1px solid var(--line); border-radius: 18px; overflow: auto; box-shadow: var(--shadow); }
table.results { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.results th { text-align: right; background: var(--cream); padding: 12px 14px; font-size: 12.5px; color: var(--ink-2); white-space: nowrap; position: sticky; top: 0; }
table.results td { padding: 11px 14px; border-top: 1px solid var(--line); vertical-align: middle; }
table.results tbody tr { cursor: pointer; transition: background .12s; }
table.results tbody tr:hover { background: var(--orange-soft); }
table.results td.en { direction: ltr; text-align: right; font-family: var(--font-en); }
.stu { color: var(--purple); }
.pct { display: inline-block; min-width: 52px; text-align: center; padding: 3px 8px; border-radius: 999px; font-weight: 800; font-family: var(--font-en); }
.pct.good { background: var(--ok-soft); color: var(--ok); }
.pct.mid { background: var(--orange-soft); color: var(--orange); }
.pct.low { background: var(--red-soft); color: var(--red); }
#student-modal .modal h3 { font-family: var(--font-display); font-size: 22px; }
#sm-stats .stat { padding: 12px; }
@media (max-width: 700px) {
  .filters { grid-template-columns: 1fr 1fr; }
  .tabs { width: 100%; }
  .tab { flex: 1; }
  table.results { font-size: 12.5px; }
}

#student-modal .modal { max-height: calc(100vh - 32px); overflow: auto; }

/* admin row: switch on the right, then state, number, title, edit link */
.admin-row { grid-template-columns: auto auto auto 1fr auto; }
.admin-row .edit-link { padding: 6px 12px; font-size: 12px; }
@media (max-width: 600px) { .admin-row { grid-template-columns: auto 1fr; } .admin-row .edit-link { grid-column: 1 / -1; justify-self: start; } }

/* ===== Exam editor ===== */
.editor-bar { display: grid; grid-template-columns: 1.6fr 1fr auto; gap: 10px; align-items: end; margin: 0 0 16px; }
.editor-bar label { display: grid; gap: 6px; font-size: 13px; font-weight: 800; }
.editor-bar select, .editor-bar input { padding: 11px 14px; border-radius: 12px; border: 2px solid var(--line); background: var(--paper); font: inherit; font-size: 14px; }
.editor-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 0 0 16px; }
.editor-status { font-size: 13px; color: var(--muted); font-weight: 700; }
.editor-status.dirty { color: var(--orange); }
.editor-status.override { color: var(--purple); }
.qedit { background: var(--paper); border: 1px solid var(--line); border-radius: 18px; padding: 16px; margin-bottom: 12px; display: grid; gap: 10px; }
.qedit .qhead { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.qedit .qhead b { font-family: var(--font-display); color: var(--orange); }
.qedit .qtools { display: flex; gap: 4px; }
.qedit .qtools button { border: 1px solid var(--line); background: var(--cream); border-radius: 8px; padding: 4px 9px; font-size: 12px; font-weight: 800; }
.qedit .qtools button.del { color: var(--red); }
.qedit textarea, .qedit input[type=text], .qedit select { width: 100%; padding: 9px 12px; border-radius: 10px; border: 2px solid var(--line); background: var(--cream); font: inherit; font-size: 14px; }
.qedit textarea { min-height: 44px; resize: vertical; }
.qedit textarea.ar, .qedit input.ar { font-family: var(--font-body); direction: rtl; text-align: right; }
.qedit textarea:focus, .qedit input:focus, .qedit select:focus { outline: none; border-color: var(--orange); background: #fff; }
.qedit .opts { display: grid; gap: 6px; }
.qedit .opt-row { display: grid; grid-template-columns: auto 1fr; gap: 8px; align-items: center; }
.qedit .opt-row input[type=radio] { width: 18px; height: 18px; accent-color: var(--ok); }

.qedit .opt-row.correct input[type=text] { border-color: var(--ok); background: var(--ok-soft); }
.qedit .row2 { display: grid; grid-template-columns: 1fr 160px; gap: 8px; }
.qedit small.hint { color: var(--muted); font-size: 12px; }
@media (max-width: 700px) { .editor-bar { grid-template-columns: 1fr; } .qedit .row2 { grid-template-columns: 1fr; } }

/* ===== استيراد الأسئلة ===== */
#import-modal .modal { max-height: calc(100vh - 32px); overflow: auto; }
#import-modal .modal h3 { font-family: var(--font-display); font-size: 22px; }
.im-preview { display: grid; gap: 8px; margin-top: 12px; }
.im-q { background: var(--cream); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; font-size: 13.5px; }
.im-q b { display: block; margin-bottom: 4px; }
.im-q ol { margin: 0; padding-inline-start: 22px; list-style: arabic-indic; }
.im-q li.ok { color: var(--ok); font-weight: 800; }

/* ===== تحليل أخطاء الطالب ===== */
.weak { margin-top: 16px; }
.weak-title { font-family: var(--font-display); font-size: 18px; margin: 0 0 2px; }
.weak-sub { margin: 0 0 10px; font-size: 12.5px; color: var(--muted); }
.weak-lesson { background: var(--cream); border: 1px solid var(--line); border-radius: 14px; padding: 10px 14px; margin-bottom: 8px; }
.weak-lesson.ok { opacity: .8; }
.weak-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; cursor: pointer; list-style: none; }
.weak-head b { font-family: var(--font-display); }
.weak-head small { color: var(--muted); flex: 1; }
.weak-list { margin: 10px 0 0; padding-inline-start: 22px; display: grid; gap: 8px; }
.weak-list li { font-size: 13.5px; line-height: 1.6; }
.weak-q { display: block; font-weight: 700; }
.weak-a { display: block; color: var(--ok); font-weight: 700; }
.weak-list small { color: var(--orange); font-weight: 800; }

/* ===== أجيال: تبويبات الفتح/الإغلاق ===== */
.gen-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 18px; }
.gen-tab { border: 2px solid var(--line); background: var(--paper); border-radius: 999px; padding: 9px 16px; font: inherit; font-weight: 800; font-size: 14px; color: var(--ink-2); cursor: pointer; }
.gen-tab.active { border-color: var(--plum); background: var(--plum); color: #fff; }
.gen-tab .badge { background: rgba(0,0,0,.15); color: inherit; }
.gen-tab.active .badge { background: rgba(255,255,255,.25); }
.filters { grid-template-columns: 2fr 1fr 1fr 1.4fr 1.2fr; }
@media (max-width: 700px) { .filters { grid-template-columns: 1fr 1fr; } }

/* ---- الإعدادات: محرر الإعلانات ---- */
.promo-edit-list { display: grid; gap: 14px; }
.promo-edit { display: grid; grid-template-columns: 180px 1fr; gap: 18px; align-items: start; }
.promo-edit-img { display: grid; gap: 8px; justify-items: center; }
.promo-edit-img img { width: 160px; height: 160px; object-fit: contain; border-radius: 14px; background: #fff; border: 1px solid var(--line); }
.promo-edit-noimg { width: 160px; height: 160px; display: grid; place-items: center; border-radius: 14px; border: 1px dashed var(--line); color: var(--muted); font-size: 13px; }
.promo-edit-fields { display: grid; gap: 8px; }
.promo-edit-fields .field { margin: 0; }
.promo-edit-fields textarea { width: 100%; font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; resize: vertical; box-sizing: border-box; }
.promo-edit-tools { display: flex; gap: 6px; justify-content: flex-end; }
@media (max-width: 640px) { .promo-edit { grid-template-columns: 1fr; } }
.st-title { font-family: var(--font-display); font-size: 19px; margin: 26px 0 6px; }
.st-hint { margin: 0 0 10px; color: var(--muted); font-size: 13.5px; }
.st-group { font-size: 14px; color: var(--plum); margin: 14px 0 6px; padding-bottom: 4px; border-bottom: 1px dashed var(--line); }
.st-group:first-child { margin-top: 0; }
.st-text { margin-bottom: 10px; }
.st-text label { display: flex; justify-content: space-between; align-items: baseline; }
.st-text textarea { width: 100%; font: inherit; padding: 10px 12px; border: 2px solid var(--line); border-radius: 12px; resize: vertical; box-sizing: border-box; background: var(--cream); }
.st-text input::placeholder, .st-text textarea::placeholder { color: #9aa0b5; opacity: 1; }
.link-btn { background: none; border: 0; color: var(--plum); font: inherit; font-size: 12.5px; font-weight: 700; cursor: pointer; padding: 0; }
.st-offer { display: grid; grid-template-columns: 220px 1fr; gap: 18px; align-items: center; }
.st-offer img { width: 220px; border-radius: 14px; border: 1px solid var(--line); background: #fff; }
.st-offer p { margin: 0 0 4px; }
.st-offer small { color: var(--muted); }
@media (max-width: 640px) { .st-offer { grid-template-columns: 1fr; } }
.st-size { color: var(--muted); font-size: 12.5px; margin: 4px 0 0; text-align: center; line-height: 1.6; }
.st-offer .st-size { text-align: start; }
