/* نظام إدارة حصص الاحتياط — الهوية البصرية
   الفكرة: "شريط الحصص" — ثماني خانات تمثل يوم المدرسة، تتكرر في كل الشاشات. */

:root {
  --ink: #13201E;
  --ink-2: #3D4C49;
  --muted: #64736F;
  --paper: #F3F5F4;
  --surface: #FFFFFF;
  --surface-2: #F8FAF9;
  --line: #D9E1DE;
  --line-strong: #B9C6C2;
  --teal-900: #0F3D3A;
  --teal-800: #144B47;
  --teal-700: #1B5E58;
  --teal-500: #2F8178;
  --teal-100: #DDEDEA;
  --teal-50: #EEF6F4;
  --amber: #E3A33B;
  --amber-ink: #8A5A0B;
  --amber-bg: #FBF0DC;
  --green: #23845A;
  --green-bg: #E1F2E9;
  --red: #B83A2E;
  --red-bg: #F8E3E0;
  --focus: #E3A33B;
  --radius-s: 8px;
  --radius-m: 12px;
  --radius-l: 18px;
  --shadow: 0 1px 0 rgba(19, 32, 30, .04), 0 8px 24px -16px rgba(15, 61, 58, .35);
  --font: 'Tajawal', 'Segoe UI', Tahoma, sans-serif;
  --font-head: 'Cairo', 'Tajawal', 'Segoe UI', Tahoma, sans-serif;
  --nav-w: 248px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--paper);
  font-feature-settings: 'tnum' 1;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--teal-700); }
h1, h2, h3, h4 { margin: 0; line-height: 1.35; font-weight: 700; font-family: var(--font-head); }
.figure b, .t-summary b, .login-brand .school, .nav .brand b, .assign-card .cls, .mobile-top b, .t-top b, .lesson-row .lp b { font-family: var(--font-head); }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ------------------------------------------------------------ التحميل */
.boot { min-height: 100dvh; display: grid; place-items: center; gap: 16px; align-content: center; color: var(--teal-900); }
.boot-rail { display: flex; gap: 5px; direction: rtl; }
.boot-rail i { width: 12px; height: 28px; border-radius: 4px; background: var(--teal-100); animation: bell 1.6s infinite; }
.boot-rail i:nth-child(2) { animation-delay: .1s } .boot-rail i:nth-child(3) { animation-delay: .2s }
.boot-rail i:nth-child(4) { animation-delay: .3s } .boot-rail i:nth-child(5) { animation-delay: .4s }
.boot-rail i:nth-child(6) { animation-delay: .5s } .boot-rail i:nth-child(7) { animation-delay: .6s }
.boot-rail i:nth-child(8) { animation-delay: .7s }
@keyframes bell { 0%, 100% { background: var(--teal-100) } 20% { background: var(--amber) } }

/* --------------------------------------------------------- تسجيل الدخول */
.login {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
}
.login-brand {
  background: var(--teal-900);
  color: #EAF3F1;
  padding: 56px 56px 40px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}
.brand-logo { display: block; width: 112px; height: 112px; border-radius: 50%; background: #fff; padding: 3px; margin-bottom: 22px; box-shadow: 0 6px 20px -8px rgba(0, 0, 0, .45); }
.nav .brand img { display: block; width: 56px; height: 56px; border-radius: 50%; background: #fff; padding: 2px; margin-bottom: 12px; }
.head-id { display: flex; align-items: center; gap: 10px; min-width: 0; }
.mini-logo { width: 32px; height: 32px; border-radius: 50%; background: #fff; flex: none; }
.t-top .mini-logo { width: 44px; height: 44px; box-shadow: 0 0 0 1px var(--line); }
.login-brand .school { font-size: clamp(2rem, 3.4vw, 2.9rem); font-weight: 700; line-height: 1.2; letter-spacing: -.01em; }
.login-brand .system { margin-top: 10px; font-size: 1.15rem; font-weight: 300; color: #B9D6D1; }
.login-brand .place { font-size: .9rem; color: #8FB3AD; }
.timetable-art {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px;
  direction: rtl;
  margin: 40px 0;
  max-width: 440px;
}
.timetable-art span { aspect-ratio: 1 / 1.25; border-radius: 6px; background: rgba(234, 243, 241, .08); }
.timetable-art span.on { background: rgba(234, 243, 241, .22); }
.timetable-art span.sub { background: var(--amber); }
.login-form-wrap { display: grid; place-items: center; padding: 40px 24px; }
.login-form { width: 100%; max-width: 380px; }
.login-form h2 { font-size: 1.5rem; margin-bottom: 6px; }
.login-form .lede { color: var(--muted); margin-bottom: 28px; }

/* ------------------------------------------------------------ النماذج */
.field { display: grid; gap: 6px; margin-bottom: 16px; }
.field label { font-weight: 500; font-size: .92rem; }
.field .hint { font-size: .82rem; color: var(--muted); }
.input, .select, textarea.input {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-m);
  background: var(--surface);
  min-height: 48px;
  transition: border-color .15s;
}
.input:focus, .select:focus { border-color: var(--teal-500); outline: none; box-shadow: 0 0 0 3px var(--teal-100); }
.input[aria-invalid="true"] { border-color: var(--red); }
.input.ltr { direction: ltr; text-align: right; letter-spacing: .04em; }
.pw { position: relative; }
.pw .input { padding-inline-start: 48px; }
.pw button {
  position: absolute; inset-inline-start: 4px; top: 50%; transform: translateY(-50%);
  width: 40px; height: 40px; border: 0; background: transparent; border-radius: 8px; cursor: pointer; color: var(--muted);
  display: grid; place-items: center;
}
.pw button:hover { color: var(--teal-700); background: var(--teal-50); }
.form-error {
  background: var(--red-bg); color: var(--red); border-radius: var(--radius-m);
  padding: 10px 14px; margin-bottom: 16px; font-size: .9rem;
}
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.check input { width: 20px; height: 20px; margin-top: 3px; accent-color: var(--teal-700); }

/* ------------------------------------------------------------ الأزرار */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 18px;
  border-radius: var(--radius-m); border: 1.5px solid transparent;
  background: var(--teal-800); color: #fff; font-weight: 500; cursor: pointer;
  text-decoration: none; white-space: nowrap;
  transition: background .15s, transform .05s;
}
.btn:hover { background: var(--teal-700); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn.block { width: 100%; min-height: 52px; font-size: 1.02rem; }
.btn.ghost { background: transparent; color: var(--teal-800); border-color: var(--line-strong); }
.btn.ghost:hover { background: var(--teal-50); }
.btn.quiet { background: transparent; color: var(--teal-800); padding-inline: 10px; }
.btn.quiet:hover { background: var(--teal-50); }
.btn.amber { background: var(--amber); color: #2B1B00; }
.btn.amber:hover { background: #D89526; }
.btn.danger { background: transparent; color: var(--red); border-color: #E6B9B3; }
.btn.danger:hover { background: var(--red-bg); }
.btn.sm { min-height: 36px; padding: 6px 12px; font-size: .88rem; border-radius: var(--radius-s); }
.btn .spin { width: 16px; height: 16px; border: 2px solid currentColor; border-top-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg) } }
.icon { width: 20px; height: 20px; flex: none; }

/* --------------------------------------------------------- الهيكل العام */
.shell { display: grid; grid-template-columns: var(--nav-w) minmax(0, 1fr); min-height: 100dvh; }
.nav {
  background: var(--teal-900);
  color: #D6E7E4;
  padding: 22px 14px;
  position: sticky; top: 0; height: 100dvh;
  display: flex; flex-direction: column; gap: 4px;
}
.nav .brand { padding: 4px 10px 22px; }
.nav .brand b { display: block; font-size: 1.02rem; color: #fff; font-weight: 600; }
.nav .brand span { font-size: .8rem; color: #8FB3AD; }
.nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 10px;
  color: #CFE2DE; text-decoration: none; font-size: .95rem;
}
.nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav a[aria-current="page"] { background: #F3F5F4; color: var(--teal-900); font-weight: 600; }
.nav .grow { flex: 1; }
.nav .who { border-top: 1px solid rgba(255, 255, 255, .1); padding: 14px 10px 0; font-size: .85rem; color: #9FC1BB; }
.nav .who button { margin-top: 8px; color: #fff; border-color: rgba(255, 255, 255, .25); }
.nav .who button:hover { background: rgba(255, 255, 255, .08); }
.nav .badge { margin-inline-start: auto; background: var(--amber); color: #2B1B00; border-radius: 999px; font-size: .75rem; padding: 0 8px; font-weight: 600; }

.shell > div { min-width: 0; }
.main { padding: 28px clamp(16px, 3vw, 40px) 96px; min-width: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head p { color: var(--muted); margin-top: 4px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }

.mobile-top, .tabbar { display: none; }

/* --------------------------------------------------------- الأسطح */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-l); padding: 20px; }
.panel + .panel { margin-top: 16px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.stack { display: grid; gap: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.divider { height: 1px; background: var(--line); margin: 16px 0; }

/* أرقام لوحة التحكم: سطر واحد مقسوم، وليس بطاقات متطابقة */
.figures {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  overflow: hidden;
}
.figure { padding: 16px 18px; border-inline-start: 1px solid var(--line); }
.figure:first-child { border-inline-start: 0; }
.figure b { display: block; font-size: 1.9rem; font-weight: 600; line-height: 1.1; }
.figure span { font-size: .82rem; color: var(--muted); }
.figure.warn b { color: var(--amber-ink); }
.figure.ok b { color: var(--green); }

/* ------------------------------------------------------ شريط الحصص */
.rail { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 6px; }
.rail .slot {
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  padding: 8px 6px 10px;
  min-height: 74px;
  display: flex; flex-direction: column; gap: 2px;
  text-align: center; font-size: .8rem;
  position: relative;
}
.rail .slot .p { font-size: .72rem; color: var(--muted); }
.rail .slot .v { font-weight: 600; font-size: .95rem; }
.rail .slot .t { font-size: .7rem; color: var(--muted); }
.rail .slot.lesson { background: var(--teal-50); border-color: var(--teal-100); }
.rail .slot.sub { background: var(--amber-bg); border-color: #EBC783; }
.rail .slot.sub .v { color: var(--amber-ink); }
.rail .slot.done { background: var(--green-bg); border-color: #B5DCC6; }
.rail .slot.need { background: #fff; border: 2px dashed var(--amber); }
.rail .slot.now::after {
  content: ''; position: absolute; inset-inline: 10px; bottom: -6px; height: 3px; border-radius: 3px; background: var(--teal-700);
}
button.slot { cursor: pointer; font: inherit; }
.rail.day { grid-template-columns: .5fr repeat(4, minmax(0, 1fr)) .5fr repeat(4, minmax(0, 1fr)); }
.rail .brk {
  border-radius: 10px; display: grid; place-items: center; font-size: .72rem; color: var(--muted);
  writing-mode: vertical-rl; text-orientation: mixed;
  background: repeating-linear-gradient(45deg, transparent 0 5px, rgba(15, 61, 58, .06) 5px 10px);
  border: 1px dashed var(--line-strong); min-height: 62px;
}
.rail .brk.empty { visibility: hidden; }
.t-hero .rail .brk { color: #9FC1BB; border-color: rgba(255, 255, 255, .18); background: repeating-linear-gradient(45deg, transparent 0 5px, rgba(255, 255, 255, .06) 5px 10px); }
.ptime { font-size: .62rem; color: var(--muted); font-weight: 400; }
table.t.bell tr.non-teaching td { background: var(--surface-2); color: var(--muted); }
table.t.bell tr.non-teaching td:first-child { font-style: normal; }
button.slot[aria-pressed="true"] { outline: 3px solid var(--teal-700); outline-offset: 1px; }

/* ------------------------------------------------------- الحالة */
.status { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 12px; border-radius: 999px; font-size: .8rem; font-weight: 500; white-space: nowrap; }
.status::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.status.pending { background: var(--amber-bg); color: var(--amber-ink); }
.status.acknowledged { background: var(--green-bg); color: var(--green); }
.status.overdue { background: var(--red-bg); color: var(--red); }
.status.cancelled { background: #ECEFEE; color: var(--muted); }

/* ------------------------------------------------------- الجداول */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-m); background: var(--surface); }
table.t { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.t th { text-align: right; font-weight: 500; color: var(--muted); font-size: .8rem; background: var(--surface-2); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.t td { white-space: nowrap; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; }
table.t tr.click { cursor: pointer; }
table.t tr.click:hover td { background: var(--teal-50); }

/* شبكة الجدول الأسبوعي */
.tt { border-collapse: separate; border-spacing: 3px; width: 100%; font-size: .82rem; }
.tt th { font-weight: 500; color: var(--muted); padding: 4px; font-size: .78rem; }
.tt th.day { text-align: right; padding-inline-end: 10px; color: var(--ink-2); white-space: nowrap; }
.tt td { text-align: center; border-radius: 6px; height: 34px; min-width: 42px; background: var(--surface-2); border: 1px solid var(--line); }
.tt td.on { background: var(--teal-50); border-color: var(--teal-100); font-weight: 500; }
.tt td.sub { background: var(--amber-bg); border-color: #EBC783; color: var(--amber-ink); font-weight: 600; }
.tt td.bad { background: var(--red-bg); border-color: #E6B9B3; color: var(--red); font-weight: 600; }
.tt td input { width: 100%; height: 30px; border: 0; background: transparent; text-align: center; direction: ltr; font: inherit; border-radius: 5px; }
.tt td input:focus { background: #fff; outline: 2px solid var(--teal-500); }

/* الجدول العام الكثيف */
.big-tt { font-size: .74rem; border-collapse: collapse; }
.big-tt th, .big-tt td { border: 1px solid var(--line); padding: 2px 4px; text-align: center; min-width: 34px; height: 26px; }
.big-tt th.name, .big-tt td.name { text-align: right; position: sticky; right: 0; background: var(--surface); z-index: 1; min-width: 150px; white-space: nowrap; }
.big-tt thead th { background: var(--surface-2); position: sticky; top: 0; z-index: 2; }
.big-tt thead th.name { z-index: 3; }
.big-tt td.on { background: var(--teal-50); }
.big-tt td.free { color: transparent; }
.big-tt td.bad { background: var(--red-bg); color: var(--red); font-weight: 600; }
.big-tt .daysep { border-inline-start: 2px solid var(--line-strong); }
.big-tt td input { width: 40px; border: 0; background: transparent; text-align: center; direction: ltr; font: inherit; }

/* ------------------------------------------------------- بطاقات التكليف */
.assign-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  padding: 18px;
  display: grid;
  gap: 12px;
  border-inline-start: 5px solid var(--amber);
}
.assign-card.acknowledged { border-inline-start-color: var(--green); }
.assign-card.overdue { border-inline-start-color: var(--red); }
.assign-card.cancelled { border-inline-start-color: var(--line-strong); opacity: .75; }
.assign-card .top { display: flex; justify-content: space-between; align-items: flex-start; gap: 6px 10px; flex-wrap: wrap; }
.assign-card .cls { font-size: 1.35rem; font-weight: 600; }
.assign-card dl { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 0; }
.assign-card dt { font-size: .76rem; color: var(--muted); }
.assign-card dd { margin: 0; font-weight: 500; }
.assign-card .foot { font-size: .82rem; color: var(--muted); }

/* ------------------------------------------------------- قائمة المرشحين */
.cand { display: grid; gap: 6px; }
.cand label {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: center;
  padding: 10px 12px; border: 1.5px solid var(--line); border-radius: var(--radius-m); background: var(--surface); cursor: pointer;
}
.cand label:hover { border-color: var(--teal-500); }
.cand label:has(input:checked) { border-color: var(--teal-700); background: var(--teal-50); }
.cand input { width: 18px; height: 18px; accent-color: var(--teal-700); }
.cand .load { font-size: .8rem; color: var(--muted); text-align: left; }
.cand .tag { font-size: .72rem; background: var(--teal-900); color: #fff; padding: 1px 8px; border-radius: 999px; margin-inline-start: 6px; }
.cand .noacc { font-size: .72rem; color: var(--amber-ink); }
.unavail { font-size: .85rem; color: var(--muted); }
.unavail .cand { margin-top: 6px; color: var(--ink); }
.send-bar { margin-top: 16px; position: sticky; bottom: 12px; z-index: 5; }
.send-bar p { background: var(--paper); border-radius: 8px; padding: 2px 8px; width: fit-content; margin-inline: auto; }
.unavail summary { cursor: pointer; padding: 6px 0; }
.unavail li { padding: 2px 0; }

.lesson-row {
  display: grid; grid-template-columns: 90px minmax(0, 1fr); gap: 16px;
  padding: 16px 0; border-top: 1px solid var(--line);
}
.lesson-row:first-of-type { border-top: 0; }
.lesson-row .lp b { display: block; font-size: 1.05rem; }
.lesson-row .lp span { font-size: .8rem; color: var(--muted); }

/* ------------------------------------------------------- عناصر عامة */
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1.5px solid var(--line); background: var(--surface); border-radius: 999px;
  padding: 6px 14px; cursor: pointer; font-size: .88rem; min-height: 36px;
}
a.chip { color: var(--ink); text-decoration: none; display: inline-flex; align-items: center; }
.chip[aria-pressed="true"] { background: var(--teal-900); color: #fff; border-color: var(--teal-900); }
.empty { text-align: center; padding: 36px 16px; color: var(--muted); }
.empty b { display: block; color: var(--ink); font-size: 1.05rem; margin-bottom: 6px; }
.note { background: var(--teal-50); border: 1px solid var(--teal-100); border-radius: var(--radius-m); padding: 12px 14px; font-size: .9rem; }
.note.warn { background: var(--amber-bg); border-color: #EBC783; }
.note.err { background: var(--red-bg); border-color: #E6B9B3; color: #7A2219; }
.issues { max-height: 320px; overflow: auto; }
.issues li { padding: 4px 0; font-size: .88rem; }
.issues li.error { color: var(--red); }
.issues li.warning { color: var(--amber-ink); }
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 16px; font-size: .92rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px; }
.filters .field { margin: 0; min-width: 150px; }
.filters .input, .filters .select { min-height: 42px; padding: 8px 12px; }
.bar-list { display: grid; gap: 8px; }
.bar-list .b { display: grid; grid-template-columns: 160px minmax(0, 1fr) 36px; gap: 10px; align-items: center; font-size: .86rem; }
.bar-list .b i { display: block; height: 12px; background: var(--teal-500); border-radius: 6px; min-width: 2px; }
.bar-list .b span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ------------------------------------------------------- النوافذ والتنبيهات */
dialog.modal {
  border: 0; border-radius: var(--radius-l); padding: 0; width: min(560px, calc(100vw - 24px));
  max-height: calc(100dvh - 32px); box-shadow: 0 24px 60px -20px rgba(15, 61, 58, .5); color: var(--ink);
}
dialog.modal::backdrop { background: rgba(15, 30, 28, .45); }
dialog.modal .m-head { padding: 18px 20px 0; }
dialog.modal .m-body { padding: 16px 20px; overflow: auto; max-height: calc(100dvh - 180px); }
dialog.modal .m-foot { padding: 12px 20px 18px; display: flex; gap: 8px; justify-content: flex-start; flex-wrap: wrap; border-top: 1px solid var(--line); }
.toasts { position: fixed; inset-inline: 0; bottom: 20px; display: grid; justify-items: center; gap: 8px; z-index: 50; pointer-events: none; padding: 0 12px; }
.toast {
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: var(--radius-m);
  box-shadow: var(--shadow); max-width: 520px; pointer-events: auto; font-size: .92rem;
  animation: toast-in .2s ease-out;
}
.toast.ok { background: var(--green); }
.toast.err { background: var(--red); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px) } }

/* ------------------------------------------------------- واجهة المعلم */
.teacher { max-width: 760px; margin: 0 auto; padding: 0 16px 100px; }
.t-top { display: flex; align-items: center; justify-content: space-between; padding: 16px 0; gap: 10px; }
.t-top .who { font-size: .85rem; color: var(--muted); }
.t-hero {
  background: var(--teal-900); color: #EAF3F1; border-radius: 22px; padding: 22px 20px 20px; margin-bottom: 18px;
}
.t-hero h1 { font-size: 1.45rem; font-weight: 600; color: #fff; }
.t-hero .date { color: #9FC1BB; font-size: .9rem; margin-top: 2px; }
.t-hero .rail { margin-top: 18px; gap: 5px; }
.t-hero .rail .slot { background: rgba(255, 255, 255, .06); border-color: rgba(255, 255, 255, .08); color: #DCEBE8; min-height: 64px; }
.t-hero .rail .slot .p, .t-hero .rail .slot .t { color: #8FB3AD; }
.t-hero .rail .slot.lesson { background: rgba(255, 255, 255, .16); }
.t-hero .rail .slot.sub { background: var(--amber); border-color: var(--amber); color: #2B1B00; }
.t-hero .rail .slot.sub .p, .t-hero .rail .slot.sub .t, .t-hero .rail .slot.sub .v { color: #2B1B00; }
.t-hero .legend { display: flex; gap: 14px; margin-top: 12px; font-size: .78rem; color: #9FC1BB; }
.t-hero .legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-inline-end: 6px; vertical-align: -1px; }
.t-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 18px; }
.t-summary div { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 12px 14px; }
.t-summary b { display: block; font-size: 1.5rem; line-height: 1.2; }
.t-summary span { font-size: .78rem; color: var(--muted); }
.t-section { margin: 22px 0 10px; display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.bell { position: relative; }
.bell .dot { position: absolute; top: 6px; inset-inline-end: 6px; width: 9px; height: 9px; background: var(--amber); border-radius: 50%; border: 2px solid var(--paper); }
.notif-item { padding: 12px 0; border-bottom: 1px solid var(--line); }
.notif-item.unread b::after { content: ''; display: inline-block; width: 7px; height: 7px; background: var(--amber); border-radius: 50%; margin-inline-start: 8px; vertical-align: 2px; }
.notif-item p { white-space: pre-line; font-size: .88rem; color: var(--ink-2); margin-top: 4px; }

.ios-steps { margin: 8px 0 0; padding-inline-start: 20px; }
.ios-steps li { padding: 3px 0; }

/* ------------------------------------------------------- الطباعة و PDF */
.print-only { display: none; }
.report-sheet { background: #fff; color: #000; padding: 24px; }
.report-sheet h1 { font-size: 1.3rem; }
.report-sheet table { width: 100%; border-collapse: collapse; font-size: 12px; margin-top: 12px; }
.report-sheet th, .report-sheet td { border: 1px solid #999; padding: 5px 7px; text-align: right; }
.report-sheet th { background: #E8EFED; }

@media print {
  body { background: #fff; }
  .nav, .tabbar, .mobile-top, .page-head .actions, .filters, .no-print { display: none !important; }
  .shell { display: block; }
  .main { padding: 0; }
  .print-only { display: block; }
  .panel { border: 0; padding: 0; }
}

/* ------------------------------------------------------- الشاشات الصغيرة */
@media (max-width: 1180px) {
  .figures { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .figure:nth-child(5) { border-inline-start: 0; }
  .figure:nth-child(n+5) { border-top: 1px solid var(--line); }
}
@media (max-width: 900px) {
  .login { grid-template-columns: 1fr; }
  .login-brand { padding: 32px 24px 28px; }
  .timetable-art { margin: 16px 0 0; max-width: 200px; gap: 3px; }
  .brand-logo { width: 72px; height: 72px; margin-bottom: 12px; }
  .login-brand .place { display: none; }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .nav { display: none; }
  .mobile-top {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 12px 16px; background: var(--teal-900); color: #fff; position: sticky; top: 0; z-index: 10;
  }
  .mobile-top b { font-weight: 600; }
  .mobile-top .btn { color: #fff; }
  .main { padding: 18px 14px 110px; }
  .send-bar { bottom: 72px; }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr);
    position: fixed; bottom: 0; inset-inline: 0; z-index: 20;
    background: var(--surface); border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .tabbar a, .tabbar button {
    display: grid; justify-items: center; gap: 2px; padding: 8px 2px 10px; font-size: .7rem;
    color: var(--muted); text-decoration: none; background: none; border: 0; cursor: pointer;
  }
  .tabbar [aria-current="page"] { color: var(--teal-800); font-weight: 600; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .figures { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .figure { border-inline-start: 0; border-top: 1px solid var(--line); }
  .figure:nth-child(-n+2) { border-top: 0; }
  .figure:nth-child(even) { border-inline-start: 1px solid var(--line); }
  .figure:nth-child(5) { border-inline-start: 0; }
  .figure b { font-size: 1.6rem; }
  .lesson-row { grid-template-columns: 1fr; gap: 10px; }
  .bar-list .b { grid-template-columns: 110px minmax(0, 1fr) 30px; }
  .rail .slot { min-height: 62px; padding: 6px 2px 8px; }
  .rail .slot .t { display: none; }
  table.t.cards thead { display: none; }
  table.t.cards tr { display: grid; grid-template-columns: 1fr auto; padding: 10px 12px; border-bottom: 1px solid var(--line); gap: 2px 10px; }
  table.t.cards td { border: 0; padding: 0; white-space: normal; }
  table.t.cards td[data-l]::before { content: attr(data-l) ': '; color: var(--muted); font-size: .8rem; }
}
@media (max-width: 420px) {
  .hide-sm { display: none; }
  .tt { border-spacing: 2px; }
  .tt td { min-width: 0; height: 30px; font-size: .72rem; }
  .t-hero .rail .slot .v { font-size: .72rem; }
  .tt th.day { padding-inline-end: 4px; font-size: .74rem; }
  .t-top b { font-size: .95rem; }
  .rail { gap: 3px; }
  .rail .slot .v { font-size: .78rem; }
  .assign-card dl { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ------------------------------------------------------- لمسات نهائية */
.panel, .figures, .table-wrap, .assign-card, .t-summary div, .filters:not(.panel .filters) {
  box-shadow: 0 1px 2px rgba(19, 32, 30, .04), 0 6px 18px -14px rgba(15, 61, 58, .35);
}
.main { max-width: 1400px; }
.filters:not(.panel .filters) { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-l); padding: 14px 16px; }
.send-bar {
  display: grid; gap: 6px; padding: 10px; border: 1px solid var(--line); border-radius: 18px;
  background: rgba(243, 245, 244, .94); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  box-shadow: 0 10px 30px -16px rgba(15, 61, 58, .5);
}
.send-bar p { background: none; padding: 0; margin: 0 auto !important; }
.lesson-row .lp b { color: var(--teal-900); }

@media (max-width: 900px) {
  h1 { font-size: 1.4rem; }
  .page-head { margin-bottom: 16px; gap: 12px; }
  .page-head .actions { width: 100%; }
  .page-head .actions .btn { flex: 1 1 auto; }
  .page-head .actions .btn.amber { flex-basis: 100%; }
  .filters .field { flex: 1 1 140px; min-width: 0; }
  .figure { padding: 14px 16px; }
  .figure span { display: block; line-height: 1.35; margin-top: 4px; }
  .figures .figure:last-child:nth-child(odd) { grid-column: 1 / -1; border-inline-start: 0; }

  .tabbar { box-shadow: 0 -6px 18px -12px rgba(15, 61, 58, .35); }
  .tabbar a, .tabbar button { gap: 3px; padding: 6px 2px 8px; }
  .tabbar .icon { width: 44px; height: 28px; padding: 4px 12px; border-radius: 999px; box-sizing: border-box; transition: background .15s; }
  .tabbar [aria-current="page"] .icon { background: var(--teal-100); color: var(--teal-900); }

  /* الجداول تتحول إلى بطاقات مرتبة على الجوال */
  table.t.cards tbody { display: block; }
  table.t.cards tr { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
  table.t.cards tr:last-child { border-bottom: 0; }
  table.t.cards td { border: 0; padding: 0; white-space: normal; }
  table.t.cards td:not([data-l]) { flex: 1 1 100%; }
  table.t.cards td:has(> b) { order: -1; font-size: 1rem; }
  table.t.cards td:has(> input[type=checkbox]) { order: -2; flex: 0 0 auto; }
  table.t.cards tr:has(> td > input[type=checkbox]) td:has(> b) { flex-basis: calc(100% - 40px); }
  table.t.cards td[data-l] { flex: 0 1 auto; font-size: .86rem; color: var(--ink-2); }
  table.t.cards td[data-l]::before { content: attr(data-l) ': '; color: var(--muted); font-size: .76rem; }
  table.t.cards td:has(> .status) { order: 5; flex: 0 0 auto; }
  table.t.cards td:last-child { order: 10; padding-top: 10px; margin-top: 2px; border-top: 1px dashed var(--line); }
  table.t.cards td:last-child:empty { display: none; }
  table.t.cards td:last-child .row { flex-wrap: wrap; gap: 4px; }
  table.t.cards td:last-child .btn { background: var(--surface-2); border: 1px solid var(--line); }

  .lesson-row { gap: 10px; padding: 14px 0; }
  .lesson-row .lp { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; }
  .lesson-row .lp span { display: inline !important; }
  .lesson-row .lp span + span::before { content: '•'; margin-inline-end: 10px; color: var(--line-strong); }
  .send-bar { bottom: 74px; }
}

/* مساحة شريط الحالة في الآيفون (الساعة والبطارية) عند فتح التطبيق من الشاشة الرئيسية */
.t-top { padding-top: calc(16px + env(safe-area-inset-top, 0px)); }
.login-brand { padding-top: calc(56px + env(safe-area-inset-top, 0px)); }
@media (max-width: 900px) {
  .mobile-top { padding-top: calc(12px + env(safe-area-inset-top, 0px)); }
  .login-brand { padding-top: calc(32px + env(safe-area-inset-top, 0px)); }
}

/* ------------------------------------------------------- التقرير الرسمي للطباعة */
#print-root { display: none; }
.rpt { font-family: var(--font); color: #111; font-size: 10.5pt; line-height: 1.55; direction: rtl; }
.rpt-head { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; padding-bottom: 10px; border-bottom: 2.5px solid #0F3D3A; }
.rpt-org { font-size: 9.5pt; line-height: 1.6; }
.rpt-org .rpt-school { font-family: var(--font-head); font-weight: 700; font-size: 11pt; color: #0F3D3A; }
.rpt-logo { width: 84px; height: 84px; object-fit: contain; }
.rpt-meta { font-size: 9pt; text-align: left; line-height: 1.7; }
.rpt-meta span { color: #555; }
.rpt-title { font-family: var(--font-head); text-align: center; font-size: 17pt; margin: 14px 0 2px; color: #0F3D3A; }
.rpt-period { text-align: center; margin: 0 0 12px; color: #333; }
.rpt-stats { display: grid; grid-template-columns: repeat(5, 1fr); border: 1px solid #9DB3AE; border-radius: 6px; overflow: hidden; margin-bottom: 14px; }
.rpt-stats div { text-align: center; padding: 8px 4px; border-inline-start: 1px solid #9DB3AE; background: #F4F8F7; }
.rpt-stats div:first-child { border-inline-start: 0; }
.rpt-stats b { display: block; font-family: var(--font-head); font-size: 15pt; color: #0F3D3A; line-height: 1.2; }
.rpt-stats span { font-size: 8.5pt; color: #444; }
.rpt-h2 { font-family: var(--font-head); font-size: 11.5pt; margin: 14px 0 6px; padding-inline-start: 8px; border-inline-start: 4px solid #E3A33B; }
.rpt-table { width: 100%; border-collapse: collapse; font-size: 9pt; table-layout: auto; }
.rpt-table th, .rpt-table td { border: 1px solid #9DB3AE; padding: 4px 6px; text-align: right; vertical-align: middle; }
.rpt-table th { background: #0F3D3A; color: #fff; font-weight: 600; font-size: 8.8pt; }
.rpt-table tbody tr:nth-child(even) td { background: #F4F8F7; }
.rpt-table .c { text-align: center; }
.rpt-table .nowrap { white-space: nowrap; }
.rpt-table .state.ok { color: #1D7048; font-weight: 600; }
.rpt-table .state.wait { color: #8A5A0B; font-weight: 600; }
.rpt-table .state.late { color: #A3291E; font-weight: 600; }
.rpt-empty { text-align: center !important; color: #666; padding: 14px !important; }
.rpt-sign { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-top: 28px; text-align: center; break-inside: avoid; }
.rpt-sign span { font-family: var(--font-head); font-weight: 600; }
.rpt-sign i { display: block; height: 36px; border-bottom: 1px dotted #555; margin: 4px 16px; }
.rpt-sign i.seal { height: 70px; width: 70px; margin: 6px auto 0; border: 1px dashed #999; border-radius: 50%; }
.rpt-sign small { color: #666; font-size: 8pt; }
.rpt-sign em { display: block; font-style: normal; font-size: 10pt; margin-top: 2px; min-height: 1.4em; }
.rpt-foot { margin-top: 18px; padding-top: 6px; border-top: 1px solid #ccc; font-size: 8pt; color: #666; text-align: center; }

@media print {
  @page { size: A4; margin: 12mm 10mm 12mm; }
  html, body { background: #fff !important; }
  body:has(#print-root > *) > *:not(#print-root) { display: none !important; }
  body:has(#print-root > *) #print-root { display: block; }
  .rpt * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .rpt-table thead { display: table-header-group; }
  .rpt-table tr { break-inside: avoid; }
}