/* إيقان — الزيتونيّ من شعار المركز، والورق الفاتح، وخطّ Readex Pro للّغتين */
@font-face {
  font-family: 'Readex Pro'; font-style: normal; font-weight: 300 700; font-display: swap;
  src: url(/fonts/readex-pro-arabic.woff2) format('woff2');
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
}
@font-face {
  font-family: 'Readex Pro'; font-style: normal; font-weight: 300 700; font-display: swap;
  src: url(/fonts/readex-pro-latin-ext.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Readex Pro'; font-style: normal; font-weight: 300 700; font-display: swap;
  src: url(/fonts/readex-pro-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --olive: #464e2e;
  --olive-2: #545d37;
  --olive-deep: #343a21;
  --olive-soft: #e8eadc;
  --olive-line: #d4d8c0;
  --bg: #f5f3ea;
  --paper: #ffffff;
  --ink: #23261b;
  --ink-2: #484c3b;
  --muted: #73776a;
  --line: #e4e2d6;
  --gold: #a98a4c;
  --ok: #2c7a4b;
  --ok-soft: #e0f0e5;
  --late: #9a5c0c;
  --late-soft: #fbeed6;
  --bad: #b03a35;
  --bad-soft: #f8e1de;
  --exc: #475b8c;
  --exc-soft: #e2e7f4;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgb(35 38 27 / 5%), 0 6px 20px rgb(35 38 27 / 6%);
  --font: 'Readex Pro', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --nav-h: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --olive: #4d5633;
    --olive-2: #5c663d;
    --olive-deep: #2b3019;
    --olive-soft: #2a2f1d;
    --olive-line: #3c432a;
    --bg: #14160f;
    --paper: #1d2016;
    --ink: #eceadf;
    --ink-2: #cfcdbf;
    --muted: #a3a693;
    --line: #313626;
    --ok: #6cc28f;
    --ok-soft: #1d3326;
    --late: #e5a54b;
    --late-soft: #3a2c15;
    --bad: #ee8a83;
    --bad-soft: #3d1f1c;
    --exc: #9fb2e6;
    --exc-soft: #222b40;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 6px 20px rgb(0 0 0 / 25%);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
h1, h2, h3 { line-height: 1.3; margin: 0; font-weight: 600; }
p { margin: 0; }
a { color: var(--olive); }
@media (prefers-color-scheme: dark) { a { color: #c6cf9f; } }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.center { text-align: center; }
.ic { width: 1.25em; height: 1.25em; flex: none; vertical-align: -0.25em; }
[dir=rtl] .flip-rtl { transform: scaleX(-1); }
.noscript { padding: 24px; text-align: center; }

/* الشعار: الصورة البيضاء قناعاً يُلوَّن بلون النصّ */
.mark {
  display: inline-block;
  width: 34px;
  height: 34px;
  background: currentColor;
  -webkit-mask: url(/img/mark-white.png) center / contain no-repeat;
  mask: url(/img/mark-white.png) center / contain no-repeat;
  flex: none;
}
.mark-xl { width: 116px; height: 116px; }
.mark-olive { color: var(--olive); }

.boot { min-height: 100vh; display: grid; place-items: center; background: var(--olive); }
.boot-mark {
  width: 84px; height: 84px; background: #fff; opacity: .9;
  -webkit-mask: url(/img/mark-white.png) center / contain no-repeat;
  mask: url(/img/mark-white.png) center / contain no-repeat;
  animation: breathe 1.6s ease-in-out infinite;
}
@keyframes breathe { 50% { opacity: .45; transform: scale(.96); } }

/* ---------- الشريط العلويّ ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  background: var(--olive);
  color: #fff;
  box-shadow: 0 2px 10px rgb(0 0 0 / 12%);
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; min-width: 0; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text b { font-size: 1.15rem; font-weight: 700; letter-spacing: .2px; }
.brand-text small { font-size: .78rem; opacity: .8; }
.topbar-actions { display: flex; align-items: center; gap: 6px; }
.lang-btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid rgb(255 255 255 / 35%);
  background: rgb(255 255 255 / 8%);
  color: #fff; border-radius: 999px; padding: 5px 12px; font-size: .88rem; cursor: pointer;
}
.lang-btn:hover { background: rgb(255 255 255 / 16%); }
.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; flex: none;
  border-radius: 12px; border: 0; background: transparent; color: inherit; cursor: pointer; text-decoration: none;
}
.icon-btn:hover { background: color-mix(in srgb, currentColor 10%, transparent); }
.icon-btn.sm { width: 32px; height: 32px; border-radius: 9px; }
.icon-btn.on-dark { color: #fff; }

/* ---------- الصفحة ---------- */
.page { width: 100%; margin: 0 auto; padding: 16px 16px 32px; }
.page-student { max-width: 640px; padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 28px); }
.page-admin { max-width: 1120px; }
.page-title { font-size: 1.4rem; margin: 4px 0 14px; }
.section-title { font-size: 1.05rem; color: var(--ink-2); margin: 22px 0 10px; }
.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}
.card + .card, .card + section, section + .card { margin-top: 14px; }
.card-title { display: flex; align-items: center; gap: 8px; font-size: 1.02rem; margin-bottom: 12px; }
.card-title .ic { color: var(--olive); }
@media (prefers-color-scheme: dark) { .card-title .ic { color: #b8c28d; } }
.hint { display: flex; gap: 6px; align-items: flex-start; font-size: .86rem; color: var(--muted); margin: 10px 2px; }
.pill {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  background: var(--olive-soft); color: var(--olive); font-size: .85rem; font-weight: 500;
}
@media (prefers-color-scheme: dark) { .pill { color: #c6cf9f; } }

/* ---------- الأزرار ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 9px 18px;
  border-radius: 12px; border: 1px solid transparent;
  font-weight: 600; font-size: .96rem; text-decoration: none; cursor: pointer;
  transition: background .15s, transform .1s, box-shadow .15s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .6; cursor: default; }
.btn.primary { background: var(--olive); color: #fff; box-shadow: 0 3px 10px rgb(70 78 46 / 25%); }
.btn.primary:hover { background: var(--olive-2); }
.btn.ghost { background: transparent; color: var(--ink-2); border-color: var(--line); }
.btn.ghost:hover { background: var(--olive-soft); }
.btn.danger { background: var(--bad); color: #fff; }
.btn.danger-ghost { background: transparent; color: var(--bad); border-color: color-mix(in srgb, var(--bad) 35%, transparent); }
.danger-text { color: var(--bad) !important; }
.btn.block { display: flex; width: 100%; }
.btn.big { min-height: 54px; font-size: 1.05rem; border-radius: 14px; }
.btn.sm { min-height: 34px; padding: 5px 12px; font-size: .86rem; border-radius: 10px; }
.btn + .btn.block, .btn.block + .btn.block { margin-top: 10px; }
.btn.is-busy { position: relative; color: transparent !important; }
.btn.is-busy::after {
  content: ''; position: absolute; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid rgb(255 255 255 / 50%); border-top-color: #fff; animation: spin .8s linear infinite;
}
.btn.ghost.is-busy::after { border-color: var(--line); border-top-color: var(--olive); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- الحقول ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; border: 0; padding: 0; min-width: 0; }
.field > span, .field > legend { font-size: .9rem; font-weight: 500; color: var(--ink-2); padding: 0; }
.field small { font-weight: 400; color: var(--muted); }
input:not([type=checkbox]):not([type=radio]), select, textarea {
  width: 100%;
  min-height: 46px;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--olive-line);
  background: var(--paper);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 120px; resize: vertical; line-height: 1.7; }
input:focus, select:focus, textarea:focus { border-color: var(--olive); box-shadow: 0 0 0 3px color-mix(in srgb, var(--olive) 18%, transparent); }
input[dir=ltr] { text-align: start; }
[dir=rtl] input[dir=ltr] { text-align: right; }
.pw-wrap { position: relative; display: block; }
.pw-wrap > input:not([type=checkbox]) { padding-inline-end: 48px; }
.pw-eye {
  position: absolute; inset-inline-end: 4px; top: 50%; transform: translateY(-50%);
  width: 40px; height: 40px; border: 0; background: transparent; color: var(--muted); cursor: pointer; border-radius: 10px;
}
.form-error {
  margin: 4px 0 12px; padding: 10px 12px; border-radius: 10px;
  background: var(--bad-soft); color: var(--bad); font-size: .92rem;
}
.form-error:empty { display: none; }

.seg { display: flex; gap: 4px; padding: 4px; border-radius: 14px; background: var(--olive-soft); flex-wrap: wrap; }
.seg-btn {
  flex: 1 1 auto; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 6px 12px; border-radius: 10px; border: 0;
  background: transparent; color: var(--ink-2); text-decoration: none; cursor: pointer; font-weight: 500; text-align: center;
}
.seg-btn.on { background: var(--paper); color: var(--ink); box-shadow: 0 1px 4px rgb(0 0 0 / 10%); font-weight: 600; }
.seg-btn input { position: absolute; opacity: 0; pointer-events: none; }

/* ---------- الدخول ---------- */
.auth { min-height: 100vh; background: var(--olive); color: #fff; display: flex; flex-direction: column; align-items: center; }
.auth-hero { position: relative; width: 100%; max-width: 460px; text-align: center; padding: calc(env(safe-area-inset-top) + 56px) 16px 26px; }
.auth-hero .mark { color: #fff; margin-bottom: 14px; }
.auth-hero h1 { font-size: 2rem; font-weight: 700; }
.auth-hero p { opacity: .85; margin-top: 2px; }
.lang-btn.on-hero { position: absolute; top: calc(env(safe-area-inset-top) + 14px); inset-inline-end: 16px; }
.auth-card { width: calc(100% - 32px); max-width: 430px; color: var(--ink); padding: 20px; }
.auth-tabs { margin-bottom: 18px; }
.auth-title { font-size: 1.25rem; margin-bottom: 6px; }
.auth-card .muted + form { margin-top: 16px; }
.auth-card .hint { justify-content: center; text-align: center; }
.auth-foot { margin-top: auto; width: 100%; max-width: 520px; padding: 34px 20px calc(env(safe-area-inset-bottom) + 18px); opacity: .55; }
.auth-foot img { width: 100%; height: auto; display: block; }
.notice {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px; margin-bottom: 14px;
  border-radius: 12px; background: var(--olive-soft); color: var(--ink); text-decoration: none; font-weight: 500;
}
.notice > span { flex: 1; }
.notice-warn { background: var(--late-soft); color: var(--late); }
.pending { text-align: center; }
.pending-ic { display: inline-grid; place-items: center; width: 64px; height: 64px; border-radius: 50%; background: var(--late-soft); color: var(--late); margin-bottom: 12px; }
.pending-ic .ic { width: 32px; height: 32px; }
.pending p { margin: 8px 0 18px; }

/* ---------- الطالب: الرئيسيّة ---------- */
.hello h1 { font-size: 1.35rem; }
.hello p { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 6px; }
.hero-check {
  display: flex; align-items: center; gap: 14px; margin-top: 16px; padding: 16px;
  border-radius: 20px; background: linear-gradient(135deg, var(--olive) 0%, var(--olive-deep) 100%);
  color: #fff; text-decoration: none; box-shadow: 0 10px 28px rgb(52 58 33 / 32%);
}
.hero-text { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.hero-text b { font-size: 1.2rem; }
.hero-text span { opacity: .85; font-size: .92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hero-rings { position: relative; width: 58px; height: 58px; display: grid; place-items: center; flex: none; }
.hero-rings .ic { width: 28px; height: 28px; position: relative; }
.hero-rings i { position: absolute; inset: 0; border-radius: 50%; border: 2px solid rgb(255 255 255 / 55%); animation: pulse 2.4s ease-out infinite; }
.hero-rings i:nth-child(2) { animation-delay: .8s; }
.hero-rings i:nth-child(3) { animation-delay: 1.6s; }
@keyframes pulse { from { transform: scale(.45); opacity: 1; } to { transform: scale(1.25); opacity: 0; } }

.lesson-list { display: flex; flex-direction: column; gap: 10px; }
.lesson-card {
  display: flex; gap: 14px; padding: 14px; border-radius: var(--radius);
  background: var(--paper); border: 1px solid var(--line); box-shadow: var(--shadow);
  border-inline-start: 4px solid var(--line);
}
.lesson-card.state-open { border-inline-start-color: var(--olive); }
.lesson-card.state-attended { border-inline-start-color: var(--ok); }
.lesson-card.state-closed, .lesson-card.state-cancelled { opacity: .72; }
.lesson-time {
  display: flex; flex-direction: column; align-items: center; justify-content: center; flex: none;
  min-width: 62px; padding: 6px; border-radius: 12px; background: var(--olive-soft); color: var(--ink-2);
  font-variant-numeric: tabular-nums; line-height: 1.25; direction: ltr;
}
.lesson-time b { font-size: 1.02rem; color: var(--ink); }
.lesson-time span { font-size: .8rem; }
.lesson-time.all-day { direction: inherit; gap: 2px; font-size: .78rem; text-align: center; }
.lesson-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.lesson-main h3 { font-size: 1.04rem; }
.lesson-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-top: 2px; }
.meta-text { font-size: .85rem; color: var(--muted); }
.checkin-btn { margin-top: 10px; align-self: flex-start; }
.tag-extra { font-size: .72rem; font-weight: 500; color: var(--gold); border: 1px solid currentColor; border-radius: 6px; padding: 0 6px; vertical-align: middle; }

.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px;
  border-radius: 999px; font-size: .8rem; font-weight: 500; white-space: nowrap;
  background: var(--olive-soft); color: var(--ink-2);
}
.chip .ic { width: 1em; height: 1em; }
.chip-present, .chip-open { background: var(--ok-soft); color: var(--ok); }
.chip-late, .chip-soon { background: var(--late-soft); color: var(--late); }
.chip-excused { background: var(--exc-soft); color: var(--exc); }
.chip-absent, .chip-cancelled { background: var(--bad-soft); color: var(--bad); }
.chip-closed { background: var(--olive-soft); color: var(--muted); }

.empty { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 28px 12px; color: var(--muted); text-align: center; }
.empty .ic { width: 40px; height: 40px; opacity: .5; }
.error-card { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; color: var(--bad); }
.error-card .ic { width: 32px; height: 32px; }
.spinner { width: 34px; height: 34px; margin: 40px auto; border-radius: 50%; border: 3px solid var(--olive-line); border-top-color: var(--olive); animation: spin .8s linear infinite; }

/* ---------- الطالب: شاشة التسجيل ---------- */
.checkin { display: flex; flex-direction: column; align-items: stretch; gap: 10px; }
.ck-head { display: flex; align-items: center; gap: 8px; }
.ck-head h1 { font-size: 1.2rem; }
.ck-visual { position: relative; width: 210px; height: 210px; margin: 14px auto 6px; display: grid; place-items: center; }
.ring-wave { position: absolute; inset: 0; border-radius: 50%; border: 2px solid var(--olive); opacity: 0; }
.ck-visual.scanning .ring-wave, .ck-visual.working .ring-wave { animation: pulse 2.4s ease-out infinite; }
.ck-visual.working .ring-wave { animation-duration: 1.1s; border-color: var(--gold); }
.ring-wave:nth-child(2) { animation-delay: .8s !important; }
.ring-wave:nth-child(3) { animation-delay: 1.6s !important; }
.ck-phone {
  position: relative; display: grid; place-items: center; width: 92px; height: 92px; border-radius: 50%;
  background: var(--olive); color: #fff; box-shadow: 0 10px 26px rgb(52 58 33 / 30%);
}
.ck-phone .ic { width: 44px; height: 44px; }
.ck-card {
  position: absolute; inset-inline-end: 22px; bottom: 26px; display: grid; place-items: center;
  width: 54px; height: 54px; border-radius: 14px; background: var(--paper); color: var(--olive);
  border: 1px solid var(--line); box-shadow: var(--shadow); transition: transform .4s;
}
.ck-card .ic { width: 30px; height: 30px; }
.ck-visual.scanning .ck-card { animation: approach 2.4s ease-in-out infinite; }
@keyframes approach { 50% { transform: translate(calc(var(--dir, 1) * -16px), -16px); } }
[dir=rtl] .ck-visual { --dir: -1; }
.ck-visual.done .ck-phone { background: var(--ok); }
.ck-visual.is-error .ck-phone { background: var(--bad); }
.ck-visual.idle .ck-phone { opacity: .85; }
.ck-msg { text-align: center; font-size: 1.15rem; font-weight: 600; margin: 4px 8px 0; }
.ck-msg.is-error { color: var(--bad); }
.ck-msg.is-ok { color: var(--ok); }
.ck-sub { text-align: center; }
.steps-card h2 { display: flex; align-items: center; gap: 8px; font-size: 1.02rem; margin-bottom: 8px; }
.steps { margin: 0; padding-inline-start: 22px; display: flex; flex-direction: column; gap: 6px; }
.steps li::marker { color: var(--olive); font-weight: 700; }
.ck-done { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 24px 4px 8px; }
.ck-badge {
  display: grid; place-items: center; width: 108px; height: 108px; border-radius: 50%;
  background: var(--ok); color: #fff; margin-bottom: 10px;
  box-shadow: 0 0 0 10px var(--ok-soft), 0 14px 30px rgb(44 122 75 / 30%);
  animation: pop .5s cubic-bezier(.2, 1.4, .4, 1);
}
.ck-done.is-late .ck-badge { background: var(--late); box-shadow: 0 0 0 10px var(--late-soft); }
.ck-badge .ic { width: 56px; height: 56px; stroke-width: 2.6; }
@keyframes pop { from { transform: scale(.4); opacity: 0; } }
.ck-done h2 { font-size: 1.45rem; }
.ck-lesson { font-size: 1.08rem; font-weight: 500; }
.ck-time { display: flex; gap: 8px; align-items: center; color: var(--muted); margin-bottom: 18px; direction: ltr; }
.choose-list { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.choose-item {
  display: flex; justify-content: space-between; gap: 12px; padding: 16px; border-radius: 14px; cursor: pointer;
  background: var(--paper); border: 1px solid var(--line); box-shadow: var(--shadow); text-align: start;
}
.choose-item:hover { border-color: var(--olive); }
.choose-item span { color: var(--muted); direction: ltr; }

/* ---------- الطالب: السجلّ والحساب ---------- */
.stat-hero { display: grid; grid-template-columns: auto 1fr; gap: 14px 16px; align-items: center; }
.stat-hero-text h2 { font-size: 1.15rem; }
.counters { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.counter { display: flex; flex-direction: column; align-items: center; padding: 8px 4px; border-radius: 12px; background: var(--olive-soft); }
.counter b { font-size: 1.3rem; line-height: 1.2; }
.counter span { font-size: .78rem; color: var(--muted); }
.counter.c-present b { color: var(--ok); }
.counter.c-late b { color: var(--late); }
.counter.c-excused b { color: var(--exc); }
.counter.c-absent b { color: var(--bad); }
.ring {
  --p: 0; --c: var(--olive);
  width: 92px; height: 92px; border-radius: 50%; display: grid; place-items: center;
  background: radial-gradient(closest-side, var(--paper) 78%, transparent 79% 100%), conic-gradient(var(--c) calc(var(--p) * 1%), var(--olive-soft) 0);
}
.ring span { font-weight: 700; font-size: 1.25rem; direction: ltr; }
.ring.tone-good { --c: var(--ok); }
.ring.tone-mid { --c: var(--late); }
.ring.tone-low { --c: var(--bad); }
.lesson-rates { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.lr-head { display: flex; justify-content: space-between; gap: 10px; }
.lr-head span { color: var(--muted); font-size: .88rem; white-space: nowrap; }
.lr-meta { font-size: .8rem; color: var(--muted); margin-top: 4px; }
.bar { height: 8px; border-radius: 99px; background: var(--olive-soft); overflow: hidden; margin-top: 6px; }
.bar i { display: block; height: 100%; border-radius: inherit; background: var(--olive); transition: width .4s; }
.plain-list { list-style: none; margin: 0; padding: 0; }
.plain-list li { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.plain-list li:last-child { border-bottom: 0; }
.pl-main { flex: 1; min-width: 0; }
.pl-side { color: var(--muted); font-size: .85rem; white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.dot-absent { background: var(--bad); }
.profile { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; }
.profile h1 { font-size: 1.25rem; }
.avatar {
  display: grid; place-items: center; width: 72px; height: 72px; border-radius: 50%;
  background: var(--olive); color: #fff; font-size: 1.8rem; font-weight: 600;
}
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; width: 100%; margin: 8px 0 0; }
.facts div { padding: 10px; border-radius: 12px; background: var(--olive-soft); }
.facts dt { font-size: .78rem; color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; }
.facts-big dd { font-size: 1.3rem; }
.big-code { font-size: 1.8rem !important; letter-spacing: 4px; font-variant-numeric: tabular-nums; color: var(--olive); }

/* ---------- شريط التنقّل السفليّ ---------- */
.bottom-nav {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: space-around;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--paper) 94%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.bottom-nav .tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); text-decoration: none; font-size: .78rem; font-weight: 500; max-width: 160px;
}
.bottom-nav .tab .ic { width: 24px; height: 24px; }
.bottom-nav .tab.active { color: var(--olive); }
@media (prefers-color-scheme: dark) { .bottom-nav .tab.active { color: #c6cf9f; } }

/* ---------- المشرف ---------- */
.adm-nav { position: sticky; top: 0; z-index: 15; background: var(--paper); border-bottom: 1px solid var(--line); }
.adm-nav-inner { display: flex; gap: 4px; max-width: 1120px; margin: 0 auto; padding: 6px 12px; overflow-x: auto; scrollbar-width: none; }
.adm-nav-inner::-webkit-scrollbar { display: none; }
.adm-tab {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 10px;
  color: var(--ink-2); text-decoration: none; white-space: nowrap; font-weight: 500; font-size: .94rem;
}
.adm-tab:hover { background: var(--olive-soft); }
.adm-tab.active { background: var(--olive); color: #fff; }
.topbar + .adm-nav { top: calc(env(safe-area-inset-top) + 62px); }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.toolbar .page-title { margin: 0; }
.toolbar-actions, .row-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.row-actions { margin-top: 12px; }
.day-nav { display: flex; align-items: center; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.day-nav h1 { font-size: 1.25rem; margin: 0 6px; }
.class-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); }
.class-grid .card + .card { margin-top: 0; }
.class-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.class-head h2 { font-size: 1.1rem; }
.ov-list { display: flex; flex-direction: column; gap: 8px; }
.ov-item {
  display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 14px;
  border: 1px solid var(--line); color: inherit; text-decoration: none; transition: border-color .15s, background .15s;
}
.ov-item:hover { border-color: var(--olive); background: var(--olive-soft); }
.ov-item.state-open { border-inline-start: 4px solid var(--olive); }
.ov-main { flex: 1; min-width: 0; }
.ov-title { display: block; }
.ov-meta { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; margin-top: 6px; font-size: .86rem; color: var(--muted); }
.ov-count { color: var(--ink-2); font-weight: 500; }
.go-ic { color: var(--muted); }
.back-link { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; color: var(--muted); margin-bottom: 10px; }
.mt-head { display: grid; gap: 14px; grid-template-columns: 1fr; }
.mt-title h1 { font-size: 1.35rem; }
.mt-title p { margin-top: 4px; }
.mt-state { margin-top: 8px; }
.mt-stats { display: flex; flex-direction: column; gap: 10px; }
.mt-big { display: flex; align-items: baseline; gap: 6px; direction: ltr; justify-content: flex-start; }
[dir=rtl] .mt-big { justify-content: flex-end; }
.mt-big b { font-size: 2.4rem; line-height: 1; color: var(--olive); }
.mt-big span { color: var(--muted); font-size: 1.1rem; }
.mt-actions { display: flex; flex-wrap: wrap; gap: 8px; }
@media (min-width: 760px) {
  .mt-head { grid-template-columns: 1.4fr 1fr; }
  .mt-actions { grid-column: 1 / -1; }
}
.roster { padding: 6px 12px; }
.roster-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 14px; padding: 10px 2px; border-bottom: 1px solid var(--line); }
.roster-row:last-child { border-bottom: 0; }
.roster-row.is-busy { opacity: .55; pointer-events: none; }
.rr-name { display: flex; flex-direction: column; min-width: 180px; flex: 1; }
.flag { display: inline-flex; align-items: center; gap: 4px; color: var(--late); font-size: .8rem; }
.seg-status { flex: none; background: var(--olive-soft); }
.seg-status .seg-btn { min-height: 34px; padding: 4px 10px; font-size: .84rem; flex: none; }
.seg-status .seg-btn.on.st-present { background: var(--ok); color: #fff; }
.seg-status .seg-btn.on.st-late { background: var(--late); color: #fff; }
.seg-status .seg-btn.on.st-excused { background: var(--exc); color: #fff; }
.seg-status .seg-btn.on.st-absent { background: var(--bad); color: #fff; }
.roster-row.st-absent .rr-name b { color: var(--bad); }

.pill-tabs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 12px; }
.pill-tab {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--paper); color: var(--ink-2); text-decoration: none; font-size: .9rem;
}
.pill-tab span { font-size: .8rem; color: var(--muted); }
.pill-tab.on { background: var(--olive); border-color: var(--olive); color: #fff; }
.pill-tab.on span { color: rgb(255 255 255 / 80%); }
.search { position: relative; display: block; margin-bottom: 12px; }
.search .ic { position: absolute; inset-inline-start: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search input[type=search] { padding-inline-start: 44px; }
.list-card { padding: 4px 14px; }
.st-row, .ls-row, .tag-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.st-row:last-child, .ls-row:last-child, .tag-row:last-child { border-bottom: 0; }
.is-off { opacity: .6; }
.st-num {
  flex: none; min-width: 52px; text-align: center; padding: 4px 6px; border-radius: 8px;
  background: var(--olive-soft); color: var(--ink-2); font-weight: 600; font-variant-numeric: tabular-nums; font-size: .9rem;
}
.st-main { flex: 1; min-width: 0; }
.st-name { border: 0; background: none; padding: 0; font-weight: 600; cursor: pointer; text-align: start; color: var(--ink); }
.st-name:hover { color: var(--olive); text-decoration: underline; }
.st-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: .84rem; color: var(--muted); margin-top: 2px; }
.code-pill { display: inline-flex; align-items: center; gap: 4px; color: var(--olive); }
.code-pill b { letter-spacing: 2px; font-variant-numeric: tabular-nums; }
.st-rate { flex: none; min-width: 46px; text-align: center; font-weight: 600; font-size: .92rem; direction: ltr; }
.tone-good { color: var(--ok); }
.tone-mid { color: var(--late); }
.tone-low { color: var(--bad); }
.st-actions, .ls-actions, .tag-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; flex: none; }
@media (max-width: 560px) {
  .st-row { flex-wrap: wrap; }
  .st-actions { width: 100%; justify-content: flex-end; }
  .st-main { flex-basis: calc(100% - 140px); }
}
.ls-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ls-slots { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.slot { padding: 2px 10px; border-radius: 8px; background: var(--olive-soft); font-size: .84rem; }
.slot b { font-weight: 600; font-variant-numeric: tabular-nums; }
.warn-text { display: inline-flex; align-items: center; gap: 6px; color: var(--late); font-size: .88rem; }
.ok-text { display: inline-flex; align-items: center; gap: 6px; color: var(--ok); font-size: .88rem; }
.bad-text { color: var(--bad); font-weight: 600; }
.slots { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.slot-row { display: flex; align-items: center; gap: 8px; }
.slot-row select { flex: 1.3; min-width: 0; }
.slot-row input { flex: 1; min-width: 0; }
.slot-row .dash { color: var(--muted); }
.slot-row-2 { align-items: flex-end; }
.slot-row-2 .field { flex: 1; }
.tag-row { align-items: flex-start; }
.tag-ic { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; background: var(--olive-soft); color: var(--olive); flex: none; }
.tag-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.tag-badges { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-url { display: flex; align-items: center; gap: 4px; min-width: 0; }
.tag-url code, .url-box code {
  font-family: ui-monospace, 'SFMono-Regular', Consolas, monospace; font-size: .84rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0;
}
.url-box { padding: 12px; border-radius: 12px; background: var(--olive-soft); margin: 10px 0; overflow-x: auto; }
.url-box code { white-space: normal; word-break: break-all; }
@media (max-width: 640px) {
  .tag-row { flex-wrap: wrap; }
  .tag-actions { width: 100%; justify-content: flex-end; }
}
.how summary { display: flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 600; list-style: none; }
.how summary::-webkit-details-marker { display: none; }
.how .steps { margin-top: 12px; }
.how p { margin-top: 12px; }
.tap-admin { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.tap-admin h1 { font-size: 1.3rem; }

.filters { display: grid; gap: 0 12px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); align-items: end; margin-bottom: 14px; }
.filters-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; grid-column: 1 / -1; }
.table-wrap { padding: 0; overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: .92rem; }
.tbl th, .tbl td { padding: 10px 12px; text-align: start; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl thead th { background: var(--olive-soft); color: var(--ink-2); font-weight: 600; font-size: .85rem; position: sticky; top: 0; }
.tbl tbody th { font-weight: 500; }
.tbl tr.is-off { opacity: .55; }
.rate-cell { position: relative; display: inline-flex; align-items: center; min-width: 90px; height: 24px; border-radius: 8px; background: var(--olive-soft); overflow: hidden; direction: ltr; }
.rate-cell i { position: absolute; inset-block: 0; left: 0; background: currentColor; opacity: .22; }
.rate-cell b { position: relative; padding: 0 8px; font-size: .85rem; }
.matrix .tbl-matrix th, .matrix .tbl-matrix td { padding: 6px 8px; text-align: center; }
.tbl-matrix thead th a { display: flex; flex-direction: column; align-items: center; text-decoration: none; color: inherit; line-height: 1.3; }
.tbl-matrix thead th small { font-weight: 400; color: var(--muted); max-width: 110px; overflow: hidden; text-overflow: ellipsis; }
.tbl-matrix .sticky { position: sticky; inset-inline-start: 0; background: var(--paper); z-index: 1; text-align: start; }
.tbl-matrix thead .sticky { background: var(--olive-soft); z-index: 2; }
.cell { font-weight: 700; }
.cell.st-present { color: var(--ok); background: var(--ok-soft); }
.cell.st-late { color: var(--late); background: var(--late-soft); }
.cell.st-excused { color: var(--exc); background: var(--exc-soft); }
.cell.st-absent { color: var(--bad); background: var(--bad-soft); }
.cell.st-none { color: var(--muted); }
.legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-size: .85rem; color: var(--muted); margin: 0 0 10px; }
.legend .cell { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 6px; }
.grid-form { display: grid; gap: 0 14px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); align-items: end; }
.grid-form > div { margin-bottom: 14px; }
.switch { display: flex; align-items: center; gap: 12px; padding: 10px 0; cursor: pointer; border-bottom: 1px solid var(--line); }
.switch:last-child { border-bottom: 0; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-ui { position: relative; width: 46px; height: 28px; flex: none; border-radius: 99px; background: var(--olive-line); transition: background .2s; }
.switch-ui::after { content: ''; position: absolute; top: 3px; inset-inline-start: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / 25%); transition: transform .2s; }
.switch input:checked + .switch-ui { background: var(--olive); }
.switch input:checked + .switch-ui::after { transform: translateX(18px); }
[dir=rtl] .switch input:checked + .switch-ui::after { transform: translateX(-18px); }
.switch input:focus-visible + .switch-ui { box-shadow: 0 0 0 3px color-mix(in srgb, var(--olive) 30%, transparent); }
.class-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.class-row input:not([type=checkbox]) { flex: 1 1 160px; min-height: 40px; }
.audit-list li { flex-wrap: wrap; gap: 2px 10px; font-size: .88rem; }

/* ---------- النوافذ ---------- */
dialog.modal {
  width: min(520px, calc(100% - 24px)); max-height: calc(100dvh - 32px);
  padding: 0; border: 0; border-radius: 20px; background: var(--paper); color: var(--ink);
  box-shadow: 0 24px 60px rgb(0 0 0 / 30%);
}
dialog.modal-wide { width: min(720px, calc(100% - 24px)); }
dialog.modal::backdrop { background: rgb(20 22 15 / 55%); backdrop-filter: blur(2px); }
dialog.modal[open] { animation: rise .2s ease-out; }
@keyframes rise { from { transform: translateY(12px); opacity: 0; } }
.modal-form { display: flex; flex-direction: column; max-height: calc(100dvh - 32px); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 16px 6px 18px; }
[dir=rtl] .modal-head { padding: 14px 18px 6px 16px; }
.modal-head h2 { font-size: 1.12rem; }
.modal-body { padding: 8px 18px 6px; overflow-y: auto; }
.modal-foot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; padding: 12px 18px 16px; border-top: 1px solid var(--line); }
.modal-foot .btn.danger-ghost { margin-inline-end: auto; }
.confirm-text { font-size: 1rem; line-height: 1.7; padding: 4px 0 10px; }
.nfc-task .ck-visual { width: 180px; height: 180px; }
@media (max-width: 560px) {
  dialog.modal, dialog.modal-wide { width: 100%; max-width: 100%; margin: auto 0 0; border-radius: 20px 20px 0 0; max-height: 92dvh; }
  .modal-form { max-height: 92dvh; }
  .modal-foot { padding-bottom: calc(env(safe-area-inset-bottom) + 14px); }
}

/* ---------- الإشعارات ---------- */
#toasts { position: fixed; z-index: 100; inset-inline: 0; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 12px); display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
.toast {
  display: flex; align-items: center; gap: 8px; max-width: 520px; padding: 12px 16px; border-radius: 14px;
  background: var(--ink); color: var(--bg); box-shadow: 0 10px 30px rgb(0 0 0 / 25%);
  transform: translateY(14px); opacity: 0; transition: transform .25s, opacity .25s; font-size: .94rem;
}
.toast.show { transform: none; opacity: 1; }
.toast-error { background: var(--bad); color: #fff; }

/* ---------- طباعة رموز الدخول ---------- */
.print-page { max-width: 900px; margin: 0 auto; padding: 16px; }
.print-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 16px; }
.print-bar select { width: auto; flex: 1; min-width: 160px; }
.print-title { font-size: 1.2rem; margin-bottom: 14px; }
.print-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.print-card { border: 1.5px dashed var(--olive-line); border-radius: 14px; padding: 14px; background: var(--paper); break-inside: avoid; }
.pc-head { display: flex; align-items: center; gap: 10px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.pc-head .mark { width: 38px; height: 38px; }
.pc-head div { display: flex; flex-direction: column; line-height: 1.2; }
.pc-head small { color: var(--muted); font-size: .76rem; }
.pc-name { font-size: 1.12rem; font-weight: 700; margin-top: 10px; }
.pc-class { color: var(--muted); font-size: .88rem; }
.pc-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 10px 0; }
.pc-facts div { background: var(--olive-soft); border-radius: 10px; padding: 6px 10px; }
.pc-facts dt { font-size: .72rem; color: var(--muted); }
.pc-facts dd { margin: 0; font-size: 1.25rem; font-weight: 700; letter-spacing: 2px; }
.pc-url { font-weight: 600; color: var(--olive); }
.pc-steps { font-size: .78rem; color: var(--ink-2); margin-top: 6px; }
.pc-other { color: var(--muted); }
@media print {
  @page { margin: 12mm; }
  body { background: #fff; }
  .no-print, .topbar, .adm-nav, #toasts { display: none !important; }
  .print-page { padding: 0; max-width: none; }
  .print-grid { grid-template-columns: 1fr 1fr; gap: 8mm; }
  .print-card { border-color: #888; }
  :root { --paper: #fff; --olive-soft: #eef0e4; --ink: #000; --muted: #555; color-scheme: light; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
