/* ═══════════════════════════════════════════
   VARIABLES
════════════════════════════════════════════ */
:root {
  --green:        #1a7a4a;
  --green-2:      #15a058;
  --green-light:  #f0fdf4;
  --green-mid:    #bbf7d0;
  --green-dark:   #0f4c2a;
  --gold:         #b8860b;
  --gold-light:   #fef3c7;
  --gold-mid:     #fcd34d;
  --blue:         #2563eb;
  --blue-light:   #eff6ff;
  --blue-mid:     #bfdbfe;
  --red:          #dc2626;
  --red-light:    #fef2f2;
  --bg:           #f1f5f9;
  --surface:      #ffffff;
  --border:       #e2e8f0;
  --border-2:     #cbd5e1;
  --text:         #0f172a;
  --text-2:       #334155;
  --text-muted:   #64748b;
  --text-faint:   #94a3b8;
  --shadow-sm:    0 1px 2px rgba(0,0,0,.06);
  --shadow:       0 1px 3px rgba(0,0,0,.10), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:    0 4px 8px rgba(0,0,0,.08), 0 2px 4px rgba(0,0,0,.05);
  --shadow-lg:    0 12px 24px rgba(0,0,0,.10), 0 4px 8px rgba(0,0,0,.06);
  --r:            14px;
  --r-sm:         8px;
  --r-xs:         6px;
  --ease:         all .2s cubic-bezier(.4,0,.2,1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ───── Typography ───── */
.ar-inline, .ar-title {
  font-family: 'Noto Sans Arabic', sans-serif;
  direction: rtl;
}
.ar-title { color: var(--green); font-size: 1.05rem; font-weight: 700; }
.ar { font-family: 'Noto Sans Arabic', sans-serif; }

td.ar, span.ar {
  font-family: 'Noto Sans Arabic', sans-serif;
  direction: rtl;
  text-align: right;
}

/* ───── Lucide icon alignment ───── */
i[data-lucide] {
  display: inline-flex;
  vertical-align: middle;
  flex-shrink: 0;
}
button i[data-lucide] { pointer-events: none; }

/* ───── Page System ───── */
.page { display: none; }
.page.active { display: block; }
.page.hidden { display: none !important; }
.view { display: none; }
.view.active { display: block; }
.hidden { display: none !important; }

/* ───── Spinner ───── */
@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin 1s linear infinite; }

/* ═══════════════════════════════════════════
   AUTH PAGE
════════════════════════════════════════════ */
#page-auth {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(20px + env(safe-area-inset-top, 0px)) 20px calc(20px + env(safe-area-inset-bottom, 0px)) 20px;
  position: relative;
  overflow: hidden;
  background: linear-gradient(160deg, #0a3d20 0%, #1a7a4a 45%, #0d5e33 100%);
}

.auth-bg {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.auth-pattern {
  position: absolute;
  inset: -100px;
  background-image:
    radial-gradient(circle at 20% 20%, rgba(255,255,255,.04) 1px, transparent 1px),
    radial-gradient(circle at 80% 80%, rgba(255,255,255,.04) 1px, transparent 1px);
  background-size: 60px 60px;
}

.auth-container {
  width: 100%;
  max-width: 460px;
  position: relative;
  z-index: 2;
}

.auth-brand {
  text-align: center;
  margin-bottom: 24px;
  color: white;
}

.auth-logo {
  width: 200px; height: 200px;
  background: none;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 12px;
  border: none;
}
.auth-logo img {
  width: 100%; height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 4px 16px rgba(0,0,0,.35));
}

.auth-brand p { color: rgba(255,255,255,.75); font-size: 1rem; margin-top: 2px; letter-spacing: .5px; }

.auth-card {
  background: var(--surface);
  border-radius: var(--r);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.6);
}

.auth-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
}

.auth-tab {
  flex: 1; padding: 14px 16px;
  border: none; background: none;
  font-size: .875rem; font-weight: 500;
  color: var(--text-muted); cursor: pointer;
  transition: var(--ease);
  display: flex; align-items: center; justify-content: center; gap: 6px;
  font-family: inherit;
}
.auth-tab.active { color: var(--green); background: white; border-bottom: 2px solid var(--green); font-weight: 600; }

.auth-form { padding: 28px 28px 24px; }

.form-group { margin-bottom: 16px; }
.form-group label {
  display: flex; align-items: center; gap: 5px;
  font-size: .8rem; font-weight: 600; color: var(--text-2);
  margin-bottom: 6px; text-transform: uppercase; letter-spacing: .4px;
}
.form-group input {
  width: 100%; padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm); font-size: .925rem;
  transition: var(--ease); outline: none; font-family: inherit;
  background: #f8fafc;
}
.form-group input:focus {
  border-color: var(--green); background: white;
  box-shadow: 0 0 0 3px rgba(26,122,74,.10);
}

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.form-error {
  background: var(--red-light); border: 1px solid #fecaca;
  color: var(--red); padding: 10px 14px;
  border-radius: var(--r-sm); font-size: .85rem; margin-bottom: 14px;
  display: flex; align-items: center; gap: 8px;
}

/* ═══════════════════════════════════════════
   BUTTONS
════════════════════════════════════════════ */
.btn-primary {
  background: linear-gradient(135deg, var(--green) 0%, var(--green-2) 100%);
  color: white; border: none;
  padding: 11px 22px; border-radius: var(--r-sm);
  font-size: .9rem; font-weight: 600; cursor: pointer;
  transition: var(--ease); font-family: inherit;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  box-shadow: 0 2px 8px rgba(26,122,74,.30);
}
.btn-primary:hover { box-shadow: 0 4px 14px rgba(26,122,74,.40); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }
.btn-primary.full { width: 100%; }

.btn-secondary {
  background: var(--surface); color: var(--text-2);
  border: 1.5px solid var(--border);
  padding: 10px 20px; border-radius: var(--r-sm);
  font-size: .9rem; font-weight: 500; cursor: pointer;
  transition: var(--ease); font-family: inherit;
  display: inline-flex; align-items: center; gap: 7px;
}
.btn-secondary:hover { border-color: var(--green); color: var(--green); background: var(--green-light); }

.btn-ghost {
  background: none; color: var(--text-muted); border: none;
  padding: 10px 16px; border-radius: var(--r-sm);
  font-size: .875rem; font-weight: 500; cursor: pointer;
  transition: var(--ease); font-family: inherit;
  display: inline-flex; align-items: center; gap: 7px;
}
.btn-ghost:hover { background: var(--border); color: var(--text); }

.btn-back {
  background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.20);
  color: rgba(255,255,255,.90); padding: 8px 16px;
  border-radius: 24px; cursor: pointer; font-size: .85rem; font-weight: 500;
  transition: var(--ease); font-family: inherit;
  display: flex; align-items: center; gap: 6px;
}
.btn-back:hover { background: rgba(255,255,255,.22); }

.btn-logout {
  background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.18);
  color: rgba(255,255,255,.85); padding: 7px 10px;
  border-radius: var(--r-sm); cursor: pointer;
  transition: var(--ease); font-family: inherit;
  display: flex; align-items: center;
}
.btn-logout:hover { background: rgba(255,255,255,.22); }

/* ═══════════════════════════════════════════
   NAVBAR
════════════════════════════════════════════ */
.navbar {
  background: linear-gradient(135deg, var(--green-dark) 0%, var(--green) 100%);
  padding: 0 24px;
  display: flex; align-items: center; justify-content: space-between;
  box-shadow: 0 2px 12px rgba(0,0,0,.18);
  position: sticky; top: 0; z-index: 100;
  min-height: 58px;
}

/* iOS standalone safe area — pushes navbar below status bar */
@supports (padding-top: env(safe-area-inset-top)) {
  .navbar {
    padding-top: env(safe-area-inset-top);
    min-height: calc(58px + env(safe-area-inset-top));
  }
}
}

.nav-brand { display: flex; align-items: center; gap: 10px; }
.nav-logo {
  width: 34px; height: 34px;
  background: rgba(255,255,255,.18);
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
}
.brand-name { color: white; font-weight: 700; font-size: 1.05rem; font-family: 'Noto Sans Arabic', sans-serif; }

.nav-tabs { display: flex; gap: 4px; }
.nav-tab {
  padding: 7px 16px; border: none;
  background: rgba(255,255,255,.10); color: rgba(255,255,255,.75);
  border-radius: 24px; cursor: pointer; font-size: .85rem; font-weight: 500;
  transition: var(--ease); font-family: inherit;
  display: flex; align-items: center; gap: 6px;
}
.nav-tab.active, .nav-tab:hover { background: rgba(255,255,255,.22); color: white; }

.nav-user { display: flex; align-items: center; gap: 10px; }
.nav-avatar {
  width: 30px; height: 30px;
  background: rgba(255,255,255,.20);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.nav-user > span { color: rgba(255,255,255,.85); font-size: .85rem; font-weight: 500; }

/* ═══════════════════════════════════════════
   LAYOUT
════════════════════════════════════════════ */
.container { max-width: 1100px; margin: 0 auto; padding: 28px 24px; }

.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 24px; gap: 20px;
}
.header-text h2 { font-size: 1.6rem; font-weight: 800; color: var(--text); }
.header-text p { color: var(--text-muted); margin-top: 3px; font-size: .9rem; }

.header-level {
  background: var(--green-light);
  border: 1px solid var(--green-mid);
  color: var(--green); font-size: .8rem; font-weight: 700;
  padding: 6px 14px; border-radius: 24px;
  display: flex; align-items: center; gap: 5px;
  white-space: nowrap;
}

/* ═══════════════════════════════════════════
   STATS GRID
════════════════════════════════════════════ */
.stats-grid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 18px; margin-bottom: 28px;
}

.stat-card {
  background: var(--surface); border-radius: var(--r);
  padding: 20px 22px; box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 16px;
  border: 1px solid var(--border);
  transition: var(--ease);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

.stat-icon-wrap {
  width: 48px; height: 48px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.green-bg { background: var(--green-light); border: 1px solid var(--green-mid); }
.blue-bg  { background: var(--blue-light);  border: 1px solid var(--blue-mid); }
.gold-bg  { background: var(--gold-light);  border: 1px solid #fde68a; }
.purple-bg { background: #f5f3ff; border: 1px solid #ddd6fe; }

.stat-value { font-size: 2rem; font-weight: 800; color: var(--text); line-height: 1; }
.stat-label { font-size: .8rem; color: var(--text-muted); margin-top: 3px; }

/* 4-column stats grid */
.stats-grid-4 { grid-template-columns: repeat(4, 1fr); }

/* ═══════════════════════════════════════════
   DASHBOARD — DOUA
════════════════════════════════════════════ */
.dash-doua {
  background: linear-gradient(135deg, #fefce8 0%, #fef9c3 50%, #fef3c7 100%);
  border: 1.5px solid #fde68a;
  border-radius: var(--r);
  padding: 18px 24px;
  margin-bottom: 20px;
  text-align: center;
  box-shadow: var(--shadow-sm);
}
.doua-ar {
  font-family: 'Amiri', 'Traditional Arabic', 'Scheherazade New', serif;
  font-size: 1.65rem;
  font-weight: 700;
  color: #92400e;
  line-height: 2;
  direction: rtl;
  margin-bottom: 6px;
}
.doua-fr {
  font-size: .92rem;
  color: #78350f;
  font-style: italic;
}
.doua-ref {
  font-size: .75rem;
  color: #a16207;
  margin-top: 4px;
}

/* ═══════════════════════════════════════════
   DASHBOARD — CONTINUE BUTTON
════════════════════════════════════════════ */
.dash-continue {
  margin-bottom: 20px;
}
.dash-continue-inner {
  background: linear-gradient(135deg, #f0fdf4 0%, #ecfdf5 50%, #d1fae5 100%);
  border: 1.5px solid var(--green-mid);
  border-radius: var(--r);
  padding: 16px 20px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
  box-shadow: var(--shadow-sm);
  transition: var(--ease);
}
.dash-continue-inner:hover { box-shadow: var(--shadow); }
.dash-continue-text {
  display: flex; align-items: center; gap: 12px; color: var(--green-dark);
}
.dash-continue-text strong { font-size: 1rem; display: block; }
.dash-continue-text small { font-size: .8rem; color: var(--text-muted); }

/* ═══════════════════════════════════════════
   DASHBOARD — GLOBAL PROGRESS BAR
════════════════════════════════════════════ */
.dash-progress-bar-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 16px 20px;
  margin-bottom: 22px;
  box-shadow: var(--shadow-sm);
}
.dash-progress-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 10px;
}
.dash-progress-label { font-size: .85rem; font-weight: 700; color: var(--text-2); }
.dash-progress-pct { font-size: 1.1rem; font-weight: 800; color: var(--green); }
.dash-progress-track {
  width: 100%; height: 12px;
  background: #e5e7eb; border-radius: 8px; overflow: hidden;
}
.dash-progress-fill {
  height: 100%; border-radius: 8px;
  background: linear-gradient(90deg, #16a34a, #22c55e);
  transition: width .6s ease;
}
.dash-progress-sub {
  font-size: .78rem; color: var(--text-muted); margin-top: 6px; text-align: right;
}

/* ═══════════════════════════════════════════
   DASHBOARD — WIDGETS ROW
════════════════════════════════════════════ */
.dash-widgets-row {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 18px; margin-bottom: 28px;
}
.dash-widget {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}
.dash-widget-header {
  font-size: .82rem; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .5px;
  display: flex; align-items: center; gap: 6px;
  margin-bottom: 14px;
}

/* Weekly goal ring */
.dash-weekly-goal {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.dash-weekly-ring {
  position: relative; width: 90px; height: 90px;
}
.dash-weekly-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg {
  fill: none; stroke: #e5e7eb; stroke-width: 3;
}
.ring-fill {
  fill: none; stroke: var(--green); stroke-width: 3;
  stroke-linecap: round; transition: stroke-dasharray .6s ease;
}
.ring-fill.complete { stroke: #c9a227; }
.ring-text {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; font-weight: 800; color: var(--text);
}
.dash-weekly-label {
  font-size: .82rem; color: var(--text-muted); text-align: center;
}

/* Performance items (best / worst) */
.perf-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--r-sm);
  margin-bottom: 8px;
}
.perf-item.best { background: #fefce8; border: 1px solid #fde68a; }
.perf-item.worst { background: #fef2f2; border: 1px solid #fecaca; }
.perf-item:last-child { margin-bottom: 0; }
.perf-icon { flex-shrink: 0; }
.perf-body { flex: 1; min-width: 0; }
.perf-label { display: block; font-size: .72rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .4px; }
.perf-title { display: block; font-size: .88rem; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.perf-score { font-size: 1.2rem; font-weight: 800; flex-shrink: 0; }
.best-score { color: #b8860b; }
.worst-score { color: #dc2626; }
.empty-state.small { padding: 16px; }
.empty-state.small p { font-size: .85rem; }

/* ═══════════════════════════════════════════
   RECENT ACTIVITY
════════════════════════════════════════════ */
.section-title {
  font-size: .9rem; font-weight: 700;
  color: var(--text-muted); text-transform: uppercase; letter-spacing: .6px;
  margin-bottom: 12px; display: flex; align-items: center; gap: 7px;
}
.recent-list { display: flex; flex-direction: column; gap: 8px; }

.recent-item {
  background: var(--surface); border-radius: var(--r-sm);
  padding: 14px 18px; box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.ri-title { font-weight: 600; font-size: .9rem; }
.ri-sub { font-size: .78rem; color: var(--text-muted); margin-top: 1px; direction: rtl; font-family: 'Noto Sans Arabic', sans-serif; }
.ri-badge {
  background: var(--green-light); color: var(--green);
  padding: 4px 11px; border-radius: 12px;
  font-size: .8rem; font-weight: 700;
  white-space: nowrap; border: 1px solid var(--green-mid);
}

.empty-state {
  text-align: center; color: var(--text-muted);
  padding: 48px 24px; background: var(--surface);
  border-radius: var(--r); border: 1px dashed var(--border);
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.empty-state p { font-size: .9rem; }

/* ═══════════════════════════════════════════
   LEVEL BANNER
════════════════════════════════════════════ */
.level-banner {
  background: linear-gradient(135deg, #fffbeb, #fef3c7);
  border: 1px solid #fde68a; border-radius: var(--r);
  padding: 16px 20px; margin-bottom: 24px;
  display: flex; align-items: center; gap: 14px;
}
.level-banner-icon {
  width: 44px; height: 44px; background: #fef9c3;
  border-radius: 10px; border: 1px solid #fde68a;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.level-banner-text { display: flex; flex-direction: column; gap: 2px; }
.level-banner-text strong { font-size: .95rem; font-weight: 700; color: #92400e; }
.level-banner-text span { font-size: .82rem; color: #a16207; }

/* ═══════════════════════════════════════════
   COLLECTIONS GRID
════════════════════════════════════════════ */
.collections-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.collection-card {
  background: var(--surface); border-radius: var(--r);
  padding: 28px 24px 22px; text-align: center;
  box-shadow: var(--shadow); cursor: pointer;
  transition: transform .15s, box-shadow .15s;
  border: 2px solid transparent;
}
.collection-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md, 0 4px 12px rgba(0,0,0,.12));
}
.collection-card.available {
  border-color: var(--green-light, #d1fae5);
}
.collection-card.locked {
  opacity: 0.6; cursor: default;
}
.collection-card-emoji {
  font-size: 3rem; line-height: 1;
  margin-bottom: 12px;
}
.collection-card-title {
  font-size: 1.3rem; font-weight: 700;
  color: var(--green); margin: 0 0 4px;
}
.collection-card-ar {
  font-family: 'Amiri', 'Noto Sans Arabic', serif;
  font-size: 1.15rem; color: #78350f;
  direction: rtl; margin: 0 0 8px;
}
.collection-card-desc {
  font-size: .85rem; color: var(--muted);
  margin: 0 0 14px; line-height: 1.4;
}
.collection-card-meta {
  display: flex; justify-content: center; gap: 16px;
  font-size: .8rem; color: var(--muted);
  margin-bottom: 12px;
}
.collection-card-meta span {
  display: flex; align-items: center; gap: 4px;
}
.collection-card-meta i { width: 14px; height: 14px; }

/* ═══════════════════════════════════════════
   COLLECTION PAGE HEADER
════════════════════════════════════════════ */
.collection-header {
  display: flex; gap: 20px; margin-bottom: 24px;
  align-items: flex-start;
}
.collection-emoji {
  font-size: 3.5rem; line-height: 1;
  flex-shrink: 0;
}
.collection-header-info { flex: 1; }
.collection-header-info h2 {
  margin: 0 0 2px; font-size: 1.5rem;
  color: var(--green);
}
.collection-desc {
  font-size: .9rem; color: var(--muted);
  margin: 6px 0 12px;
}

/* ═══════════════════════════════════════════
   ADMIN BOOK ACCESS - GROUP HEADER
════════════════════════════════════════════ */
.book-access-group-header {
  font-size: .85rem; font-weight: 700;
  color: var(--green); text-transform: uppercase;
  letter-spacing: .5px; padding: 10px 0 6px;
  border-bottom: 1px solid var(--border, #e5e7eb);
  margin-bottom: 4px; margin-top: 8px;
}
.book-access-group-header:first-child { margin-top: 0; }

/* ═══════════════════════════════════════════
   BOOKS GRID
════════════════════════════════════════════ */
.books-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 16px;
}

.book-card {
  background: var(--surface); border-radius: var(--r);
  padding: 22px 16px 18px; text-align: center;
  box-shadow: var(--shadow); cursor: pointer;
  transition: var(--ease);
  border: 1.5px solid var(--border);
  position: relative; overflow: hidden;
}
.book-card.available:hover {
  transform: translateY(-4px); box-shadow: var(--shadow-lg);
  border-color: var(--green);
}
.book-card.locked { cursor: not-allowed; opacity: .65; }

.book-card::after {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--green), #22d3ee);
  opacity: 0; transition: var(--ease);
}
.book-card.available:hover::after { opacity: 1; }

.book-icon-wrap {
  width: 56px; height: 56px; border-radius: 14px; margin: 0 auto 14px;
  display: flex; align-items: center; justify-content: center;
}
.book-icon-wrap.avail { background: var(--green-light); border: 1.5px solid var(--green-mid); }
.book-icon-wrap.lock  { background: #f1f5f9; border: 1.5px solid var(--border); }

.book-card h4 { font-size: .95rem; font-weight: 700; color: var(--text); }
.book-card p  { font-size: .78rem; color: var(--text-muted); margin-top: 3px; }

.book-progress-mini {
  margin: 10px 0 8px; height: 4px; background: var(--border);
  border-radius: 2px; overflow: hidden;
}
.book-progress-mini-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--green), #22d3ee);
  border-radius: 2px;
}

.badge-available {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--green-light); color: var(--green);
  font-size: .72rem; font-weight: 700;
  padding: 3px 10px; border-radius: 12px;
  border: 1px solid var(--green-mid);
}
.badge-locked {
  display: inline-flex; align-items: center; gap: 4px;
  background: #f1f5f9; color: var(--text-muted);
  font-size: .72rem; font-weight: 600;
  padding: 3px 10px; border-radius: 12px;
}

/* ═══════════════════════════════════════════
   BOOK DETAIL
════════════════════════════════════════════ */
.book-header {
  background: var(--surface); border-radius: var(--r);
  padding: 28px; box-shadow: var(--shadow); border: 1px solid var(--border);
  display: flex; gap: 24px; align-items: flex-start; margin-bottom: 24px;
}
.book-icon-large {
  width: 72px; height: 72px; border-radius: var(--r);
  background: var(--green-light); border: 2px solid var(--green-mid);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.book-header-info { flex: 1; }
.book-title-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.book-title-row h2 { font-size: 1.5rem; font-weight: 800; }
.book-level-tag {
  background: var(--gold-light); color: var(--gold);
  font-size: .75rem; font-weight: 700; padding: 3px 10px;
  border-radius: 12px; border: 1px solid #fde68a;
}
.book-desc { color: var(--text-muted); font-size: .875rem; margin-top: 6px; }
.book-progress-row {
  display: flex; align-items: center; gap: 12px; margin-top: 14px;
}
.book-progress-bar {
  flex: 1; height: 7px; background: var(--border);
  border-radius: 4px; overflow: hidden;
}
.book-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--green), #22d3ee);
  border-radius: 4px; transition: width .5s ease;
}
.book-progress-text { font-size: .8rem; font-weight: 600; color: var(--text-muted); white-space: nowrap; }

/* Units */
.unit-block {
  background: var(--surface); border-radius: var(--r);
  box-shadow: var(--shadow); margin-bottom: 16px;
  border: 1px solid var(--border); overflow: hidden;
}
.unit-header {
  background: linear-gradient(135deg, #f8fafc, #f1f5f9);
  padding: 14px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.unit-header h3 {
  font-size: 1rem; font-weight: 700;
  display: flex; align-items: center; gap: 10px;
}
.unit-num {
  width: 28px; height: 28px; border-radius: 8px;
  background: linear-gradient(135deg, var(--green), var(--green-2));
  color: white; font-size: .8rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.unit-ar { font-family: 'Noto Sans Arabic', sans-serif; color: var(--green); font-size: .9rem; direction: rtl; }
.unit-prog { font-size: .8rem; color: var(--text-muted); font-weight: 500; background: var(--border); padding: 3px 10px; border-radius: 12px; }

.lesson-item {
  display: flex; align-items: center; gap: 14px;
  padding: 13px 20px; cursor: pointer;
  transition: var(--ease);
  border-bottom: 1px solid #f8fafc;
}
.lesson-item:hover { background: #f8fafc; }
.lesson-item:last-child { border-bottom: none; }

.lesson-status {
  width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .78rem; font-weight: 700; flex-shrink: 0;
}
.lesson-status.done { background: var(--green-light); color: var(--green); border: 1.5px solid var(--green-mid); }
.lesson-status.todo { background: #f1f5f9; color: var(--text-muted); border: 1.5px solid var(--border); font-size: .75rem; }

.lesson-info { flex: 1; min-width: 0; }
.lesson-item-title { font-weight: 600; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lesson-item-ar { font-family: 'Noto Sans Arabic', sans-serif; font-size: .82rem; color: var(--text-muted); direction: rtl; }

.type-chip {
  font-size: .72rem; font-weight: 700; padding: 3px 9px;
  border-radius: 10px; text-transform: uppercase; letter-spacing: .3px;
  white-space: nowrap;
}
.type-chip.grammar    { background: var(--blue-light); color: var(--blue); border: 1px solid var(--blue-mid); }
.type-chip.vocabulary { background: var(--gold-light); color: var(--gold); border: 1px solid #fde68a; }

.lesson-score { font-size: .8rem; font-weight: 700; color: var(--green); white-space: nowrap; }
.lesson-arrow { color: var(--text-faint); flex-shrink: 0; }

/* ═══════════════════════════════════════════
   LESSON PAGE
════════════════════════════════════════════ */
.lesson-container { max-width: 840px; }

.lesson-section {
  background: var(--surface); border-radius: var(--r);
  box-shadow: var(--shadow); padding: 32px;
  border: 1px solid var(--border); margin-bottom: 20px;
}

.lesson-header { text-align: center; margin-bottom: 28px; }

.lesson-type-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 14px; border-radius: 20px;
  font-size: .78rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .4px;
  margin-bottom: 10px;
}
.lesson-type-chip.grammar    { background: var(--blue-light); color: var(--blue);  border: 1px solid var(--blue-mid); }
.lesson-type-chip.vocabulary { background: var(--gold-light); color: var(--gold);  border: 1px solid #fde68a; }

.lesson-header h2 { font-size: 1.5rem; font-weight: 800; }

/* Theory */
.theory-block h3 {
  font-family: 'Noto Sans Arabic', sans-serif;
  font-size: 1.5rem; font-weight: 700; color: var(--green);
  direction: rtl; text-align: right;
  padding-bottom: 10px; border-bottom: 2px solid var(--green-mid);
  margin: 0 0 20px;
}
.theory-block h4 { font-size: 1.15rem; font-weight: 700; color: var(--text); margin: 20px 0 10px; }

.theory-text {
  background: #f8fafc; border-right: 4px solid var(--green);
  padding: 16px 20px; border-radius: 0 var(--r-sm) var(--r-sm) 0;
  font-family: 'Noto Sans Arabic', sans-serif; font-size: 1.2rem;
  line-height: 2.2; direction: rtl; text-align: right; margin-bottom: 18px;
}

.theory-table-wrap { overflow-x: auto; margin-bottom: 16px; border-radius: var(--r-sm); overflow: hidden; border: 1px solid var(--border); }
.theory-table { width: 100%; border-collapse: collapse; font-size: 1rem; }
.theory-table th {
  background: var(--green); color: white;
  padding: 10px 14px; text-align: left;
  font-weight: 600; font-size: .95rem; letter-spacing: .3px;
}
.theory-table td {
  padding: 9px 14px; border-bottom: 1px solid var(--border); color: var(--text);
  vertical-align: middle;
}
.theory-table tr:nth-child(even) td { background: #f8fafc; }
.theory-table tr:hover td { background: #f0fdf4; }
.theory-table td.ar { font-family: 'Noto Sans Arabic', sans-serif; font-size: 1.15rem; direction: rtl; text-align: right; font-weight: 600; }

.theory-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px; margin-bottom: 16px;
}
.theory-card {
  background: #f8fafc; border: 1.5px solid var(--border);
  border-radius: var(--r-sm); padding: 12px 10px;
  text-align: center; display: flex; flex-direction: column; gap: 4px;
  transition: var(--ease);
}
.theory-card:hover { border-color: var(--green); background: var(--green-light); }
.theory-card.hl { border-color: var(--green); background: var(--green-light); }
.theory-card .ar.big { font-size: 1.8rem; font-weight: 700; color: var(--green); direction: rtl; display: block; }
.theory-card span { font-size: .85rem; font-weight: 600; color: var(--text-2); }
.theory-card small { font-size: .7rem; color: var(--text-muted); direction: rtl; font-family: 'Noto Sans Arabic', sans-serif; }

.theory-rule {
  background: #fffbeb; border: 1.5px solid #fde68a;
  border-radius: var(--r-sm); padding: 18px 22px;
  font-size: 1.15rem; margin-top: 16px; line-height: 2;
}
.theory-rule ul { margin-top: 8px; padding-right: 20px; }
.theory-rule li { margin-bottom: 5px; line-height: 1.7; }

/* Lesson CTA */
.lesson-cta {
  margin-top: 32px; padding: 20px 22px;
  background: linear-gradient(135deg, #f0fdf4, #dcfce7);
  border-radius: var(--r-sm); border: 1px solid var(--green-mid);
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.lesson-cta-text { display: flex; align-items: center; gap: 12px; flex: 1; }
.lesson-cta-text strong { font-size: .9rem; font-weight: 700; color: var(--text); display: block; }
.lesson-cta-text p { font-size: .8rem; color: var(--text-muted); margin: 0; }

/* ═══════════════════════════════════════════
   QUIZ
════════════════════════════════════════════ */
.quiz-header { margin-bottom: 24px; }
.quiz-header-top {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px;
}
.quiz-header-top h3 {
  font-size: 1rem; font-weight: 700;
  display: flex; align-items: center; gap: 7px;
}
.quiz-counter {
  font-size: .85rem; font-weight: 700;
  background: var(--green-light); color: var(--green);
  padding: 4px 12px; border-radius: 12px; border: 1px solid var(--green-mid);
}
.quiz-bar {
  height: 6px; background: var(--border); border-radius: 3px; overflow: hidden;
}
.quiz-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--green), #22d3ee);
  border-radius: 3px; transition: width .4s ease;
}

.quiz-question { margin-bottom: 20px; }
.quiz-q-text { font-size: 1.05rem; font-weight: 600; color: var(--text); line-height: 1.6; margin-bottom: 16px; }

/* Hint FR (info icon for Arabic questions) */
.quiz-q-row { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 16px; }
.quiz-q-row .quiz-question-text { flex: 1; font-size: 1.05rem; font-weight: 600; color: var(--text); line-height: 1.6; }
.quiz-hint-btn {
  width: 26px; height: 26px; flex-shrink: 0; margin-top: 2px;
  border-radius: 50%; border: 1.5px solid var(--blue-mid);
  background: var(--blue-light); color: var(--blue);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: .75rem; font-weight: 700;
  font-family: inherit; transition: var(--ease);
  position: relative;
}
.quiz-hint-btn:hover { background: var(--blue-mid); }
.quiz-hint-tooltip {
  display: none; position: absolute; top: 32px; right: 0;
  background: var(--surface); border: 1.5px solid var(--blue-mid);
  border-radius: var(--r-sm); padding: 10px 14px;
  font-size: .82rem; font-weight: 500; color: var(--text-2);
  box-shadow: var(--shadow-md); white-space: nowrap; z-index: 50;
  min-width: 180px; max-width: 320px; white-space: normal;
  line-height: 1.5;
}
.quiz-hint-btn.open .quiz-hint-tooltip { display: block; }
.quiz-hint-tooltip::before {
  content: ''; position: absolute; top: -6px; right: 10px;
  width: 10px; height: 10px; background: var(--surface);
  border-left: 1.5px solid var(--blue-mid); border-top: 1.5px solid var(--blue-mid);
  transform: rotate(45deg);
}

.quiz-options { display: flex; flex-direction: column; gap: 10px; }
.quiz-option {
  padding: 13px 16px; border: 2px solid var(--border); border-radius: var(--r-sm);
  cursor: pointer; transition: var(--ease); font-size: .9rem;
  font-family: inherit; background: var(--surface);
  display: flex; align-items: center; gap: 12px;
  text-align: left;
}
.quiz-option:hover:not(:disabled) { border-color: var(--green); background: var(--green-light); }
.quiz-option.selected  { border-color: var(--blue); background: var(--blue-light); }
.quiz-option.correct   { border-color: var(--green); background: var(--green-light); font-weight: 600; }
.quiz-option.wrong     { border-color: var(--red); background: var(--red-light); }
.quiz-option:disabled  { cursor: default; }

.opt-letter {
  width: 28px; height: 28px; flex-shrink: 0;
  border-radius: 8px; border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem; font-weight: 700; background: #f8fafc;
  transition: var(--ease);
}
.quiz-option:hover:not(:disabled) .opt-letter { border-color: var(--green); color: var(--green); }
.quiz-option.selected .opt-letter  { border-color: var(--blue);  background: var(--blue);  color: white; }
.quiz-option.correct  .opt-letter  { border-color: var(--green); background: var(--green); color: white; }
.quiz-option.wrong    .opt-letter  { border-color: var(--red);   background: var(--red);   color: white; }

.opt-text { font-family: 'Noto Sans Arabic', sans-serif; direction: rtl; flex: 1; }

.quiz-explanation {
  margin-top: 14px; padding: 12px 16px;
  background: var(--green-light);
  border-left: 3px solid var(--green);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  font-size: .85rem; color: var(--green-dark);
  display: flex; align-items: flex-start; gap: 8px;
}
.quiz-explanation.wrong {
  background: var(--red-light);
  border-left-color: var(--red);
  color: var(--red);
}
.quiz-explanation.correct {
  background: var(--green-light);
  border-left-color: var(--green);
  color: var(--green-dark);
}

.quiz-nav {
  display: flex; justify-content: space-between; gap: 12px; margin-top: 20px;
}

/* ═══════════════════════════════════════════
   RESULTS
════════════════════════════════════════════ */
.results-wrap { max-width: 560px; margin: 0 auto; }

.results-top {
  text-align: center; padding-bottom: 28px;
  border-bottom: 1px solid var(--border); margin-bottom: 24px;
}
.results-badge {
  width: 80px; height: 80px; border-radius: 20px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 16px;
  background: linear-gradient(135deg, var(--green-light), var(--green-mid));
  border: 2px solid var(--green-mid);
}
.results-badge.fail { background: var(--red-light); border-color: #fecaca; }

.results-top h2 { font-size: 1.5rem; font-weight: 800; margin-bottom: 20px; }

/* Score ring */
.score-ring {
  position: relative; width: 120px; height: 120px; margin: 0 auto 20px;
}
.score-ring svg { width: 120px; height: 120px; }
.score-inner {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
}
#score-value { font-size: 2rem; font-weight: 800; color: var(--text); }
.score-inner small { font-size: .9rem; font-weight: 600; color: var(--text-muted); }

.results-top > p { color: var(--text-muted); font-size: .9rem; margin-bottom: 20px; }

.results-stats {
  display: flex; justify-content: center; gap: 16px;
}
.res-stat {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 16px; border-radius: 12px;
  font-size: .85rem; font-weight: 700;
}
.res-stat.green { background: var(--green-light); color: var(--green); border: 1px solid var(--green-mid); }
.res-stat.red   { background: var(--red-light);   color: var(--red);   border: 1px solid #fecaca; }

.results-details { display: flex; flex-direction: column; gap: 8px; max-height: 320px; overflow-y: auto; }
.rd-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 11px 14px; border-radius: var(--r-sm); font-size: .85rem;
}
.rd-item.ok   { background: #f0fdf4; border: 1px solid var(--green-mid); }
.rd-item.fail { background: var(--red-light); border: 1px solid #fecaca; }
.rd-icon { flex-shrink: 0; margin-top: 1px; }
.rd-q { font-weight: 600; }
.rd-a { font-size: .78rem; color: var(--text-muted); margin-top: 2px; font-family: 'Noto Sans Arabic', sans-serif; direction: rtl; }

.results-actions {
  display: flex; gap: 12px; justify-content: center;
  flex-wrap: wrap; margin-top: 24px;
}

/* ═══════════════════════════════════════════
   UTILITIES
════════════════════════════════════════════ */
.loading {
  text-align: center; color: var(--text-muted); padding: 40px;
  display: flex; align-items: center; justify-content: center; gap: 10px;
}

/* ═══════════════════════════════════════════
   MOBILE BOTTOM NAV
════════════════════════════════════════════ */
.mobile-bottom-nav {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 200;
  padding: 6px 0;
  padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -2px 10px rgba(0,0,0,.08);
}
.mob-tab {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  gap: 2px; padding: 6px 4px;
  background: none; border: none; color: var(--text-muted);
  font-size: .65rem; font-weight: 600; font-family: inherit;
  cursor: pointer; transition: var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.mob-tab.active { color: var(--green); }
.mob-tab:active { transform: scale(.95); }

/* ═══════════════════════════════════════════
   RESPONSIVE
════════════════════════════════════════════ */

/* ── Tablet (< 1024px) ── */
@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(3, 1fr); gap: 14px; }
  .stats-grid-4 { grid-template-columns: repeat(2, 1fr); }
  .books-grid { grid-template-columns: repeat(auto-fill, minmax(155px, 1fr)); }
  .book-header { gap: 18px; }
  .container { max-width: 100%; padding: 24px 20px; }
}

/* ── Mobile (< 768px) ── */
@media (max-width: 768px) {
  /* Bottom nav visible */
  .mobile-bottom-nav { display: flex; }

  /* Top nav: hide tabs, compact */
  .nav-tabs { display: none; }
  .navbar { height: calc(52px + env(safe-area-inset-top, 0px)); padding: env(safe-area-inset-top, 0px) 14px 0 14px; }
  .nav-user > span { display: none; }
  .brand-name { font-size: .9rem; }

  /* Content padding for bottom nav safe area */
  #page-dashboard, #page-book { padding-bottom: calc(70px + env(safe-area-inset-bottom, 0px)); }

  /* Layout */
  .container { padding: 16px 14px; }
  .page-header { flex-direction: column; align-items: flex-start; gap: 10px; }
  .header-text h2 { font-size: 1.3rem; }
  .header-level { align-self: flex-start; }

  /* Stats */
  .stats-grid { grid-template-columns: 1fr; gap: 10px; }
  .stats-grid-4 { grid-template-columns: repeat(2, 1fr); }
  .stat-card { padding: 14px 16px; gap: 12px; }
  .stat-value { font-size: 1.6rem; }
  .stat-icon-wrap { width: 42px; height: 42px; }

  /* Dashboard widgets */
  .dash-widgets-row { grid-template-columns: 1fr; }
  .dash-continue-inner { flex-direction: column; text-align: center; }
  .dash-continue-text { flex-direction: column; gap: 6px; }

  /* Forms */
  .form-row { grid-template-columns: 1fr; gap: 10px; }
  .auth-form { padding: 20px 18px; }
  .auth-brand h1 { font-size: 1.6rem; }
  .auth-logo { width: 140px; height: 140px; }

  /* Books */
  .books-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
  .book-card { padding: 16px 12px 14px; }
  .book-icon-wrap { width: 48px; height: 48px; }
  .book-card h4 { font-size: .85rem; }

  /* Book detail */
  .book-header { flex-direction: column; padding: 18px; gap: 14px; }
  .book-icon-large { width: 56px; height: 56px; }
  .book-title-row h2 { font-size: 1.2rem; }
  .unit-header { padding: 12px 14px; flex-wrap: wrap; gap: 8px; }
  .lesson-item { padding: 11px 14px; gap: 10px; }
  .lesson-item-meta { display: flex; flex-direction: column; gap: 4px; align-items: flex-end; }
  .lesson-arrow { display: none; }

  /* Lesson */
  .lesson-section { padding: 18px 14px; }
  .lesson-header h2 { font-size: 1.2rem; }
  .lesson-cta { flex-direction: column; padding: 16px; gap: 12px; }
  .lesson-cta .btn-primary { width: 100%; }

  /* Theory tables */
  .theory-table th, .theory-table td { padding: 7px 10px; font-size: .8rem; }
  .theory-table td.ar { font-size: .9rem; }
  .theory-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 8px; }

  /* Quiz */
  .quiz-nav { flex-direction: column; gap: 8px; }
  .quiz-nav .btn-primary, .quiz-nav .btn-ghost { width: 100%; justify-content: center; }
  .quiz-q-text { font-size: .95rem; }
  .quiz-option { padding: 12px 14px; }
  .opt-text { font-size: .9rem; }

  /* Results */
  .results-wrap { padding: 0; }
  .results-actions { flex-direction: column; }
  .results-actions button { width: 100%; justify-content: center; }
  .score-ring { width: 100px; height: 100px; }
  .score-ring svg { width: 100px; height: 100px; }
  #score-value { font-size: 1.5rem; }

  /* Level banner */
  .level-banner { padding: 12px 14px; gap: 10px; }
  .level-banner-text strong { font-size: .85rem; }
  .level-banner-text span { font-size: .75rem; }
}

/* ── Small phones (< 400px) ── */
@media (max-width: 400px) {
  .books-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .book-card { padding: 14px 10px 12px; }
  .book-card h4 { font-size: .78rem; }
  .auth-container { max-width: 100%; }
  .auth-form { padding: 16px 14px; }
  .stat-card { padding: 12px; }
  .lesson-item { gap: 8px; }
  .type-chip { font-size: .65rem; padding: 2px 7px; }
  .lesson-status { width: 30px; height: 30px; }
}

/* ── Touch improvements ── */
@media (hover: none) and (pointer: coarse) {
  .book-card:hover { transform: none; box-shadow: var(--shadow); }
  .stat-card:hover { transform: none; box-shadow: var(--shadow); }
  .quiz-option:hover:not(:disabled) { border-color: var(--border); background: var(--surface); }
  .quiz-option:hover:not(:disabled) .opt-letter { border-color: var(--border); color: inherit; }
  .quiz-option:active:not(:disabled) { border-color: var(--green); background: var(--green-light); }
  .quiz-option:active:not(:disabled) .opt-letter { border-color: var(--green); color: var(--green); }

  /* Larger tap targets */
  .quiz-option { min-height: 48px; }
  .lesson-item { min-height: 56px; }
  .btn-primary, .btn-secondary, .btn-ghost { min-height: 44px; }
}

/* ── Landscape mobile ── */
@media (max-height: 500px) and (orientation: landscape) {
  .navbar { height: 44px; }
  .mobile-bottom-nav { padding: 4px 0; }
  .mob-tab span { display: none; }
  .auth-brand { margin-bottom: 12px; }
  .auth-logo { display: none; }
}

/* ── Dark mode support (follows system preference) ── */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f172a;
    --surface: #1e293b;
    --border: #334155;
    --border-2: #475569;
    --text: #f1f5f9;
    --text-2: #cbd5e1;
    --text-muted: #94a3b8;
    --text-faint: #64748b;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.2);
    --shadow: 0 1px 3px rgba(0,0,0,.3);
    --shadow-md: 0 4px 8px rgba(0,0,0,.25);
    --shadow-lg: 0 12px 24px rgba(0,0,0,.3);
  }
  .form-group input { background: #0f172a; color: var(--text); }
  .form-group input:focus { background: var(--surface); }
  .theory-table tr:nth-child(even) td { background: rgba(255,255,255,.03); }
  .theory-table tr:hover td { background: rgba(26,122,74,.15); }
  .theory-text { background: rgba(255,255,255,.05); }
  .theory-card { background: rgba(255,255,255,.05); }
  .auth-card { border-color: var(--border); }
  .mobile-bottom-nav { background: #1e293b; border-color: #334155; }
}

/* ═══════════════ ADMIN PANEL ═══════════════ */
.admin-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 24px;
  margin-bottom: 20px;
}
.admin-card h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.05rem;
  margin-bottom: 16px;
  color: var(--green);
}
.admin-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}
@media (max-width: 600px) {
  .admin-form-row { grid-template-columns: 1fr; }
}
.admin-table-wrap { overflow-x: auto; }
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
}
.admin-table th {
  text-align: left;
  padding: 10px 12px;
  background: var(--green-light);
  color: var(--green);
  font-weight: 600;
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .3px;
}
.admin-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.admin-table tr:hover td { background: rgba(26,122,74,.04); }
.admin-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.btn-sm {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 8px;
  border-radius: var(--r-xs);
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  transition: var(--ease);
}
.btn-sm:hover { background: var(--green-light); color: var(--green); border-color: var(--green); }
.btn-sm.btn-danger:hover { background: #fef2f2; color: #dc2626; border-color: #dc2626; }
.btn-outline { background: transparent; }

/* Badges */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 600;
}
.badge-green { background: #dcfce7; color: #16a34a; }
.badge-red { background: #fef2f2; color: #dc2626; }
.badge-gold { background: #fef9c3; color: #a16207; }
.badge-gray { background: #f1f5f9; color: #64748b; }

/* Book Access Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}
.modal-card {
  background: var(--surface);
  border-radius: var(--r);
  width: 100%;
  max-width: 520px;
  max-height: 80vh;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}
.modal-card.modal-large {
  max-width: 800px;
  max-height: 85vh;
}
.modal-card.modal-large .modal-body {
  overflow-y: auto;
  max-height: calc(85vh - 60px);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .95rem;
  margin: 0;
}
.modal-close {
  padding: 6px;
  border-radius: 50%;
}
.modal-body {
  padding: 16px 20px;
  overflow-y: auto;
  max-height: 60vh;
}
.book-access-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.book-access-row:last-child { border-bottom: none; }
.book-access-info {
  flex: 1;
  display: flex;
  flex-direction: column;
}
.book-access-info strong { font-size: .9rem; }
.book-access-info small { color: var(--text-muted); font-family: 'Noto Sans Arabic', serif; }

/* Modal actions */
.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 16px;
}

/* Form select */
.form-select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-size: .9rem;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  transition: var(--ease);
}
.form-select:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(26,122,74,.1);
}

/* Toggle Switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: #cbd5e1;
  border-radius: 24px;
  transition: var(--ease);
}
.toggle-slider::before {
  content: '';
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: var(--ease);
}
.toggle-switch input:checked + .toggle-slider { background: var(--green); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(20px); }
.toggle-switch input:disabled + .toggle-slider { opacity: .5; cursor: default; }

/* Dark mode admin */
@media (prefers-color-scheme: dark) {
  .admin-card { background: var(--surface); border-color: var(--border); }
  .admin-table th { background: rgba(26,122,74,.15); }
  .admin-table tr:hover td { background: rgba(26,122,74,.1); }
  .btn-sm { background: var(--surface); border-color: var(--border); color: var(--text); }
  .badge-green { background: rgba(22,163,74,.15); color: #4ade80; }
  .badge-red { background: rgba(220,38,38,.15); color: #f87171; }
  .badge-gold { background: rgba(161,98,7,.15); color: #fbbf24; }
  .badge-gray { background: rgba(100,116,139,.15); color: #94a3b8; }
  .modal-card { background: var(--surface); }
  .toggle-slider { background: #475569; }
}
