/* =========================================================
   أولمبياد مسجد الحسين الشتوية — الأنماط
   الهاتف أولًا، RTL، ألوان: أبيض + سماوي + أزرق هادئ
   ========================================================= */

:root {
  --bg: #F1F8FB;
  --surface: #FFFFFF;
  --surface-2: #F6FBFD;
  --line: #DCEBF2;
  --line-2: #C7DFEA;
  --ink: #0C2532;
  --ink-2: #3A5A6B;
  --muted: #6A8797;
  --primary: #0893B5;
  --primary-hover: #077E9C;
  --primary-ink: #066F8A;
  --primary-soft: #E1F4FA;
  --primary-soft-2: #CBEBF5;
  --on-primary: #FFFFFF;
  --pos: #0E8F62;
  --pos-soft: #E2F5EC;
  --neg: #CF3D46;
  --neg-soft: #FCEAEB;
  --warn: #A86A00;
  --warn-soft: #FFF3DA;
  --cat-att: #7CCBEF;
  --cat-qur: #0E8FB0;
  --cat-rel: #2F6BD8;
  --cat-eth: #8A97F0;
  --cat-act: #E9A23B;
  --cat-ded: #CF3D46;
  --empty-cell: #E3EEF3;
  --shadow-sm: 0 1px 2px rgba(12, 37, 50, .05);
  --shadow: 0 1px 2px rgba(12, 37, 50, .05), 0 6px 20px -8px rgba(12, 60, 80, .14);
  --shadow-lg: 0 18px 48px -12px rgba(8, 40, 60, .28);
  --radius: 18px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --font-body: 'IBM Plex Sans Arabic', 'Segoe UI', Tahoma, 'Noto Sans Arabic', system-ui, sans-serif;
  --font-display: 'Readex Pro', 'IBM Plex Sans Arabic', 'Segoe UI', Tahoma, system-ui, sans-serif;
  --gutter: 16px;
  --topbar-h: 60px;
  --nav-h: 66px;
  --hero-a: #E6F6FB;
  --hero-b: #D3ECFA;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #08151D;
    --surface: #0F202A;
    --surface-2: #132834;
    --line: #1D3644;
    --line-2: #284656;
    --ink: #E4F2F7;
    --ink-2: #B0CAD6;
    --muted: #7F9CAB;
    --primary: #2CB9DB;
    --primary-hover: #4CC6E3;
    --primary-ink: #6AD3EC;
    --primary-soft: #10323F;
    --primary-soft-2: #164252;
    --on-primary: #04202A;
    --pos: #3CC491;
    --pos-soft: #0E3226;
    --neg: #F0727A;
    --neg-soft: #3A1A1F;
    --warn: #E8B04F;
    --warn-soft: #34280F;
    --cat-att: #6DBFE6;
    --cat-qur: #2CB9DB;
    --cat-rel: #5B8EF0;
    --cat-eth: #A1ACF6;
    --cat-act: #EDB04F;
    --cat-ded: #F0727A;
    --empty-cell: #1A3140;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px -10px rgba(0, 0, 0, .5);
    --shadow-lg: 0 18px 48px -12px rgba(0, 0, 0, .6);
    --hero-a: #0F2633;
    --hero-b: #0C2F42;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #08151D;
  --surface: #0F202A;
  --surface-2: #132834;
  --line: #1D3644;
  --line-2: #284656;
  --ink: #E4F2F7;
  --ink-2: #B0CAD6;
  --muted: #7F9CAB;
  --primary: #2CB9DB;
  --primary-hover: #4CC6E3;
  --primary-ink: #6AD3EC;
  --primary-soft: #10323F;
  --primary-soft-2: #164252;
  --on-primary: #04202A;
  --pos: #3CC491;
  --pos-soft: #0E3226;
  --neg: #F0727A;
  --neg-soft: #3A1A1F;
  --warn: #E8B04F;
  --warn-soft: #34280F;
  --cat-att: #6DBFE6;
  --cat-qur: #2CB9DB;
  --cat-rel: #5B8EF0;
  --cat-eth: #A1ACF6;
  --cat-act: #EDB04F;
  --cat-ded: #F0727A;
  --empty-cell: #1A3140;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px -10px rgba(0, 0, 0, .5);
  --shadow-lg: 0 18px 48px -12px rgba(0, 0, 0, .6);
  --hero-a: #0F2633;
  --hero-b: #0C2F42;
}

/* ---------- الأساس ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
body.no-scroll { overflow: hidden; }
h1, h2, h3, h4 { font-family: var(--font-display); line-height: 1.3; margin: 0; text-wrap: balance; font-weight: 600; }
h1 { font-size: 1.55rem; }
h2 { font-size: 1.12rem; }
h3 { font-size: 1rem; }
p { margin: 0; }
a { color: var(--primary-ink); text-decoration: none; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2.5px solid var(--primary); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
bdi.num { unicode-bidi: isolate; }
.muted { color: var(--muted); }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.warn { color: var(--warn); }
.ltr-inline { direction: ltr; unicode-bidi: isolate; display: inline-block; }
.ic { width: 20px; height: 20px; flex: none; }

/* ألوان التصنيفات: الصنف يحدد --c فقط، وكل مكوّن يقرر كيف يستخدمه */
.c-att { --c: var(--cat-att); }
.c-qur { --c: var(--cat-qur); }
.c-rel { --c: var(--cat-rel); }
.c-eth { --c: var(--cat-eth); }
.c-act { --c: var(--cat-act); }
.c-ded { --c: var(--cat-ded); }
.dotc { display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: var(--c); flex: none; }

/* ---------- الهيكل ---------- */
.app { min-height: 100vh; }
.topbar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 30;
  height: var(--topbar-h);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding-inline: var(--gutter);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); min-width: 0; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; flex: none;
  background: linear-gradient(145deg, #2CC4E6, #0B7FB6); color: #fff;
}
.brand-mark .ic { width: 22px; height: 22px; stroke-width: 2; }
.brand-mark.lg { width: 56px; height: 56px; border-radius: 16px; }
.brand-mark.lg .ic { width: 32px; height: 32px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.brand-text b { font-family: var(--font-display); font-weight: 600; font-size: .98rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-text small { color: var(--primary-ink); font-size: .74rem; font-weight: 500; }
.top-actions { display: flex; align-items: center; gap: 6px; flex: none; }
.user-chip {
  display: flex; align-items: center; gap: 8px; padding: 4px 6px 4px 12px;
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px; min-height: 40px;
}
.uc-name { font-weight: 500; font-size: .9rem; }

.view {
  max-width: 1100px; margin-inline: auto;
  padding-inline: var(--gutter); padding-block: 18px 40px;
  display: flex; flex-direction: column; gap: 18px;
  outline: none;
}
.app.is-staff .view { padding-bottom: calc(var(--nav-h) + 28px + env(safe-area-inset-bottom, 0px)); }

/* التنقل السفلي (هاتف) */
.nav {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 25;
  background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  box-shadow: 0 -6px 20px -14px rgba(8, 40, 60, .25);
}
.nav-inner { display: flex; max-width: 640px; margin-inline: auto; }
.nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: var(--nav-h); color: var(--muted); font-size: .74rem; font-weight: 500;
  background: none; border: 0; padding: 6px 2px; position: relative;
}
.nav-item .ic { width: 23px; height: 23px; }
.nav-item[aria-current="page"], .nav-item.is-on { color: var(--primary-ink); }
.nav-item[aria-current="page"]::before {
  content: ""; position: absolute; top: 0; width: 28px; height: 3px; border-radius: 0 0 3px 3px; background: var(--primary);
}
.nav-extra { display: none; }

/* ---------- الأزرار ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 8px 18px; border-radius: 12px;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink);
  font-weight: 600; font-size: .94rem; white-space: nowrap; text-decoration: none;
  transition: background .15s, border-color .15s, transform .08s;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-soft { background: var(--primary-soft); border-color: transparent; color: var(--primary-ink); }
.btn-soft:hover { background: var(--primary-soft-2); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: var(--neg); border-color: var(--neg); color: #fff; }
.btn.danger { color: var(--neg); }
.btn-sm { min-height: 38px; padding: 6px 12px; font-size: .86rem; border-radius: 10px; }
.btn-sm .ic { width: 18px; height: 18px; }
.btn-lg { min-height: 52px; font-size: 1rem; }
.btn-block { width: 100%; }
.btn.is-loading { opacity: .7; pointer-events: none; }
.btn:disabled { opacity: .55; cursor: default; }
.btn-icon {
  width: 42px; height: 42px; display: grid; place-items: center; flex: none;
  border-radius: 12px; border: 0; background: transparent; color: var(--ink-2);
}
.btn-icon:hover { background: var(--primary-soft); color: var(--primary-ink); }
.link { font-weight: 600; font-size: .9rem; }

/* ---------- الصور الرمزية ---------- */
.av {
  --h: 195;
  display: grid; place-items: center; flex: none; border-radius: 50%; overflow: hidden;
  background: hsl(var(--h) 70% 92%); color: hsl(var(--h) 65% 30%);
  font-family: var(--font-display); font-weight: 600;
}
:root[data-theme="dark"] .av { background: hsl(var(--h) 45% 22%); color: hsl(var(--h) 70% 82%); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .av { background: hsl(var(--h) 45% 22%); color: hsl(var(--h) 70% 82%); } }
.av img { width: 100%; height: 100%; object-fit: cover; }
.av-xs { width: 30px; height: 30px; font-size: .8rem; }
.av-sm { width: 38px; height: 38px; font-size: .88rem; }
.av-md { width: 46px; height: 46px; font-size: 1rem; }
.av-lg { width: 72px; height: 72px; font-size: 1.4rem; }

/* علامة المجموعة: الحرف الأول على لون المجموعة */
.gcard-mark {
  width: 46px; height: 46px; border-radius: 14px; flex: none; display: grid; place-items: center;
  font-family: var(--font-display); font-weight: 700; font-size: 1.25rem;
  background: linear-gradient(150deg, hsl(var(--h, 195) 80% 62%), hsl(calc(var(--h, 195) + 14) 70% 42%));
  color: #fff;
}
.gcard-mark.sm { width: 34px; height: 34px; border-radius: 10px; font-size: .95rem; }
.gcard-mark.lg { width: 56px; height: 56px; border-radius: 16px; font-size: 1.5rem; }

/* ---------- البطل (الصفحة الرئيسية) ---------- */
.hero {
  position: relative; overflow: hidden;
  border-radius: 24px; padding: 26px 20px 20px;
  background: linear-gradient(160deg, var(--hero-a), var(--hero-b));
  border: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 10px;
}
.hero h1 { font-size: clamp(1.6rem, 6vw, 2.4rem); font-weight: 700; letter-spacing: -.01em; max-width: 18ch; }
.hero-desc { color: var(--ink-2); max-width: 56ch; font-size: 1rem; }
.eyebrow { color: var(--primary-ink); font-weight: 600; font-size: .82rem; letter-spacing: .02em; }
.hero-flakes { position: absolute; inset-inline-end: -26px; top: -22px; color: var(--primary); opacity: .13; pointer-events: none; }
.hero-flakes .ic { position: absolute; stroke-width: 1.2; }
.hero-flakes .ic:nth-child(1) { width: 170px; height: 170px; inset-inline-end: 0; top: 0; }
.hero-flakes .ic:nth-child(2) { width: 64px; height: 64px; inset-inline-end: 170px; top: 104px; }
.hero-flakes .ic:nth-child(3) { width: 40px; height: 40px; inset-inline-end: 130px; top: 24px; }
.hero-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 8px 0 0; }
.hero-stats > div { background: color-mix(in srgb, var(--surface) 78%, transparent); border-radius: 14px; padding: 10px 12px; }
.hero-stats dt { font-size: .76rem; color: var(--muted); }
.hero-stats dd { margin: 0; font-family: var(--font-display); font-size: 1.45rem; font-weight: 700; line-height: 1.2; }
.hero-stats dd small { font-size: .7rem; font-weight: 500; color: var(--muted); }

/* ---------- أقسام عامة ---------- */
.block { display: flex; flex-direction: column; gap: 12px; }
.sec-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.sec-head .muted { font-size: .86rem; }
.greet { display: flex; flex-direction: column; gap: 2px; }
.greet.row { flex-direction: row; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--ink-2); font-weight: 500; font-size: .92rem; align-self: flex-start; min-height: 36px; }
.back .ic { width: 18px; height: 18px; }
.page-head { --h: 195; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.page-head > div { flex: 1; min-width: 0; }
.page-head p { color: var(--muted); }
.page-head .head-act { flex: none; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.banner { padding: 12px 14px; border-radius: var(--radius-md); font-weight: 500; }
.banner-warn { background: var(--warn-soft); color: var(--warn); }
.hint { color: var(--muted); font-size: .84rem; display: flex; gap: 6px; align-items: flex-start; }
.hint .ic { width: 16px; height: 16px; margin-top: 3px; }
.lead { color: var(--ink-2); }

/* مقطع اختيار (Segmented) */
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 3px; gap: 2px; max-width: 100%; overflow-x: auto; }
.seg button { border: 0; background: transparent; padding: 7px 12px; border-radius: 9px; font-size: .86rem; font-weight: 500; color: var(--ink-2); white-space: nowrap; min-height: 36px; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--primary-ink); box-shadow: var(--shadow-sm); font-weight: 600; }

/* ---------- بطاقات المجموعات ---------- */
.group-grid { display: grid; grid-template-columns: 1fr; gap: 10px; }
.gcard {
  --h: 195;
  display: flex; align-items: center; gap: 12px; padding: 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  color: var(--ink); box-shadow: var(--shadow-sm); transition: border-color .15s, box-shadow .15s, transform .1s;
}
.gcard:hover { border-color: hsl(var(--h) 60% 70%); box-shadow: var(--shadow); }
.gcard:active { transform: scale(.99); }
.gcard-body { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.gcard-body b { font-family: var(--font-display); font-weight: 600; font-size: 1.04rem; }
.gcard-body span { color: var(--muted); font-size: .86rem; }
.gcard-week { display: flex; flex-direction: column; align-items: flex-end; text-align: end; }
.gcard-week small { color: var(--muted); font-size: .72rem; }
.gcard-week b { font-family: var(--font-display); font-size: 1.15rem; }
.gcard-week b small { font-size: .74rem; }

/* شرح القواعد */
.rules-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 16px; }
.rules-card summary { list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 0; cursor: pointer; font-family: var(--font-display); font-weight: 600; }
.rules-card summary::-webkit-details-marker { display: none; }
.rules-card summary > span { display: flex; align-items: center; gap: 8px; }
.rules-card summary .sum-ic { transition: transform .2s; transform: rotate(-90deg); }
.rules-card[open] summary .sum-ic { transform: rotate(90deg); }
.rules-card[open] { padding-bottom: 16px; }
.rules-cap { margin-bottom: 12px; color: var(--ink-2); }
.rules { display: grid; grid-template-columns: 1fr; gap: 10px; }
.rule { border: 1px solid var(--line); border-radius: var(--radius-md); padding: 12px 14px; background: var(--surface-2); }
.rule-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }
.rule-head h4 { display: flex; align-items: center; gap: 8px; font-size: .96rem; }
.rule-limit { font-size: .76rem; color: var(--muted); background: var(--surface); border: 1px solid var(--line); padding: 2px 8px; border-radius: 999px; }
.rule ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; }
.rule li { display: flex; justify-content: space-between; gap: 8px; font-size: .9rem; }
.rule li .num { font-weight: 700; }

/* ---------- عدّاد الأسبوع (25 خانة) ---------- */
.meter { display: grid; grid-template-columns: repeat(25, 1fr); gap: 3px; direction: rtl; }
.meter i { height: 12px; border-radius: 3px; background: var(--c, var(--empty-cell)); }
.meter-sm { gap: 1.5px; width: 100%; max-width: 150px; }
.meter-sm i { height: 6px; border-radius: 1.5px; }
.legend { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: .8rem; color: var(--ink-2); }
.legend li { display: flex; align-items: center; gap: 6px; }
.legend i { width: 9px; height: 9px; border-radius: 2.5px; background: var(--c); }
.legend b { font-weight: 600; color: var(--ink); }

/* ---------- قائمة الطلاب ---------- */
.slist { display: flex; flex-direction: column; gap: 8px; }
.scard {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink);
  box-shadow: var(--shadow-sm);
}
a.scard:hover { border-color: var(--line-2); }
.scard-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.scard-name { font-weight: 600; font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.scard-week { display: flex; align-items: center; gap: 8px; font-size: .78rem; color: var(--muted); }
.scard-pts { display: flex; flex-direction: column; align-items: center; min-width: 52px; line-height: 1.1; }
.scard-pts b { font-family: var(--font-display); font-size: 1.4rem; font-weight: 700; }
.scard-pts small { color: var(--muted); font-size: .72rem; }
.scard.staff { flex-direction: column; align-items: stretch; padding: 0; gap: 0; overflow: hidden; }
.scard-top { display: flex; align-items: center; gap: 12px; padding: 12px 14px 10px; color: var(--ink); }
.scard-top .pill { align-self: flex-start; }

/* إجراءات سريعة داخل البطاقة */
.qa { display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--line); }
.qa-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 54px; border: 0; background: transparent; color: var(--ink-2); font-size: .8rem; font-weight: 600;
}
.qa-btn + .qa-btn { border-inline-start: 1px solid var(--line); }
.qa-btn:hover { background: var(--surface-2); }
.qa-btn:active { background: var(--primary-soft); }
.qa-pos { color: var(--primary-ink); }
.qa-pos .ic { stroke-width: 2.4; }
.qa-neg { color: var(--neg); }
.qa-btn.is-on { color: var(--pos); }

/* شارات صغيرة */
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: .74rem; font-weight: 600; white-space: nowrap; }
.pill .ic { width: 14px; height: 14px; stroke-width: 2.4; }
.pill-pos { background: var(--pos-soft); color: var(--pos); }
.pill-neg { background: var(--neg-soft); color: var(--neg); }
.pill-muted { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.pills { display: flex; gap: 6px; flex-wrap: wrap; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.chip { font-size: .74rem; background: var(--primary-soft); color: var(--primary-ink); padding: 1px 8px; border-radius: 999px; }

/* ---------- ملف الطالب ---------- */
.profile {
  --h: 195;
  background: var(--surface); border: 1px solid var(--line); border-radius: 22px; padding: 18px;
  display: flex; flex-direction: column; gap: 14px; box-shadow: var(--shadow);
}
.profile-top { display: flex; gap: 14px; align-items: flex-start; }
.profile-id { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.profile-id h1 { font-size: 1.4rem; }
.profile-id p { color: var(--muted); font-size: .9rem; }
.profile-points { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.profile-points .big { display: flex; align-items: baseline; gap: 8px; }
.profile-points .big b { font-family: var(--font-display); font-size: 3rem; font-weight: 700; line-height: 1; color: var(--primary-ink); }
.profile-points .big span { color: var(--ink-2); font-weight: 500; }
.profile-points .wk { display: flex; flex-direction: column; align-items: flex-end; }
.profile-points .wk span { font-size: .8rem; color: var(--muted); }
.profile-points .wk b { font-family: var(--font-display); font-size: 1.5rem; font-weight: 700; line-height: 1.1; }
.profile-points .wk b small { font-size: .9rem; color: var(--muted); font-weight: 500; }
.kv { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 0; }
.kv > div { background: var(--surface-2); border-radius: 12px; padding: 8px 12px; }
.kv dt { font-size: .76rem; color: var(--muted); }
.kv dd { margin: 0; font-family: var(--font-display); font-weight: 700; font-size: 1.15rem; }
.att-line { display: flex; align-items: center; gap: 6px; color: var(--ink-2); font-size: .9rem; }
.att-line .ic { width: 18px; height: 18px; color: var(--primary-ink); }
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: .76rem; font-weight: 600; padding: 3px 9px 3px 10px; border-radius: 999px; background: var(--primary-soft); color: var(--primary-ink); }
.badge .ic { width: 14px; height: 14px; }

.actions-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.act {
  display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 58px; padding: 10px;
  border-radius: 16px; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font-weight: 600; font-size: .96rem; box-shadow: var(--shadow-sm);
}
.act:active { transform: scale(.98); }
.act .ic { width: 22px; height: 22px; }
.act-primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.act-primary .ic { stroke-width: 2.4; }
.act-neg { color: var(--neg); }
.act.is-on { color: var(--pos); background: var(--pos-soft); border-color: transparent; }

/* ---------- السجل ---------- */
.week-block { display: flex; flex-direction: column; gap: 6px; }
.week-block + .week-block { margin-top: 10px; }
.week-head { display: flex; align-items: center; justify-content: space-between; padding-inline: 4px; }
.week-head h3 { font-size: .9rem; color: var(--ink-2); font-weight: 600; }
.week-sum { display: flex; gap: 8px; font-weight: 700; font-size: .9rem; }
.week-sum .num:last-child:not(:first-child) { color: var(--neg); }
.tx-list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.panel .tx-list { border: 0; border-radius: 0; background: transparent; }
.tx { display: flex; align-items: center; gap: 12px; padding: 11px 14px; }
.tx + .tx { border-top: 1px solid var(--line); }
.tx-pts {
  min-width: 46px; height: 34px; padding-inline: 6px; border-radius: 10px; display: grid; place-items: center; flex: none;
  font-family: var(--font-display); font-weight: 700; font-size: 1rem;
  background: color-mix(in srgb, var(--c, var(--primary)) 16%, transparent);
  color: color-mix(in srgb, var(--c, var(--primary)) 70%, var(--ink));
}
.tx-neg .tx-pts { background: var(--neg-soft); color: var(--neg); }
.tx-body { flex: 1; min-width: 0; }
.tx-title { font-weight: 600; font-size: .94rem; }
.tx-meta { color: var(--muted); font-size: .78rem; display: flex; flex-wrap: wrap; align-items: center; gap: 0 2px; }
.tx-meta a { color: var(--ink-2); font-weight: 600; }
.dot { margin-inline: 5px; }
.tx-void { opacity: .55; }
.tx-void .tx-pts { text-decoration: line-through; }

/* ---------- الحالات ---------- */
.state { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: 36px 16px; color: var(--muted); background: var(--surface); border: 1px dashed var(--line-2); border-radius: var(--radius); }
.state > .ic { width: 34px; height: 34px; color: var(--primary); opacity: .75; margin-bottom: 4px; }
.state h3 { color: var(--ink); }
.state p { max-width: 40ch; font-size: .9rem; }
.state .btn { margin-top: 8px; }
.state-error > .ic { color: var(--neg); }
.state-loading { border: 0; background: transparent; align-items: stretch; gap: 10px; padding: 0; }
.skel { height: 64px; border-radius: var(--radius); background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%); background-size: 200% 100%; animation: skel 1.2s infinite linear; border: 1px solid var(--line); }
.skel-lg { height: 140px; }
@keyframes skel { to { background-position: -200% 0; } }

/* ---------- الإشعارات ---------- */
.toasts {
  position: fixed; z-index: 60; inset-inline: 0; bottom: calc(var(--nav-h) + 10px + env(safe-area-inset-bottom, 0px));
  display: flex; flex-direction: column; align-items: center; gap: 8px; padding-inline: 12px; pointer-events: none;
}
.toast {
  pointer-events: auto; width: 100%; max-width: 480px;
  display: flex; align-items: center; gap: 10px; padding: 10px 8px 10px 14px; border-radius: 14px;
  background: #0E2A38; color: #EAF6FA; box-shadow: var(--shadow-lg);
  animation: toast-in .22s ease-out;
}
:root[data-theme="dark"] .toast { background: #E8F5FA; color: #0C2532; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .toast { background: #E8F5FA; color: #0C2532; } }
.toast > .ic { width: 22px; height: 22px; }
.toast-success > .ic { color: #3CD39A; }
.toast-error { background: #B42F38; color: #fff; }
:root[data-theme="dark"] .toast-error { background: #B42F38; color: #fff; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .toast-error { background: #B42F38; color: #fff; } }
.toast-info > .ic { color: #6AD3EC; }
.toast-text { flex: 1; font-weight: 500; font-size: .92rem; }
.toast-action { border: 0; background: rgba(255, 255, 255, .14); color: inherit; font-weight: 700; padding: 8px 14px; border-radius: 10px; min-height: 40px; }
.toast-x { border: 0; background: none; color: inherit; opacity: .7; width: 34px; height: 34px; display: grid; place-items: center; }
.toast-x .ic { width: 16px; height: 16px; }
.toast.out { opacity: 0; transform: translateY(8px); transition: .2s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } }
.app:not(.is-staff) ~ .toasts { bottom: calc(16px + env(safe-area-inset-bottom, 0px)); }

/* ---------- النوافذ ---------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(4, 22, 32, .45); animation: fade .2s; }
.sheet {
  position: relative; width: 100%; max-width: 640px; max-height: 92vh; max-height: 92dvh;
  background: var(--surface); border-radius: 22px 22px 0 0; box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; animation: up .24s cubic-bezier(.2, .8, .2, 1);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.sheet-grip { width: 40px; height: 4px; border-radius: 4px; background: var(--line-2); margin: 8px auto 0; flex: none; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 12px 6px 18px; flex: none; }
.sheet-head h2 { font-size: 1.1rem; }
.sheet-body { overflow-y: auto; padding: 4px 18px 18px; display: flex; flex-direction: column; gap: 14px; overscroll-behavior: contain; }
.sheet-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); flex: none; }
.sheet-wrap.out .sheet { transform: translateY(30px); opacity: 0; transition: .18s; }
.sheet-wrap.out .sheet-backdrop { opacity: 0; transition: .18s; }
@keyframes up { from { transform: translateY(40px); opacity: .4; } }
@keyframes fade { from { opacity: 0; } }

/* نافذة إضافة النقاط */
.ps-head { display: flex; align-items: center; gap: 12px; }
.ps-who { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.ps-who b { font-size: 1.05rem; }
.ps-who span { color: var(--muted); font-size: .84rem; }
.ps-week { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.15; }
.ps-week b { font-family: var(--font-display); font-size: 1.5rem; font-weight: 700; }
.ps-week b small { font-size: .85rem; color: var(--muted); font-weight: 500; }
.ps-week span { font-size: .76rem; color: var(--muted); }
.ps-cat { display: flex; flex-direction: column; gap: 8px; }
.ps-cat-head { display: flex; align-items: center; justify-content: space-between; }
.ps-cat-head h3 { display: flex; align-items: center; gap: 8px; font-size: 1rem; }
.cap { font-size: .8rem; font-weight: 600; color: var(--ink-2); background: var(--surface-2); border: 1px solid var(--line); padding: 1px 9px; border-radius: 999px; }
.cap-full { color: var(--pos); background: var(--pos-soft); border-color: transparent; }
.ps-reasons { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 8px; }
.reason {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 66px; padding: 8px; border-radius: 14px;
  border: 1.5px solid var(--primary-soft-2); background: var(--primary-soft); color: var(--ink);
  transition: transform .08s, background .15s;
}
.reason:hover { border-color: var(--primary); }
.reason:active { transform: scale(.96); }
.r-name { font-weight: 600; font-size: .92rem; }
.r-pts { display: flex; align-items: center; gap: 4px; font-family: var(--font-display); font-weight: 700; font-size: 1.15rem; color: var(--primary-ink); }
.r-pts .ic { width: 14px; height: 14px; }
.reason.is-blocked { background: var(--surface-2); border-color: var(--line); border-style: dashed; color: var(--muted); }
.reason.is-blocked .r-pts { color: var(--muted); }
.ps-note { font-size: .8rem; color: var(--muted); }
.ps-cat.is-done .ps-cat-head h3 { color: var(--muted); }
.shake { animation: shake .35s; }
@keyframes shake { 20%, 60% { transform: translateX(-5px); } 40%, 80% { transform: translateX(5px); } }
.ded-list { display: flex; flex-direction: column; gap: 8px; }
.ded {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 56px; padding: 10px 16px;
  border-radius: 14px; border: 1.5px solid var(--neg-soft); background: var(--surface); text-align: start; font-weight: 600;
}
.ded:hover { border-color: var(--neg); }
.ded b { font-family: var(--font-display); color: var(--neg); font-size: 1.15rem; }

/* ---------- لوحة الأستاذ ---------- */
.mygroups { display: grid; gap: 10px; }
.mgcard { --h: 195; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden; }
.mgcard-main { display: flex; align-items: center; gap: 12px; padding: 14px; color: var(--ink); }
.mgcard-main > span:nth-child(2) { flex: 1; display: flex; flex-direction: column; }
.mgcard-main b { font-family: var(--font-display); font-size: 1.1rem; font-weight: 600; }
.mgcard-main .muted { font-size: .86rem; }
.go { color: var(--muted); }
.mgcard-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--line); background: var(--surface-2); flex-wrap: wrap; }
.att-sum { display: flex; align-items: center; gap: 6px; font-size: .84rem; color: var(--ink-2); }
.att-sum .ic { width: 17px; height: 17px; }
.card-list { box-shadow: var(--shadow-sm); }

/* ---------- الحضور ---------- */
.att-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.att-list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.att-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; }
.att-row + .att-row { border-top: 1px solid var(--line); }
.att-name { flex: 1; min-width: 0; font-weight: 600; font-size: .95rem; }
.att-name small { font-size: .78rem; }
.seg-att button { min-height: 42px; padding-inline: 14px; }
.seg-att button[data-st="present"][aria-pressed="true"] { background: var(--pos); color: #fff; }
.seg-att button[data-st="absent"][aria-pressed="true"] { background: var(--neg); color: #fff; }

/* ---------- النماذج ---------- */
.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; border: 0; padding: 0; margin: 0; min-width: 0; }
.field > span, .field > legend { font-weight: 600; font-size: .88rem; color: var(--ink-2); padding: 0; margin-bottom: 6px; }
.field > span { margin-bottom: 0; }
.field-inline { flex-direction: row; align-items: center; gap: 10px; }
input:not([type=checkbox]):not([type=radio]):not([type=file]), select, textarea {
  width: 100%; min-height: 46px; padding: 10px 12px; border-radius: 12px;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink);
}
textarea { resize: vertical; line-height: 1.6; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft-2); }
.form-error { color: var(--neg); background: var(--neg-soft); padding: 10px 12px; border-radius: 10px; font-size: .9rem; font-weight: 500; }
.search-inline { position: relative; display: flex; align-items: center; flex: 1; min-width: 200px; }
.search-inline .ic { position: absolute; inset-inline-start: 12px; color: var(--muted); width: 18px; height: 18px; pointer-events: none; }
.search-inline input { padding-inline-start: 38px !important; }
.search-inline.big input { min-height: 52px; font-size: 1.05rem; }
.check-list { display: flex; flex-direction: column; gap: 6px; }
.check-list.compact { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.check { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; background: var(--surface); }
.check input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.check-box { width: 22px; height: 22px; border-radius: 7px; border: 1.5px solid var(--line-2); display: grid; place-items: center; flex: none; margin-top: 1px; color: transparent; background: var(--surface); }
.check-box .ic { width: 15px; height: 15px; stroke-width: 3; }
.check input:checked + .check-box { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.check input:focus-visible + .check-box { outline: 2.5px solid var(--primary); outline-offset: 2px; }
.check > span:last-child { display: flex; flex-direction: column; font-size: .92rem; }
.check > span:last-child .ic { width: 16px; height: 16px; display: inline; vertical-align: -3px; }
.check small { color: var(--muted); font-size: .8rem; }
.check-inline { padding: 6px 10px; border: 0; background: transparent; align-items: center; }
.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatch { --h: 195; cursor: pointer; }
.swatch input { position: absolute; opacity: 0; }
.swatch span { display: block; width: 36px; height: 36px; border-radius: 11px; background: linear-gradient(150deg, hsl(var(--h) 80% 62%), hsl(calc(var(--h) + 14) 70% 42%)); border: 3px solid transparent; }
.swatch input:checked + span { border-color: var(--ink); }
.swatch input:focus-visible + span { outline: 2.5px solid var(--primary); outline-offset: 2px; }
.photo-row { display: flex; align-items: center; gap: 14px; }
.photo-btns { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.mini-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 12px; max-height: 240px; overflow-y: auto; }
.mini-list li { display: flex; align-items: center; gap: 10px; padding: 6px 10px; }
.mini-list li + li { border-top: 1px solid var(--line); }
.mini-list li > span:nth-child(2) { flex: 1; }
.add-row { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.add-row select { flex: 1; min-width: 180px; }

/* ---------- تسجيل الدخول ---------- */
.login { display: grid; gap: 16px; max-width: 440px; margin-inline: auto; width: 100%; padding-top: 12px; }
.login-card { background: var(--surface); border: 1px solid var(--line); border-radius: 22px; padding: 24px 20px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px; }
.login-card h1 { font-size: 1.35rem; margin-top: 6px; }
.login-card form { display: flex; flex-direction: column; gap: 14px; margin-top: 8px; }
.demo-box { display: flex; flex-direction: column; gap: 8px; }
.demo-box h2 { font-size: .9rem; color: var(--muted); font-weight: 600; }
.demo-acc { display: grid; grid-template-columns: auto 1fr; gap: 0 10px; text-align: start; padding: 10px 14px; border-radius: 14px; border: 1px dashed var(--line-2); background: var(--surface-2); }
.demo-acc:hover { border-color: var(--primary); }
.demo-acc b { color: var(--primary-ink); }
.demo-acc span { direction: ltr; text-align: end; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .86rem; color: var(--ink-2); }
.demo-acc small { grid-column: 1 / -1; color: var(--muted); }

/* ---------- السجل والفلاتر ---------- */
.filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; align-items: center; }
.filters .search-inline { grid-column: 1 / -1; min-width: 0; }
.filters select, .filters input[type=date] { min-height: 42px; font-size: .88rem; padding: 8px 10px; }
.log-sum { display: flex; gap: 14px; font-weight: 600; color: var(--ink-2); font-size: .9rem; }

/* ---------- لوحة الإدارة ---------- */
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 0; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); padding: 12px 14px; color: var(--ink); box-shadow: var(--shadow-sm); }
a.tile:hover { border-color: var(--primary); }
.tile dt { font-size: .8rem; color: var(--muted); }
.tile dd { margin: 0; font-family: var(--font-display); font-weight: 700; font-size: 1.6rem; line-height: 1.25; }
.tile dd small { font-size: .8rem; color: var(--muted); font-weight: 500; }
.dash-grid { display: grid; gap: 14px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 12px; box-shadow: var(--shadow-sm); min-width: 0; }
.panel .tx { padding-inline: 0; }
.rank { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; counter-reset: r; }
.rank li a { display: flex; align-items: center; gap: 10px; padding: 8px 0; color: var(--ink); }
.rank li + li a { border-top: 1px solid var(--line); }
.rank li a > span:nth-child(2) { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.rank small { color: var(--muted); font-size: .78rem; }
.rank-val { font-family: var(--font-display); font-weight: 700; color: var(--pos); }
.gstats { display: flex; flex-direction: column; }
.gstat { --h: 195; display: grid; grid-template-columns: 1fr; gap: 6px; padding: 12px 0; color: var(--ink); }
.gstat + .gstat { border-top: 1px solid var(--line); }
.gstat-name { display: flex; align-items: center; gap: 10px; }
.gstat-name small { color: var(--muted); margin-inline-start: auto; }
.gstat-m { display: grid; grid-template-columns: 92px 1fr 44px; align-items: center; gap: 10px; font-size: .82rem; color: var(--muted); }
.gstat-m b { color: var(--ink); text-align: end; }
.bar { display: block; height: 8px; border-radius: 8px; background: var(--empty-cell); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 8px; background: var(--c, var(--primary)); }
.bar-pos i { background: var(--pos); }
.hbars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.hbars li { display: grid; grid-template-columns: 96px 1fr auto; gap: 10px; align-items: center; font-size: .88rem; }
.hb-l { display: flex; align-items: center; gap: 6px; }
.hb-v { display: flex; gap: 8px; align-items: baseline; min-width: 70px; justify-content: flex-end; }
.hb-v small { color: var(--muted); }
.sub { font-size: .92rem; color: var(--ink-2); }
.plain { margin: 0; padding-inline-start: 20px; display: flex; flex-direction: column; gap: 4px; font-size: .9rem; }
.plain li { display: flex; justify-content: space-between; gap: 8px; }
.admin-groups { display: grid; gap: 10px; }
.agcard { --h: 195; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 10px; box-shadow: var(--shadow-sm); }
.agcard.is-off { opacity: .6; }
.agcard-top { display: flex; align-items: center; gap: 12px; }
.ag-teachers { display: flex; align-items: center; gap: 6px; font-size: .86rem; color: var(--ink-2); }
.ag-teachers .ic { width: 17px; height: 17px; color: var(--muted); }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.rows { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.row-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; flex-wrap: wrap; }
.row-item + .row-item { border-top: 1px solid var(--line); }
.row-item.is-off { opacity: .6; }
.row-main { flex: 1; min-width: 140px; display: flex; flex-direction: column; color: var(--ink); }
.row-main small { color: var(--muted); font-size: .8rem; }
.row-main .bar { margin-top: 6px; max-width: 260px; }
.row-num { display: flex; flex-direction: column; align-items: center; line-height: 1.15; }
.row-num b { font-family: var(--font-display); font-size: 1.1rem; }
.row-num small { color: var(--muted); font-size: .72rem; }

/* جدول التقارير: بطاقات على الهاتف، جدول على الشاشات الكبيرة */
.table-wrap { overflow-x: auto; }
.rtable { width: 100%; border-collapse: collapse; }
.rtable thead { display: none; }
.rtable tr { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); padding: 12px 14px; margin-bottom: 8px; }
.rtable td { display: flex; flex-direction: column; font-size: .9rem; }
.rtable td::before { content: attr(data-l); font-size: .72rem; color: var(--muted); }
.rtable td:first-child { grid-column: 1 / -1; font-weight: 600; font-size: 1rem; }
.rtable td:first-child::before { display: none; }

/* سجل النشاط */
.alog { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.alog li { display: flex; gap: 10px; padding: 10px 14px; align-items: flex-start; }
.alog li + li { border-top: 1px solid var(--line); }
.alog p { font-size: .92rem; }
.alog small { color: var(--muted); font-size: .78rem; }

/* قائمة «المزيد» والبحث */
.more-list { display: flex; flex-direction: column; }
.more-list a, .more-list button { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 8px 4px; color: var(--ink); font-weight: 500; border: 0; background: none; text-align: start; width: 100%; }
.more-list > * + * { border-top: 1px solid var(--line); }
.more-list span { flex: 1; }
.more-list button { color: var(--neg); }
.qr { display: flex; flex-direction: column; gap: 6px; min-height: 120px; }
.qr-h { font-size: .8rem; color: var(--muted); margin-top: 6px; }
.qr-list { list-style: none; margin: 0; padding: 0; }
.qr-list a { display: flex; align-items: center; gap: 10px; padding: 8px 4px; color: var(--ink); border-radius: 10px; }
.qr-list a:hover { background: var(--surface-2); }
.qr-list a > span:nth-child(2) { flex: 1; display: flex; flex-direction: column; }
.qr-list small { color: var(--muted); font-size: .8rem; }
.qr-pts { font-family: var(--font-display); font-weight: 700; color: var(--primary-ink); }

/* ---------- الشاشات الأوسع ---------- */
@media (min-width: 600px) {
  :root { --gutter: 24px; }
  .group-grid { grid-template-columns: repeat(2, 1fr); }
  .mygroups, .admin-groups { grid-template-columns: repeat(2, 1fr); }
  .rules { grid-template-columns: repeat(2, 1fr); }
  .tiles { grid-template-columns: repeat(3, 1fr); }
  .actions-grid { grid-template-columns: repeat(4, 1fr); }
  .kv { grid-template-columns: repeat(4, 1fr); }
  .filters { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .hero { padding: 36px 32px 26px; }
  .sheet-wrap { align-items: center; padding: 24px; }
  .sheet { border-radius: 22px; max-height: 86vh; }
  .sheet-grip { display: none; }
  .sheet-head { padding-top: 14px; }
  .sheet-sm { max-width: 440px; }
  .sheet-search { align-self: flex-start; margin-top: 8vh; }
  .toasts { bottom: 24px; }
  .slist.grid2 { display: grid; grid-template-columns: 1fr 1fr; }
}

@media (min-width: 760px) {
  .rtable thead { display: table-header-group; }
  .rtable tr { display: table-row; background: none; border: 0; padding: 0; margin: 0; }
  .rtable th { text-align: start; font-size: .78rem; color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
  .rtable td { display: table-cell; padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: .92rem; }
  .rtable td::before { display: none; }
  .rtable td:first-child { font-size: .92rem; }
  .table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
  .rtable tbody tr:last-child td { border-bottom: 0; }
  .dash-grid { grid-template-columns: 1fr 1fr; }
  .panel-wide { grid-column: 1 / -1; }
  .gstat { grid-template-columns: minmax(200px, 1.2fr) 1fr 1fr; align-items: center; gap: 20px; }
  .gstat-name small { margin-inline-start: 0; }
  .filters { grid-template-columns: 2fr repeat(3, minmax(0, 1fr)); }
  .filters .search-inline { grid-column: auto; }
  .slist { display: grid; grid-template-columns: 1fr 1fr; }
}

/* الكمبيوتر: التنقل يصبح شريطًا جانبيًا */
@media (min-width: 1000px) {
  .group-grid { grid-template-columns: repeat(3, 1fr); }
  .tiles { grid-template-columns: repeat(6, 1fr); }
  .app.is-staff { display: grid; grid-template-columns: 232px 1fr; grid-template-rows: auto 1fr; }
  .app.is-staff .topbar { grid-column: 1 / -1; }
  .app.is-staff .nav {
    position: sticky; top: var(--topbar-h); bottom: auto; align-self: start; height: calc(100vh - var(--topbar-h));
    border-top: 0; border-inline-start: 0; border-inline-end: 1px solid var(--line); box-shadow: none; background: var(--surface); padding: 14px 10px;
  }
  .app.is-staff .nav-inner { flex-direction: column; gap: 2px; max-width: none; }
  .app.is-staff .nav-item { flex: none; flex-direction: row; justify-content: flex-start; gap: 12px; min-height: 44px; padding: 8px 12px; border-radius: 12px; font-size: .92rem; }
  .app.is-staff .nav-item[aria-current="page"] { background: var(--primary-soft); }
  .app.is-staff .nav-item[aria-current="page"]::before { display: none; }
  .app.is-staff .nav-extra { display: flex; }
  .app.is-staff .nav-more { display: none; }
  .app.is-staff .view { padding-bottom: 48px; width: 100%; }
  .toasts { inset-inline-start: 232px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ضبط الهاتف الضيق */
@media (max-width: 599px) {
  .page-head .head-act { flex-basis: 100%; }
  .uc-name { display: none; }
  .user-chip { padding: 4px; }
  .brand-text b { font-size: .92rem; }
}
@media (max-width: 380px) {
  .top-actions .btn-sm span { display: none; }
}

/* انتظار الخادم */
.more-list button.plain-row { color: var(--ink); }
.btn.is-loading, .reason.is-busy, .qa-btn.is-busy { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-loading > *, .reason.is-busy > *, .qa-btn.is-busy > * { visibility: hidden; }
.btn.is-loading::after, .reason.is-busy::after, .qa-btn.is-busy::after {
  content: ""; position: absolute; inset: 0; margin: auto; width: 20px; height: 20px; border-radius: 50%;
  border: 2.5px solid var(--primary); border-top-color: transparent; animation: spin .7s linear infinite;
}
.btn-primary.is-loading::after { border-color: var(--on-primary); border-top-color: transparent; }
.sheet.is-saving .reason:not(.is-busy) { opacity: .5; }
.att-row.is-busy { opacity: .55; pointer-events: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* شعار مسجد الحسين — على خلفية بيضاء دائمًا لأن نص الشعار كحلي */
.brand-mark { background: #fff; border: 1px solid var(--line); padding: 3px; overflow: hidden; }
.brand-mark img { width: 100%; height: 100%; object-fit: contain; }
.logo-tile { flex: none; display: grid; place-items: center; background: #fff; border-radius: 18px; border: 1px solid var(--line); box-shadow: var(--shadow-sm); padding: 8px; }
.logo-tile img { width: 100%; height: auto; }
.hero-top { display: flex; align-items: center; gap: 16px; position: relative; }
.hero-top .logo-tile { width: 84px; }
.hero-title { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.login-logo { width: 96px; align-self: center; }
.login-card h1 { text-align: center; }
.login-card > .muted { text-align: center; }
@media (min-width: 600px) { .hero-top .logo-tile { width: 112px; } }

/* ================= الرتب ================= */
/* لون لكل رتبة: تدرّج من الأخضر المائي إلى الأزرق الداكن، والقمة ذهبية */
.rk-1 { --rk: 168; --rs: 55%; }
.rk-2 { --rk: 192; --rs: 72%; }
.rk-3 { --rk: 205; --rs: 75%; }
.rk-4 { --rk: 216; --rs: 72%; }
.rk-5 { --rk: 228; --rs: 66%; }
.rk-6 { --rk: 245; --rs: 55%; }
.rk-7 { --rk: 38;  --rs: 88%; }
:root { --rk-bg-l: 93%; --rk-fg-l: 34%; --rk-solid-l: 46%; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --rk-bg-l: 20%; --rk-fg-l: 74%; --rk-solid-l: 52%; } }
:root[data-theme="dark"] { --rk-bg-l: 20%; --rk-fg-l: 74%; --rk-solid-l: 52%; }

.rk-ico { display: inline-grid; place-items: center; flex: none; border-radius: 10px; background: hsl(var(--rk) var(--rs) var(--rk-bg-l)); color: hsl(var(--rk) var(--rs) var(--rk-fg-l)); }
.rk-ico-sm { width: 30px; height: 30px; }
.rk-ico-sm .ic { width: 18px; height: 18px; }
.rk-chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px 2px 8px; border-radius: 999px; font-size: .76rem; font-weight: 600;
  background: hsl(var(--rk) var(--rs) var(--rk-bg-l)); color: hsl(var(--rk) var(--rs) var(--rk-fg-l)); }
.rk-chip .ic { width: 14px; height: 14px; }

.rank-card { background: var(--surface); border: 1px solid var(--line); border-radius: 22px; padding: 18px; display: flex; flex-direction: column; gap: 14px; box-shadow: var(--shadow); }
.rank-head { display: flex; align-items: center; gap: 14px; }
.rk-emblem { position: relative; flex: none; display: grid; place-items: center; width: 68px; height: 76px; color: #fff; }
.rk-hex { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; filter: drop-shadow(0 6px 10px hsl(var(--rk) var(--rs) 30% / .35)); }
.rk-hex-out { fill: hsl(var(--rk) var(--rs) var(--rk-solid-l)); }
.rk-hex-in { fill: hsl(var(--rk) var(--rs) calc(var(--rk-solid-l) + 9%)); stroke: rgba(255, 255, 255, .55); stroke-width: 1.6; }
.rk-emblem .rk-g { position: relative; width: 32px; height: 32px; margin-top: -4px; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .18)); }
.rk-emblem b { position: absolute; bottom: -6px; left: 50%; width: 22px; height: 22px; transform: translateX(-50%) rotate(45deg); border-radius: 4px; display: grid; place-items: center;
  background: var(--surface); border: 2px solid hsl(var(--rk) var(--rs) var(--rk-solid-l)); color: hsl(var(--rk) var(--rs) var(--rk-fg-l)); font-family: var(--font-display); font-size: .78rem; line-height: 1; }
.rk-emblem-md { width: 54px; height: 60px; }
.rk-emblem-md .rk-g { width: 25px; height: 25px; }
.rk-emblem-md b { width: 19px; height: 19px; font-size: .7rem; bottom: -5px; }
.rank-id { min-width: 0; }
.rank-id small { color: hsl(var(--rk) var(--rs) var(--rk-fg-l)); font-weight: 600; font-size: .8rem; }
.rank-id h2 { font-size: 1.45rem; font-weight: 700; }
.rank-id p { color: var(--muted); font-size: .88rem; }
.rank-bar { height: 12px; border-radius: 12px; background: var(--empty-cell); overflow: hidden; }
.rank-bar i { display: block; height: 100%; border-radius: 12px; background: linear-gradient(90deg, hsl(var(--rk) var(--rs) calc(var(--rk-solid-l) + 12%)), hsl(var(--rk) var(--rs) var(--rk-solid-l))); }
.rank-bar-meta { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; font-size: .84rem; color: var(--ink-2); margin-top: 6px; }
.rank-path { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; position: relative; }
.rank-path::before { content: ""; position: absolute; top: 19px; inset-inline: 7%; height: 2px; background: var(--line); }
.rank-path li { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; min-width: 0; }
.rk-dot { position: relative; width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: var(--surface); border: 1.5px solid var(--line-2); color: var(--muted); }
.rk-dot .ic { width: 20px; height: 20px; }
.rank-path li small { font-size: .66rem; line-height: 1.25; color: var(--muted); font-weight: 600; overflow-wrap: anywhere; }
.rank-path li.done .rk-dot { background: hsl(var(--rk) var(--rs) var(--rk-bg-l)); border-color: transparent; color: hsl(var(--rk) var(--rs) var(--rk-fg-l)); }
.rank-path li.current .rk-dot { background: hsl(var(--rk) var(--rs) var(--rk-solid-l)); border-color: transparent; color: #fff; transform: scale(1.12); box-shadow: 0 4px 12px -4px hsl(var(--rk) var(--rs) 30%); }
.rank-path li.current small { color: hsl(var(--rk) var(--rs) var(--rk-fg-l)); }
.rank-path li.locked .rk-dot { opacity: .55; border-style: dashed; }
.rk-lock { position: absolute; bottom: -5px; inset-inline-end: -5px; width: 16px; height: 16px; border-radius: 6px; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--line-2); }
.rk-lock .ic { width: 10px; height: 10px; stroke-width: 2.4; }
.rank-more { align-self: flex-start; }
.rank-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.rank-list li { display: flex; align-items: center; gap: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow-sm); }
.rank-list li > div { flex: 1; min-width: 0; }
.rank-list small { color: hsl(var(--rk) var(--rs) var(--rk-fg-l)); font-weight: 600; font-size: .78rem; }
.rank-list h3 { font-size: 1.15rem; }
.rank-list p { color: var(--muted); font-size: .86rem; }
.rank-range { font-family: var(--font-display); font-weight: 700; color: hsl(var(--rk) var(--rs) var(--rk-fg-l)); white-space: nowrap; }
.explain { display: grid; gap: 10px; }
.explain > div { display: flex; gap: 12px; align-items: flex-start; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-md); padding: 12px 14px; }
.explain .ic { color: var(--primary-ink); margin-top: 2px; }
.explain span { display: flex; flex-direction: column; }
.explain small { color: var(--muted); }

/* المحفظة */
.wallet-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 12px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); }
.wallet-line > .ic { color: var(--primary-ink); }
.wallet-line > span { font-weight: 600; }
.wallet-line > b { font-family: var(--font-display); font-size: 1.25rem; }
.wallet-line > small { color: var(--muted); flex: 1; }
.wallet-line.is-neg > b { color: var(--neg); }
.wallet-amt { display: flex; flex-direction: column; align-items: center; line-height: 1.15; min-width: 56px; }
.wallet-amt b { font-family: var(--font-display); font-size: 1.25rem; color: var(--primary-ink); }
.wallet-amt small { color: var(--muted); font-size: .72rem; }
.wallet-amt.is-neg b { color: var(--neg); }
.row-btn { all: unset; box-sizing: border-box; display: flex; align-items: center; gap: 10px; width: 100%; cursor: pointer; }
.row-btn:focus-visible { outline: 2.5px solid var(--primary); outline-offset: 2px; border-radius: 10px; }
.seg-wide { display: flex; width: 100%; }
.seg-wide button { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; }
.seg-wide button .ic { width: 18px; height: 18px; }

/* لوحة الترتيب */
.seg-scroll { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.seg-link { padding: 7px 12px; border-radius: 9px; font-size: .86rem; font-weight: 500; color: var(--ink-2); white-space: nowrap; min-height: 36px; display: inline-flex; align-items: center; }
.seg-link[aria-current="true"] { background: var(--surface); color: var(--primary-ink); box-shadow: var(--shadow-sm); font-weight: 600; }
.lb { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.lb li + li { border-top: 1px solid var(--line); }
.lb a { display: flex; align-items: center; gap: 10px; padding: 10px 14px; color: var(--ink); }
.lb-pos { width: 30px; text-align: center; font-family: var(--font-display); font-weight: 700; color: var(--muted); flex: none; }
.lb .top .lb-pos { color: #fff; background: var(--primary); border-radius: 9px; height: 30px; display: grid; place-items: center; }
.lb .top-1 .lb-pos { background: hsl(38 88% 48%); }
.lb .top-2 .lb-pos { background: hsl(210 12% 58%); }
.lb .top-3 .lb-pos { background: hsl(24 60% 50%); }
.lb-name { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.lb-name b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-name small { color: var(--muted); font-size: .78rem; }
.lb-pts { display: flex; flex-direction: column; align-items: center; line-height: 1.1; min-width: 48px; }
.lb-pts b { font-family: var(--font-display); font-size: 1.15rem; }
.lb-pts small { color: var(--muted); font-size: .7rem; }
.quick-links { display: grid; gap: 10px; }
.qlink { display: flex; align-items: center; gap: 12px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); box-shadow: var(--shadow-sm); }
.qlink > .ic:first-child { width: 26px; height: 26px; color: var(--primary-ink); }
.qlink span { flex: 1; display: flex; flex-direction: column; }
.qlink small { color: var(--muted); font-size: .84rem; }
@media (min-width: 600px) { .quick-links, .explain { grid-template-columns: 1fr 1fr; } .rank-path li small { font-size: .74rem; } .rk-dot { width: 42px; height: 42px; } .rank-path::before { top: 21px; } }

/* الرقم داخل المعيّن يبقى مستقيمًا */
.rk-emblem b > span { display: block; transform: rotate(-45deg); }
.rk-g { stroke: none; }
.rank-path li.current .rk-dot .rk-g, .rk-dot .rk-g { width: 20px; height: 20px; }

/* ملاحظات الخصومات (للإدارة) */
.tx-note { margin-top: 4px; font-size: .84rem; color: var(--ink-2); background: var(--warn-soft); border-radius: 8px; padding: 4px 8px; display: flex; gap: 6px; align-items: flex-start; }
.tx-note .ic { width: 15px; height: 15px; margin-top: 3px; color: var(--warn); }
.notes { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.note-item { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.note-item.is-new { border-color: var(--warn); box-shadow: inset 4px 0 0 var(--warn); }
.note-top { display: flex; align-items: flex-start; gap: 10px; }
.note-top > div { flex: 1; min-width: 0; }
.note-top .tx-pts { background: var(--neg-soft); color: var(--neg); }
.note-text { font-size: .94rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.notes-panel h2 { display: flex; align-items: center; gap: 8px; }
.ded-list + .hint, .field small.muted { display: flex; gap: 4px; align-items: center; font-size: .78rem; }
.field small.muted .ic { width: 14px; height: 14px; }

/* مشاركة الإنجاز */
.share-btn .ic { width: 20px; height: 20px; }
.sheet-share { max-width: 520px; }
.share-preview { width: 100%; max-width: 100%; aspect-ratio: 1080 / 1350; max-height: 56vh; margin-inline: auto; border-radius: 16px; overflow: hidden; border: 1px solid var(--line); background: var(--surface-2); display: grid; place-items: center; }
.share-preview img { width: 100%; height: 100%; object-fit: contain; }

/* أزرار ملف الطالب: إضافة نقاط بعرض كامل، ثم الخصم والحضور */
.actions-grid .act-primary { grid-column: 1 / -1; }
@media (min-width: 600px) { .actions-grid { grid-template-columns: repeat(3, 1fr); } .actions-grid .act-primary { grid-column: auto; } }

/* تنبيهات الأسبوع والاستيراد */
.alerts-panel { border-color: var(--warn-soft); }
.alerts-panel h2 { display: flex; align-items: center; gap: 8px; }
.alerts-panel h2 .ic { color: var(--warn); }
.alerts-panel.ok h2 .ic { color: var(--pos); }
.alert-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.alert-list li + li { border-top: 1px solid var(--line); }
.alert-list a { display: flex; align-items: center; gap: 10px; padding: 9px 0; color: var(--ink); }
.al-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.al-main small { color: var(--muted); font-size: .8rem; }
.import-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.import-list li { border: 1px solid var(--line); border-radius: var(--radius-md); padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; }
.import-list p { font-size: .88rem; color: var(--ink-2); }
.import-list p.warn { color: var(--warn); }
.im-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
