/* ==========================================================================
   خدمة خامسة وسادسة — الملاك ميخائيل شيراتون
   ========================================================================== */
:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --primary: #1d4ed8;
  --primary-ink: #ffffff;
  --primary-soft: #dbeafe;
  --navy: #1e3a8a;
  --gold: #f59e0b;
  --gold-soft: #fef3c7;
  --green: #16a34a;
  --green-soft: #dcfce7;
  --red: #dc2626;
  --red-soft: #fee2e2;
  --orange: #ea580c;
  --orange-soft: #ffedd5;
  --purple: #7c3aed;
  --purple-soft: #ede9fe;
  --teal: #0d9488;
  --teal-soft: #ccfbf1;
  --shadow: 0 1px 2px rgb(15 23 42 / 6%), 0 4px 16px rgb(15 23 42 / 6%);
  --shadow-lg: 0 10px 40px rgb(15 23 42 / 18%);
  --radius: 18px;
  --radius-sm: 12px;
  --sidebar: 264px;
  --font: 'Cairo', 'Segoe UI', Tahoma, system-ui, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1120; --surface: #111a2e; --surface-2: #0f172a; --ink: #e2e8f0; --ink-2: #cbd5e1; --muted: #94a3b8;
    --line: #1e293b; --primary: #3b82f6; --primary-soft: #172554; --gold-soft: #422006; --green-soft: #052e16;
    --red-soft: #450a0a; --orange-soft: #431407; --purple-soft: #2e1065; --teal-soft: #042f2e;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 4px 16px rgb(0 0 0 / 25%); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b1120; --surface: #111a2e; --surface-2: #0f172a; --ink: #e2e8f0; --ink-2: #cbd5e1; --muted: #94a3b8;
  --line: #1e293b; --primary: #3b82f6; --primary-soft: #172554; --gold-soft: #422006; --green-soft: #052e16;
  --red-soft: #450a0a; --orange-soft: #431407; --purple-soft: #2e1065; --teal-soft: #042f2e;
  --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 4px 16px rgb(0 0 0 / 25%); color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); background: var(--bg); color: var(--ink);
  font-size: 15px; line-height: 1.7; -webkit-font-smoothing: antialiased;
}
/* يمنع انزلاق الصفحة يمين وشمال بدون كسر الهيدر الثابت (clip لا ينشئ منطقة تمرير) */
html { overflow-x: hidden; overflow-x: clip; }
h1, h2, h3, h4 { margin: 0; line-height: 1.35; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary); }
img { max-width: 100%; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
[hidden] { display: none !important; }

.boot { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 12px; color: var(--muted); }
.boot img { border-radius: 18px; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(.94); opacity: .7; } }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 6px;
  padding: 20px 14px; background: linear-gradient(180deg, var(--navy), #172554); color: #fff; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 18px; }
.brand img { width: 46px; height: 46px; border-radius: 13px; box-shadow: 0 4px 14px rgb(0 0 0 / 25%); }
.brand b { display: block; font-size: 15px; font-weight: 800; }
.brand small { display: block; font-size: 12px; opacity: .75; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 12px; color: #dbeafe;
  text-decoration: none; font-weight: 600; transition: background .15s;
}
.nav-item:hover { background: rgb(255 255 255 / 8%); }
.nav-item.active { background: #fff; color: var(--navy); box-shadow: 0 4px 14px rgb(0 0 0 / 20%); }
.nav-item .ico { font-size: 19px; width: 24px; text-align: center; }
.nav-item .count { margin-inline-start: auto; background: var(--gold); color: #1f2937; border-radius: 99px; padding: 0 8px; font-size: 12px; font-weight: 800; }
.sidebar .spacer { flex: 1; }
.sidebar .who { padding: 12px; border-radius: 14px; background: rgb(255 255 255 / 8%); font-size: 13px; }
.sidebar .who b { display: block; font-size: 14px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px;
  padding: 14px 28px; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 20px; font-weight: 800; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .mobile-brand { display: none; }
.content { padding: 24px 28px 48px; max-width: 1280px; width: 100%; margin: 0 auto; }
.tabbar { display: none; }

@media (max-width: 899px) {
  .shell { display: block; }
  .sidebar { display: none; }
  .topbar { padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top)); }
  .topbar .mobile-brand { display: block; width: 34px; height: 34px; border-radius: 10px; }
  .topbar h1 { font-size: 17px; }
  .content { padding: 16px 16px calc(96px + var(--safe-b)); }
  .tabbar {
    display: flex; position: fixed; inset-inline: 0; bottom: 0; z-index: 30; background: var(--surface);
    border-top: 1px solid var(--line); padding: 6px 4px calc(6px + var(--safe-b)); box-shadow: 0 -4px 20px rgb(15 23 42 / 8%);
  }
  .tabbar a {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 4px 2px; border-radius: 12px;
    color: var(--muted); text-decoration: none; font-size: 11px; font-weight: 700; position: relative; min-width: 0;
  }
  .tabbar a .ico { font-size: 21px; line-height: 1.2; }
  .tabbar a span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  .tabbar a.active { color: var(--primary); background: var(--primary-soft); }
  .tabbar a .count { position: absolute; top: 0; inset-inline-end: 14%; background: var(--red); color: #fff; font-size: 10px; border-radius: 99px; padding: 0 5px; }
}

/* ---------- Buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); border-radius: 12px; padding: 9px 16px; font-weight: 700;
  cursor: pointer; text-decoration: none; white-space: nowrap; transition: transform .08s, background .15s, box-shadow .15s;
  min-height: 42px;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); box-shadow: 0 4px 14px color-mix(in srgb, var(--primary) 35%, transparent); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.gold { background: var(--gold); border-color: var(--gold); color: #1f2937; }
.btn.danger { color: var(--red); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.sm { padding: 5px 11px; min-height: 34px; font-size: 13px; border-radius: 10px; }
.btn.icon { padding: 0; width: 42px; }
.btn.block { width: 100%; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 13px; font-weight: 700; color: var(--ink-2); }
.input, select.input, textarea.input {
  width: 100%; border: 1.5px solid var(--line); background: var(--surface); border-radius: 12px; padding: 10px 14px;
  min-height: 44px; outline: none; transition: border-color .15s, box-shadow .15s;
}
textarea.input { min-height: 96px; resize: vertical; line-height: 1.7; }
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 18%, transparent); }
.input[type="date"] { direction: rtl; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 600; }
.check input { width: 20px; height: 20px; accent-color: var(--primary); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 600px) { .form-grid { grid-template-columns: 1fr; } }

/* ---------- Layout helpers ---------- */
.grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
@media (max-width: 1100px) { .cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 720px) { .cols-2, .cols-3 { grid-template-columns: 1fr; } .span-2 { grid-column: auto; } }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.xs { font-size: 12px; }
.bold { font-weight: 800; }
.center { text-align: center; }
.mt { margin-top: 16px; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); min-width: 0; }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h2, .card-head h3 { font-size: 17px; font-weight: 800; flex: 1; min-width: 0; }
.card-head .sub { font-size: 13px; color: var(--muted); font-weight: 500; }
.section-title { font-size: 18px; font-weight: 800; margin: 8px 0 12px; }

.kpi { display: flex; gap: 14px; align-items: center; }
.kpi .ico { flex: none; width: 50px; height: 50px; border-radius: 15px; display: grid; place-items: center; font-size: 24px; background: var(--primary-soft); }
.kpi .val { font-size: 26px; font-weight: 900; line-height: 1.1; }
.kpi .lbl { font-size: 13px; color: var(--muted); font-weight: 600; }
.kpi .delta { font-size: 12px; font-weight: 800; }
.up { color: var(--green); } .down { color: var(--red); }
.tone-gold .ico { background: var(--gold-soft); } .tone-green .ico { background: var(--green-soft); }
.tone-red .ico { background: var(--red-soft); } .tone-purple .ico { background: var(--purple-soft); }
.tone-orange .ico { background: var(--orange-soft); } .tone-teal .ico { background: var(--teal-soft); }

/* ---------- Pills, chips, badges ---------- */
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 1px 10px; border-radius: 99px; font-size: 12px; font-weight: 800; white-space: nowrap; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); }
.pill.green { background: var(--green-soft); color: var(--green); border-color: transparent; }
.pill.red { background: var(--red-soft); color: var(--red); border-color: transparent; }
.pill.gold { background: var(--gold-soft); color: #b45309; border-color: transparent; }
.pill.blue { background: var(--primary-soft); color: var(--primary); border-color: transparent; }
.pill.purple { background: var(--purple-soft); color: var(--purple); border-color: transparent; }
.pill.gray { background: var(--surface-2); color: var(--muted); }
:root[data-theme="dark"] .pill.gold { color: var(--gold); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .pill.gold { color: var(--gold); } }

.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; border: 1.5px solid var(--line); background: var(--surface);
  padding: 7px 16px; border-radius: 99px; font-weight: 700; cursor: pointer; white-space: nowrap; flex: none;
}
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.chip .avatar { width: 26px; height: 26px; font-size: 12px; }

.avatar {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; flex: none;
  font-weight: 800; color: #fff; background: var(--primary); font-size: 15px;
}
.avatar.lg { width: 64px; height: 64px; font-size: 24px; }

.progress { height: 10px; background: var(--surface-2); border-radius: 99px; overflow: hidden; border: 1px solid var(--line); }
.progress > i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--primary), #60a5fa); transition: width .6s ease; }
.progress.gold > i { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.progress.green > i { background: linear-gradient(90deg, #16a34a, #4ade80); }

.empty { text-align: center; padding: 32px 16px; color: var(--muted); }
.empty .big { font-size: 42px; display: block; margin-bottom: 6px; }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: start; font-size: 12px; font-weight: 800; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface-2); }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: var(--surface-2); }
.person { display: flex; align-items: center; gap: 10px; min-width: 0; }
.person .avatar { width: 34px; height: 34px; font-size: 13px; }
.person b { display: block; font-weight: 700; white-space: nowrap; }
.person small { display: block; color: var(--muted); font-size: 12px; }

/* ---------- Toolbar & segmented ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.segmented { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 3px; gap: 2px; }
.segmented button { border: 0; background: transparent; padding: 6px 14px; border-radius: 9px; font-weight: 700; cursor: pointer; color: var(--muted); }
.segmented button.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

/* ---------- Modal ---------- */
dialog.modal {
  border: 0; padding: 0; border-radius: 22px; width: min(640px, calc(100vw - 24px)); max-height: calc(100vh - 40px);
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow-lg);
}
dialog.modal.wide { width: min(920px, calc(100vw - 24px)); }
dialog.modal::backdrop { background: rgb(15 23 42 / 55%); backdrop-filter: blur(3px); }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); z-index: 2; }
.modal-head h2 { font-size: 18px; font-weight: 800; flex: 1; }
.modal-body { padding: 20px 22px; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 14px 22px; border-top: 1px solid var(--line); position: sticky; bottom: 0; background: var(--surface); }
@media (max-width: 600px) {
  dialog.modal, dialog.modal.wide { width: 100vw; max-width: 100vw; max-height: 92vh; margin: auto 0 0; border-radius: 22px 22px 0 0; }
  .modal-foot { padding-bottom: calc(14px + var(--safe-b)); }
}

/* ---------- Toasts ---------- */
#toasts { position: fixed; z-index: 100; top: 16px; inset-inline: 0; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast { pointer-events: auto; background: #0f172a; color: #fff; padding: 11px 20px; border-radius: 14px; font-weight: 700; box-shadow: var(--shadow-lg); animation: toast-in .25s ease; max-width: calc(100vw - 32px); }
.toast.ok { background: #15803d; } .toast.err { background: #b91c1c; }
@keyframes toast-in { from { transform: translateY(-12px); opacity: 0; } }

/* ---------- Login ---------- */
.login {
  min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
  background: radial-gradient(1200px 600px at 100% -10%, #3b82f6 0%, transparent 60%), radial-gradient(900px 500px at -10% 110%, #f59e0b55 0%, transparent 60%), linear-gradient(160deg, #1e3a8a, #0f172a);
}
.login-card { width: min(440px, 100%); background: var(--surface); border-radius: 26px; padding: 30px 26px; box-shadow: var(--shadow-lg); }
.login-card .logo { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; margin-bottom: 22px; }
.login-card .logo img { width: 84px; height: 84px; border-radius: 22px; box-shadow: 0 8px 24px rgb(30 58 138 / 35%); }
.login-card h1 { font-size: 21px; font-weight: 900; }
.login-card .logo p { color: var(--muted); font-size: 14px; }
.apk-link { margin-top: 12px; text-decoration: none; }
.demo { margin-top: 20px; padding-top: 18px; border-top: 1px dashed var(--line); }
.demo-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.demo-btn { display: flex; align-items: center; gap: 10px; border: 1.5px solid var(--line); background: var(--surface-2); border-radius: 14px; padding: 10px 12px; cursor: pointer; text-align: start; }
.demo-btn:hover { border-color: var(--primary); }
.demo-btn .e { font-size: 24px; }
.demo-btn b { display: block; font-size: 14px; }
.demo-btn small { display: block; font-size: 11px; color: var(--muted); direction: ltr; text-align: end; }
.error-box { background: var(--red-soft); color: var(--red); padding: 10px 14px; border-radius: 12px; font-weight: 700; font-size: 14px; }

/* ==========================================================================
   صفحة الطالب — ألوان مبهجة
   ========================================================================== */
.hero {
  position: relative; overflow: hidden; border-radius: 24px; padding: 24px; color: #fff;
  background: linear-gradient(135deg, #7c3aed 0%, #db2777 55%, #f97316 100%); box-shadow: 0 10px 30px rgb(124 58 237 / 30%);
}
.hero::after { content: ''; position: absolute; width: 260px; height: 260px; border-radius: 50%; background: rgb(255 255 255 / 10%); inset-inline-start: -60px; top: -90px; }
.hero > * { position: relative; z-index: 1; }
.hero h2 { font-size: 24px; font-weight: 900; }
.hero .sub { opacity: .9; font-weight: 600; }
.hero-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 18px; }
.hero-stat { background: rgb(255 255 255 / 16%); border-radius: 16px; padding: 12px; text-align: center; backdrop-filter: blur(4px); }
.hero-stat .v { font-size: 26px; font-weight: 900; line-height: 1.2; }
.hero-stat .l { font-size: 12px; font-weight: 700; opacity: .92; }
.level-bar { margin-top: 16px; background: rgb(255 255 255 / 18%); border-radius: 16px; padding: 12px 14px; }
.level-bar .progress { background: rgb(255 255 255 / 25%); border: 0; height: 12px; }
.level-bar .progress > i { background: linear-gradient(90deg, #fde68a, #fbbf24); }

.flame { font-size: 64px; line-height: 1; filter: drop-shadow(0 6px 14px rgb(249 115 22 / 45%)); animation: flicker 2.2s ease-in-out infinite; }
@keyframes flicker { 50% { transform: scale(1.06) rotate(-3deg); } }
.flame.off { filter: grayscale(1); opacity: .45; animation: none; }

.weeks { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 8px; }
.week {
  border-radius: 16px; padding: 10px 6px; text-align: center; border: 2px solid var(--line); background: var(--surface-2);
}
.week .e { font-size: 26px; display: block; line-height: 1.3; }
.week .d { font-size: 11px; font-weight: 700; color: var(--muted); }
.week.present { background: var(--green-soft); border-color: #86efac; }
.week.late { background: var(--gold-soft); border-color: #fcd34d; }
.week.absent { background: var(--red-soft); border-color: #fca5a5; }
.week.excused { background: var(--primary-soft); border-color: #93c5fd; }

.verse-card {
  border-radius: 20px; padding: 22px; color: #fff; text-align: center; position: relative; overflow: hidden;
  background: linear-gradient(135deg, #1e3a8a, #2563eb); box-shadow: 0 10px 30px rgb(37 99 235 / 30%);
}
.verse-card::before { content: '❝'; position: absolute; top: -18px; inset-inline-end: 12px; font-size: 110px; opacity: .15; }
.verse-card .q { font-size: 20px; font-weight: 800; line-height: 1.9; }
.verse-card .lbl { display: inline-block; background: var(--gold); color: #1f2937; font-weight: 800; font-size: 12px; padding: 2px 12px; border-radius: 99px; margin-bottom: 10px; }

.lesson-body { white-space: pre-line; line-height: 2; font-size: 16px; }

.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.badge-card { text-align: center; padding: 16px 10px; border-radius: 18px; border: 2px solid var(--line); background: var(--surface); position: relative; }
.badge-card .e { font-size: 42px; display: block; line-height: 1.25; }
.badge-card b { display: block; font-size: 14px; }
.badge-card small { display: block; font-size: 11.5px; color: var(--muted); min-height: 34px; }
.badge-card.earned { border-color: #fcd34d; background: linear-gradient(180deg, var(--gold-soft), var(--surface)); }
.badge-card.earned::after { content: '✓'; position: absolute; top: 8px; inset-inline-start: 10px; width: 22px; height: 22px; border-radius: 50%; background: var(--green); color: #fff; font-size: 13px; font-weight: 900; display: grid; place-items: center; }
.badge-card:not(.earned) .e { filter: grayscale(1); opacity: .45; }
.badge-card .progress { height: 7px; margin-top: 8px; }

.reward { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-radius: 16px; border: 1.5px solid var(--line); }
.reward .e { font-size: 30px; }
.reward.unlocked { background: var(--green-soft); border-color: #86efac; }
.reward:not(.unlocked) { opacity: .85; }

.task {
  display: flex; align-items: center; gap: 14px; padding: 14px; border-radius: 16px; border: 1.5px solid var(--line);
  background: var(--surface); transition: background .2s;
}
.task .e { font-size: 30px; width: 48px; height: 48px; display: grid; place-items: center; border-radius: 14px; background: var(--surface-2); flex: none; }
.task.approved { background: var(--green-soft); border-color: #86efac; }
.task.submitted { background: var(--gold-soft); border-color: #fcd34d; }
.task b { display: block; }
.task-check {
  flex: none; width: 46px; height: 46px; border-radius: 50%; border: 2.5px solid var(--line); background: var(--surface);
  font-size: 22px; cursor: pointer; display: grid; place-items: center; transition: transform .15s;
}
.task-check:hover { transform: scale(1.08); border-color: var(--green); }
.task.submitted .task-check { border-color: var(--gold); background: #fff7ed; }
.task.approved .task-check { background: var(--green); border-color: var(--green); color: #fff; cursor: default; }

.ring-wrap { position: relative; display: inline-grid; place-items: center; }
.ring-wrap .ring-label { position: absolute; text-align: center; line-height: 1.2; }
.ring-wrap .ring-label b { display: block; font-size: 24px; font-weight: 900; }
.ring-wrap .ring-label small { font-size: 11px; color: var(--muted); font-weight: 700; }

.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 200; overflow: hidden; }
.confetti i { position: absolute; top: -20px; width: 10px; height: 14px; border-radius: 2px; animation: fall 1.6s ease-in forwards; }
@keyframes fall { to { transform: translateY(105vh) rotate(720deg); opacity: .7; } }

/* ==========================================================================
   ولي الأمر
   ========================================================================== */
.child-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.note { padding: 14px 16px; border-radius: 16px; background: var(--surface-2); border: 1px solid var(--line); }
.note .meta { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); margin-bottom: 4px; flex-wrap: wrap; }
.stars { color: var(--gold); letter-spacing: 1px; font-size: 14px; }
.timeline { position: relative; display: flex; flex-direction: column; gap: 12px; padding-inline-start: 26px; }
.timeline::before { content: ''; position: absolute; inset-inline-start: 9px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.tl-item { position: relative; }
.tl-item::before { content: ''; position: absolute; inset-inline-start: -23px; top: 18px; width: 14px; height: 14px; border-radius: 50%; background: var(--surface); border: 3px solid var(--muted); }
.tl-item.current::before { border-color: var(--primary); background: var(--primary); box-shadow: 0 0 0 5px var(--primary-soft); }
.tl-item.upcoming::before { border-color: var(--gold); }
.tl-item.past::before { border-color: var(--green); background: var(--green); }
.tl-item .card { padding: 14px 16px; }
.tl-item.current .card { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }

/* ==========================================================================
   الخادم — بوابة التقييم الجماعي
   ========================================================================== */
.bulk-bar { position: sticky; top: 64px; z-index: 10; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; box-shadow: var(--shadow); margin-bottom: 14px; }
@media (max-width: 899px) { .bulk-bar { top: 58px; } }
.bulk-list { display: flex; flex-direction: column; gap: 10px; }
.bulk-row { background: var(--surface); border: 1.5px solid var(--line); border-radius: 16px; padding: 12px 14px; transition: border-color .15s; }
.bulk-row.dirty { border-color: var(--gold); }
.bulk-row .top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.att-seg { display: inline-flex; gap: 4px; margin-inline-start: auto; }
.att-seg button {
  border: 1.5px solid var(--line); background: var(--surface); border-radius: 10px; padding: 5px 10px; cursor: pointer;
  font-weight: 800; font-size: 13px; color: var(--muted); min-height: 38px; display: inline-flex; align-items: center; gap: 4px;
}
.att-seg button.on[data-v="present"] { background: var(--green); border-color: var(--green); color: #fff; }
.att-seg button.on[data-v="late"] { background: var(--gold); border-color: var(--gold); color: #1f2937; }
.att-seg button.on[data-v="absent"] { background: var(--red); border-color: var(--red); color: #fff; }
.att-seg button.on[data-v="excused"] { background: var(--primary); border-color: var(--primary); color: #fff; }
.scores-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; align-items: center; }
.stepper { display: inline-flex; align-items: center; border: 1.5px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--surface-2); }
.stepper .lbl { padding: 0 10px; font-size: 12.5px; font-weight: 700; color: var(--ink-2); white-space: nowrap; }
.stepper button { border: 0; background: var(--surface); width: 32px; height: 36px; cursor: pointer; font-size: 18px; font-weight: 800; color: var(--primary); }
.stepper output { min-width: 30px; text-align: center; font-weight: 900; }
.stepper.has { border-color: var(--green); background: var(--green-soft); }
.note-toggle { margin-inline-start: auto; }
.bulk-note { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-top: 10px; align-items: start; }
.rate-pick { display: inline-flex; gap: 2px; }
.rate-pick button { border: 0; background: none; font-size: 22px; cursor: pointer; color: var(--line); padding: 0 1px; line-height: 1; }
.rate-pick button.on { color: var(--gold); }
@media (max-width: 600px) {
  .att-seg { margin-inline-start: 0; width: 100%; }
  .att-seg button { flex: 1; justify-content: center; padding: 5px 4px; }
  .bulk-note { grid-template-columns: 1fr; }
}

.heat { display: grid; gap: 4px; }
.heat .cell { border-radius: 8px; height: 36px; display: grid; place-items: center; font-size: 11.5px; font-weight: 800; color: #fff; }
.heat .rowlabel { font-size: 13px; font-weight: 700; display: flex; align-items: center; white-space: nowrap; }
.heat .collabel { font-size: 10.5px; color: var(--muted); text-align: center; font-weight: 700; }

.status-dots { display: inline-flex; gap: 4px; }
.status-dots i { width: 14px; height: 14px; border-radius: 4px; display: inline-block; }
.st-on_time { background: var(--green); } .st-late { background: var(--gold); } .st-missing { background: var(--red); } .st-pending { background: var(--line); }

.class-card { border-top: 5px solid var(--c, var(--primary)); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); font-weight: 700; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 4px; margin-inline-end: 5px; vertical-align: -1px; }

/* ---------- Charts ---------- */
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart text { font-family: var(--font); fill: var(--muted); font-size: 11px; font-weight: 700; }
.chart .grid-line { stroke: var(--line); stroke-dasharray: 3 4; }
.chart .val { fill: var(--ink); font-weight: 800; }
.bars-h { display: flex; flex-direction: column; gap: 10px; }
.bar-h { display: grid; grid-template-columns: 110px 1fr 48px; gap: 10px; align-items: center; font-size: 13px; font-weight: 700; }
.bar-h .track { height: 12px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.bar-h .track i { display: block; height: 100%; border-radius: 99px; }

.menu { position: relative; }
.menu-pop { position: absolute; top: calc(100% + 8px); inset-inline-end: 0; min-width: 220px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-lg); padding: 6px; z-index: 50; }
.menu-pop button, .menu-pop a { display: flex; width: 100%; gap: 10px; align-items: center; padding: 10px 12px; border: 0; background: none; border-radius: 10px; cursor: pointer; text-align: start; font-weight: 600; text-decoration: none; color: var(--ink); }
.menu-pop button:hover { background: var(--surface-2); }
.menu-pop .head { padding: 10px 12px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }

.fade-in { animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media print {
  .sidebar, .tabbar, .topbar .btn, .toolbar { display: none !important; }
  .shell { display: block; }
  .card { box-shadow: none; break-inside: avoid; }
}

/* ---------- Chart primitives (validated categorical palette) ---------- */
:root { --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #4a3aa7; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #9085e9; } }
:root[data-theme="dark"] { --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #9085e9; }

.bc { display: flex; align-items: stretch; gap: 6px; height: var(--h); }
.bc-col { flex: 1; min-width: 0; display: flex; flex-direction: column; outline: none; }
.bc-bar-wrap { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; border-bottom: 1px solid var(--line); padding-top: 20px; }
.bc-bar { display: block; width: min(34px, 70%); border-radius: 4px 4px 0 0; transition: filter .15s; }
.bc-col:hover .bc-bar, .bc-col:focus .bc-bar { filter: brightness(1.12); opacity: 1 !important; }
.bc-val { font-size: 12px; font-weight: 900; color: var(--ink); margin-bottom: 2px; }
.bc-x { font-size: 10.5px; color: var(--muted); text-align: center; font-weight: 700; padding-top: 4px; white-space: nowrap; overflow: hidden; }

.lc { position: relative; padding: 26px 8px 0 0; padding-inline-start: 34px; padding-inline-end: 8px; overflow: hidden; }
.lc-plot { position: relative; height: var(--h); }
.lc-plot svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.lc-plot polyline { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.lc-grid { position: absolute; inset-inline: 0; border-top: 1px dashed var(--line); }
.lc-grid span { position: absolute; inset-inline-start: -34px; top: -9px; font-size: 10.5px; color: var(--muted); font-weight: 700; }
.lc-dot { position: absolute; width: 9px; height: 9px; margin: -4.5px -4.5px 0 0; border-radius: 50%; box-shadow: 0 0 0 2px var(--surface); pointer-events: none; }
.lc-end { position: absolute; transform: translate(100%, -150%); font-size: 12px; font-weight: 900; color: var(--ink); pointer-events: none; background: var(--surface); padding: 0 4px; border-radius: 6px; }
.lc-hit { position: absolute; top: 0; bottom: 0; outline: none; }
.lc-hit:hover, .lc-hit:focus { background: linear-gradient(90deg, transparent calc(50% - 1px), var(--muted) calc(50% - 1px), var(--muted) calc(50% + 1px), transparent calc(50% + 1px)); opacity: .35; }
.lc-x { position: relative; height: 22px; margin-top: 4px; }
.lc-x span { position: absolute; transform: translateX(50%); font-size: 10.5px; color: var(--muted); font-weight: 700; white-space: nowrap; }

.heat-scale { display: flex; align-items: center; gap: 3px; margin-top: 10px; font-size: 11px; color: var(--muted); font-weight: 700; }
.heat-scale i { width: 22px; height: 10px; border-radius: 3px; }
.heat-scale span { margin: 0 6px; }
.heat .cell { outline: none; }
.heat .cell:hover, .heat .cell:focus { box-shadow: 0 0 0 2px var(--ink); }

.chart-tip {
  position: fixed; z-index: 300; display: none; pointer-events: none; white-space: pre-line;
  background: #0f172a; color: #fff; font-size: 12.5px; font-weight: 700; padding: 7px 11px; border-radius: 10px;
  box-shadow: var(--shadow-lg); max-width: 260px; line-height: 1.6;
}

@media (max-width: 899px) {
  .bulk-bar { position: static; }
  #bk-save {
    position: fixed; z-index: 25; inset-inline: 16px; bottom: calc(78px + var(--safe-b));
    min-height: 50px; font-size: 16px; box-shadow: 0 8px 24px color-mix(in srgb, var(--primary) 45%, transparent);
  }
  .bulk-list { padding-bottom: 70px; }
  .scores-row { display: grid; grid-template-columns: 1fr 1fr; }
  .scores-row .stepper { justify-content: space-between; }
  .scores-row .note-toggle { grid-column: 1 / -1; margin: 0; }
}
@media (max-width: 899px) {
  .scores-row .stepper { min-width: 0; }
  .scores-row .stepper .lbl { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; padding: 0 6px; font-size: 12px; }
  .scores-row .stepper button { width: 30px; flex: none; }
  .scores-row .stepper output { min-width: 24px; flex: none; }
}

/* Heatmap sequential ramp — light: pale→deep; dark: near-surface→bright */
:root {
  --heat-0: #cde2fb; --heat-1: #9ec5f4; --heat-2: #6da7ec; --heat-3: #3987e5; --heat-4: #256abf; --heat-5: #184f95; --heat-6: #0d366b;
  --heat-ink-0: #0d366b; --heat-ink-1: #0d366b; --heat-ink-2: #0d366b; --heat-ink-3: #fff; --heat-ink-4: #fff; --heat-ink-5: #fff; --heat-ink-6: #fff;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --heat-0: #104281; --heat-1: #1c5cab; --heat-2: #256abf; --heat-3: #3987e5; --heat-4: #6da7ec; --heat-5: #9ec5f4; --heat-6: #cde2fb;
    --heat-ink-0: #fff; --heat-ink-1: #fff; --heat-ink-2: #fff; --heat-ink-3: #fff; --heat-ink-4: #0d366b; --heat-ink-5: #0d366b; --heat-ink-6: #0d366b;
  }
}
:root[data-theme="dark"] {
  --heat-0: #104281; --heat-1: #1c5cab; --heat-2: #256abf; --heat-3: #3987e5; --heat-4: #6da7ec; --heat-5: #9ec5f4; --heat-6: #cde2fb;
  --heat-ink-0: #fff; --heat-ink-1: #fff; --heat-ink-2: #fff; --heat-ink-3: #fff; --heat-ink-4: #0d366b; --heat-ink-5: #0d366b; --heat-ink-6: #0d366b;
}

/* ==========================================================================
   الحضور السريع — ضغطة واحدة لكل طالب
   ========================================================================== */
.mode-switch { display: flex; width: 100%; margin-bottom: 14px; }
.mode-switch button { flex: 1; padding: 9px 10px; font-size: 14px; }

.q-head {
  position: sticky; top: 64px; z-index: 10; background: var(--surface); border: 1px solid var(--line);
  border-radius: 18px; padding: 12px 14px; box-shadow: var(--shadow); margin-bottom: 12px;
  display: flex; flex-direction: column; gap: 8px;
}
@media (max-width: 899px) { .q-head { top: 58px; } }
.date-chip {
  position: relative; display: inline-flex; align-items: center; gap: 6px; font-weight: 800; font-size: 14px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 99px; padding: 5px 12px; cursor: pointer;
}
.date-chip input { position: absolute; inset: 0; opacity: 0; width: 100%; cursor: pointer; }
.save-state { font-size: 12.5px; font-weight: 800; white-space: nowrap; }
.save-state.saving { color: var(--muted); }
.save-state.saved { color: var(--green); }
.save-state.error { color: var(--red); }
.linkish { border: 0; background: none; color: inherit; text-decoration: underline; font: inherit; cursor: pointer; padding: 0; }
.q-count { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.q-count b { font-size: 20px; font-weight: 900; }
.q-head .progress { height: 8px; }
.q-head .btn { min-height: 46px; font-size: 15px; background: var(--green-soft); border-color: #86efac; color: var(--green); }

.q-list { display: flex; flex-direction: column; gap: 8px; }
.q-row {
  display: grid; grid-template-columns: 1fr auto; border-radius: 16px; border: 2px solid var(--line);
  background: var(--surface); overflow: hidden; transition: background .12s, border-color .12s;
}
.q-main {
  display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 8px 14px; border: 0; background: none;
  text-align: start; cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation; min-width: 0;
}
.q-main:active { transform: scale(.985); }
.q-main b { flex: 1; min-width: 0; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.q-status { font-size: 13px; font-weight: 800; white-space: nowrap; color: var(--muted); }
.q-more-btn {
  width: 52px; border: 0; border-inline-start: 1px solid var(--line); background: none; font-size: 22px; font-weight: 900;
  color: var(--muted); cursor: pointer; touch-action: manipulation;
}
.q-more { grid-column: 1 / -1; display: flex; gap: 8px; padding: 0 12px 12px; }
.q-more[hidden] { display: none; }
.q-more button { flex: 1; min-height: 42px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface-2); font-weight: 800; cursor: pointer; }

.q-row.present { background: var(--green-soft); border-color: #4ade80; }
.q-row.present .q-status { color: var(--green); }
.q-row.late { background: var(--gold-soft); border-color: #fbbf24; }
.q-row.late .q-status { color: #b45309; }
.q-row.absent { background: var(--red-soft); border-color: #f87171; }
.q-row.absent .q-status { color: var(--red); }
.q-row.excused { background: var(--primary-soft); border-color: #93c5fd; }
.q-row.excused .q-status { color: var(--primary); }
.q-row.none .q-status { font-weight: 600; }
:root[data-theme="dark"] .q-row.late .q-status { color: var(--gold); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .q-row.late .q-status { color: var(--gold); } }

/* ==========================================================================
   الإشعارات
   ========================================================================== */
.bell { position: relative; font-size: 20px; text-decoration: none; }
.bell-count {
  position: absolute; top: 2px; inset-inline-end: 0; min-width: 19px; height: 19px; padding: 0 5px; border-radius: 99px;
  background: var(--red); color: #fff; font-size: 11px; font-weight: 900; line-height: 19px; text-align: center;
  box-shadow: 0 0 0 2px var(--bg);
}
.notif-list { display: flex; flex-direction: column; gap: 8px; }
.notif {
  display: flex; align-items: flex-start; gap: 10px; width: 100%; text-align: start; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px;
  font: inherit; color: inherit; touch-action: manipulation;
}
.notif:active { transform: scale(.99); }
.notif.unread { background: var(--primary-soft); border-color: color-mix(in srgb, var(--primary) 35%, transparent); }
.notif-dot { flex: none; width: 9px; height: 9px; margin-top: 8px; border-radius: 50%; background: transparent; }
.notif.unread .notif-dot { background: var(--primary); }
.notif-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.notif-text b { font-weight: 700; line-height: 1.6; }
.notif.unread .notif-text b { font-weight: 900; }
.notif-body { font-size: 13.5px; color: var(--ink-2); white-space: pre-line; overflow-wrap: anywhere; }
.notif-time { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.notif-go { flex: none; align-self: center; font-size: 22px; color: var(--muted); }
