/* Dashboard shell (creator + admin) */
body.app { background: #FBFAFD; }
.shell { display: grid; grid-template-columns: 264px minmax(0, 1fr); min-height: 100dvh; }
.sidebar {
  position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; gap: 6px;
  background: #fff; border-inline-end: 1px solid var(--border); padding: 18px 14px; overflow-y: auto; z-index: 40;
}
.sidebar .brand { padding: 4px 8px 18px; }
.nav-group { font-size: 11px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: .08em; padding: 14px 10px 6px; }
html[lang="ar"] .nav-group { letter-spacing: 0; text-transform: none; }
.nav-link {
  display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 10px; color: var(--text-2);
  font-weight: 600; font-size: 14px; transition: background .15s, color .15s; position: relative;
}
.nav-link svg { width: 19px; height: 19px; flex: none; }
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link.active { background: var(--violet-soft); color: var(--violet-hover); }
.nav-link.active::before { content: ""; position: absolute; inset-inline-start: -14px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--violet); }
html[dir="rtl"] .nav-link.active::before { border-radius: 3px 0 0 3px; }
.nav-link .count { margin-inline-start: auto; font-size: 11px; background: var(--coral); color: #fff; border-radius: 99px; padding: 1px 7px; }
.sidebar-foot { margin-top: auto; padding-top: 14px; }
.plan-card { padding: 14px; border-radius: 14px; background: var(--plum); color: #fff; font-size: 13px; position: relative; overflow: hidden; }
.plan-card::after { content: ""; position: absolute; width: 90px; height: 90px; border-radius: 50%; background: var(--violet); opacity: .35; inset-inline-end: -30px; top: -30px; }
.plan-card strong { display: block; font-size: 14px; margin-bottom: 4px; }
.plan-card .progress { background: rgba(255,255,255,.15); margin: 10px 0 6px; height: 6px; }
.plan-card .progress span { background: var(--lavender); }
.plan-card a { color: var(--lavender); font-weight: 600; position: relative; z-index: 1; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 12px; padding: 12px 28px;
  background: rgba(251, 250, 253, .86); backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid transparent;
}
.topbar.scrolled { border-bottom-color: var(--border); }
.topbar .menu-btn { display: none; }
.topbar-title { font-weight: 700; font-size: 15px; }
.topbar-actions { margin-inline-start: auto; display: flex; align-items: center; gap: 6px; }
.icon-btn { position: relative; width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--border); background: #fff; display: grid; place-items: center; cursor: pointer; color: var(--text-2); transition: background .15s, color .15s; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn .dot { position: absolute; top: 8px; inset-inline-end: 9px; width: 8px; height: 8px; border-radius: 50%; background: var(--coral); border: 2px solid #fff; }
.avatar { width: 38px; height: 38px; border-radius: 12px; background: var(--violet-soft); color: var(--violet-hover); display: grid; place-items: center; font-weight: 700; overflow: hidden; flex: none; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.user-btn { display: flex; align-items: center; gap: 10px; padding: 3px 10px 3px 3px; border-radius: 14px; border: 1px solid var(--border); background: #fff; cursor: pointer; font: inherit; color: var(--text); }
html[dir="rtl"] .user-btn { padding: 3px 3px 3px 10px; }
.user-btn .avatar { width: 34px; height: 34px; border-radius: 11px; }
.user-btn .u-name { font-size: 13px; font-weight: 600; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.content { padding: 8px 28px 48px; width: 100%; max-width: 1360px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin: 12px 0 22px; }
.page-head h1 { margin: 0; font-size: 1.6rem; }
.page-head p { margin: 4px 0 0; color: var(--text-2); }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.notice-bar { background: var(--plum); color: #fff; font-size: 13px; padding: 10px 28px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.notice-bar a, .notice-bar button { color: var(--lavender); font-weight: 600; background: none; border: 0; cursor: pointer; font: inherit; padding: 0; }

/* stat tiles */
.stat { padding: 18px; border-radius: var(--radius-lg); background: #fff; border: 1px solid var(--border); display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.stat-top { display: flex; align-items: center; justify-content: space-between; color: var(--text-2); font-size: 13px; font-weight: 600; }
.stat-icon { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; background: var(--violet-soft); color: var(--violet); }
.stat-icon svg { width: 18px; height: 18px; }
.stat-icon.coral { background: #FFEDE8; color: var(--coral); }
.stat-icon.plum { background: #EDEAF3; color: var(--plum); }
.stat-icon.green { background: var(--success-bg); color: var(--success); }
.stat-value { font-size: 1.75rem; font-weight: 800; line-height: 1.1; font-family: "Plus Jakarta Sans", sans-serif; font-variant-numeric: tabular-nums; }
.stat-sub { font-size: 12px; color: var(--text-2); }

/* charts */
.chart { width: 100%; }
.chart text { font-family: var(--font); fill: var(--text-2); font-size: 11px; }
.chart .grid-line { stroke: var(--border); stroke-dasharray: 3 4; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--text-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-inline-end: 6px; vertical-align: -1px; }
.chart-tip { position: fixed; pointer-events: none; z-index: 100; padding: 6px 10px; border-radius: 8px; background: var(--plum); color: #fff; font-size: 12px; white-space: nowrap; transform: translate(-50%, -120%); }
.hbar { display: flex; flex-direction: column; gap: 12px; }
.hbar-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; font-size: 13px; }
.hbar-row .progress { grid-column: 1 / -1; height: 7px; }

/* filters/toolbars */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.toolbar .search { position: relative; flex: 1; min-width: 200px; max-width: 380px; }
.toolbar .search svg { position: absolute; top: 50%; inset-inline-start: 12px; transform: translateY(-50%); width: 17px; height: 17px; color: var(--text-3); pointer-events: none; }
.toolbar .search .input { padding-inline-start: 38px; }
.toolbar .select { width: auto; min-width: 150px; }

/* list items */
.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: 0; }
.list-item.unread { background: #FCFAFF; }
.list-item.unread .li-title::after { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--coral); margin-inline-start: 8px; vertical-align: 2px; }
.li-icon { width: 38px; height: 38px; border-radius: 12px; background: var(--violet-soft); color: var(--violet); display: grid; place-items: center; flex: none; }
.li-icon svg { width: 18px; height: 18px; }
.li-title { font-weight: 600; font-size: 14px; }
.li-sub { font-size: 12px; color: var(--text-2); }

/* exam editor */
.steps { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.steps::-webkit-scrollbar { display: none; }
.step { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--border); background: #fff; font-weight: 600; font-size: 14px; color: var(--text-2); cursor: pointer; white-space: nowrap; font-family: inherit; }
.step .num { width: 24px; height: 24px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-2); font-size: 12px; }
.step.active { border-color: var(--violet); color: var(--violet-hover); background: var(--violet-soft); }
.step.active .num { background: var(--violet); color: #fff; }
.step.done .num { background: var(--success-bg); color: var(--success); }
.save-state { font-size: 12px; color: var(--text-2); display: inline-flex; align-items: center; gap: 6px; }
.save-state.saving::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--warning); }
.save-state.saved::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--success); }
.save-state.error::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); }
.q-card { border: 1px solid var(--border); border-radius: 16px; background: #fff; transition: box-shadow .15s, border-color .15s; }
.q-card:hover { border-color: var(--border-strong); }
.q-card.invalid { border-color: #F3B5BC; }
.q-card.dragging { opacity: .5; }
.q-card.drop-target { box-shadow: 0 0 0 2px var(--violet); }
.q-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; cursor: pointer; }
.q-num { width: 30px; height: 30px; border-radius: 9px; background: var(--violet-soft); color: var(--violet-hover); display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; }
.q-title { flex: 1; min-width: 0; font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.q-meta { display: flex; gap: 6px; align-items: center; }
.q-body { padding: 4px 16px 16px; border-top: 1px solid var(--border); }
.drag-handle { cursor: grab; color: var(--text-3); display: grid; place-items: center; width: 22px; }
.drag-handle svg { width: 16px; height: 16px; }
.opt-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.opt-row .input { flex: 1; }
.opt-mark { width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--border); display: grid; place-items: center; cursor: pointer; background: #fff; flex: none; color: var(--text-3); }
.opt-mark.on { background: var(--success-bg); border-color: var(--success); color: var(--success); }
.opt-mark svg { width: 18px; height: 18px; }
.type-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.type-tile { display: flex; flex-direction: column; gap: 8px; padding: 14px; border: 1px solid var(--border); border-radius: 14px; background: #fff; cursor: pointer; text-align: start; font: inherit; color: var(--text); transition: border-color .15s, background .15s; }
.type-tile:hover { border-color: var(--violet); background: var(--violet-soft); }
.type-tile svg { width: 22px; height: 22px; color: var(--violet); }
.type-tile span { font-weight: 600; font-size: 14px; }
.media-thumbs { display: flex; gap: 8px; flex-wrap: wrap; }
.media-thumb { position: relative; width: 84px; height: 84px; border-radius: 12px; overflow: hidden; border: 1px solid var(--border); background: var(--surface-2); }
.media-thumb img { width: 100%; height: 100%; object-fit: cover; }
.media-thumb button { position: absolute; top: 4px; inset-inline-end: 4px; width: 22px; height: 22px; border-radius: 6px; border: 0; background: rgba(33,26,53,.7); color: #fff; cursor: pointer; display: grid; place-items: center; }
.media-thumb button svg { width: 12px; height: 12px; }
.field-row { display: grid; grid-template-columns: 22px minmax(0, 2fr) minmax(0, 1.2fr) minmax(0, 1.2fr) auto auto; gap: 8px; align-items: center; padding: 10px; border: 1px solid var(--border); border-radius: 12px; margin-bottom: 8px; background: #fff; }
@media (max-width: 760px) { .field-row { grid-template-columns: 22px 1fr auto; } .field-row > .select, .field-row > .switch { grid-column: 2 / -1; } }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.setting-row:last-child { border-bottom: 0; }
.setting-row .s-title { font-weight: 600; font-size: 14px; }
.setting-row .s-desc { font-size: 12px; color: var(--text-2); }
.setting-row .select, .setting-row .input { width: auto; min-width: 160px; max-width: 220px; }
@media (max-width: 600px) { .setting-row { flex-direction: column; align-items: stretch; } .setting-row .select, .setting-row .input { max-width: none; } }
.preview-q { border: 1px solid var(--border); border-radius: 14px; padding: 14px; margin-bottom: 10px; }
.preview-q.bad { border-color: #F3B5BC; background: #FFFAFA; }

/* grading */
.answer-block { border: 1px solid var(--border); border-radius: 16px; padding: 16px; background: #fff; }
.answer-block.pending { border-color: var(--lavender); box-shadow: 0 0 0 3px var(--violet-soft); }
.answer-block .resp { background: var(--surface-2); border-radius: 12px; padding: 12px 14px; white-space: pre-wrap; word-break: break-word; }
.opt-line { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--border); margin-bottom: 6px; font-size: 14px; }
.opt-line.correct { border-color: #9FDDB8; background: var(--success-bg); }
.opt-line.wrong { border-color: #F3B5BC; background: var(--danger-bg); }
.opt-line .tag { margin-inline-start: auto; font-size: 11px; font-weight: 700; }
.timeline { position: relative; padding-inline-start: 18px; }
.timeline::before { content: ""; position: absolute; inset-inline-start: 5px; top: 4px; bottom: 4px; width: 2px; background: var(--border); }
.tl-item { position: relative; padding: 6px 0 10px; font-size: 13px; }
.tl-item::before { content: ""; position: absolute; inset-inline-start: -17px; top: 11px; width: 10px; height: 10px; border-radius: 50%; background: var(--lavender); border: 2px solid #fff; }
.tl-item.w2::before, .tl-item.w3::before { background: var(--coral); }

@media (max-width: 980px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset-block: 0; inset-inline-start: 0; width: 280px; transform: translateX(-105%); transition: transform .25s var(--ease); box-shadow: var(--shadow-lg); }
  html[dir="rtl"] .sidebar { transform: translateX(105%); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open::after { content: ""; position: fixed; inset: 0; background: rgba(33,26,53,.35); z-index: 35; }
  .topbar { padding: 10px 16px; }
  .topbar .menu-btn { display: grid; }
  .content { padding: 4px 16px 40px; }
  .notice-bar { padding: 10px 16px; }
  .user-btn .u-name { display: none; }
}

/* AI subscription & payment */
.pay-steps { margin: 12px 0 0; padding: 0; list-style: none; counter-reset: pay; display: flex; flex-direction: column; gap: 16px; }
.pay-steps > li { position: relative; padding-inline-start: 44px; counter-increment: pay; }
.pay-steps > li::before { content: counter(pay); position: absolute; inset-inline-start: 0; top: -2px; width: 30px; height: 30px; border-radius: 10px; background: var(--plum); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 13px; }
.pay-steps > li:last-child::before { background: var(--coral); }
.pay-accts { display: grid; grid-template-columns: minmax(0, 380px); gap: 10px; margin-top: 10px; }
@media (max-width: 560px) { .pay-accts { grid-template-columns: 1fr; } }
.pay-acct { display: flex; align-items: center; gap: 10px; padding: 12px; border: 1px solid var(--border); border-radius: 14px; background: #fff; }
.pay-acct small { display: block; color: var(--text-2); font-size: 12px; }
.pay-ic { width: 36px; height: 36px; border-radius: 11px; background: var(--violet-soft); color: var(--violet); display: grid; place-items: center; flex: none; }
.btn-whatsapp { --b-bg: #1FA855; --b-fg: #fff; --b-border: #1FA855; display: inline-flex; flex-wrap: wrap; }
.btn-whatsapp:hover { background: #178a45; color: #fff; }
.ai-feats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 640px) { .ai-feats { grid-template-columns: 1fr; } }
.ai-feat { display: flex; gap: 12px; padding: 14px; border: 1px solid var(--border); border-radius: 16px; background: #fff; }
.ai-feat p { margin: 2px 0 0; font-size: 13px; color: var(--text-2); }
.ai-hero { text-align: center; margin-bottom: 18px; }
.ai-price { margin: 10px 0 4px; }
.ai-price b { font-size: 2.6rem; font-family: "Plus Jakarta Sans", sans-serif; font-weight: 800; color: var(--violet); }
.ai-banner { border-radius: 22px; padding: 24px; background: linear-gradient(135deg, var(--plum), #3b2c6b); color: #fff; position: relative; overflow: hidden; }
.ai-banner::after { content: ""; position: absolute; width: 220px; height: 220px; border-radius: 50%; background: var(--violet); opacity: .45; filter: blur(30px); inset-inline-end: -60px; top: -80px; }
.ai-banner > * { position: relative; z-index: 1; }
.ai-banner .muted { color: #CFC7E6; }
.free-banner { display: flex; align-items: center; gap: 14px; padding: 18px 20px; border-radius: 18px; background: var(--success-bg); border: 1px solid #BDE8CD; }
.free-banner svg.i { color: var(--success); width: 26px; height: 26px; }
