/* ═══════════════════════════════════════════════════════════
   حضوري — نظام الحضور والانصراف بالموقع الجغرافي
   ملف التنسيقات — JavaScript + CSS خالصان
   ═══════════════════════════════════════════════════════════ */

/* الهوية البصرية مستوحاة من شعار المعهد: الأزرق الملكي + الأحمر + لمسات فضية */
:root {
  --bg: #f2f4fa;
  --card: #ffffff;
  --ink: #10152e;
  --muted: #5f6b8a;
  --line: #e3e7f2;
  --brand: #2B3990;
  --brand-2: #1B75BC;
  --brand-deep: #222E86;
  --brand-soft: #EDF0FB;
  --brand-ink: #232C7A;
  --gold: #d97706;
  --gold-soft: #fef3c7;
  --danger: #C1272D;
  --danger-soft: #fdecec;
  --warn: #d97706;
  --warn-soft: #fef3e2;
  --ok: #059669;
  --ok-soft: #ecfdf5;
  --ok-ink: #065f46;
  --info: #1B75BC;
  --info-soft: #e8f1f9;
  --side: #141B52;
  --side-2: #1B2465;
  --side-ink: #c4cdf0;
  --shadow: 0 1px 2px rgba(24, 32, 78, .05), 0 12px 32px -14px rgba(24, 32, 78, .18);
  --shadow-lg: 0 18px 48px -16px rgba(24, 32, 78, .26);
  --radius: 18px;
  --font: 'Cairo', 'Tajawal', 'Segoe UI', Tahoma, system-ui, sans-serif;
  --font-display: 'Cairo', 'Tajawal', 'Segoe UI', Tahoma, sans-serif;
  --font-body: 'Tajawal', 'Cairo', 'Segoe UI', Tahoma, system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
  font-size: 14.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* الخطوط الاحترافية: Cairo للعناوين والواجهة · Tajawal للنصوص */
h1, h2, h3, h4, h5, h6, .btn, .tab, .side-link, .auth-tab, .auth-subtab,
.stat b, .brand-mini b, .side-brand b, .top-clock, .ck-wrap, .clock-hero,
.modal-head h4, .page-head h3, label.field > span, .chip, .demo-chip,
.paper-opt, .orient-opt, .pts-tile b, .auth-brand h1, .pr-doc {
  font-family: var(--font-display);
}
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: .92em; }
.ic { width: 1.2em; height: 1.2em; fill: currentColor; flex: none; vertical-align: -.18em; }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: #c3cdd9; border-radius: 9px; }
::-webkit-scrollbar-track { background: transparent; }

/* ═══════════ الأزرار ═══════════ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45em;
  font-family: inherit; font-size: .93em; font-weight: 700;
  padding: .58em 1.1em; border-radius: 12px; border: 1px solid transparent;
  cursor: pointer; transition: .18s; white-space: nowrap; user-select: none;
  background: #edf0f8; color: var(--ink);
}
.btn:hover { filter: brightness(.97); transform: translateY(-1.5px); }
.btn:active { transform: translateY(0) scale(.975); transition: .08s; }
.btn.primary { background: linear-gradient(135deg, #2E3192, #1B75BC); color: #fff; box-shadow: 0 8px 20px -8px rgba(43, 57, 144, .55); }
.btn.primary:hover { box-shadow: 0 12px 26px -8px rgba(43, 57, 144, .68); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.dangersoft { background: var(--danger-soft); color: var(--danger); }
.btn.warnsoft { background: var(--warn-soft); color: var(--warn); }
.btn.oksoft { background: var(--ok-soft); color: var(--ok-ink); }
.btn.ghost { background: transparent; border-color: var(--line); color: inherit; }
.btn.ghost:hover { background: rgba(0, 0, 0, .04); }
.btn.lg { padding: .8em 1.4em; font-size: 1.02em; border-radius: 14px; }
.btn.sm { padding: .35em .7em; font-size: .85em; border-radius: 9px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.icon-btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 11px; border: none; cursor: pointer;
  background: transparent; color: inherit; transition: .15s;
}
.icon-btn:hover { background: rgba(0, 0, 0, .06); }

/* ═══════════ شاشة الدخول ═══════════ */
.auth-view { display: grid; grid-template-columns: 1.05fr 1fr; min-height: 100vh; }
.auth-hero {
  position: relative; display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(900px 520px at 85% -10%, rgba(72, 96, 224, .28), transparent 60%),
    radial-gradient(760px 520px at -10% 110%, rgba(193, 39, 45, .16), transparent 60%),
    linear-gradient(160deg, #10164a 0%, #1a2160 55%, #0d1238 100%);
  color: #eaf2fa; padding: 3rem; overflow: hidden;
}
.auth-hero::before {
  content: ''; position: absolute; inset: 0; opacity: .5;
  background-image: radial-gradient(rgba(255, 255, 255, .08) 1px, transparent 1.4px);
  background-size: 26px 26px;
}
/* كتلاً ضوئية عائمة لحركة حية في الخلفية */
.auth-hero .hero-blob {
  position: absolute; border-radius: 50%; filter: blur(70px); opacity: .5; pointer-events: none;
  animation: blobFloat 14s ease-in-out infinite alternate;
}
.hero-blob.b1 { width: 420px; height: 420px; background: radial-gradient(circle, rgba(72, 96, 224, .4), transparent 65%); top: -120px; inset-inline-end: -100px; }
.hero-blob.b2 { width: 360px; height: 360px; background: radial-gradient(circle, rgba(193, 39, 45, .24), transparent 65%); bottom: -110px; inset-inline-start: -90px; animation-delay: -7s; }
@keyframes blobFloat {
  from { transform: translate(0, 0) scale(1); }
  to { transform: translate(-36px, 30px) scale(1.12); }
}
.auth-brand { position: relative; max-width: 480px; animation: brandIn .7s cubic-bezier(.2, .9, .3, 1.05); }
@keyframes brandIn { from { opacity: 0; transform: translateY(16px); } }
.brand-mark {
  width: 74px; height: 74px; border-radius: 22px; display: grid; place-items: center;
  background: linear-gradient(135deg, #2E3192, #1B75BC); color: #fff; font-size: 2em;
  box-shadow: 0 14px 34px -10px rgba(43, 57, 144, .6); margin-bottom: 1.2rem;
  animation: markGlow 3.2s ease-in-out infinite;
}
@keyframes markGlow {
  0%, 100% { box-shadow: 0 14px 34px -10px rgba(43, 57, 144, .6); }
  50% { box-shadow: 0 14px 44px -6px rgba(46, 117, 188, .8); }
}
.brand-mark .ic { width: 1.5em; height: 1.5em; }
.auth-brand h1 { font-size: 2.5rem; font-weight: 900; letter-spacing: -.5px; }
.brand-sub { color: #9aa8d8; margin: .5rem 0 2rem; font-size: 1.06rem; }
.brand-feats { list-style: none; display: grid; gap: .95rem; }
.brand-feats li { display: flex; gap: .7rem; align-items: flex-start; color: #c9d3f2; }
.brand-feats .ic { color: #93B4F5; margin-top: .18em; width: 1.25em; height: 1.25em; }
.auth-panel { display: flex; flex-direction: column; background: var(--bg); }
.auth-top { display: flex; justify-content: flex-start; padding: 1.1rem 1.4rem; }
[dir="ltr"] .auth-top { justify-content: flex-end; }
.auth-card {
  position: relative;
  width: min(440px, 100%); margin: auto; background: var(--card);
  border: 1px solid var(--line); border-radius: 22px; padding: 1.8rem;
  box-shadow: var(--shadow);
  overflow: hidden;
}
/* شريط توقيع بألوان الشعار أعلى بطاقة الدخول */
.auth-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px;
  background: linear-gradient(90deg, #2E3192, #1B75BC 55%, #C1272D);
}
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; background: #edf1f6; border-radius: 13px; padding: 4px; margin-bottom: 1.4rem; }
.auth-tab {
  border: none; background: transparent; font: inherit; font-weight: 700;
  padding: .55em; border-radius: 10px; cursor: pointer; color: var(--muted);
}
.auth-tab.active { background: #fff; color: var(--brand-ink); box-shadow: 0 1px 4px rgba(0, 0, 0, .08); }
.auth-form h2 { font-size: 1.35rem; margin-bottom: .2rem; }
.auth-form > .muted { margin-bottom: 1.2rem; }
.auth-form .btn[type="submit"] { margin-top: .4rem; }
.demo-box {
  margin-top: 1.3rem; padding: .85rem; background: #f7f8fc; border: 1px dashed #c3cdf2;
  border-radius: 12px; display: grid; gap: .5rem; font-size: .88em;
}
.demo-chip {
  text-align: start; font-family: inherit; font-size: .95em; cursor: pointer;
  background: #fff; border: 1px solid var(--line); border-radius: 9px; padding: .45em .7em;
  transition: .15s;
}
.demo-chip:hover { border-color: var(--brand); background: var(--brand-soft); }
.auth-foot { text-align: center; color: var(--muted); font-size: .85em; padding: 1.4rem; }

/* ═══════════ الحقول ═══════════ */
.field { display: grid; gap: .35rem; margin-bottom: .95rem; }
.field > span { font-weight: 700; font-size: .88em; color: #334155; }
.field input, .field select, .field textarea {
  font-family: inherit; font-size: .95em; padding: .62em .8em;
  border: 1.5px solid var(--line); border-radius: 11px; background: #fff; color: var(--ink);
  transition: .15s; width: 100%;
}
.field textarea { resize: vertical; min-height: 84px; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3.5px rgba(43, 57, 144, .15);
}
.in-ico { position: relative; }
.in-ico .ic { position: absolute; top: 50%; inset-inline-start: .75em; transform: translateY(-50%); color: var(--muted); }
.in-ico input { padding-inline-start: 2.4em; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.form-error {
  background: var(--danger-soft); color: var(--danger); font-weight: 700; font-size: .88em;
  border-radius: 10px; padding: .6em .8em; margin-bottom: .8rem;
}

/* ═══════════ الهيكل العام للتطبيق ═══════════ */
.app-view { min-height: 100vh; display: flex; flex-direction: column; }
.app-view.with-sidebar { flex-direction: row; }
.topbar {
  display: flex; align-items: center; gap: .9rem;
  background: rgba(255, 255, 255, .86); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  padding: .55rem 1.1rem; position: sticky; top: 0; z-index: 40; min-height: 60px;
}
/* خط توقيع بألوان الشعار أسفل الشريط العلوي */
.topbar::after {
  content: ''; position: absolute; bottom: -1px; left: 0; right: 0; height: 2.5px;
  background: linear-gradient(90deg, var(--danger) 0%, #1B75BC 35%, #2E3192 100%);
  opacity: .9; pointer-events: none;
}
.brand-mini { display: flex; align-items: center; gap: .45rem; font-size: 1.08rem; color: var(--brand-deep); }
.brand-mini .ic { width: 1.35em; height: 1.35em; }
.top-clock {
  display: inline-flex; align-items: center; gap: .45rem; margin-inline-start: .4rem;
  background: var(--brand-soft); color: var(--brand-ink); font-weight: 800;
  border-radius: 10px; padding: .32em .8em; font-variant-numeric: tabular-nums;
  font-size: .95em;
}
.top-actions { display: flex; align-items: center; gap: .35rem; margin-inline-start: auto; }
.avatar {
  width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand), var(--brand-deep));
  color: #fff; font-weight: 800; font-size: 1.05em; flex: none;
}
.who { display: flex; align-items: center; gap: .6rem; }
.who-txt { line-height: 1.25; }
.who-txt b { font-size: .92em; display: block; }
.who-txt small { color: var(--muted); font-size: .78em; }
.page-title { font-size: 1.12rem; font-weight: 800; }
.menu-btn { display: none; }

/* ═══════════ تبويبات الموظف السفلية/العلوية ═══════════ */
.tabbar {
  display: flex; gap: .25rem; background: var(--card); border-bottom: 1px solid var(--line);
  padding: .45rem .8rem; overflow-x: auto; position: sticky; top: 60px; z-index: 39;
}
.tab {
  display: inline-flex; align-items: center; gap: .4em; border: none; cursor: pointer;
  background: transparent; font: inherit; font-weight: 700; color: var(--muted);
  padding: .5em .95em; border-radius: 11px; transition: .15s; white-space: nowrap;
}
.tab:hover { background: #edf0f8; color: var(--ink); }
.tab.active { background: var(--brand-soft); color: var(--brand-ink); box-shadow: inset 0 -2px 0 var(--brand); }

/* ═══════════ الشريط الجانبي للإدارة ═══════════ */
.sidebar {
  width: 252px; flex: none; color: var(--side-ink);
  background: linear-gradient(195deg, #141B52 0%, #1B2465 55%, #10163E 100%);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
  z-index: 60; border-inline-end: 1px solid rgba(148, 163, 220, .16);
}
.side-brand {
  display: flex; gap: .7rem; align-items: center; padding: 1.05rem 1.15rem;
  border-bottom: 1px solid rgba(255, 255, 255, .08); color: #fff;
}
.side-brand .ic { width: 1.9em; height: 1.9em; color: #8FA8F0; }
.side-brand b { font-size: 1.1rem; display: block; line-height: 1.2; }
.side-brand small { color: #7d93b2; font-size: .78em; }
.side-nav { flex: 1; overflow-y: auto; padding: .7rem .6rem; display: grid; gap: 2px; align-content: start; }
.side-link {
  display: flex; align-items: center; gap: .65em; width: 100%;
  border: none; background: transparent; color: var(--side-ink); cursor: pointer;
  font: inherit; font-size: .93em; font-weight: 600; text-align: start;
  padding: .58em .8em; border-radius: 11px; transition: .16s; position: relative;
}
.side-link .ic { transition: transform .18s; }
.side-link:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.side-link:hover .ic { transform: scale(1.14); }
.side-link.active {
  background: linear-gradient(135deg, rgba(96, 120, 240, .32), rgba(27, 117, 188, .18));
  color: #fff; box-shadow: inset 0 0 0 1px rgba(143, 168, 240, .3);
}
.side-link.active::before {
  content: ''; position: absolute; inset-inline-start: 0; top: 22%; bottom: 22%;
  width: 3.5px; border-radius: 4px; background: #8FA8F0; box-shadow: 0 0 12px rgba(143, 168, 240, .9);
}
.side-badge {
  margin-inline-start: auto; background: var(--danger); color: #fff; font-size: .72em;
  font-weight: 800; min-width: 1.5em; text-align: center; border-radius: 99px; padding: .1em .45em;
}
.side-foot { padding: .9rem; border-top: 1px solid rgba(255, 255, 255, .07); }
.side-foot .btn { color: #ffd9df; border-color: rgba(255, 255, 255, .16); }
.side-foot .btn:hover { background: rgba(193, 39, 45, .22); }
.side-scrim { display: none; }
.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.main-col .topbar { position: sticky; top: 0; }
.admin-top { gap: 1rem; }

/* ═══════════ محتوى الصفحات ═══════════ */
.page-host { flex: 1; padding: 1.35rem; max-width: 1280px; width: 100%; margin: 0 auto; }
.page { display: grid; gap: 1.15rem; }
/* حركة دخول متدرجة لعناصر الصفحة */
.page > * { animation: fadeUp .38s cubic-bezier(.2, .8, .3, 1) both; }
.page > *:nth-child(1) { animation-delay: .02s; }
.page > *:nth-child(2) { animation-delay: .07s; }
.page > *:nth-child(3) { animation-delay: .12s; }
.page > *:nth-child(4) { animation-delay: .17s; }
.page > *:nth-child(5) { animation-delay: .22s; }
.page > *:nth-child(6) { animation-delay: .27s; }
.page > *:nth-child(n+7) { animation-delay: .32s; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(9px); } to { opacity: 1; transform: none; } }
.page-head { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; }
.page-head h3 { font-size: 1.16rem; font-weight: 800; }
.page-head .spacer { flex: 1; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.15rem 1.25rem; box-shadow: var(--shadow);
  transition: box-shadow .25s, transform .25s, border-color .25s;
}
@media (hover: hover) {
  .card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); border-color: #d7dfeb; }
}
.card h4 { font-size: 1rem; font-weight: 800; margin-bottom: .8rem; display: flex; align-items: center; gap: .5em; }
.card h4 .ic { color: var(--brand); }
.grid-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }

/* بطاقات الإحصائيات */
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem 1.15rem; display: flex; gap: .9rem; align-items: center; box-shadow: var(--shadow);
}
.stat-ico {
  width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; font-size: 1.35em; flex: none;
}
.stat-ico.ok { background: var(--ok-soft); color: var(--ok); }
.stat-ico.warn { background: var(--warn-soft); color: var(--warn); }
.stat-ico.danger { background: var(--danger-soft); color: var(--danger); }
.stat-ico.info { background: var(--info-soft); color: var(--info); }
.stat-ico.gold { background: var(--gold-soft); color: var(--gold); }
.stat b { font-size: 1.5rem; font-weight: 900; display: block; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat small { color: var(--muted); font-weight: 700; font-size: .84em; }

/* ═══════════ الشارات والوسوم ═══════════ */
.chip {
  display: inline-flex; align-items: center; gap: .3em; font-size: .78em; font-weight: 800;
  padding: .22em .75em; border-radius: 99px; white-space: nowrap;
}
.chip.ok { background: var(--ok-soft); color: var(--ok-ink); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.danger { background: var(--danger-soft); color: var(--danger); }
.chip.info { background: var(--info-soft); color: var(--info); }
.chip.gray { background: #edf0f8; color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; display: inline-block; }
.dot.pulse { animation: pulse 1.4s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(43, 57, 144, .5); } 70% { box-shadow: 0 0 0 7px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
.spin-ic { animation: spin 1.1s linear infinite; }

/* ═══════════ الجداول ═══════════ */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; background: var(--card); }
table.tbl { width: 100%; border-collapse: collapse; font-size: .9em; min-width: 640px; }
.tbl th {
  text-align: start; font-size: .8em; color: var(--muted); font-weight: 800;
  background: #f4f6fb; padding: .7em .85em; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.tbl td { padding: .66em .85em; border-bottom: 1px solid #eef0f7; vertical-align: middle; }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl tbody tr:hover { background: #f6f8fd; }
.tbl .num { font-variant-numeric: tabular-nums; }
.row-actions { display: flex; gap: .3rem; justify-content: flex-end; }
.empty {
  text-align: center; color: var(--muted); padding: 2.2rem 1rem; font-weight: 600;
}
.empty .ic { width: 2.2em; height: 2.2em; opacity: .4; display: block; margin: 0 auto .5rem; }

/* ═══════════ بوابة الموظف — الحضور ═══════════ */
.emp-hero {
  display: grid; grid-template-columns: 1.25fr 1fr; gap: 1.15rem;
}
.checkin-card {
  background:
    radial-gradient(600px 300px at 90% -20%, rgba(72, 96, 224, .14), transparent 60%),
    radial-gradient(500px 300px at 0% 120%, rgba(27, 117, 188, .1), transparent 55%),
    var(--card);
  border: 1px solid var(--line); border-radius: 20px; padding: 1.5rem;
  box-shadow: var(--shadow); display: grid; gap: 1rem; justify-items: center; text-align: center;
}
.big-clock {
  font-size: 3rem; font-weight: 900; letter-spacing: 1px; line-height: 1.1;
  font-variant-numeric: tabular-nums; color: var(--ink);
}
.big-date { color: var(--muted); font-weight: 700; }
.state-line { display: flex; gap: .5rem; align-items: center; font-weight: 800; }
.btn-check {
  position: relative; width: 168px; height: 168px; border-radius: 50%; border: none;
  cursor: pointer; font-family: inherit; color: #fff; transition: .2s; display: grid; place-items: center; gap: .1em;
  background: linear-gradient(145deg, #2E3192, #1B75BC);
  box-shadow: 0 18px 38px -12px rgba(34, 46, 134, .6), inset 0 -4px 10px rgba(0, 0, 0, .18);
  font-size: 1.02rem; font-weight: 900;
}
.btn-check .ic { width: 1.9em; height: 1.9em; }
.btn-check small { display: block; font-weight: 700; opacity: .85; font-size: .78em; }
.btn-check.out { background: linear-gradient(145deg, #d94a50, #9E1C22); box-shadow: 0 18px 38px -12px rgba(158, 28, 34, .6), inset 0 -4px 10px rgba(0, 0, 0, .18); }
.btn-check:hover:not(:disabled) { transform: scale(1.035); }
.btn-check:disabled { filter: grayscale(.55); opacity: .6; cursor: not-allowed; }
.btn-check .ring {
  position: absolute; inset: -9px; border-radius: 50%;
  border: 2.5px dashed rgba(43, 57, 144, .45); animation: spin 14s linear infinite;
}
.btn-check.out .ring { border-color: rgba(193, 39, 45, .4); }
@keyframes spin { to { transform: rotate(360deg); } }
.gps-line { display: flex; align-items: center; gap: .45em; font-size: .9em; color: var(--muted); font-weight: 700; flex-wrap: wrap; justify-content: center; }
.gps-line .ic { color: var(--brand); }

/* لوحة الرادار */
.radar-card { display: grid; gap: .8rem; }
.radar-box { position: relative; border-radius: 16px; overflow: hidden; border: 1px solid var(--line); background: #0b1524; }
.radar-box canvas { display: block; width: 100%; height: auto; }
.radar-meta { display: flex; justify-content: space-between; gap: .6rem; font-size: .85em; color: var(--muted); font-weight: 700; flex-wrap: wrap; }

/* الجدول الزمني لليوم */
.timeline { display: grid; gap: .55rem; }
.tl-item {
  display: flex; gap: .8rem; align-items: center; background: #f7f9fb;
  border: 1px solid var(--line); border-radius: 12px; padding: .6rem .85rem;
}
.tl-ico { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: none; background: var(--brand-soft); color: var(--brand-ink); }
.tl-ico.gray { background: #edf0f8; color: var(--muted); }
.tl-ico.warn { background: var(--warn-soft); color: var(--warn); }
.tl-item b { display: block; font-size: .92em; }
.tl-item small { color: var(--muted); }

/* أرقام ملخص الأسبوع */
.week-strip { display: grid; grid-template-columns: repeat(7, 1fr); gap: .5rem; }
.wd {
  background: #f7f9fb; border: 1px solid var(--line); border-radius: 12px;
  text-align: center; padding: .55rem .2rem;
}
.wd small { display: block; color: var(--muted); font-weight: 800; font-size: .72em; }
.wd b { font-size: .92em; font-variant-numeric: tabular-nums; }
.wd.off { opacity: .45; }
.wd.today { border-color: var(--brand); background: var(--brand-soft); }
.wd .st { display: block; width: 8px; height: 8px; border-radius: 50%; margin: .25rem auto 0; }
.st-present { background: var(--ok); }
.st-late { background: var(--warn); }
.st-absent { background: var(--danger); }
.st-none { background: #c7cee6; }

/* ═══════════ الإشعارات ═══════════ */
.notif-wrap { position: relative; }
.badge {
  position: absolute; top: 2px; inset-inline-end: 2px; background: var(--danger); color: #fff;
  font-size: .68em; font-weight: 800; min-width: 1.55em; height: 1.55em; line-height: 1.55em;
  text-align: center; border-radius: 99px; padding: 0 .25em;
}
.notif-panel {
  position: absolute; top: calc(100% + 8px); inset-inline-end: 0; width: min(360px, 92vw);
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: 0 18px 44px -12px rgba(24, 32, 78, .3); z-index: 80; overflow: hidden;
}
.notif-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: .7rem 1rem; border-bottom: 1px solid var(--line); font-weight: 800;
}
.notif-list { max-height: 340px; overflow-y: auto; }
.notif-item { display: flex; gap: .7rem; padding: .75rem 1rem; border-bottom: 1px solid #f0f2f8; }
.notif-item:last-child { border-bottom: none; }
.notif-item.unread { background: #f3f5fc; }
.notif-ico { width: 34px; height: 34px; border-radius: 10px; background: var(--brand-soft); color: var(--brand-ink); display: grid; place-items: center; flex: none; }
.notif-item b { font-size: .88em; display: block; }
.notif-item small { color: var(--muted); font-size: .8em; }
.notif-item p { font-size: .84em; color: #475569; }
.notif-empty { padding: 1.6rem; text-align: center; color: var(--muted); font-weight: 700; }

/* ═══════════ النوافذ المنبثقة ═══════════ */
.modal-scrim {
  position: fixed; inset: 0; background: rgba(12, 16, 44, .55); backdrop-filter: blur(3px);
  z-index: 100; display: grid; place-items: center; padding: 1rem; animation: fadeIn .18s;
}
@keyframes fadeIn { from { opacity: 0; } }
.modal {
  width: min(560px, 100%); max-height: 88vh; overflow-y: auto;
  background: var(--card); border-radius: 20px; box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .5);
  animation: pop .22s cubic-bezier(.2, .9, .3, 1.2);
}
@keyframes pop { from { opacity: 0; transform: scale(.94) translateY(10px); } }
.modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 1rem 1.3rem; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: var(--card); z-index: 2; border-radius: 20px 20px 0 0;
}
.modal-head h4 { font-size: 1.05rem; font-weight: 800; }
.modal-body { padding: 1.25rem 1.3rem; }
.modal-foot { display: flex; gap: .6rem; justify-content: flex-end; padding: 0 1.3rem 1.25rem; }

/* ═══════════ التنبيهات المنزلقة ═══════════ */
.toast-root {
  position: fixed; bottom: 1.2rem; inset-inline-start: 50%; transform: translateX(-50%);
  z-index: 200; display: grid; gap: .55rem; width: min(420px, calc(100vw - 2rem));
}
[dir="rtl"] .toast-root { transform: translateX(50%); }
.toast {
  display: flex; gap: .7rem; align-items: flex-start; background: #131a3d; color: #eaf2fa;
  border-radius: 14px; padding: .8rem 1rem; box-shadow: 0 16px 40px -10px rgba(0, 0, 0, .45);
  animation: toastIn .28s cubic-bezier(.2, .9, .3, 1.15);
}
@keyframes toastIn { from { opacity: 0; transform: translateY(14px) scale(.97); } }
.toast.leaving { animation: toastOut .25s forwards; }
@keyframes toastOut { to { opacity: 0; transform: translateY(8px) scale(.97); } }
.toast .ic { margin-top: .15em; }
.toast.ok .ic { color: #34d399; }
.toast.err .ic { color: #fb7185; }
.toast.warn .ic { color: #fbbf24; }
.toast b { display: block; font-size: .92em; }
.toast small { color: #9fb6c9; font-size: .82em; }

/* ═══════════ صفحات الإدارة ═══════════ */
.filters { display: flex; gap: .7rem; flex-wrap: wrap; align-items: flex-end; }
.filters .field { margin-bottom: 0; min-width: 150px; flex: 1; max-width: 240px; }
.filters .field.grow { max-width: none; }

.chart-box canvas { width: 100%; height: auto; display: block; }
.legend { display: flex; gap: 1.1rem; flex-wrap: wrap; font-size: .82em; font-weight: 700; color: var(--muted); }
.legend i { width: 11px; height: 11px; border-radius: 3.5px; display: inline-block; margin-inline-end: .4em; }

/* الحضور المباشر */
.live-grid { display: grid; grid-template-columns: 1fr 1.2fr; gap: 1.15rem; }
.live-item { display: flex; align-items: center; gap: .8rem; padding: .6rem .4rem; border-bottom: 1px solid #eef0f7; }
.live-item:last-child { border-bottom: none; }
.live-timer { margin-inline-start: auto; font-weight: 900; font-variant-numeric: tabular-nums; color: var(--brand-ink); background: var(--brand-soft); padding: .15em .6em; border-radius: 8px; font-size: .9em; }

/* الإعلانات */
.ann-card { border: 1px solid var(--line); border-radius: 14px; padding: 1rem 1.1rem; background: var(--card); }
.ann-card.pinned { border-color: #f3d9a4; background: linear-gradient(0deg, #fffdf6, #fff); }
.ann-head { display: flex; align-items: center; gap: .6rem; margin-bottom: .35rem; flex-wrap: wrap; }
.ann-head b { font-size: 1em; }
.ann-head .when { margin-inline-start: auto; color: var(--muted); font-size: .8em; font-weight: 700; }
.ann-body { color: #3f4f5f; font-size: .93em; white-space: pre-wrap; }
.ann-list { display: grid; gap: .8rem; }

/* ملف الموظف */
.profile-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.15rem; }
.kv { display: grid; gap: .1rem; padding: .55rem 0; border-bottom: 1px dashed var(--line); }
.kv small { color: var(--muted); font-weight: 700; }
.kv b { font-size: .95em; }

/* شريط التقدم */
.progress { height: 9px; border-radius: 9px; background: #e7ebf5; overflow: hidden; }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), #6E8FE8); border-radius: 9px; transition: width .4s; }

/* الطباعة */
@media print {
  body { background: #fff; }
  .sidebar, .topbar, .tabbar, .filters, .btn, .row-actions, .side-foot, .notif-wrap { display: none !important; }
  .page-host { padding: 0; max-width: none; }
  .card, .table-wrap { box-shadow: none; border-color: #bbb; }
  .app-view.with-sidebar { display: block; }
  .print-head { display: block !important; text-align: center; margin-bottom: 1rem; }
}
.print-head { display: none; }

/* ═══════════ التجاوب ═══════════ */
@media (max-width: 1024px) {
  .emp-hero, .live-grid, .profile-grid { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .auth-view { grid-template-columns: 1fr; }
  .auth-hero { padding: 2rem; }
  .brand-feats { display: none; }
  .auth-brand h1 { font-size: 1.9rem; }
  .auth-brand .brand-sub { margin-bottom: 0; font-size: .95rem; }
  .auth-panel { min-height: 60vh; }

  .sidebar {
    position: fixed; inset-block: 0; inset-inline-start: 0;
    transform: translateX(105%);
  }
  [dir="ltr"] .sidebar { transform: translateX(-105%); }
  .sidebar.open { transform: none; box-shadow: 0 0 60px rgba(0, 0, 0, .4); }
  .side-scrim.show { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 55; }
  .menu-btn { display: inline-flex; }
  .who-txt { display: none; }
  .page-host { padding: 1rem .85rem 5.4rem; }
  .tabbar {
    position: fixed; bottom: 0; top: auto; inset-inline: 0; z-index: 45;
    border-bottom: none; border-top: 1px solid var(--line);
    padding: .3rem .4rem calc(.3rem + env(safe-area-inset-bottom));
    justify-content: space-around; background: #fff;
  }
  .tab { flex-direction: column; gap: .12em; font-size: .72em; padding: .35em .7em; }
  .tab .ic { width: 1.45em; height: 1.45em; }
  .top-clock { display: none; }
  .grid2 { grid-template-columns: 1fr; gap: 0; }
  .big-clock { font-size: 2.4rem; }
}
@media (min-width: 901px) {
  .side-scrim { display: none !important; }
}

/* ═══════════ الأمان: بصمة الجهاز + القياسات الحيوية ═══════════ */

/* تبويبات الدخول الفرعية (هوية / القياسات الحيوية / مفتاح المرور) */
.auth-subtabs {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px;
  background: #edf1f6; border-radius: 12px; padding: 4px; margin-bottom: 1.1rem;
}
.auth-subtab {
  display: inline-flex; align-items: center; justify-content: center; gap: .4em;
  border: none; background: transparent; font: inherit; font-size: .92em; font-weight: 700;
  padding: .55em .4em; border-radius: 9px; cursor: pointer; color: var(--muted); transition: .15s;
}
.auth-subtab.active { background: #fff; color: var(--brand-ink); box-shadow: 0 1px 4px rgba(0, 0, 0, .08); }

/* شارة بصمة الجهاز في شاشة الدخول */
.fp-chip {
  width: min(440px, 100%); margin: .9rem auto 0; display: flex; align-items: center; gap: .5em;
  background: var(--card); border: 1px dashed #c3cdf2; color: var(--brand-ink);
  padding: .55em .95em; border-radius: 12px; font-size: .88em; font-weight: 600;
}
.fp-chip .ic { color: var(--brand); }
.fp-mono {
  font-family: ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
  font-size: .95em; letter-spacing: .06em; direction: ltr; unicode-bidi: embed;
}

/* صندوق الكاميرا مع إطار توجيه الوجه */
.cam-box {
  position: relative; border-radius: 15px; overflow: hidden;
  background: #0a0f26; aspect-ratio: 4 / 3; border: 1px solid #1a2350;
}
.cam-box.sm { aspect-ratio: 16 / 10; }
.cam-box video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); display: block; }
.cam-guide {
  position: absolute; top: 50%; left: 50%; width: 44%; aspect-ratio: .76;
  transform: translate(-50%, -50%); border: 2.5px dashed rgba(255, 255, 255, .8);
  border-radius: 50%; pointer-events: none;
  box-shadow: 0 0 0 999px rgba(6, 10, 32, .35), inset 0 0 22px rgba(143, 168, 240, .2);
}
.cam-status {
  position: absolute; bottom: 8px; inset-inline: 8px; text-align: center;
  background: rgba(6, 10, 30, .72); color: #d9e2f8; font-size: .82em; font-weight: 700;
  padding: .38em .6em; border-radius: 9px; pointer-events: none; min-height: 1.9em;
}

/* قسم تسجيل البصمة الوجهية داخل النوافذ */
.face-enroll { border: 1.5px solid var(--line); border-radius: 14px; padding: .85rem; margin: .8rem 0; background: #f7f8fc; }
.face-thumb {
  width: 58px; height: 58px; border-radius: 12px; object-fit: cover;
  border: 2px solid var(--ok); box-shadow: 0 3px 10px -4px rgba(13, 146, 104, .5);
}

/* ملاحظات حالة الجهاز */
.dev-note {
  display: flex; align-items: flex-start; gap: .5em; font-size: .88em; font-weight: 600;
  background: var(--info-soft); color: var(--info); border-radius: 11px; padding: .6em .8em; margin: .6rem 0;
}
.dev-note .ic { margin-top: .15em; }
.dev-note.ok { background: var(--ok-soft); color: var(--ok-ink); }
.dev-note.warn { background: var(--warn-soft); color: var(--warn); }

/* بطاقة أمان الحساب في ملف الموظف */
.sec-card { border-top: 3px solid var(--brand); }

/* تنبيهات التزوير */
.fraud-item {
  display: flex; align-items: center; gap: .7rem; padding: .65rem .8rem; margin-bottom: .55rem;
  background: var(--danger-soft); border: 1px solid #ffd0da; border-radius: 12px;
}
.fraud-item b { color: var(--danger); display: block; }
.fraud-item small { color: #9f3c56; display: block; }
.fraud-item .when { color: var(--muted); font-size: .82em; white-space: nowrap; }
.fraud-ico {
  width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center;
  background: #fff; color: var(--danger); flex: none;
}

@media (max-width: 900px) {
  .cam-guide { width: 54%; }
  .fp-chip { font-size: .8em; }
}

/* ═══════════ الماسح الخفي: التحقق الحيوي عند الحضور دون عرض الوجه ═══════════ */
.scan-visual {
  position: relative; border-radius: 16px; overflow: hidden;
  aspect-ratio: 4 / 3; border: 1px solid #1a2350;
  background: radial-gradient(120% 100% at 50% 0%, #182252 0%, #0b1030 70%);
  display: grid; place-items: center;
}
/* الفيديو يعمل خلف الكواليس فقط — لا يُعرض للمستخدم مطلقاً أثناء التحقق */
.scan-visual video {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; transform: scaleX(-1);
  opacity: 0; pointer-events: none;
}
.scan-face-ico {
  position: relative; z-index: 2; width: 78px; height: 78px; border-radius: 24px;
  display: grid; place-items: center; color: #9DB8F5;
  background: rgba(96, 120, 240, .12); border: 2px solid rgba(157, 184, 245, .4);
}
.scan-face-ico .ic { width: 42px; height: 42px; }
.scan-rings { position: absolute; inset: 0; display: grid; place-items: center; z-index: 1; }
.scan-rings span {
  position: absolute; border-radius: 26px;
  border: 2px solid rgba(96, 120, 240, .55);
  width: 110px; height: 110px; opacity: 0;
  animation: scanPulse 2.2s ease-out infinite;
}
.scan-rings span:nth-child(2) { animation-delay: .7s; }
.scan-rings span:nth-child(3) { animation-delay: 1.4s; }
@keyframes scanPulse {
  0% { transform: scale(.72); opacity: .85; }
  70% { transform: scale(1.55); opacity: 0; }
  100% { transform: scale(1.55); opacity: 0; }
}
.scan-status {
  position: absolute; bottom: 10px; inset-inline: 10px; z-index: 3; text-align: center;
  background: rgba(6, 15, 26, .8); color: #d6e1fa; font-size: .84em; font-weight: 700;
  padding: .42em .6em; border-radius: 10px; min-height: 2em; pointer-events: none;
}

/* ملاحظة الخصوصية */
.privacy-note {
  display: flex; align-items: center; gap: .5em; margin-top: .65rem;
  font-size: .82em; font-weight: 700; color: var(--brand-ink);
  background: var(--brand-soft); border: 1px dashed #c3cdf2;
  padding: .5em .75em; border-radius: 10px;
}
.privacy-note .ic { flex: none; color: var(--brand); }

/* ═══════════ القياسات الحيوية في ملف الموظف ═══════════ */
.bio-card .bio-row {
  display: flex; align-items: flex-start; gap: .8rem; padding: .75rem 0;
}
.bio-row-ico {
  flex: none; width: 46px; height: 46px; border-radius: 13px;
  display: grid; place-items: center;
}
.bio-row-ico .ic { width: 24px; height: 24px; }
.bio-row-ico.face { background: var(--info-soft); color: var(--info); }
.bio-row-ico.device { background: var(--ok-soft); color: var(--ok-ink); }
.bio-row-txt { flex: 1; min-width: 0; }
.bio-row-txt b { display: block; font-size: .96em; }
.bio-row-txt > small { display: block; color: var(--muted); font-size: .8em; margin-top: .15em; line-height: 1.55; }
.bio-row-state { margin-top: .45em; display: flex; align-items: center; flex-wrap: wrap; gap: .3em; }
.bio-row-actions { flex: none; display: flex; flex-direction: column; gap: .4rem; align-items: stretch; }
.bio-sep { border-top: 1px dashed var(--line); margin: .2rem 0; }

/* تبويبات الدخول بثلاثة أعمدة */
.auth-subtabs.three { grid-template-columns: 1fr 1fr 1fr; }
.auth-subtabs.three .auth-subtab { font-size: .82em; padding: .5em .3em; flex-direction: column; gap: .25em; }

/* بطاقة تعريف بصمة الجهاز/Passkey في شاشة الدخول */
.bio-hero {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  gap: .45rem; padding: 1.1rem .8rem; margin-bottom: .9rem;
  border: 1.5px dashed #c3cdf2; border-radius: 14px; background: #f6f8fd;
}
.bio-hero-ico {
  width: 58px; height: 58px; border-radius: 50%; display: grid; place-items: center;
  background: radial-gradient(circle at 35% 30%, #4C63D8, #2B3990);
  color: #fff; box-shadow: 0 8px 20px -8px rgba(43, 57, 144, .65);
}
.bio-hero-ico .ic { width: 30px; height: 30px; }
.bio-hero b { font-size: 1.02em; }
.bio-hero .muted { font-size: .84em; line-height: 1.6; margin: 0; }

/* مؤشر تقدم التقاط لقطات الوجه الثلاث */
.enroll-progress {
  display: flex; align-items: center; gap: .45rem; margin-top: .7rem;
  padding: .5rem .3rem;
}
.ep-dot {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid #c3cdf2; background: #fff; transition: .25s;
}
.ep-dot.done { background: var(--brand); border-color: var(--brand); box-shadow: 0 0 0 3px var(--ok-soft); }
.enroll-progress b { font-size: .84em; color: var(--muted); margin-inline-start: .3em; }

/* ═══════════ توافق أعمق مع أنظمة تشغيل الجوال ═══════════ */
html, body { -webkit-tap-highlight-color: transparent; }
body { touch-action: manipulation; overscroll-behavior-y: none; -webkit-font-smoothing: antialiased; }
img, svg, video { max-width: 100%; }
button, .btn, .tab, .icon-btn, .auth-tab, .auth-subtab, .side-link { touch-action: manipulation; user-select: none; -webkit-user-select: none; }

/* أهداف لمس مريحة ومنع تكبير iOS عند التركيز على الحقول */
@media (max-width: 900px) {
  input, select, textarea { font-size: 16px; }
  .btn { min-height: 44px; }
  .btn.lg { min-height: 50px; }
  .auth-card { padding: 1.15rem 1rem; border-radius: 18px; }
  .auth-panel { padding: 1rem .9rem calc(1.2rem + env(safe-area-inset-bottom)); }
  .topbar { padding-top: env(safe-area-inset-top); }
  .modal { width: min(94vw, 480px); max-height: 88vh; }
  .modal-body { overflow-y: auto; -webkit-overflow-scrolling: touch; }
  .bio-row { flex-wrap: wrap; }
  .bio-row-actions { flex-direction: row; width: 100%; }
  .bio-row-actions .btn { flex: 1; }
  .scan-face-ico { width: 62px; height: 62px; }
  .scan-face-ico .ic { width: 34px; height: 34px; }
  .scan-rings span { width: 92px; height: 92px; }
  .toast-root { bottom: calc(4.6rem + env(safe-area-inset-bottom)); }
}

/* ═══════════ بيانات المنشأة: الشعار والتوقيعات ═══════════ */
.org-name-line { font-weight: 800; color: #A8B8F5; font-size: .92em; letter-spacing: .3px; margin-top: .15rem; }
.brand-mark .org-logo-img { width: 74px; height: 74px; object-fit: contain; border-radius: 16px; background: #fff; padding: 6px; box-shadow: 0 8px 22px -8px rgba(0,0,0,.35); }
.side-brand .org-logo-img, .brand-mini .org-logo-img { width: 34px; height: 34px; object-fit: contain; border-radius: 9px; background: #fff; padding: 2px; flex-shrink: 0; }
.upload-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: .9rem; }
.upload-tile { border: 1.5px dashed var(--line); border-radius: 14px; padding: 1rem; display: flex; flex-direction: column; gap: .45rem; align-items: flex-start; }
.upload-prev { width: 100%; height: 96px; border-radius: 10px; background: #f3f5fb; display: flex; align-items: center; justify-content: center; gap: .4rem; color: #94a3b8; overflow: hidden; }
.upload-prev .ic { width: 26px; height: 26px; }
.upload-prev img { max-width: 100%; max-height: 100%; object-fit: contain; }

/* ═══════════ نقاط الانضباط ═══════════ */
.pt-dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-inline-end: .45em; vertical-align: -1px; box-shadow: inset 0 0 0 1.5px rgba(255,255,255,.35); }
.pt-dot.red { background: #ef4444; }
.pt-dot.green { background: #10b981; }
.pt-dot.black { background: #1e293b; }
.pts-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .7rem; }
.pts-tile { border-radius: 14px; padding: .85rem .5rem; text-align: center; color: #fff; }
.pts-tile.red { background: linear-gradient(135deg, #ef4444, #b91c1c); }
.pts-tile.green { background: linear-gradient(135deg, #10b981, #047857); }
.pts-tile.black { background: linear-gradient(135deg, #475569, #0f172a); }
.pts-tile b { font-size: 1.5em; display: block; line-height: 1.15; }
.pts-tile small { opacity: .92; font-weight: 700; }
.pts-log-item { display: flex; gap: .6rem; padding: .45rem 0; border-bottom: 1px dashed var(--line); align-items: center; font-size: .86em; }
.pts-log-item:last-child { border-bottom: none; }
.pts-summary-line { font-weight: 800; margin-bottom: .7rem; display: flex; align-items: center; gap: .3rem; }
.card.dev-note { align-items: flex-start; }

/* ═══════════ الطباعة الاحترافية (A4) ═══════════ */
#printArea { display: none; }
@media print {
  @page { size: A4; margin: 12mm; }
  body.print-mode { background: #fff !important; }
  body.print-mode > *:not(#printArea) { display: none !important; }
  body.print-mode #printArea { display: block !important; }
  .pr-doc { font-family: Cairo, sans-serif; color: #111827; }
  .pr-head { display: flex; align-items: center; gap: 12px; border-bottom: 3px solid #2B3990; padding-bottom: 10px; margin-bottom: 8px; }
  .pr-head-logo img { width: 76px; height: 76px; object-fit: contain; }
  .pr-logo-fallback { width: 76px; height: 76px; border-radius: 14px; background: #2B3990; color: #fff; display: flex; align-items: center; justify-content: center; }
  .pr-logo-fallback .ic { width: 38px; height: 38px; }
  .pr-head-org { flex: 1; }
  .pr-head-org b { font-size: 1.35em; display: block; }
  .pr-head-org small { display: block; color: #4b5563; font-size: .82em; }
  .pr-head-title { text-align: end; }
  .pr-head-title b { font-size: 1.12em; display: block; color: #2B3990; }
  .pr-head-title small { color: #6b7280; font-size: .82em; }
  .pr-meta { display: flex; justify-content: space-between; font-size: .8em; color: #6b7280; border-bottom: 1px solid #e5e7eb; padding-bottom: 6px; margin-bottom: 12px; }
  .pr-table-wrap { margin-bottom: 14px; }
  .pr-tbl { width: 100%; border-collapse: collapse; font-size: .85em; }
  .pr-tbl th { background: #2B3990; color: #fff; padding: 7px 8px; text-align: start; font-weight: 700; }
  .pr-tbl td { border: 1px solid #d1d5db; padding: 6px 8px; }
  .pr-tbl tbody tr:nth-child(even) { background: #f3f5fb; }
  .pr-total td { background: #e8ecf8 !important; font-weight: 800; }
  .pr-info { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px 14px; margin-bottom: 10px; font-size: .85em; }
  .pr-info div span { display: block; color: #6b7280; font-size: .86em; }
  .pr-points { display: flex; gap: 16px; align-items: center; margin-bottom: 10px; font-size: .95em; flex-wrap: wrap; }
  .pr-dot { display: inline-block; width: 11px; height: 11px; border-radius: 50%; }
  .pr-dot.red { background: #ef4444; }
  .pr-dot.green { background: #10b981; }
  .pr-dot.black { background: #1e293b; }
  .pr-signs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 26px; page-break-inside: avoid; }
  .pr-sign { text-align: center; }
  .pr-sign-box { height: 66px; display: flex; align-items: flex-end; justify-content: center; }
  .pr-sign-box img { max-height: 62px; max-width: 150px; object-fit: contain; }
  .pr-sign-line { display: block; width: 80%; border-bottom: 2px dotted #6b7280; margin-bottom: 8px; }
  .pr-sign b { font-size: .85em; color: #374151; border-top: 1.5px solid #9ca3af; padding-top: 4px; display: block; width: 85%; margin: 0 auto; }
  .pr-foot { display: flex; justify-content: space-between; font-size: .75em; color: #9ca3af; border-top: 1px solid #e5e7eb; margin-top: 14px; padding-top: 6px; }
}

/* ═══════════ بطاقة الدخول بالقياسات الحيوية بأسلوب iOS ═══════════ */
.ios-face-card {
  position: relative; display: grid; justify-items: center; gap: .55rem; text-align: center;
  background: radial-gradient(130% 120% at 50% 0%, #182252 0%, #0b1030 68%);
  border: 1px solid #1a2350; border-radius: 22px; padding: 1.5rem 1rem 1.15rem;
  overflow: hidden;
}
.ifc-frame { position: relative; width: 104px; height: 104px; display: grid; place-items: center; }
.ifc-frame video {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  transform: scaleX(-1); opacity: 0; pointer-events: none; /* تعمل خلف الكواليس فقط */
}
.ifc-frame::before {
  content: ''; position: absolute; inset: 0; border-radius: 26px;
  border: 2px solid rgba(157, 184, 245, .42);
  box-shadow: inset 0 0 24px rgba(96, 120, 240, .14);
}
.ifc-ico { width: 58px; height: 58px; color: #9DB8F5; z-index: 2; transition: .3s; }
.ios-face-card.scanning .ifc-ico { animation: ifcGlow 1.6s ease-in-out infinite; }
@keyframes ifcGlow {
  0%, 100% { color: #9DB8F5; filter: drop-shadow(0 0 2px rgba(157, 184, 245, .3)); }
  50% { color: #C9D8FA; filter: drop-shadow(0 0 10px rgba(157, 184, 245, .8)); }
}
.ifc-beam {
  position: absolute; left: 12%; right: 12%; top: 8%; height: 3px; border-radius: 3px;
  background: linear-gradient(90deg, transparent, #6E8FE8, transparent);
  z-index: 3; opacity: 0;
}
.ios-face-card.scanning .ifc-beam { opacity: 1; animation: ifcBeam 1.5s ease-in-out infinite; }
@keyframes ifcBeam { 0% { top: 10%; } 50% { top: 86%; } 100% { top: 10%; } }
.ifc-rings { position: absolute; inset: 0; display: grid; place-items: center; z-index: 1; pointer-events: none; }
.ifc-rings span {
  position: absolute; width: 104px; height: 104px; border-radius: 26px;
  border: 2px solid rgba(96, 120, 240, .5); opacity: 0;
  animation: ifcPulse 2s ease-out infinite;
}
.ifc-rings span:nth-child(2) { animation-delay: 1s; }
@keyframes ifcPulse {
  0% { transform: scale(.9); opacity: .8; }
  75% { transform: scale(1.45); opacity: 0; }
  100% { transform: scale(1.45); opacity: 0; }
}
.ifc-title { color: #e8edfc; font-size: 1.02em; z-index: 2; }
.ifc-status { color: #93a8e8; font-size: .86em; font-weight: 700; min-height: 1.5em; z-index: 2; }
.ifc-check { width: 58px; height: 58px; color: #34d399; z-index: 2; }
.ios-face-card.ok { border-color: rgba(52, 211, 153, .55); }
.ios-face-card.ok .ifc-check { animation: ifcPop .5s cubic-bezier(.2, .9, .3, 1.45); }
@keyframes ifcPop { from { transform: scale(.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.ios-face-card.ok .ifc-frame::before { border-color: rgba(52, 211, 153, .7); }
.ios-face-card.fail .ifc-frame { animation: ifcShake .42s; }
.ios-face-card.fail .ifc-ico { color: #fda4af; }
.ios-face-card.fail .ifc-frame::before { border-color: rgba(253, 164, 175, .6); }
@keyframes ifcShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-7px); }
  40% { transform: translateX(7px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
}

/* ═══════════ الخرائط الحية (Leaflet) ═══════════ */
.map-box {
  position: relative; border-radius: 16px; overflow: hidden;
  border: 1px solid var(--line); height: 320px; background: #e7edf4;
  z-index: 0;
}
.map-box.tall { height: 380px; }
.map-box.modal-map { height: 300px; }
.map-box .leaflet-container { height: 100%; width: 100%; font: inherit; }
.map-fallback {
  display: grid; place-items: center; align-content: center; gap: .5rem; height: 100%;
  color: var(--muted); font-weight: 700; font-size: .9em; padding: 1rem; text-align: center;
}
.map-fallback .ic { width: 34px; height: 34px; opacity: .5; }
/* علامة مخصصة دائرية */
.lm-pin {
  width: 32px; height: 32px; border-radius: 50%; background: var(--pin, #2B3990);
  border: 3px solid #fff; box-shadow: 0 5px 12px rgba(15, 23, 42, .4);
  display: grid; place-items: center; color: #fff;
}
.lm-pin .ic { width: 15px; height: 15px; fill: #fff; }
.lm-pin b { font-size: .82em; font-weight: 900; color: #fff; line-height: 1; }
.lm-pin-wrap { background: transparent; border: none; }
/* نبض نقطة موقعي الحالي */
.leaflet-interactive.lm-me-marker { animation: lmMePulse 2s infinite; }
@keyframes lmMePulse {
  0%, 100% { stroke-width: 3; }
  50% { stroke-width: 6; }
}
.leaflet-control-attribution { font-size: .62rem !important; direction: ltr; }
.leaflet-tooltip { font-family: var(--font); font-weight: 700; direction: rtl; }

/* ─── أزرار التحكم العائمة على الخريطة (نوع الخريطة · موقعي · الكل · ملء الشاشة) ─── */
.lm-ctrl {
  position: absolute; top: 10px; inset-inline-end: 10px; z-index: 500;
  display: flex; flex-direction: column; gap: 7px;
}
.lm-ctrl button {
  width: 38px; height: 38px; border-radius: 12px; border: 1px solid var(--line);
  background: rgba(255, 255, 255, .94); color: var(--brand); cursor: pointer;
  display: grid; place-items: center; box-shadow: 0 4px 14px rgba(15, 23, 42, .18);
  backdrop-filter: blur(6px); -webkit-tap-highlight-color: transparent;
  transition: transform .15s, background .2s, color .2s; touch-action: manipulation;
}
.lm-ctrl button:active { transform: scale(.92); }
.lm-ctrl button .ic { width: 19px; height: 19px; fill: currentColor; }
.lm-ctrl button:hover { background: var(--brand); color: #fff; }
.lm-ctrl button.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.lm-ctrl button.busy { animation: lmMePulse 1s infinite; opacity: .7; pointer-events: none; }
[dir="ltr"] .lm-ctrl { inset-inline-end: auto; inset-inline-start: 10px; }

/* بلاطات الخريطة: ظهور ناعم */
.lm-tiles { filter: saturate(.96); }
.leaflet-tile { transition: opacity .25s; }

/* شارة انقطاع بلاطات الخريطة */
.lm-net-badge {
  position: absolute; bottom: 26px; inset-inline: 10px; z-index: 500;
  display: flex; align-items: center; gap: .5rem; justify-content: center; flex-wrap: wrap;
  background: rgba(15, 23, 42, .88); color: #fff; border-radius: 12px;
  padding: .5rem .75rem; font-size: .8rem; font-weight: 700; text-align: center;
  backdrop-filter: blur(6px); box-shadow: 0 6px 18px rgba(0, 0, 0, .3);
}
.lm-net-badge .ic { width: 16px; height: 16px; fill: #fbbf24; flex: none; }
.lm-net-badge .btn { padding: .25rem .7rem; font-size: .75rem; color: #fff; border-color: rgba(255,255,255,.4); }
.lm-net-badge .btn:hover { background: rgba(255, 255, 255, .18); }
.lm-net-badge.hidden { display: none; }

/* ملء الشاشة للخريطة (Fullscreen API أو نمط CSS) */
.map-box:fullscreen { border-radius: 0; border: none; background: #10131f; }
.map-box.fs {
  position: fixed; inset: 0; z-index: 3000; height: 100% !important;
  border-radius: 0; border: none; background: #10131f;
  height: 100dvh !important;
}
.map-box:fullscreen .leaflet-container, .map-box.fs .leaflet-container { height: 100%; }

/* ─── شريط تثبيت التطبيق (PWA) ─── */
.install-pill {
  position: fixed; bottom: calc(1rem + env(safe-area-inset-bottom)); inset-inline-start: 1rem; z-index: 2600;
  display: flex; align-items: center; gap: .7rem; max-width: min(430px, calc(100vw - 2rem));
  background: #141B52; color: #fff; border-radius: 16px; padding: .7rem .85rem;
  box-shadow: 0 12px 34px rgba(10, 14, 40, .45); border: 1px solid rgba(255, 255, 255, .12);
  transform: translateY(140%); opacity: 0; transition: transform .35s cubic-bezier(.2,.9,.3,1), opacity .3s;
}
.install-pill.show { transform: translateY(0); opacity: 1; }
.install-pill .ip-ico {
  width: 40px; height: 40px; border-radius: 12px; background: linear-gradient(135deg, #2B3990, #4A5FD5);
  display: grid; place-items: center; flex: none;
}
.install-pill .ip-ico .ic { width: 21px; height: 21px; fill: #fff; }
.install-pill .ip-txt { flex: 1; min-width: 0; line-height: 1.35; }
.install-pill .ip-txt b { display: block; font-size: .88em; }
.install-pill .ip-txt small { display: block; color: #b9c2e8; font-size: .72em; }
.install-pill .btn.primary { background: #fff; color: #141B52; flex: none; }
.install-pill .icon-btn { color: #b9c2e8; flex: none; }
.install-pill .icon-btn .ic { fill: currentColor; }

/* خطوات التثبيت على iOS */
.ios-steps { display: grid; gap: .7rem; padding: .2rem 0 .5rem; }
.ios-step { display: flex; align-items: center; gap: .7rem; font-weight: 600; font-size: .93em; }
.ios-step .n {
  width: 26px; height: 26px; border-radius: 50%; flex: none;
  background: var(--brand); color: #fff; display: grid; place-items: center;
  font-size: .8em; font-weight: 900;
}

/* ═══════════ تقدم رصيد النقاط الخضراء ═══════════ */
.pts-progress-card {
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--card);
  padding: 1rem 1.15rem; box-shadow: var(--shadow); display: grid; gap: .55rem;
}
.pts-progress-card.ok { border-color: #b9e8d4; background: linear-gradient(0deg, var(--ok-soft), #fff 70%); }
.pts-progress-head { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.pts-progress-head b { display: inline-flex; align-items: center; gap: .4em; font-size: .98em; }
.pts-progress-head b .ic { color: var(--gold); }
.pts-progress-head .chip { margin-inline-start: auto; }
.pts-progress { height: 12px; border-radius: 9px; background: #e8eef4; overflow: hidden; }
.pts-progress > i {
  display: block; height: 100%; border-radius: 9px;
  background: linear-gradient(90deg, #34d399, #059669);
  box-shadow: 0 0 10px rgba(16, 185, 129, .5);
  transition: width .6s cubic-bezier(.2, .8, .3, 1);
}

/* تبويبات الموظف بستة أقسام على الجوال */
@media (max-width: 900px) {
  .tab { font-size: .68em; padding: .4em .55em; }
  .tab .ic { width: 1.5em; height: 1.5em; }
}

/* احترام تفضيل تقليل الحركة */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ═══════════ شارة حالة الاتصال بقاعدة البيانات (MySQL / وضع محلي) ═══════════ */
.sync-pill {
  display: inline-flex; align-items: center; gap: .45em;
  font-size: .78em; font-weight: 700;
  padding: .32em .7em; border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card); color: var(--muted);
  width: fit-content; transition: .25s;
}
.sync-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: #9aa3b5; flex: none; }
.sync-pill.sync-online { background: var(--ok-soft); border-color: #b8e6cf; color: var(--ok-ink); }
.sync-pill.sync-online .dot { background: var(--ok); box-shadow: 0 0 0 3px rgba(5,150,105,.15); }
.sync-pill.sync-syncing { background: var(--info-soft); border-color: #bcd9f0; color: var(--info); }
.sync-pill.sync-syncing .dot { background: var(--info); animation: syncPulse 1s infinite; }
.sync-pill.sync-offline { background: var(--warn-soft); border-color: #f0dcbc; color: var(--warn); }
.sync-pill.sync-offline .dot { background: var(--warn); }
@keyframes syncPulse { 0%,100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.5); opacity: .55; } }
#syncPillAdmin { margin: .55rem .9rem .2rem; }
#syncPillEmp { margin-inline-start: .4rem; }
#syncPillAuth { margin: .7rem auto 0; }
@media (max-width: 760px) { #syncPillEmp { display: none; } }

/* ═══════════ تحصين أنظمة تشغيل الجوال (iOS / Android) ═══════════ */
/* ارتفاعات ديناميكية: احترام شريط عنوان المتصفح المتحرك وشريط الموقف في iOS */
@supports (height: 100dvh) {
  .auth-view { min-height: 100dvh; }
  .app-view { min-height: 100dvh; }
  .app-view.with-sidebar .sidebar { height: 100dvh; }
  .map-box.fs { height: 100dvh !important; }
}
/* تمرير ناعم بمس جوهري لمناطق التمرير الطويلة */
.page-host, .side-nav, .notif-panel, .modal-body { -webkit-overflow-scrolling: touch; }
/* وضع التطبيق المثبت (standalone): ألوان الخلفية خلف مساحات الأمان */
@media all and (display-mode: standalone) {
  body { background: #141B52; }
  .app-view { padding-top: env(safe-area-inset-top); }
  body { padding-bottom: env(safe-area-inset-bottom); }
}

@media (max-width: 900px) {
  /* خريطة أطول تملأ الشاشة على الجوال */
  .map-box { height: clamp(280px, 52vh, 460px); border-radius: 14px; }
  .map-box.tall { height: clamp(300px, 56vh, 500px); }
  .map-box.modal-map { height: 240px; }
  /* أزرار الخريطة أكبر قليلاً للمس */
  .lm-ctrl button { width: 42px; height: 42px; }
  .lm-ctrl { top: 8px; inset-inline-end: 8px; }
  /* إخفاء أزرار التكبير الافتراضية — الإيماءات (قرصة/تمديد) متاحة دائماً */
  .leaflet-control-zoom { display: none; }
  /* الشريط الجانبي يحترم مساحة الإشعارات في iOS عند فتحه كدرج */
  .sidebar { padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom); }
  .install-pill { inset-inline: .8rem; max-width: none; }
  .install-pill .ip-txt small { display: none; }
}
/* أفقي على الجوال: شريط التبويبات يصبح أعلى الشاشة بقليل لتفادي شريط iOS السفلي */
@media (max-width: 900px) and (orientation: landscape) {
  .emp-tabs { bottom: env(safe-area-inset-bottom); }
  .map-box { height: clamp(220px, 70vh, 420px); }
}
/* احترام تقليل الحركة لمن يفضّل ذلك */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ═══════════════════════════════════════════════════════════
   لمسات احترافية: Ripple · حركات · لحظة النجاح · خريطة الشهر
   ═══════════════════════════════════════════════════════════ */

/* ─── أثر النقر المتراقص (Ripple) ─── */
.btn, .tab, .side-link, .btn-check, .auth-tab { overflow: hidden; }
.ripple {
  position: absolute; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, rgba(255, 255, 255, .5) 0%, rgba(255, 255, 255, .18) 45%, transparent 70%);
  transform: scale(0); animation: rippleGo .6s ease-out forwards; z-index: 0;
}
.btn.ghost .ripple, .tab .ripple, .side-link .ripple, .auth-tab .ripple {
  background: radial-gradient(circle, rgba(43, 57, 144, .22) 0%, rgba(43, 57, 144, .08) 45%, transparent 70%);
}
@keyframes rippleGo { to { transform: scale(1); opacity: 0; } }

/* ─── اهتزاز رسائل الخطأ عند الظهور ─── */
.form-error:not(.hidden) { animation: shakeX .45s cubic-bezier(.36, .07, .19, .97); }
@keyframes shakeX {
  10%, 90% { transform: translateX(-1px); }
  20%, 80% { transform: translateX(2px); }
  30%, 50%, 70% { transform: translateX(-4px); }
  40%, 60% { transform: translateX(4px); }
}

/* ─── شريط زمن التنبيه + نبضة الأيقونة ─── */
.toast { overflow: hidden; position: relative; }
.toast .toast-bar {
  position: absolute; bottom: 0; inset-inline-start: 0; height: 3px; width: 100%;
  background: linear-gradient(90deg, #34d399, #1B75BC);
  transform-origin: inline-start; animation: toastBar 3.4s linear forwards;
  border-radius: 0 3px 3px 0;
}
[dir="rtl"] .toast .toast-bar { transform-origin: right; }
.toast.err .toast-bar { background: linear-gradient(90deg, #fb7185, #C1272D); }
.toast.warn .toast-bar { background: linear-gradient(90deg, #fbbf24, #d97706); }
@keyframes toastBar { from { transform: scaleX(1); } to { transform: scaleX(0); } }
.toast .ic { animation: toastIco .45s cubic-bezier(.2, .9, .3, 1.4); }
@keyframes toastIco { from { transform: scale(0) rotate(-30deg); } }

/* ─── لحظة النجاح: طبقة كاملة بعلامة ✓ ترسم نفسها ─── */
#fxRoot { pointer-events: none; }
.fx-success {
  position: fixed; inset: 0; z-index: 300; display: grid; place-items: center; align-content: center;
  gap: .4rem; background: rgba(10, 14, 40, .45); backdrop-filter: blur(4px);
  opacity: 0; transition: opacity .28s;
}
.fx-success.show { opacity: 1; }
.fx-success.bye { opacity: 0; transition: opacity .3s; }
.fx-ring { position: relative; width: 108px; height: 108px; }
.fx-ring svg { width: 100%; height: 100%; }
.fx-circle {
  stroke: #34d399; stroke-width: 3.5; stroke-linecap: round;
  stroke-dasharray: 145; stroke-dashoffset: 145;
  animation: fxDraw .55s ease-out forwards;
}
.fx-check {
  stroke: #fff; stroke-width: 4.5; stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 34; stroke-dashoffset: 34;
  animation: fxDraw .34s ease-out .45s forwards;
}
@keyframes fxDraw { to { stroke-dashoffset: 0; } }
.fx-big-ico {
  position: absolute; inset: 0; margin: auto; width: 2em; height: 2em; color: #a7f3d0;
  opacity: 0; animation: fxIco .3s ease .6s forwards;
}
@keyframes fxIco { from { transform: scale(.6); } to { opacity: .95; transform: scale(1); } }
.fx-burst {
  position: absolute; width: 108px; height: 108px; border-radius: 50%;
  box-shadow: 0 0 0 0 rgba(52, 211, 153, .45);
  animation: fxBurst .9s ease-out .35s;
}
@keyframes fxBurst { 40% { box-shadow: 0 0 0 26px rgba(52, 211, 153, 0); } 100% { box-shadow: 0 0 0 30px rgba(52, 211, 153, 0); } }
.fx-title {
  color: #fff; font-size: 1.25rem; font-weight: 900; margin-top: .7rem;
  opacity: 0; transform: translateY(10px); animation: fxText .35s ease-out .55s forwards;
}
.fx-sub {
  color: #c7d6f5; font-weight: 700; font-size: .95em;
  opacity: 0; transform: translateY(8px); animation: fxText .35s ease-out .7s forwards;
}
@keyframes fxText { to { opacity: 1; transform: none; } }

/* ─── دخول متتالٍ لعناصر الصفحة (Stagger) ─── */
.page > * { animation: fadeUp .42s cubic-bezier(.2, .9, .3, 1) both; }
.page > *:nth-child(2) { animation-delay: .06s; }
.page > *:nth-child(3) { animation-delay: .12s; }
.page > *:nth-child(4) { animation-delay: .18s; }
.page > *:nth-child(5) { animation-delay: .24s; }
.page > *:nth-child(n+6) { animation-delay: .28s; }

/* ─── زر الصوت: حالة كتم واضحة ─── */
.snd-btn { color: var(--brand-deep); }
.snd-btn:hover { background: var(--brand-soft); }
.snd-btn.muted-btn { color: #9aa4c2; }

/* ─── أيقونة بطاقة إحصائية تتحرك بلطف عند التحويم ─── */
@media (hover: hover) {
  .stat:hover .stat-ico { transform: scale(1.1) rotate(-6deg); transition: .25s cubic-bezier(.2, .9, .3, 1.35); }
}

/* ═══════════ خريطة حرارة الحضور الشهرية ═══════════ */
.hm-summary { display: flex; gap: .55rem; flex-wrap: wrap; margin-bottom: .95rem; }
.hm-sum {
  display: flex; flex-direction: column; align-items: center; min-width: 76px;
  padding: .5rem .8rem; border-radius: 13px; border: 1px solid var(--line); background: #f8fafc;
}
.hm-sum b { font-size: 1.25rem; font-weight: 900; line-height: 1.15; }
.hm-sum small { color: var(--muted); font-weight: 700; font-size: .78em; }
.hm-sum.ok b { color: var(--ok); } .hm-sum.ok { background: var(--ok-soft); border-color: #c7ecd9; }
.hm-sum.warn b { color: var(--warn); } .hm-sum.warn { background: var(--warn-soft); border-color: #f4e0c0; }
.hm-sum.danger b { color: var(--danger); } .hm-sum.danger { background: var(--danger-soft); border-color: #f5cccc; }
.hm-sum.info b { color: var(--info); } .hm-sum.info { background: var(--info-soft); border-color: #c8dff0; }
.hm-sum.brand b { color: var(--brand); } .hm-sum.brand { background: var(--brand-soft); border-color: #ccd4f2; }
.hm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: 5px; }
.hm-cell {
  position: relative; aspect-ratio: 1; border-radius: 9px; display: grid; place-items: center;
  font-size: .72em; font-weight: 800; cursor: default; border: 1px solid transparent;
  background: #eef1f7; color: #8b95b2; transition: transform .15s;
  animation: hmIn .3s ease both;
}
.hm-cell:nth-child(2n) { animation-delay: .02s; }
@keyframes hmIn { from { opacity: 0; transform: scale(.8); } }
.hm-cell:hover { transform: scale(1.12); z-index: 2; }
.hm-cell i { position: absolute; bottom: 5px; width: 5px; height: 5px; border-radius: 50%; }
.hm-cell.present { background: #d8f5e6; color: #065f46; border-color: #b5e8cd; }
.hm-cell.present i { background: #10b981; }
.hm-cell.late { background: #fdeecd; color: #92400e; border-color: #f3ddb0; }
.hm-cell.late i { background: #f59e0b; }
.hm-cell.absent { background: #fbdddd; color: #99272c; border-color: #f2c0c2; }
.hm-cell.absent i { background: #C1272D; }
.hm-cell.leave { background: #dcebfa; color: #1a5a8a; border-color: #c0dcf4; }
.hm-cell.leave i { background: #1B75BC; }
.hm-cell.weekend { background: #eef0f5; color: #a4adc6; }
.hm-cell.today { outline: 2.5px solid var(--brand); outline-offset: 1.5px; }
.hm-legend { display: flex; gap: 1rem; flex-wrap: wrap; margin-top: .9rem; font-size: .82em; font-weight: 700; color: var(--muted); }
.hm-legend span { display: inline-flex; align-items: center; gap: .35em; }
.hm-legend i.lg { width: 12px; height: 12px; border-radius: 4px; display: inline-block; }
.hm-legend i.present { background: #10b981; } .hm-legend i.late { background: #f59e0b; }
.hm-legend i.absent { background: #C1272D; } .hm-legend i.leave { background: #1B75BC; }
.hm-legend i.weekend { background: #cfd5e4; }
@media (max-width: 640px) {
  .hm-grid { grid-template-columns: repeat(7, 1fr); }
  .hm-cell { font-size: .68em; border-radius: 8px; }
}

/* ═══════════════════════════════════════════════════════════
   الساعة الاحترافية — شارة الشريط العلوي + بطاقة البطل
   ═══════════════════════════════════════════════════════════ */
.top-clock { cursor: default; }
.ck-wrap { display: inline-flex; align-items: center; gap: .45em; }
.ck-ic { color: var(--brand-2); }
.ck-time { display: inline-flex; align-items: baseline; gap: .02em; }
.ck-time b { font-variant-numeric: tabular-nums; font-size: 1.08em; font-weight: 900; }
.ck-colon { font-style: normal; font-weight: 900; animation: ckBlink 1s steps(1) infinite; }
@keyframes ckBlink { 50% { opacity: .2; } }
.ck-secs { color: var(--brand-2); font-size: .84em; font-variant-numeric: tabular-nums; font-weight: 800; }
.ck-ampm {
  font-size: .74em; background: var(--brand); color: #fff;
  border-radius: 6px; padding: .08em .5em; font-weight: 800; line-height: 1.5;
}

/* بطاقة الساعة الكبيرة (البطل) */
.clock-hero {
  position: relative; display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap;
  background: linear-gradient(135deg, var(--side) 0%, var(--side-2) 52%, #2A3AA8 100%);
  color: #fff; border-radius: 20px; padding: 1.25rem 1.45rem;
  box-shadow: var(--shadow-lg); overflow: hidden;
  animation: fadeUp .4s ease both;
}
.clock-hero::before {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(60% 90% at 85% 10%, rgba(124, 156, 255, .22), transparent 60%);
}
.clock-hero > * { position: relative; }
.ch-ring { width: 118px; height: 118px; position: relative; flex: none; }
.ch-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ch-ring-bg { fill: none; stroke: rgba(255, 255, 255, .14); stroke-width: 8; }
.ch-ring-fg {
  fill: none; stroke: #7C9CFF; stroke-width: 8; stroke-linecap: round;
  filter: drop-shadow(0 0 5px rgba(124, 156, 255, .55));
  transition: stroke-dashoffset .95s linear;
}
.ch-ring-fg.no-anim { transition: none; }
.ch-ring-mid { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; gap: 0; }
.ch-sec-num { font-size: 1.45rem; font-weight: 900; font-variant-numeric: tabular-nums; line-height: 1.1; }
.ch-ring-mid small { font-size: .62rem; color: #AFC0F5; font-weight: 700; }
.ch-main { flex: 1; min-width: 210px; }
.ch-time {
  display: flex; align-items: baseline; gap: .1em; line-height: 1;
  font-size: clamp(2.1rem, 5vw, 3rem); font-weight: 900;
}
.ch-time b { font-variant-numeric: tabular-nums; letter-spacing: .01em; }
.ch-ampm {
  font-size: .32em; background: rgba(255, 255, 255, .16); border: 1px solid rgba(255, 255, 255, .18);
  padding: .25em .7em; border-radius: 8px; align-self: center; margin-inline-start: .4em; font-weight: 800;
}
.ch-dates {
  display: flex; gap: .6rem; align-items: center; flex-wrap: wrap;
  margin-top: .6rem; color: #CDD7FA; font-weight: 700; font-size: .95em;
}
.ch-date.hijri { color: #FFD9A8; }
.ch-sep { width: 1px; height: 14px; background: rgba(255, 255, 255, .28); }
.ch-day { margin-top: .3rem; color: #9DB1F0; font-weight: 800; font-size: .9em; }
.ch-greet {
  display: flex; gap: .5rem; align-items: center; align-self: center;
  background: rgba(255, 255, 255, .1); border: 1px solid rgba(255, 255, 255, .15);
  padding: .55rem 1rem; border-radius: 999px; font-weight: 800; font-size: 1.02em;
  animation: chGreetIn .5s .15s ease both;
}
@keyframes chGreetIn { from { opacity: 0; transform: translateY(8px); } }
.ch-greet-ico { color: #FFD9A8; display: inline-flex; }
.ch-greet-ico .ic { animation: chStarSpin 6s linear infinite; }
@keyframes chStarSpin { to { transform: rotate(360deg); } }

@media (max-width: 640px) {
  .clock-hero { flex-direction: column; padding: 1.15rem 1rem; gap: .85rem; text-align: center; }
  .ch-main { min-width: 0; width: 100%; display: grid; justify-items: center; gap: .15rem; }
  .ch-time { justify-content: center; }
  .ch-dates {
    flex-direction: row; justify-content: center; align-items: center;
    flex-wrap: nowrap; gap: .45rem;
  }
  .ch-date { white-space: nowrap; font-size: .88em; }
  .ch-day { text-align: center; }
  .clock-hero .ch-greet { align-self: center; }
  .ch-ring { width: 96px; height: 96px; }
}

/* ═══════════════════════════════════════════════════════════
   نافذة الطباعة الذكية — اختيار حجم الورق والاتجاه
   ═══════════════════════════════════════════════════════════ */
.paper-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(98px, 1fr));
  gap: .6rem; margin: .2rem 0 1rem;
}
.paper-opt {
  position: relative; display: grid; justify-items: center; gap: .32rem;
  padding: .8rem .5rem .65rem; border: 2px solid var(--line); border-radius: 14px;
  background: #fff; cursor: pointer; transition: .18s; overflow: hidden;
}
.paper-opt:hover { transform: translateY(-2px); border-color: #B9C3EA; box-shadow: var(--shadow); }
.paper-opt.selected { border-color: var(--brand); background: var(--brand-soft); box-shadow: inset 0 0 0 1px var(--brand); }
.paper-opt b { font-size: .84em; }
.paper-opt small { color: var(--muted); font-size: .7em; font-weight: 700; }
.paper-shape {
  display: block; border: 2px solid var(--brand); border-radius: 3px;
  background: linear-gradient(180deg, #fff 0%, #EEF1FB 100%);
}
.paper-shape.a4 { width: 30px; height: 42px; }
.paper-shape.a5 { width: 26px; height: 37px; }
.paper-shape.letter { width: 32px; height: 41px; }
.paper-shape.legal { width: 30px; height: 50px; }
.paper-shape.thermal {
  width: 20px; height: 44px; border-radius: 8px 8px 3px 3px;
  background: repeating-linear-gradient(180deg, #fff 0 8px, #F1F4FC 8px 11px);
}
.paper-check {
  position: absolute; top: 6px; inset-inline-end: 6px; width: 20px; height: 20px;
  border-radius: 50%; background: var(--brand); color: #fff;
  display: grid; place-items: center; opacity: 0; transform: scale(.4);
  transition: .22s cubic-bezier(.2, .9, .3, 1.4);
}
.paper-check .ic { width: .7em; height: .7em; }
.paper-opt.selected .paper-check { opacity: 1; transform: scale(1); }
.paper-opt.selected { animation: paperSel .3s cubic-bezier(.2, .9, .3, 1.3); }
@keyframes paperSel { 45% { transform: scale(.965); } }
.orient-row { display: flex; gap: .6rem; margin-bottom: .2rem; }
.orient-row.disabled { opacity: .45; pointer-events: none; }
.orient-opt {
  flex: 1; display: flex; align-items: center; gap: .6rem;
  padding: .65rem .85rem; border: 2px solid var(--line); border-radius: 12px;
  background: #fff; cursor: pointer; font-weight: 800; font-size: .92em; transition: .15s;
}
.orient-opt:hover { border-color: #B9C3EA; }
.orient-opt.selected { border-color: var(--brand); background: var(--brand-soft); }
.orient-shape { border: 2px solid var(--brand); border-radius: 3px; flex: none; }
.orient-shape.portrait { width: 14px; height: 20px; }
.orient-shape.landscape { width: 20px; height: 14px; }

/* ═══════════════════════════════════════════════════════════
   الطباعة الذكية — تحسينات فوق الأساس + ختم QR + الورق الحراري
   ═══════════════════════════════════════════════════════════ */
/* ختم التحقق QR — قواعد أساسية (تعمل في الشاشة والطباعة معاً لضمان الحجم الثابت) */
.pr-seal {
  display: flex; gap: 12px; align-items: center; width: max-content; max-width: 100%;
  border: 1.5px dashed #94A3B8; border-radius: 12px; padding: 10px 14px; margin-top: 18px;
  background: #F8FAFF;
}
.pr-seal-qr { width: 86px; height: 86px; flex: none; background: #fff; }
.pr-seal-qr svg { width: 100%; height: 100%; display: block; }
.pr-seal-info { display: grid; gap: 2px; font-size: 12px; color: #334155; }
.pr-seal-info b { font-size: 1.08em; color: #0F172A; }
.pr-seal-info small { color: #64748B; margin-bottom: 2px; }
.pr-seal-info i { font-style: normal; color: #64748B; }
.pr-mono { font-family: 'Courier New', monospace; font-weight: 700; letter-spacing: .4px; }

@media print {
  /* الافتراضي — يُستبدل ديناميكياً بـ #dynPrintCss حسب اختيار المستخدم */
  @page { size: A4; margin: 12mm; }

  /* جداول متعددة الصفحات: تكرار الرأس + منع قطع الصفوف */
  .pr-tbl thead { display: table-header-group; }
  .pr-tbl tr { page-break-inside: avoid; }
  .pr-signs, .pr-seal, .pr-receiver { page-break-inside: avoid; }

  /* A5 — تصغير متناسب */
  .pr-doc.paper-a5 { font-size: .88em; }
  .pr-doc.paper-a5 .pr-head-logo img, .pr-doc.paper-a5 .pr-logo-fallback { width: 58px; height: 58px; }
  .pr-doc.paper-a5 .pr-seal-qr { width: 72px; height: 72px; }

  /* الاتجاه العرضي — خط أدق للجداول العريضة */
  .pr-doc.landscape .pr-tbl { font-size: .76em; }
  .pr-doc.landscape .pr-tbl th, .pr-doc.landscape .pr-tbl td { padding: 4px 6px; }

  /* ═══ الورق الحراري 80مم — إيصال رأسي ═══ */
  .pr-doc.paper-thermal { width: 70mm; margin: 0 auto; font-size: 11.5px; }
  .pr-doc.paper-thermal .pr-head { flex-direction: column; text-align: center; gap: 6px; border-bottom-width: 2px; }
  .pr-doc.paper-thermal .pr-head-logo img, .pr-doc.paper-thermal .pr-logo-fallback { width: 44px; height: 44px; border-radius: 9px; }
  .pr-doc.paper-thermal .pr-head-title { text-align: center; }
  .pr-doc.paper-thermal .pr-meta { flex-direction: column; gap: 2px; align-items: center; }
  .pr-doc.paper-thermal .pr-tbl, .pr-doc.paper-thermal .pr-tbl tbody { display: block; }
  .pr-doc.paper-thermal .pr-tbl thead { display: none; }
  .pr-doc.paper-thermal .pr-tbl tr {
    display: block; border: 1px solid #CBD5E1; border-radius: 8px;
    padding: 6px 9px; margin-bottom: 6px;
  }
  .pr-doc.paper-thermal .pr-tbl td {
    display: flex; justify-content: space-between; align-items: baseline; gap: 10px;
    border: none; padding: 1.5px 0; background: transparent !important;
  }
  .pr-doc.paper-thermal .pr-tbl td::before { content: attr(data-l) ': '; font-weight: 700; color: #475569; }
  .pr-doc.paper-thermal .pr-tbl th.hide-t, .pr-doc.paper-thermal .pr-tbl td.hide-t { display: none; }
  .pr-doc.paper-thermal .pr-total { border-color: #2B3990; background: #EEF2FF !important; }
  .pr-doc.paper-thermal .pr-info { grid-template-columns: 1fr 1fr; gap: 4px 10px; }
  .pr-doc.paper-thermal .pr-signs { display: none; }
  .pr-doc.paper-thermal .pr-seal { margin: 12px auto 0; flex-direction: column; text-align: center; }
  .pr-doc.paper-thermal .pr-seal-qr { width: 72px; height: 72px; }
  .pr-receiver { margin-top: 12mm; text-align: center; }
  .pr-receiver .pr-sign-line { display: block; width: 68%; margin: 0 auto 4px; border-bottom: 1.5px dotted #6B7280; }
  .pr-receiver b { font-size: .8em; color: #374151; }
}

/* انسجام الساعة داخل بطاقة الحضور وبطاقات الإدارة */
.checkin-card > div:first-child { width: 100%; }
.checkin-card .clock-hero { width: 100%; justify-content: center; text-align: start; }
.grid-cards .clock-hero { grid-column: 1 / -1; margin-bottom: .2rem; }
