:root {
  --navy-950: #031025;
  --navy-900: #061b3f;
  --navy-800: #08285d;
  --navy-700: #0b3677;
  --cyan-500: #11d7ff;
  --cyan-400: #42e5ff;
  --cyan-200: #b9f5ff;
  --ice-50: #f4fbff;
  --ice-100: #e9f8ff;
  --slate-700: #31435f;
  --slate-500: #687891;
  --line: rgba(17, 215, 255, 0.22);
  --white: #ffffff;
  --gold: #f6d47a;
  --danger: #e5484d;
  --success: #20c997;
  --warning: #f59f00;
  --shadow-soft: 0 22px 60px rgba(4, 18, 42, 0.12);
  --shadow-card: 0 18px 44px rgba(8, 40, 93, 0.14);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --sidebar-w: 318px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { min-height: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100%;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Kufi Arabic", "Noto Sans Arabic", Arial, sans-serif;
  color: var(--navy-950);
  background:
    radial-gradient(circle at 14% 8%, rgba(17,215,255,.18), transparent 26rem),
    radial-gradient(circle at 90% 18%, rgba(6,27,63,.12), transparent 25rem),
    linear-gradient(145deg, #f9fdff 0%, #edf8ff 48%, #ffffff 100%);
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(120deg, transparent 0 52%, rgba(17,215,255,.04) 52% 53%, transparent 53% 100%),
    radial-gradient(circle at 1px 1px, rgba(8,40,93,.08) 1px, transparent 0);
  background-size: 100% 100%, 26px 26px;
  mask-image: linear-gradient(to bottom, rgba(0,0,0,.9), rgba(0,0,0,.35));
}

button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

[hidden] { display: none !important; }

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
}

[dir="rtl"] .app-shell { grid-template-columns: minmax(0, 1fr) var(--sidebar-w); }
[dir="rtl"] .sidebar { grid-column: 2; }
[dir="rtl"] .main { grid-column: 1; grid-row: 1; }

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px;
  background:
    linear-gradient(180deg, rgba(3,16,37,.98), rgba(6,27,63,.94)),
    radial-gradient(circle at top, rgba(17,215,255,.22), transparent 24rem);
  color: white;
  overflow-y: auto;
  border-inline-end: 1px solid rgba(255,255,255,.08);
  box-shadow: 12px 0 60px rgba(3,16,37,.16);
}
[dir="rtl"] .sidebar { border-inline-start: 1px solid rgba(255,255,255,.08); border-inline-end: none; box-shadow: -12px 0 60px rgba(3,16,37,.16); }

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 6px 24px;
}
.logo-mark {
  width: 58px;
  height: 58px;
  flex: 0 0 58px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 25%, white, #e8faff 72%);
  color: var(--navy-900);
  border: 1px solid rgba(17,215,255,.68);
  box-shadow: 0 0 0 7px rgba(17,215,255,.08), 0 0 28px rgba(17,215,255,.42);
  font-family: Georgia, serif;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -3px;
}
.brand-title { font-size: 22px; font-weight: 900; letter-spacing: .5px; }
.brand-subtitle { color: var(--cyan-200); font-size: 12px; margin-top: 3px; }

.nav-group { display: grid; gap: 10px; margin: 18px 0; }
.nav-title { color: rgba(255,255,255,.54); font-size: 12px; font-weight: 700; padding: 0 10px; }
.nav-item {
  width: 100%;
  color: rgba(255,255,255,.84);
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 14px;
  transition: transform .22s ease, background .22s ease, border-color .22s ease, color .22s ease;
}
.nav-item:hover, .nav-item.active {
  transform: translateY(-1px);
  background: linear-gradient(135deg, rgba(17,215,255,.16), rgba(255,255,255,.07));
  border-color: rgba(17,215,255,.34);
  color: white;
}
.nav-left { display: flex; align-items: center; gap: 10px; }
.nav-icon { width: 26px; height: 26px; display: grid; place-items: center; border-radius: 10px; background: rgba(17,215,255,.13); color: var(--cyan-400); }
.nav-lock { color: var(--gold); font-size: 13px; }

.sidebar-card {
  margin-top: 22px;
  padding: 18px;
  border-radius: 22px;
  background: linear-gradient(145deg, rgba(255,255,255,.11), rgba(255,255,255,.045));
  border: 1px solid rgba(17,215,255,.22);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.12);
}
.sidebar-card strong { display: block; margin-bottom: 7px; }
.sidebar-card p { margin: 0 0 12px; color: rgba(255,255,255,.72); font-size: 13px; line-height: 1.7; }

.main { min-width: 0; padding: 30px clamp(18px, 3vw, 46px) 56px; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 15;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: -30px calc(clamp(18px, 3vw, 46px) * -1) 26px;
  padding: 18px clamp(18px, 3vw, 46px);
  background: rgba(244,251,255,.78);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(8,40,93,.08);
}
.topbar-left { display: flex; align-items: center; gap: 14px; min-width: 0; }
.mobile-menu { display: none; }
.page-kicker { color: var(--cyan-500); font-weight: 900; font-size: 12px; letter-spacing: .14em; text-transform: uppercase; }
.page-title { margin: 2px 0 0; font-size: clamp(24px, 3.6vw, 46px); line-height: 1.16; letter-spacing: -.03em; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

.btn {
  min-height: 44px;
  border: 0;
  border-radius: 999px;
  padding: 0 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  color: white;
  background: linear-gradient(135deg, var(--navy-900), var(--navy-700));
  box-shadow: 0 14px 30px rgba(8,40,93,.22);
  transition: transform .2s ease, box-shadow .2s ease, opacity .2s ease;
  font-weight: 800;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 18px 40px rgba(8,40,93,.28); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn-cyan { background: linear-gradient(135deg, #06b6e9, var(--cyan-500)); color: var(--navy-950); }
.btn-ghost { background: rgba(255,255,255,.82); color: var(--navy-900); border: 1px solid rgba(8,40,93,.1); box-shadow: none; }
.btn-danger { background: linear-gradient(135deg, #c92a2a, #ff5d5d); }
.btn-small { min-height: 36px; padding: 0 13px; font-size: 13px; }
.btn-icon { width: 44px; padding: 0; }

.hero {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(280px, .9fr);
  gap: 24px;
  align-items: stretch;
  padding: clamp(24px, 4vw, 42px);
  border-radius: var(--radius-xl);
  color: white;
  background:
    radial-gradient(circle at 15% 20%, rgba(17,215,255,.36), transparent 24rem),
    linear-gradient(135deg, var(--navy-950), var(--navy-900) 48%, #0b3c86);
  box-shadow: var(--shadow-soft);
}
.hero::after {
  content: "";
  position: absolute;
  inset-inline-end: -12%;
  bottom: -40%;
  width: 52%;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 2px solid rgba(17,215,255,.28);
  box-shadow: inset 0 0 80px rgba(17,215,255,.15), 0 0 80px rgba(17,215,255,.14);
}
.hero-content { position: relative; z-index: 1; }
.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 999px;
  padding: 8px 13px;
  background: rgba(17,215,255,.14);
  border: 1px solid rgba(17,215,255,.28);
  color: var(--cyan-200);
  font-weight: 900;
  font-size: 13px;
}
.hero h2 { margin: 18px 0 12px; font-size: clamp(32px, 6vw, 76px); line-height: .98; letter-spacing: -.055em; }
.hero p { margin: 0; color: rgba(255,255,255,.76); max-width: 780px; line-height: 1.9; font-size: 16px; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 26px; }
.hero-panel {
  position: relative;
  z-index: 1;
  padding: 24px;
  border-radius: 26px;
  background: linear-gradient(145deg, rgba(255,255,255,.16), rgba(255,255,255,.06));
  border: 1px solid rgba(255,255,255,.18);
  backdrop-filter: blur(14px);
}
.hero-stat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.hero-stat { padding: 16px; border-radius: 18px; background: rgba(255,255,255,.09); border: 1px solid rgba(255,255,255,.12); }
.hero-stat b { font-size: 26px; display: block; color: white; }
.hero-stat span { color: rgba(255,255,255,.68); font-size: 12px; }

.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)); }
.section { margin-top: 26px; }
.section-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.section-title { margin: 0; font-size: 24px; letter-spacing: -.02em; }
.section-note { margin: 5px 0 0; color: var(--slate-500); line-height: 1.7; }

.card {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-lg);
  background: rgba(255,255,255,.86);
  border: 1px solid rgba(8,40,93,.08);
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(18px);
}
.card.pad { padding: 22px; }
.card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 4px;
  background: linear-gradient(90deg, transparent, var(--cyan-500), transparent);
  opacity: .7;
}
.card h3 { margin: 0 0 10px; font-size: 20px; }
.card p { color: var(--slate-500); line-height: 1.8; }

.level-card {
  padding: 22px;
  min-height: 220px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform .22s ease, border-color .22s ease;
}
.level-card:hover { transform: translateY(-4px); border-color: rgba(17,215,255,.32); }
.level-number { font-size: 56px; font-weight: 950; color: rgba(8,40,93,.12); line-height: .9; }
.level-card.active .level-number { color: rgba(17,215,255,.26); }
.level-status { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 900; color: var(--navy-900); background: var(--ice-100); border: 1px solid var(--line); padding: 7px 10px; border-radius: 999px; }
.level-card.locked { opacity: .82; }
.level-card.locked::after {
  content: "🔒";
  position: absolute;
  inset-inline-end: 20px;
  top: 18px;
  font-size: 22px;
  filter: drop-shadow(0 8px 14px rgba(8,40,93,.14));
}

.section-tabs {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 4px 2px 14px;
  scrollbar-width: thin;
}
.tab {
  flex: 0 0 auto;
  min-height: 45px;
  border: 1px solid rgba(8,40,93,.09);
  border-radius: 999px;
  background: rgba(255,255,255,.9);
  color: var(--navy-800);
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 900;
  transition: background .2s ease, transform .2s ease, color .2s ease;
}
.tab.active, .tab:hover { background: var(--navy-900); color: white; transform: translateY(-1px); }

.content-area { min-height: 360px; }
.empty-state, .locked-state {
  min-height: 340px;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 32px;
  border-radius: var(--radius-xl);
  background:
    radial-gradient(circle at top, rgba(17,215,255,.18), transparent 28rem),
    rgba(255,255,255,.78);
  border: 1px solid rgba(8,40,93,.08);
  box-shadow: var(--shadow-card);
}
.empty-icon, .locked-icon {
  width: 78px;
  height: 78px;
  margin: 0 auto 16px;
  display: grid;
  place-items: center;
  border-radius: 25px;
  color: var(--cyan-500);
  background: linear-gradient(145deg, white, var(--ice-100));
  border: 1px solid var(--line);
  font-size: 30px;
  box-shadow: 0 18px 38px rgba(8,40,93,.1);
}
.locked-icon { color: var(--gold); }
.empty-state h3, .locked-state h3 { margin: 0 0 8px; font-size: 25px; }
.empty-state p, .locked-state p { max-width: 620px; margin: 0 auto 18px; color: var(--slate-500); line-height: 1.8; }

.question-card { padding: 22px; display: grid; gap: 14px; }
.question-options { display: grid; gap: 8px; }
.option-pill { padding: 11px 13px; border-radius: 14px; background: var(--ice-100); color: var(--navy-800); border: 1px solid rgba(8,40,93,.08); }
.answer-box { padding: 16px; border-radius: 16px; background: linear-gradient(145deg, rgba(17,215,255,.12), rgba(255,255,255,.9)); border: 1px solid var(--line); }
.video-frame { position: relative; width: 100%; aspect-ratio: 16/9; border-radius: 20px; overflow: hidden; background: var(--navy-900); }
.video-frame iframe { width: 100%; height: 100%; border: 0; }
.news-card img, .rx-card img { width: 100%; height: 210px; object-fit: cover; border-radius: 18px; background: var(--ice-100); }
.meta-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; color: var(--slate-500); font-size: 13px; }
.chip { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 6px 10px; background: var(--ice-100); border: 1px solid rgba(8,40,93,.08); color: var(--navy-800); font-weight: 800; font-size: 12px; }

.auth-layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 520px);
}
[dir="rtl"] .auth-layout { grid-template-columns: minmax(360px, 520px) minmax(0, 1fr); }
.auth-visual {
  position: relative;
  padding: clamp(32px, 6vw, 84px);
  color: white;
  background:
    radial-gradient(circle at 26% 20%, rgba(17,215,255,.38), transparent 28rem),
    linear-gradient(140deg, var(--navy-950), var(--navy-900), #0b3c86);
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow: hidden;
}
.auth-visual::after {
  content: "";
  position: absolute;
  inset-inline-end: -18%;
  bottom: -25%;
  width: 62%;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 2px solid rgba(17,215,255,.24);
  box-shadow: 0 0 120px rgba(17,215,255,.18), inset 0 0 80px rgba(17,215,255,.12);
}
.auth-visual h1 { margin: 22px 0 14px; font-size: clamp(44px, 8vw, 104px); line-height: .94; letter-spacing: -.07em; }
.auth-visual p { max-width: 700px; color: rgba(255,255,255,.75); font-size: 18px; line-height: 1.9; }
.auth-panel { display: grid; place-items: center; padding: 26px; }
.auth-card { width: min(100%, 460px); padding: 26px; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 6px; border-radius: 999px; background: var(--ice-100); margin-bottom: 20px; }
.auth-tabs button { border: 0; border-radius: 999px; min-height: 42px; background: transparent; color: var(--slate-500); font-weight: 900; }
.auth-tabs button.active { background: white; color: var(--navy-900); box-shadow: 0 8px 22px rgba(8,40,93,.08); }

.form { display: grid; gap: 14px; }
.form-row { display: grid; gap: 7px; }
label { color: var(--navy-800); font-weight: 900; font-size: 13px; }
.input, textarea, select {
  width: 100%;
  border: 1px solid rgba(8,40,93,.12);
  border-radius: 16px;
  min-height: 48px;
  padding: 12px 14px;
  outline: none;
  background: rgba(255,255,255,.88);
  color: var(--navy-950);
  transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
}
textarea { min-height: 120px; resize: vertical; line-height: 1.7; }
.input:focus, textarea:focus, select:focus { border-color: rgba(17,215,255,.7); box-shadow: 0 0 0 4px rgba(17,215,255,.13); background: white; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }

.table-wrap { overflow-x: auto; border-radius: 20px; border: 1px solid rgba(8,40,93,.08); background: white; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { padding: 13px 14px; border-bottom: 1px solid rgba(8,40,93,.08); text-align: start; vertical-align: top; }
th { background: var(--ice-100); color: var(--navy-800); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
td { color: var(--slate-700); font-size: 13px; }

.toast-wrap { position: fixed; z-index: 1000; inset-inline-end: 22px; bottom: 22px; display: grid; gap: 10px; width: min(420px, calc(100vw - 44px)); }
.toast { padding: 14px 16px; border-radius: 18px; background: var(--navy-900); color: white; box-shadow: 0 18px 45px rgba(3,16,37,.25); border: 1px solid rgba(17,215,255,.24); animation: slideIn .22s ease both; }
.toast.error { background: #7f1d1d; }
.toast.success { background: #0b5c4a; }
@keyframes slideIn { from { transform: translateY(12px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.loading {
  min-height: 220px;
  display: grid;
  place-items: center;
  color: var(--slate-500);
}
.spinner { width: 44px; height: 44px; border-radius: 50%; border: 4px solid rgba(8,40,93,.1); border-top-color: var(--cyan-500); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.admin-layout .main { padding-bottom: 80px; }
.admin-tabs { display: flex; flex-wrap: wrap; gap: 10px; margin: 18px 0; }
.admin-tabs .tab { min-height: 40px; font-size: 13px; }
.editor-grid { display: grid; grid-template-columns: minmax(320px, 470px) minmax(0, 1fr); gap: 18px; align-items: start; }
.admin-form-card { position: sticky; top: 108px; }
.code-like { direction: ltr; text-align: left; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; color: var(--slate-700); white-space: pre-wrap; word-break: break-word; }

.status-dot { display: inline-flex; align-items: center; gap: 8px; }
.status-dot::before { content:""; width: 9px; height: 9px; border-radius: 50%; background: var(--slate-500); }
.status-dot.active::before, .status-dot.reviewed::before, .status-dot.manual_active::before { background: var(--success); }
.status-dot.pending::before, .status-dot.past_due::before { background: var(--warning); }
.status-dot.locked::before, .status-dot.canceled::before, .status-dot.inactive::before { background: var(--danger); }

.kbd { direction: ltr; display: inline-flex; align-items: center; border: 1px solid rgba(8,40,93,.14); border-bottom-width: 2px; padding: 3px 7px; border-radius: 8px; background: white; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }

@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero { grid-template-columns: 1fr; }
  .editor-grid { grid-template-columns: 1fr; }
  .admin-form-card { position: relative; top: auto; }
}

@media (max-width: 880px) {
  :root { --sidebar-w: 300px; }
  .app-shell, [dir="rtl"] .app-shell { display: block; }
  .sidebar {
    position: fixed;
    z-index: 50;
    inset-block: 0;
    inset-inline-start: 0;
    width: var(--sidebar-w);
    transform: translateX(-105%);
    transition: transform .24s ease;
  }
  [dir="rtl"] .sidebar { inset-inline-start: auto; inset-inline-end: 0; transform: translateX(105%); }
  .sidebar.open { transform: translateX(0); }
  .mobile-menu { display: inline-flex; }
  .main { padding-inline: 16px; }
  .topbar { margin-inline: -16px; padding-inline: 16px; }
  .auth-layout, [dir="rtl"] .auth-layout { grid-template-columns: 1fr; }
  .auth-visual { min-height: 44vh; }
}

@media (max-width: 640px) {
  .grid-2, .grid-3, .grid-4, .form-grid { grid-template-columns: 1fr; }
  .topbar { align-items: flex-start; }
  .topbar-actions { flex-wrap: wrap; justify-content: flex-end; }
  .hero { padding: 22px; border-radius: 24px; }
  .hero-stat-grid { grid-template-columns: 1fr; }
  .section-head { display: block; }
  .auth-panel { padding: 16px; }
  .auth-card { padding: 20px; }
}
