@font-face { font-family: "Ruqaa"; src: url(vendor/fonts/aref-ruqaa-arabic-400.woff2) format("woff2"); font-weight: 400; font-display: swap; unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFF; }
@font-face { font-family: "Ruqaa"; src: url(vendor/fonts/aref-ruqaa-arabic-700.woff2) format("woff2"); font-weight: 700; font-display: swap; unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFF; }
@font-face { font-family: "Ruqaa"; src: url(vendor/fonts/aref-ruqaa-latin-400.woff2) format("woff2"); font-weight: 400; font-display: swap; unicode-range: U+0000-00FF; }
@font-face { font-family: "Ruqaa"; src: url(vendor/fonts/aref-ruqaa-latin-700.woff2) format("woff2"); font-weight: 700; font-display: swap; unicode-range: U+0000-00FF; }
@font-face { font-family: "Readex"; src: url(vendor/fonts/readex-pro-arabic.woff2) format("woff2"); font-weight: 160 700; font-display: swap; unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFF; }
@font-face { font-family: "Readex"; src: url(vendor/fonts/readex-pro-latin.woff2) format("woff2"); font-weight: 160 700; font-display: swap; unicode-range: U+0000-00FF, U+2000-206F; }

:root {
  color-scheme: light;
  --cover: #1f35a8;
  --cover-deep: #16277f;
  --cover-tab: #3448bd;
  --paper: #fbfdff;
  --paper-shade: #eef3fb;
  --rule: #c5d6ef;
  --ink: #141d58;
  --ink-soft: #55608f;
  --pen: #d3202f;
  --marker: #ffe83d;
  --green: #0a7f58;
  --orange: #b95600;
  --blue: #1560cf;
  --violet: #6a35b5;
  --pink: #c31c74;
  --line: 58px;
  --margin: 76px;
  --hand: "Ruqaa", "Geeza Pro", "Traditional Arabic", serif;
  --ui: "Readex", "Geeza Pro", "SF Arabic", Tahoma, sans-serif;
  --step--1: .84rem;
  --step-0: 1rem;
  --step-1: 1.25rem;
  --step-2: 1.6rem;
  --step-3: 2.4rem;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--cover);
  color: var(--ink);
  font: 400 var(--step-0)/1.6 var(--ui);
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
h1, h2, h3, p { margin: 0; }
:focus-visible { outline: 3px solid var(--cover); outline-offset: 2px; border-radius: 4px; }
.num { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; }

/* ———————— الغلاف والأقسام ———————— */
.shell {
  display: grid;
  grid-template-columns: 172px minmax(0, 1fr);
  min-height: 100dvh;
  padding-block: 22px;
  padding-inline-end: 30px;
  max-width: 1500px;
  margin-inline: auto;
}
.rail { padding-inline-start: 18px; position: sticky; top: 22px; align-self: start; }
.cover-label {
  display: block;
  width: calc(100% - 22px);
  margin: 0 4px 26px 18px;
  padding: 8px 12px 6px;
  background: var(--paper);
  border: 2px solid var(--pen);
  outline: 2px solid var(--paper);
  border-radius: 7px;
  transform: rotate(1.5deg);
  text-align: start;
  transition: transform .12s;
}
.cover-label:hover { transform: rotate(0deg); }
.cover-label:focus-visible { outline: 3px solid var(--marker); outline-offset: 2px; }
.cover-label span { display: block; font-size: var(--step--1); color: var(--pen); }
.cover-label strong { display: block; font: 700 1.3rem/1.4 var(--hand); overflow-wrap: anywhere; }
.cover-label small { display: block; font-size: .78rem; color: var(--ink-soft); text-decoration: underline; text-underline-offset: 3px; }

.class-list { display: grid; gap: 8px; margin-top: 12px; }
.class-row { display: grid; grid-template-columns: minmax(0, 1fr) 96px 104px 76px; align-items: center; gap: 10px; }
.class-row.is-open .class-name { border-color: var(--ink); }
.class-name { font: 700 1.15rem/1.4 var(--hand); }
.class-count { font-size: var(--step--1); color: var(--ink-soft); }
.class-open { font-size: var(--step--1); font-weight: 500; text-align: center; background: var(--marker); border-radius: 6px; padding: 6px 4px; }
.class-row .btn { padding-inline: 10px; }
.tabs { display: flex; flex-direction: column; gap: 6px; }
.tabs a {
  padding: 14px 20px;
  background: var(--cover-tab);
  color: #fff;
  text-decoration: none;
  font-weight: 500;
  border-radius: 0 10px 10px 0;
  border-radius: 10px 0 0 10px;
  border-start-start-radius: 10px;
  border-end-start-radius: 10px;
  border-start-end-radius: 0;
  border-end-end-radius: 0;
  margin-inline-end: -1px;
}
.tabs a:hover { background: #4a5fd4; }
.tabs a[aria-current="page"] { background: var(--paper); color: var(--ink); font-weight: 700; padding-inline-start: 26px; }
.tabs a:focus-visible { outline-color: var(--marker); outline-offset: -5px; }

.page {
  position: relative;
  background: var(--paper);
  min-height: calc(100dvh - 44px);
  border-radius: 4px 0 0 4px;
  box-shadow: -5px 5px 0 #dfe8f6, -10px 10px 0 #c4d2ec;
  outline: none;
  overflow: clip;
}

/* صفحات داخلية: الهامش الأحمر يقطع الصفحة كلها */
.sheet-page { padding: 34px clamp(20px, 3vw, 44px) 56px; padding-inline-start: calc(var(--margin) + 22px); position: relative; min-height: inherit; }
.margin-line::before {
  content: ""; position: absolute; inset-block: 0; inset-inline-start: var(--margin);
  width: 2px; background: var(--pen); opacity: .55; pointer-events: none;
}
.page-title { font: 700 var(--step-3)/1.25 var(--hand); }
.page-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 14px 24px; margin-bottom: 26px; }
.page-sub { color: var(--ink-soft); }
.section-title { font: 700 var(--step-2)/1.3 var(--hand); margin: 40px 0 12px; }

/* ———————— الأزرار ———————— */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 8px 18px;
  background: var(--paper); border: 2px solid var(--ink); border-radius: 8px;
  font-weight: 500; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--paper-shade); }
.btn.primary { background: var(--ink); color: #fff; }
.btn.primary:hover { background: var(--cover); border-color: var(--cover); }
.btn.quiet { border-color: transparent; background: transparent; color: var(--ink-soft); text-decoration: underline; text-underline-offset: 4px; padding-inline: 8px; }
.btn.quiet:hover { color: var(--ink); background: transparent; }
.btn.danger { color: var(--pen); border-color: var(--pen); }
.btn.danger:hover { background: #fdecee; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.icon-btn { width: 44px; height: 44px; display: inline-grid; place-items: center; background: transparent; border: 2px solid var(--rule); border-radius: 8px; font-size: 1.2rem; line-height: 1; color: var(--ink); text-decoration: none; }
.icon-btn:hover { border-color: var(--ink); }
.icon-btn[disabled] { opacity: .35; cursor: not-allowed; }
.field { min-height: 44px; padding: 8px 12px; background: #fff; border: 2px solid var(--rule); border-radius: 8px; width: 100%; }
.field:focus { outline: none; border-color: var(--cover); }

/* ———————— شاشة اليوم ———————— */
.day-head { position: relative; padding: 28px clamp(20px, 3vw, 44px) 20px; padding-inline-start: calc(var(--margin) + 22px); }
.day-top { display: flex; flex-wrap: wrap; align-items: start; justify-content: space-between; gap: 16px 28px; }
.day-weekday { font: 700 clamp(2.8rem, 6vw, 4.6rem)/1.15 var(--hand); }
.day-dates { color: var(--ink-soft); margin-top: 6px; }
.day-dates b { color: var(--ink); font-weight: 500; }
.day-nav { display: flex; align-items: center; gap: 6px; margin-top: 14px; }
.pick-btn {
  position: relative;
  padding: 18px 30px;
  background: var(--marker);
  border: 0;
  font: 700 var(--step-1)/1.3 var(--ui);
  color: var(--ink);
  border-radius: 3px 18px 4px 22px / 20px 4px 22px 5px;
  box-shadow: 0 5px 0 var(--ink);
  transition: transform .08s, box-shadow .08s;
}
.pick-btn:hover { background: #ffef73; }
.pick-btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }
.pick-btn[disabled] { opacity: .5; cursor: not-allowed; }

.lesson { display: block; margin-top: 18px; }
.lesson span { display: block; font-size: var(--step--1); color: var(--pen); }
.lesson input {
  width: 100%; border: 0; border-bottom: 3px solid var(--ink); background: transparent;
  font: 400 clamp(1.5rem, 3vw, 2.2rem)/1.5 var(--hand); padding: 2px 0 4px;
}
.lesson input::placeholder { color: #9aa8cc; }
.lesson input:focus { outline: none; border-bottom-color: var(--cover); background: linear-gradient(transparent 70%, #fff7b0 70%); }

.day-tally { display: flex; flex-wrap: wrap; gap: 6px 30px; margin-top: 14px; align-items: center; min-height: 44px; }
.day-tally b { font: 700 var(--step-1)/1 var(--ui); }
.star-of-day { color: var(--pen); font-family: var(--hand); font-size: var(--step-1); }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.seg { display: inline-flex; border: 2px solid var(--ink); border-radius: 8px; overflow: hidden; }
.seg button { min-height: 40px; padding: 4px 14px; border: 0; background: transparent; font-size: var(--step--1); }
.seg button + button { border-inline-start: 2px solid var(--ink); }
.seg button[aria-pressed="true"] { background: var(--ink); color: #fff; }
.seg button:focus-visible { outline-offset: -5px; outline-color: var(--marker); }

/* سطور الكرّاسة: كل طالبة على سطر، ونقاطها في الهامش */
.roster {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 430px), 1fr));
  border-top: 2px solid var(--ink);
  background: repeating-linear-gradient(to bottom, transparent 0 calc(var(--line) - 1px), var(--rule) calc(var(--line) - 1px) var(--line));
}
.row {
  position: relative;
  display: grid;
  grid-template-columns: var(--margin) minmax(0, 1fr) auto auto;
  align-items: center;
  height: var(--line);
  border-bottom: 1px solid var(--rule);
  padding-inline-end: 12px;
  background: var(--paper);
}
.row::before { content: ""; position: absolute; inset-block: 0; inset-inline-start: var(--margin); width: 2px; background: var(--pen); opacity: .55; }
.row-points { display: grid; place-items: center; }
.pen-circle {
  min-width: 42px; height: 40px; padding-inline: 6px;
  display: inline-grid; place-items: center;
  color: var(--pen);
  font: 700 1.25rem/1 var(--hand);
  border: 2px solid var(--pen);
  border-radius: 52% 48% 56% 44% / 46% 58% 42% 54%;
  transform: rotate(-4deg);
}
.pen-empty { color: var(--rule); font-size: 1.1rem; }
.row-name {
  height: 100%; min-width: 0;
  padding-inline: 16px 8px;
  border: 0; background: transparent;
  text-align: start; font-size: 1.08rem; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.row-name:hover { background: linear-gradient(transparent 62%, #fff4a0 62%, #fff4a0 92%, transparent 92%); }
.row-name:focus-visible { outline-offset: -4px; }
.row.picked .row-name { background: linear-gradient(transparent 12%, var(--marker) 12%, var(--marker) 88%, transparent 88%); }
.row.absent .row-name { color: #8c95b8; text-decoration: line-through; text-decoration-color: var(--pen); }
.row-stamps { display: flex; align-items: center; padding-inline-end: 6px; }
.row-stamps .mini + .mini { margin-inline-start: -9px; }
.row-more { font-size: var(--step--1); color: var(--ink-soft); margin-inline-start: 4px; }

.status-btn {
  min-width: 72px; min-height: 36px; padding: 2px 10px;
  border-radius: 6px; border: 2px solid var(--rule); background: transparent;
  font-size: var(--step--1); color: var(--ink-soft);
}
.status-btn:hover { border-color: var(--ink); }
.status-btn.absent { background: var(--pen); border-color: var(--pen); color: #fff; }
.status-btn.late { background: #fff0dc; border-color: var(--orange); color: #8e4100; }
.status-btn.excused { background: #e2eeff; border-color: var(--blue); color: #0f4aa3; }

/* ———————— الأختام ———————— */
.stamp {
  --c: var(--violet);
  display: grid; place-items: center;
  color: var(--c); border: 3px solid var(--c);
  outline: 1.5px solid var(--c); outline-offset: 3px;
  font-family: var(--hand); font-weight: 700; line-height: 1;
}
.stamp.round { border-radius: 50%; aspect-ratio: 1; }
.stamp.oval { border-radius: 50%; aspect-ratio: 1.5; }
.stamp.rect { border-radius: 10px; aspect-ratio: 1.7; }
.mini {
  --c: var(--violet);
  display: inline-grid; place-items: center;
  height: 28px; padding-inline: 8px;
  background: var(--paper);
  border: 1.5px solid var(--c); color: var(--c);
  font: 700 .82rem/1 var(--hand);
  border-radius: 50%;
  transform: rotate(var(--r, -7deg));
  white-space: nowrap;
}
.c-violet { --c: var(--violet); } .c-pink { --c: var(--pink); } .c-green { --c: var(--green); }
.c-orange { --c: var(--orange); } .c-blue { --c: var(--blue); } .c-pen { --c: var(--pen); }

/* ———————— نافذة الاختيار ———————— */
dialog { color: var(--ink); }
.picker {
  width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; border: 0; padding: 0;
  background: var(--cover); color: #fff;
  overflow-y: auto;
}
.picker::backdrop { background: var(--cover); }
.pk-wrap { min-height: 100%; display: grid; grid-template-rows: auto minmax(220px, 1fr) auto; padding: 18px clamp(16px, 4vw, 48px) 28px; }
.pk-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; color: #d7deff; }
.pk-top .icon-btn { color: #fff; border-color: #6a7ad8; }
.pk-top .icon-btn:hover { border-color: #fff; }
.pk-stage { position: relative; display: grid; place-items: center; text-align: center; padding-block: 18px 104px; }
.pk-name { position: relative; display: inline-block; padding: .08em .35em .16em; font: 700 var(--fs, clamp(3rem, 9vw, 7.5rem))/1.3 var(--hand); text-wrap: balance; max-width: 22ch; }
.pk-name::before {
  content: ""; position: absolute; inset: .06em 0 .02em; z-index: 0;
  background: var(--marker);
  border-radius: 6px 26px 8px 34px / 30px 8px 34px 8px;
  transform: scaleX(0); transform-origin: right center;
}
.pk-name span { position: relative; z-index: 1; }
.pk-name.shuffling { color: #b9c5ff; }
.pk-name.landed { color: var(--ink); }
.pk-name.landed::before { transform: scaleX(1); transition: transform .32s cubic-bezier(.2,.8,.2,1); }
.pk-slot { position: absolute; inset-block-start: calc(100% - 14px); inset-inline-end: -24px; width: clamp(96px, 10vw, 136px); pointer-events: none; z-index: 2; }
.pk-slot .stamp { background: var(--paper); font-size: clamp(1.5rem, 2.6vw, 2.2rem); filter: url(#ink); transform: rotate(-13deg); }
.pk-slot.slam .stamp { animation: slam .26s cubic-bezier(.3, 1.3, .6, 1) both; }
@keyframes slam {
  0% { transform: rotate(-4deg) scale(2.6); opacity: 0; }
  70% { transform: rotate(-13deg) scale(.94); opacity: 1; }
  100% { transform: rotate(-13deg) scale(1); opacity: 1; }
}
.pk-stage.thud { animation: thud .22s ease-out; }
@keyframes thud { 40% { transform: translateY(5px); } }

.pk-panel { background: var(--paper); color: var(--ink); border-radius: 10px; padding: 18px clamp(14px, 2vw, 26px); max-width: 1020px; width: 100%; margin-inline: auto; box-shadow: 0 8px 0 var(--cover-deep); }
.pk-stamps { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
.pk-stamp {
  display: grid; justify-items: center; align-content: start; gap: 10px; padding: 12px 4px 8px;
  border: 2px solid transparent; background: transparent; border-radius: 10px;
  font-size: var(--step--1); color: var(--ink-soft);
}
.pk-stamp:hover { background: var(--paper-shade); }
.pk-stamp[aria-pressed="true"] { border-color: var(--ink); background: var(--paper-shade); color: var(--ink); }
.pk-stamp .stamp { width: min(92px, 100%); font-size: clamp(.95rem, 1.6vw, 1.25rem); }
.pk-stamp .stamp.rect, .pk-stamp .stamp.oval { margin-block: 10px; }
.pk-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 22px; margin-top: 12px; padding-top: 14px; border-top: 1px solid var(--rule); }
.stepper { display: inline-flex; align-items: center; gap: 8px; }
.stepper output { min-width: 44px; text-align: center; font: 700 1.8rem/1 var(--hand); color: var(--pen); }
.pk-today { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-height: 30px; color: var(--ink-soft); font-size: var(--step--1); }
.pk-hint { color: var(--ink-soft); }
.chip-x { display: inline-flex; align-items: center; gap: 4px; padding: 0 2px; border: 0; background: transparent; font-size: var(--step--1); color: var(--ink-soft); }
.chip-x:hover { color: var(--pen); }

/* ———————— الحوارات ———————— */
.sheet, .confirm {
  border: 0; border-radius: 12px; padding: 0; background: var(--paper);
  box-shadow: 0 10px 0 var(--cover-deep);
  width: min(720px, calc(100vw - 28px)); max-height: calc(100dvh - 40px);
}
.confirm { width: min(460px, calc(100vw - 28px)); }
.sheet::backdrop, .confirm::backdrop { background: rgba(14, 24, 90, .68); }
.sheet-in { padding: 24px clamp(18px, 3vw, 30px); }
.sheet-title { font: 700 var(--step-2)/1.3 var(--hand); margin-bottom: 4px; }
.sheet-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-start; margin-top: 20px; align-items: center; }
.form-row { display: grid; gap: 4px; margin-top: 14px; }
.form-row > span { font-size: var(--step--1); color: var(--ink-soft); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.import-list { margin-top: 14px; max-height: 42dvh; overflow: auto; border: 2px solid var(--rule); border-radius: 8px; }
.import-list label { display: flex; align-items: center; gap: 10px; min-height: 42px; padding: 4px 12px; border-bottom: 1px solid var(--rule); }
.import-list label:last-child { border-bottom: 0; }
.import-list input { width: 20px; height: 20px; accent-color: var(--ink); flex: none; }
.import-list small { color: var(--pen); margin-inline-start: auto; white-space: nowrap; }
.error-note { margin-top: 14px; color: var(--pen); }

.stats-row { display: flex; flex-wrap: wrap; gap: 8px 30px; margin-block: 14px; }
.stats-row div { display: grid; }
.stats-row b { font: 700 var(--step-2)/1.15 var(--ui); }
.stats-row span { font-size: var(--step--1); color: var(--ink-soft); }
.stamp-tally { display: flex; flex-wrap: wrap; gap: 10px 14px; }
.simple-list { list-style: none; margin: 0; padding: 0; }
.simple-list li { display: flex; justify-content: space-between; gap: 14px; padding: 8px 0; border-bottom: 1px solid var(--rule); }
.simple-list li span:last-child { white-space: nowrap; }

/* ———————— الطالبات ———————— */
.add-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); gap: 18px; margin-bottom: 8px; }
.add-card h2 { font: 700 var(--step-1)/1.4 var(--hand); margin-bottom: 6px; }
.add-card p { color: var(--ink-soft); font-size: var(--step--1); margin-top: 8px; }
.add-line { display: flex; gap: 8px; }
.drop {
  display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap;
  min-height: 62px; padding: 10px 14px; text-align: center;
  border: 2px dashed var(--ink-soft); border-radius: 8px; cursor: pointer; font-weight: 500;
}
.drop:hover, .drop.over { background: #fff9c9; border-color: var(--ink); }
.drop:focus-within { outline: 3px solid var(--cover); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.students-table td.name-cell { width: 100%; }
.link-name { border: 0; background: transparent; padding: 4px 0; font-weight: 500; text-align: start; }
.link-name:hover { text-decoration: underline; text-underline-offset: 4px; }

/* ———————— الجداول ———————— */
.table-scroll { overflow-x: auto; border: 2px solid var(--ink); border-radius: 6px; background: #fff; }
table.ledger { border-collapse: separate; border-spacing: 0; width: 100%; font-size: .95rem; }
.ledger th, .ledger td { border-bottom: 1px solid var(--rule); border-inline-start: 1px solid var(--rule); padding: 0; height: 46px; text-align: center; white-space: nowrap; background: #fff; }
.ledger th:first-child, .ledger td:first-child { border-inline-start: 0; }
.ledger thead th { position: sticky; top: 0; background: var(--paper-shade); font-weight: 500; font-size: var(--step--1); z-index: 2; padding: 4px 8px; }
.ledger .sticky-name { position: sticky; inset-inline-start: 0; z-index: 3; text-align: start; padding-inline: 14px; min-width: 190px; max-width: 280px; overflow: hidden; text-overflow: ellipsis; box-shadow: inset 2px 0 0 var(--pen); box-shadow: -2px 0 0 var(--pen) inset; font-weight: 500; }
.ledger thead .sticky-name { z-index: 4; background: var(--paper-shade); }
.ledger tfoot td { background: var(--paper-shade); font-weight: 500; border-bottom: 0; padding-inline: 8px; }
.ledger tbody tr:last-child td { border-bottom: 2px solid var(--ink); }
.ledger .sum { font-weight: 700; padding-inline: 12px; background: #f7f9fe; }
.ledger .actions { padding-inline: 8px; }
.day-link { display: block; text-decoration: none; line-height: 1.25; padding: 2px 0; min-width: 34px; }
.day-link:hover { text-decoration: underline; }
.day-link small { display: block; font-size: .72rem; color: var(--ink-soft); }
.ledger thead th.is-today { background: var(--marker); }
.cell-btn { width: 100%; height: 100%; min-width: 38px; min-height: 45px; border: 0; background: transparent; font-weight: 700; }
.cell-btn:hover:not([disabled]) { background: #fff7b0; }
.cell-btn:focus-visible { outline-offset: -4px; }
.cell-btn[disabled] { cursor: default; }
.cell-btn.present { color: var(--green); font-weight: 400; }
.cell-btn.absent { background: #fce3e5; color: #b00f1d; }
.cell-btn.late { background: #fff0dc; color: #8e4100; }
.cell-btn.excused { background: #e2eeff; color: #0f4aa3; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-block: 0 12px; font-size: var(--step--1); color: var(--ink-soft); }
.legend b { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 4px; margin-inline-end: 4px; }
.legend .absent { background: #fce3e5; color: #b00f1d; } .legend .late { background: #fff0dc; color: #8e4100; }
.legend .excused { background: #e2eeff; color: #0f4aa3; } .legend .present { color: var(--green); font-weight: 400; }
.month-nav { display: flex; align-items: center; gap: 8px; }
.month-nav strong { min-width: 130px; text-align: center; font: 700 var(--step-1)/1.2 var(--hand); }
.grade-input { width: 100%; min-width: 62px; height: 45px; border: 0; background: transparent; text-align: center; font-variant-numeric: tabular-nums; }
.grade-input:focus { outline: none; background: #fff7b0; box-shadow: inset 0 0 0 2px var(--ink); }
.grade-input.over { background: #fce3e5; color: #b00f1d; font-weight: 700; }
.assess-head { display: grid; gap: 0; min-width: 96px; }
.assess-head button { border: 0; background: transparent; padding: 3px 4px; font-weight: 500; line-height: 1.3; }
.assess-head button:hover { text-decoration: underline; }
.assess-head small { color: var(--ink-soft); }

/* ———————— لوحة النقاط ———————— */
.rank { list-style: none; margin: 0; padding: 0; border-top: 2px solid var(--ink); }
.rank li { display: grid; grid-template-columns: 54px minmax(130px, 1.2fr) minmax(80px, 2fr) auto; align-items: center; gap: 12px; min-height: 52px; border-bottom: 1px solid var(--rule); }
.rank .pos { font: 700 1.2rem/1 var(--hand); color: var(--ink-soft); text-align: center; }
.rank .bar { height: 14px; background: var(--paper-shade); border-radius: 2px; }
.rank .bar i { display: block; height: 100%; background: var(--marker); border-radius: 2px; box-shadow: inset 0 0 0 1px #d9c200; }
.rank .tot { width: 100px; text-align: end; font-weight: 700; white-space: nowrap; }
.rank li.first .pos { color: var(--pen); }

.empty { padding: 44px 0; max-width: 56ch; }
.empty h2 { font: 700 var(--step-2)/1.3 var(--hand); margin-bottom: 8px; }
.empty p { color: var(--ink-soft); margin-bottom: 18px; }
.empty-roster { padding: 40px clamp(20px, 3vw, 44px); padding-inline-start: calc(var(--margin) + 22px); background: var(--paper); position: relative; }

.data-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.note { color: var(--ink-soft); max-width: 70ch; }

.toast {
  position: fixed; inset-block-end: 22px; inset-inline-start: 50%; transform: translate(50%, 30px);
  background: var(--ink); color: #fff; padding: 11px 20px; border-radius: 8px;
  opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s; z-index: 50;
  max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(50%, 0); }

/* ———————— الجوال والأجهزة اللوحية ———————— */
@media (max-width: 820px) {
  :root { --margin: 52px; --line: 60px; }
  body { background: var(--paper); }
  .shell { display: block; padding: 0 0 70px; }
  .rail { position: static; padding: 0; background: var(--cover); }
  .cover-label, .cover-label:hover { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; margin: 0; padding: 10px 16px; transform: none; border: 0; outline: 0; border-radius: 0; background: var(--cover); color: #fff; }
  .cover-label:focus-visible { outline-offset: -5px; }
  .cover-label span { display: none; }
  .cover-label small { color: #d7deff; white-space: nowrap; }
  .class-row { grid-template-columns: minmax(0, 1fr) auto auto; padding-bottom: 10px; border-bottom: 1px solid var(--rule); }
  .class-row .class-name { grid-column: 1 / -1; }
  .class-row .class-count { grid-column: 1; }
  .tabs { position: fixed; inset: auto 0 0 0; z-index: 20; flex-direction: row; gap: 0; background: var(--cover); padding-bottom: env(safe-area-inset-bottom); }
  .tabs a, .tabs a[aria-current="page"] { flex: 1; padding: 14px 2px; text-align: center; border-radius: 0; font-size: .86rem; margin: 0; background: transparent; }
  .tabs a[aria-current="page"] { background: var(--paper); color: var(--ink); padding-inline: 2px; }
  .page { box-shadow: none; border-radius: 0; min-height: 0; }
  .sheet-page, .day-head, .empty-roster { padding-inline: calc(var(--margin) + 12px) 14px; }
  .pick-btn { width: 100%; }
  .row { grid-template-columns: var(--margin) minmax(0, 1fr) auto auto; padding-inline-end: 8px; }
  .row-name { padding-inline: 10px 4px; font-size: 1rem; }
  .row-stamps .mini:nth-child(n+2) { display: none; }
  .status-btn { min-width: 58px; padding-inline: 4px; }
  .pk-stamps { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .pk-slot { inset-inline-end: 0; }
  .ledger .sticky-name { min-width: 130px; max-width: 150px; padding-inline: 8px; }
  .rank li { grid-template-columns: 38px minmax(0, 1fr) auto; }
  .rank .bar { display: none; }
  .form-grid { grid-template-columns: 1fr; }
  .toast { inset-block-end: 76px; }
}

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