/* ═════════ الهوية: كحلي عميق + رمل كهرماني (من الـ Hourglass) ═════════ */
:root {
  --font-body: 'IBM Plex Sans Arabic', 'Segoe UI', Tahoma, system-ui, sans-serif;
  --font-head: 'Readex Pro', 'IBM Plex Sans Arabic', 'Segoe UI', Tahoma, system-ui, sans-serif;
  --sand: #f2b84b;
  --glass: #8fd3e3;
  --on-sand: #2a1c00;
  --r-ctl: 8px;
  --r-box: 14px;
  --shadow: 0 10px 30px -12px rgba(2, 8, 20, .55);
}
[data-theme="dark"], .on-dark {
  --bg: #0a1322; --bg2: #0e1a2e; --surface: #12213a; --surface2: #182a48; --line: #263c60;
  --text: #e8eef7; --muted: #9aaac4; --accent: #f2b84b; --accent-text: #f2b84b;
  --ok: #62d6a4; --info: #7fcfe3; --warn: #f2b84b; --orange: #f09a5b; --bad: #f58a8a;
  --focus: #8fd3e3;
  color-scheme: dark;
}
[data-theme="light"] {
  --bg: #eaf0f7; --bg2: #f4f7fb; --surface: #ffffff; --surface2: #f0f4f9; --line: #d3deeb;
  --text: #0d1a2d; --muted: #4f627d; --accent: #f0b13f; --accent-text: #8a5800;
  --ok: #0c7a52; --info: #0b6f88; --warn: #8a5800; --orange: #a14f10; --bad: #b42323;
  --focus: #0b6f88;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-body); background: var(--bg); color: var(--text);
  line-height: 1.7; min-height: 100vh; -webkit-font-smoothing: antialiased;
  transition: background-color .25s, color .25s;
}
h1, h2, h3, h4 { font-family: var(--font-head); line-height: 1.35; font-weight: 600; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
a { color: var(--accent-text); }
ul { list-style: none; }
.num, .tnum { font-family: var(--font-head); font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; display: inline-block; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }
::selection { background: color-mix(in srgb, var(--sand) 45%, transparent); }

/* ═════════ أزرار وحقول ═════════ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .55rem 1.1rem; border-radius: var(--r-ctl); font-weight: 600; font-size: .95rem;
  border: 1px solid var(--line); background: var(--surface2); transition: transform .12s, background .15s, border-color .15s, opacity .15s;
  white-space: nowrap; text-decoration: none; color: var(--text);
}
.btn:hover { border-color: var(--muted); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn--primary { background: var(--accent); border-color: transparent; color: var(--on-sand); }
.btn--danger { color: var(--bad); }
.btn--primary:hover { background: color-mix(in srgb, var(--accent) 88%, #fff); border-color: transparent; }
.btn--danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, transparent); background: transparent; }
.btn--danger:hover { background: color-mix(in srgb, var(--bad) 14%, transparent); border-color: var(--bad); }
.btn--ghost { background: transparent; }
.btn--sm { padding: .3rem .65rem; font-size: .85rem; }
.btn--block { width: 100%; padding: .75rem 1rem; }
.icon-btn {
  display: inline-grid; place-items: center; width: 2.4rem; height: 2.4rem; border-radius: var(--r-ctl);
  border: 1px solid var(--line); background: var(--surface2); color: var(--text); transition: background .15s, border-color .15s;
}
.icon-btn:hover { border-color: var(--muted); }
.icon-btn--sm { width: 2rem; height: 2rem; }
.icon { width: 1.15em; height: 1.15em; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.field { display: grid; gap: .3rem; }
.field > label { font-size: .88rem; color: var(--muted); font-weight: 500; }
.field .hint { font-size: .8rem; color: var(--muted); }
.input, select.input {
  width: 100%; padding: .6rem .8rem; border-radius: var(--r-ctl); background: var(--bg2);
  border: 1px solid var(--line); transition: border-color .15s, box-shadow .15s;
}
.input:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 28%, transparent); }
.input::placeholder { color: color-mix(in srgb, var(--muted) 75%, transparent); }
select.input { appearance: none; padding-inline-end: 2rem;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(0% + 1.1rem) 55%, calc(0% + .8rem) 55%; background-size: 5px 5px; background-repeat: no-repeat; }
.pw { position: relative; }
.pw .input { padding-left: 2.8rem; }
.pw button { position: absolute; inset-block: 0; left: .35rem; width: 2.2rem; color: var(--muted); display: grid; place-items: center; }
.form-error { color: var(--bad); font-size: .9rem; min-height: 1.4em; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .9rem; }
.form-grid .span2 { grid-column: 1 / -1; }

/* ═════════ شارات التقدير ═════════ */
.chip {
  display: inline-flex; align-items: center; gap: .3rem; padding: .08rem .6rem; border-radius: 999px; font-size: .8rem; font-weight: 600;
  background: color-mix(in srgb, var(--c, var(--muted)) 16%, transparent); color: var(--c, var(--muted));
  border: 1px solid color-mix(in srgb, var(--c, var(--muted)) 35%, transparent);
}
.g-a { --c: var(--ok); } .g-b { --c: var(--info); } .g-c { --c: var(--warn); } .g-d { --c: var(--orange); } .g-f { --c: var(--bad); } .g-n { --c: var(--muted); }
.chip--gpa { min-width: 3.2rem; justify-content: center; font-family: var(--font-head); }

/* ═════════ شاشة التحميل ═════════ */
.loader { background: #0a1322; }
.loader__label { color: #9aaac4; }

/* ═════════ تنبيهات ═════════ */
.toasts { position: fixed; inset-block-end: 1rem; inset-inline-start: 1rem; z-index: 300; display: grid; gap: .5rem; max-width: min(92vw, 380px); }
.toast {
  background: var(--surface2); border: 1px solid var(--line); border-inline-start: 4px solid var(--info);
  padding: .65rem .9rem; border-radius: var(--r-ctl); box-shadow: var(--shadow); font-size: .95rem;
  animation: toast-in .25s ease;
}
.toast--ok { border-inline-start-color: var(--ok); } .toast--err { border-inline-start-color: var(--bad); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ═════════ نافذة وشريط جانبي منبثق ═════════ */
.overlay { position: fixed; inset: 0; z-index: 200; background: rgba(3, 8, 18, .6); display: grid; place-items: center; padding: 1rem; animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-box); width: min(560px, 100%); max-height: 92vh; overflow: auto; box-shadow: var(--shadow); animation: pop .2s ease; }
.modal--wide { width: min(760px, 100%); }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98); } }
.modal__head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 1.25rem; border-bottom: 1px solid var(--line); }
.modal__head h2 { font-size: 1.1rem; }
.modal__body { padding: 1.25rem; display: grid; gap: 1rem; }
.modal__foot { display: flex; gap: .6rem; justify-content: flex-end; padding: 0 1.25rem 1.25rem; }
.drawer-wrap { place-items: stretch; justify-items: end; padding: 0; }
.drawer { width: min(720px, 100%); height: 100%; background: var(--bg2); border-inline-end: 1px solid var(--line); overflow: auto; animation: slide .25s ease; }

@keyframes slide { from { transform: translateX(-30px); opacity: 0; } }
.drawer__head { position: sticky; top: 0; z-index: 2; background: var(--bg2); display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 1rem 1.25rem; border-bottom: 1px solid var(--line); }
.drawer__body { padding: 1.25rem; display: grid; gap: 1.25rem; }

/* ═════════ الصفحة الرئيسية ═════════ */
.hero { position: relative; min-height: 100vh; background: #0a1322; color: var(--text); isolation: isolate; overflow: hidden; display: flex; flex-direction: column; }
.lines { position: absolute; inset: 0; z-index: -1; overflow: hidden; direction: ltr; background: #0a1322; }
.lines::after { content: ''; position: absolute; inset: 0; background:
  radial-gradient(ellipse at 70% 50%, rgba(10, 19, 34, .1), rgba(10, 19, 34, .86) 72%),
  linear-gradient(180deg, rgba(10, 19, 34, .55), rgba(10, 19, 34, .2) 40%, rgba(10, 19, 34, .85)); }
.lines .layer {
  position: absolute; top: 50%; left: 50%; width: 90px; height: 250vh; opacity: .55;
  box-shadow: inset -10px 0 40px #000, inset 10px 0 40px #000, inset -10px 0 10px rgba(255,255,255,.12), inset 10px 0 10px rgba(255,255,255,.12), 0 0 50px #000;
  background-size: 35px 35px;
}
.lines .l1 { background: #101c32 radial-gradient(#f2b84b 9px, #000 9px, #000 13px, transparent 13px); background-size: 35px 35px; transform: translate(-50%, -50%) rotate(45deg); z-index: 10; animation: dots-a 3s linear infinite; }
.lines .l2 { background: #101c32 radial-gradient(#8fd3e3 9px, #000 9px, #000 13px, transparent 13px); background-size: 35px 35px; transform: translate(-50%, -38%) rotate(45deg); z-index: 8; animation: dots-b 3s linear infinite; }
.lines .l3 { background: #101c32 radial-gradient(#ffd98a 9px, #000 9px, #000 13px, transparent 13px); background-size: 35px 35px; transform: translate(-50%, -62%) rotate(45deg); z-index: 8; animation: dots-b 3s linear infinite; }
.lines .l4 { background: #101c32 radial-gradient(#62d6a4 9px, #000 9px, #000 13px, transparent 13px); background-size: 35px 35px; transform: translate(-50%, -50%) rotate(-45deg); z-index: 11; animation: dots-a 3s linear infinite; }
.lines .l5 { background: #101c32 radial-gradient(#e58b9b 9px, #000 9px, #000 13px, transparent 13px); background-size: 35px 35px; transform: translate(-50%, -38%) rotate(-45deg); z-index: 9; animation: dots-b 3s linear infinite; }
.lines .l6 { background: #101c32 radial-gradient(#8fd3e3 9px, #000 9px, #000 13px, transparent 13px); background-size: 35px 35px; transform: translate(-50%, -62%) rotate(-45deg); z-index: 9; animation: dots-b 3s linear infinite; }
@keyframes dots-a { to { background-position: 35px -35px; } }
@keyframes dots-b { from { background-position: 35px -35px; } to { background-position: 0 0; } }

.topbar-pub { display: flex; justify-content: space-between; align-items: center; padding: 1.1rem clamp(1rem, 4vw, 3rem); }
.brand { display: inline-flex; align-items: center; gap: .6rem; font-family: var(--font-head); font-weight: 600; font-size: 1.15rem; color: inherit; text-decoration: none; }
.brand__mark { width: 2.2rem; height: 2.2rem; border-radius: 10px; display: grid; place-items: center; background: color-mix(in srgb, var(--sand) 16%, transparent); color: var(--sand); border: 1px solid color-mix(in srgb, var(--sand) 40%, transparent); }
.hero__grid { flex: 1; display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr); gap: clamp(1.5rem, 5vw, 4.5rem); align-items: center; padding: 1rem clamp(1rem, 4vw, 3rem) 4rem; max-width: 1240px; width: 100%; margin-inline: auto; }
.hero h1 { font-size: clamp(2rem, 4.6vw, 3.4rem); font-weight: 700; letter-spacing: -.01em; }
.hero__lead { margin-top: 1.1rem; color: #bccae0; font-size: 1.12rem; max-width: 34em; }
.live { display: flex; flex-wrap: wrap; gap: 1.2rem 2.2rem; margin-top: 2rem; }
.live div { display: grid; }
.live b { font-family: var(--font-head); font-size: 1.7rem; font-weight: 600; color: var(--text); }
.live span { color: var(--muted); font-size: .9rem; }
.login-card { background: color-mix(in srgb, #12213a 88%, transparent); backdrop-filter: blur(8px); border: 1px solid #2a4066; border-radius: 18px; padding: clamp(1.2rem, 3vw, 1.8rem); box-shadow: var(--shadow); display: grid; gap: 1rem; }
.login-card h2 { font-size: 1.35rem; }
.login-card p.sub { color: var(--muted); font-size: .92rem; margin-top: -.5rem; }
.demo { display: grid; gap: .5rem; border-top: 1px dashed #2a4066; padding-top: 1rem; }
.demo > span { color: var(--muted); font-size: .88rem; }
.demo__row { display: flex; flex-wrap: wrap; gap: .5rem; }
.demo button { padding: .35rem .7rem; border-radius: 999px; border: 1px solid #34517c; background: #162744; font-size: .85rem; transition: background .15s, border-color .15s; }
.demo button:hover { background: #1d3358; border-color: var(--sand); }
.demo small { color: var(--muted); }

.showcase { padding: clamp(3rem, 8vw, 6rem) clamp(1rem, 4vw, 3rem); background: var(--bg); }
.showcase__inner { max-width: 1100px; margin-inline: auto; }
.showcase h2 { font-size: clamp(1.5rem, 3vw, 2.1rem); }
.showcase p.lead { color: var(--muted); margin-top: .6rem; max-width: 40em; }
.fan-wrap { margin-top: 3rem; display: grid; place-items: center; min-height: 260px; }
.fan { direction: ltr; display: flex; justify-content: center; perspective: 10px; transform: perspective(300px) rotateX(20deg); perspective-origin: center center; transform-style: preserve-3d; transition: all 1.3s ease-out; will-change: perspective; }
.fan:hover, .fan:focus-within { perspective: 1000px; transform: perspective(10000px) rotateX(0deg); transition: all 1.3s ease-in; }
.fan__card {
  direction: rtl; position: relative; width: 190px; height: 190px; padding: 1rem; display: flex; flex-direction: column; justify-content: flex-end; gap: .35rem;
  border-radius: 12px; border: 1px solid #3d5a8a; color: #fff; transform-style: preserve-3d;
  background: linear-gradient(160deg, #1d3358, #12213a); box-shadow: 0 0 20px 4px rgba(127, 207, 227, .22);
  opacity: 0; transition: all .3s ease; transition-delay: 1s; cursor: default;
}
.fan__card .icon { width: 2rem; height: 2rem; color: var(--sand); margin-bottom: auto; stroke-width: 1.5; }
.fan__card h3 { font-size: 1.02rem; }
.fan__card p { font-size: .82rem; color: #b9c8de; line-height: 1.55; opacity: 0; max-height: 0; transition: all .3s ease; }
.fan__card:hover { box-shadow: 0 0 30px 10px rgba(242, 184, 75, .3); border-color: var(--sand); }
.fan__card:hover p { opacity: 1; max-height: 6rem; }
.fan:hover .fan__card, .fan:focus-within .fan__card { opacity: 1; transition-delay: 0s; }
.fan__card--c { opacity: 1; z-index: 2; }
.fan__card--l1 { transform: translateX(-30px) translateZ(-25px) rotateY(-5deg); }
.fan__card--l2 { transform: translateX(-60px) translateZ(-50px) rotateY(-10deg); }
.fan__card--r1 { transform: translateX(30px) translateZ(-25px) rotateY(5deg); }
.fan__card--r2 { transform: translateX(60px) translateZ(-50px) rotateY(10deg); }
.fan__hint { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--font-head); font-size: 1.2rem; color: #fff; background: radial-gradient(circle at 50% 0, #3a56a0, #1c2d63); border-radius: 12px; transition: opacity .6s ease; pointer-events: none; }
.fan:hover .fan__hint, .fan:focus-within .fan__hint { opacity: 0; }
.foot-pub { padding: 1.5rem; text-align: center; color: var(--muted); font-size: .88rem; border-top: 1px solid var(--line); background: var(--bg); }

/* ═════════ هيكل لوحة الإدارة ═════════ */
.shell { display: grid; grid-template-columns: 260px minmax(0, 1fr); min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; background: var(--surface); border-inline-end: 1px solid var(--line); padding: 1.1rem .9rem; display: flex; flex-direction: column; gap: 1.2rem; z-index: 50; }
.side .brand { padding-inline: .4rem; }
.nav { display: grid; gap: .25rem; }
.nav a {
  display: flex; align-items: center; gap: .7rem; padding: .6rem .8rem; border-radius: var(--r-ctl); color: var(--muted); text-decoration: none; font-weight: 500; transition: background .15s, color .15s;
}
.nav a:hover { background: var(--surface2); color: var(--text); }
.nav a[aria-current="page"] { background: color-mix(in srgb, var(--sand) 16%, transparent); color: var(--accent-text); box-shadow: inset 3px 0 0 var(--sand); }
[dir="rtl"] .nav a[aria-current="page"] { box-shadow: inset -3px 0 0 var(--sand); }
.side__foot { margin-top: auto; display: grid; gap: .6rem; padding: .8rem; border: 1px solid var(--line); border-radius: var(--r-box); background: var(--bg2); }
.side__foot b { display: block; font-size: .95rem; }
.side__foot small { color: var(--muted); }
.main { min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem clamp(1rem, 3vw, 2rem); border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(6px); position: sticky; top: 0; z-index: 40; }
.topbar h1 { font-size: 1.35rem; }
.topbar__actions { display: flex; gap: .5rem; align-items: center; }
.menu-btn { display: none; }
.page { padding: clamp(1rem, 3vw, 2rem); display: grid; gap: 1.4rem; max-width: 1400px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-box); }
.panel__head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .9rem 1.1rem; border-bottom: 1px solid var(--line); }
.panel__head h2 { font-size: 1rem; }
.panel__body { padding: 1.1rem; }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); }
.kpi { padding: 1.1rem 1.3rem; display: grid; gap: .1rem; }
.kpi + .kpi { border-inline-start: 1px solid var(--line); }
.kpi b { font-family: var(--font-head); font-size: 1.9rem; font-weight: 600; line-height: 1.2; }
.kpi span { color: var(--muted); font-size: .9rem; }
.kpi small { color: var(--muted); font-size: .8rem; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 1.4rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.4rem; }

.toolbar { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
.toolbar .grow { flex: 1 1 220px; position: relative; }
.toolbar .grow .icon { position: absolute; inset-inline-start: .75rem; top: 50%; transform: translateY(-50%); color: var(--muted); }
.toolbar .grow .input { padding-inline-start: 2.4rem; }
.toolbar select.input { width: auto; min-width: 9rem; }
.spacer { flex: 1; }

.table-wrap { overflow: auto; border-radius: var(--r-box); border: 1px solid var(--line); background: var(--surface); }
.table { width: 100%; border-collapse: collapse; font-size: .93rem; }
.table th, .table td { padding: .65rem .9rem; text-align: start; white-space: nowrap; }
.table thead th { position: sticky; top: 0; background: var(--surface2); color: var(--muted); font-weight: 600; font-size: .84rem; border-bottom: 1px solid var(--line); }
.table th.sortable { cursor: pointer; user-select: none; }
.table th.sortable:hover { color: var(--text); }
.table tbody tr { border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent); transition: background .12s; }
.table tbody tr:last-child { border-bottom: 0; }
.table tbody tr:hover { background: color-mix(in srgb, var(--surface2) 70%, transparent); }
.table .actions { display: flex; gap: .3rem; justify-content: flex-end; }
.table td.name { font-weight: 600; white-space: normal; min-width: 11rem; }
.table .muted, .muted { color: var(--muted); }
.table--tight th, .table--tight td { padding: .5rem .7rem; }
.empty { padding: 2.2rem 1rem; text-align: center; color: var(--muted); }
.empty b { display: block; color: var(--text); margin-bottom: .2rem; font-family: var(--font-head); }

.mark-input { width: 4.6rem; padding: .3rem .4rem; text-align: center; font-family: var(--font-head); direction: ltr; }
.mark-input.is-bad { border-color: var(--bad); }
tr.saved { animation: saved 1.1s ease; }
@keyframes saved { 0% { background: color-mix(in srgb, var(--ok) 28%, transparent); } 100% { background: transparent; } }
.statline { display: flex; flex-wrap: wrap; gap: 1.6rem; padding: .9rem 1.1rem; }
.statline div { display: grid; }
.statline b { font-family: var(--font-head); font-size: 1.25rem; }
.statline span { color: var(--muted); font-size: .84rem; }

/* ═════════ الرسوم البيانية ═════════ */
.columns { display: flex; align-items: flex-end; gap: .55rem; height: 210px; padding-top: 1.4rem; }
.columns .col { flex: 1; display: grid; grid-template-rows: auto 1fr auto; height: 100%; text-align: center; gap: .25rem; min-width: 0; }
.columns .bar-slot { display: flex; align-items: flex-end; }
.columns .bar { width: 100%; border-radius: 6px 6px 0 0; background: var(--c, var(--glass)); height: 0; transition: height .8s cubic-bezier(.2, .8, .2, 1); min-height: 2px; }
.columns .val { font-family: var(--font-head); font-size: .8rem; color: var(--muted); }
.columns .lab { font-size: .8rem; font-weight: 600; }
.hbars { display: grid; gap: .55rem; }
.hbar { display: grid; grid-template-columns: minmax(8rem, 12rem) 1fr 3.2rem; gap: .7rem; align-items: center; font-size: .88rem; }
.hbar .lab { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar .track { height: .7rem; background: var(--surface2); border-radius: 99px; overflow: hidden; }
.hbar .fill { display: block; height: 100%; width: 0; border-radius: 99px; background: var(--c, var(--glass)); transition: width .9s cubic-bezier(.2, .8, .2, 1); }
.hbar .v { font-family: var(--font-head); text-align: end; direction: ltr; }
.donut-row { display: flex; align-items: center; gap: 1.4rem; flex-wrap: wrap; }
.donut { width: 150px; height: 150px; flex: none; }
.legend { display: grid; gap: .4rem; font-size: .88rem; }
.legend li { display: flex; align-items: center; gap: .5rem; }
.legend i { width: .7rem; height: .7rem; border-radius: 3px; background: var(--c); flex: none; }
.legend .tnum { margin-inline-start: auto; color: var(--muted); }
.linechart { width: 100%; height: auto; overflow: visible; }
.linechart text { font-family: var(--font-head); font-size: 11px; fill: var(--muted); }
.linechart .grid { stroke: var(--line); stroke-width: 1; }
.linechart .ln { fill: none; stroke: var(--sand); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw 1.1s ease forwards; }
.linechart .dot { fill: var(--bg2); stroke: var(--sand); stroke-width: 2.5; }
@keyframes draw { to { stroke-dashoffset: 0; } }

.rank-list { display: grid; }
.rank-list li { display: flex; align-items: center; gap: .8rem; padding: .6rem 0; border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent); }
.rank-list li:last-child { border-bottom: 0; }
.rank-list .pos { width: 1.8rem; height: 1.8rem; border-radius: 50%; display: grid; place-items: center; background: var(--surface2); font-family: var(--font-head); font-size: .82rem; flex: none; }
.rank-list li:first-child .pos { background: var(--sand); color: var(--on-sand); }
.rank-list .who { flex: 1; min-width: 0; }
.rank-list .who b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-list .who small { color: var(--muted); }
.feed { display: grid; }
.feed li { display: grid; grid-template-columns: auto 1fr; gap: .2rem .7rem; padding: .55rem 0; border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent); font-size: .9rem; }
.feed li:last-child { border-bottom: 0; }
.feed i { width: .55rem; height: .55rem; border-radius: 50%; background: var(--sand); margin-top: .55rem; }
.feed small { grid-column: 2; color: var(--muted); }

/* ═════════ بوابة الطالب ═════════ */
.s-top { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .9rem clamp(1rem, 4vw, 2.5rem); border-bottom: 1px solid var(--line); background: var(--surface); position: sticky; top: 0; z-index: 40; }
.s-top .who { display: flex; align-items: center; gap: .8rem; }
.s-page { max-width: 1100px; margin-inline: auto; padding: clamp(1rem, 3vw, 2rem); display: grid; gap: 1.4rem; }
.s-hero { display: grid; grid-template-columns: auto 1fr; gap: clamp(1.2rem, 4vw, 2.5rem); align-items: center; padding: clamp(1.2rem, 3vw, 1.8rem); }
.ring { position: relative; width: 168px; height: 168px; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring .bg { fill: none; stroke: var(--surface2); stroke-width: 12; }
.ring .fg { fill: none; stroke: var(--sand); stroke-width: 12; stroke-linecap: round; transition: stroke-dashoffset 1.3s cubic-bezier(.2, .8, .2, 1); }
.ring__txt { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.ring__txt b { font-family: var(--font-head); font-size: 2.3rem; line-height: 1; }
.ring__txt span { color: var(--muted); font-size: .82rem; margin-top: .25rem; }
.s-id h1 { font-size: clamp(1.4rem, 3vw, 1.9rem); }
.s-meta { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .6rem; }
.s-meta .chip { --c: var(--muted); }
.s-stats { display: flex; flex-wrap: wrap; gap: .5rem 2rem; margin-top: 1.1rem; }
.s-stats div { display: grid; }
.s-stats b { font-family: var(--font-head); font-size: 1.4rem; font-weight: 600; }
.s-stats span { color: var(--muted); font-size: .85rem; }
.tabs { display: flex; flex-wrap: wrap; gap: .4rem; }
.tab { padding: .45rem .95rem; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-size: .9rem; font-weight: 500; transition: all .15s; }
.tab:hover { border-color: var(--muted); }
.tab[aria-selected="true"] { background: var(--sand); color: var(--on-sand); border-color: transparent; font-weight: 600; }
.course { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.6fr) auto; gap: 1.2rem; align-items: center; padding: 1rem 1.2rem; }
.course + .course { border-top: 1px solid var(--line); }
.course h3 { font-size: 1rem; }
.course .code { color: var(--muted); font-size: .84rem; }
.meter { position: relative; display: grid; grid-template-columns: 20fr 20fr 60fr; gap: 3px; }
.meter .seg { position: relative; height: .7rem; background: var(--surface2); border-radius: 4px; overflow: hidden; }
.meter .seg i { position: absolute; inset-block: 0; inset-inline-start: 0; width: 0; background: var(--c); transition: width .9s cubic-bezier(.2, .8, .2, 1); }
.meter .seg:nth-child(1) { --c: var(--info); } .meter .seg:nth-child(2) { --c: #8a9cf0; } .meter .seg:nth-child(3) { --c: var(--sand); }
.meter__avg { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--text); opacity: .7; border-radius: 2px; }
.meter__nums { display: flex; justify-content: space-between; margin-top: .35rem; font-size: .78rem; color: var(--muted); gap: .5rem; flex-wrap: wrap; }
.course__score { display: flex; align-items: center; gap: .7rem; justify-content: flex-end; min-width: 8rem; }
.course__score b { font-family: var(--font-head); font-size: 1.5rem; font-weight: 600; }
.pending { color: var(--muted); font-size: .88rem; }
.legend-inline { display: flex; flex-wrap: wrap; gap: .4rem 1.2rem; font-size: .8rem; color: var(--muted); padding: .7rem 1.2rem; border-top: 1px solid var(--line); }
.legend-inline i { display: inline-block; width: .6rem; height: .6rem; border-radius: 2px; margin-inline-end: .35rem; background: var(--c); }
.calc-row { display: grid; grid-template-columns: 1fr 5rem 6.5rem auto; gap: .5rem; align-items: center; margin-bottom: .5rem; }
.calc-out { display: flex; align-items: baseline; gap: .6rem; margin-top: .9rem; padding-top: .9rem; border-top: 1px dashed var(--line); }
.calc-out b { font-family: var(--font-head); font-size: 1.8rem; color: var(--accent-text); }

/* ═════════ طباعة كشف الدرجات ═════════ */
#print-root { display: none; }
@media print {
  body.printing { background: #fff; color: #000; }
  body.printing #app, body.printing .overlay, body.printing .toasts, body.printing .loader { display: none !important; }
  body.printing #print-root { display: block; padding: 0; color: #000; font-family: var(--font-body); }
  #print-root h1 { font-size: 20pt; } #print-root h2 { font-size: 13pt; margin: 16pt 0 6pt; }
  #print-root table { width: 100%; border-collapse: collapse; font-size: 10.5pt; }
  #print-root th, #print-root td { border: 1px solid #888; padding: 4pt 7pt; text-align: start; }
  #print-root th { background: #eee; }
  #print-root .pr-head { display: flex; justify-content: space-between; border-bottom: 2px solid #000; padding-bottom: 8pt; margin-bottom: 10pt; }
}

/* ═════════ استجابة الشاشات ═════════ */
@media (max-width: 1000px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset-block: 0; inset-inline-start: 0; width: 270px; transform: translateX(100%); transition: transform .25s ease; box-shadow: var(--shadow); }
  [dir="ltr"] .side { transform: translateX(-100%); }
  .shell.nav-open .side { transform: none; }
  .menu-btn { display: inline-grid; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .kpi:nth-child(3) { border-inline-start: 0; }
  .kpi:nth-child(n+3) { border-top: 1px solid var(--line); }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .hero__grid { grid-template-columns: 1fr; padding-bottom: 2.5rem; }
  .fan { transform: none; perspective: none; display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .9rem; width: 100%; }
  .fan__card, .fan__card--l1, .fan__card--l2, .fan__card--r1, .fan__card--r2 { transform: none; opacity: 1; width: auto; height: auto; min-height: 150px; }
  .fan__card p { opacity: 1; max-height: none; }
  .fan__hint { display: none; }
  .fan-wrap { min-height: 0; }
  .course { grid-template-columns: 1fr; gap: .8rem; }
  .course__score { justify-content: flex-start; }
  .s-hero { grid-template-columns: 1fr; justify-items: center; text-align: center; }
  .s-meta, .s-stats { justify-content: center; }
}
@media (max-width: 560px) {
  .form-grid { grid-template-columns: 1fr; }
  .hbar { grid-template-columns: 1fr 3rem; } .hbar .track { grid-column: 1 / -1; order: 3; }
  .calc-row { grid-template-columns: 1fr 4rem 5.5rem auto; }
  .kpi b { font-size: 1.5rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; transition-delay: 0s !important; }
  .fan__card { opacity: 1; }
}
