/* نظام الموارد البشرية — تنسيقات الواجهة (RTL). بلا أي اعتماد خارجي. */

:root {
  /* v1.4 §7: لوحة ألوان عصرية فاتحة — خلفية رمادية-زرقاء فاتحة، بطاقات
     بيضاء، أزرق داكن (--accent) للأساس/الترويسات/العنصر النشط، أزرق حيوي
     (--accent-2) للأزرار/الروابط/التركيز. --accent-dark بقي كاسم بديل
     (alias) لدرجة أغمق من --accent-2 تُستخدم في حالات hover. */
  --bg: #f4f6fa;
  --card: #ffffff;
  --border: #e2e6ec;
  --text: #1c2733;
  --muted: #6b7688;
  --accent: #1e3a5f;
  --accent-2: #2d6cdf;
  --accent-dark: #1d4ed8;
  --danger: #dc2626;
  --ok: #16a34a;
  --warn: #d97706;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(20, 25, 35, 0.08);
  --sidebar-width: 226px;
  --sidebar-width-collapsed: 64px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, Arial, sans-serif;
  font-size: 15px;
  min-height: 100%;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }

button {
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 15px;
  transition: background .15s ease, border-color .15s ease;
}
button:hover { background: #f4f7fb; border-color: #d3dae5; }
button:disabled { opacity: .6; cursor: default; }

input, select, textarea {
  font-family: inherit;
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 11px;
  min-height: 38px;
  background: #fff;
  color: var(--text);
}
textarea { min-height: auto; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px rgba(45, 108, 223, 0.15);
}
/* مربعات الاختيار/الراديو بحجمها الطبيعي — لا ترث حشوة وارتفاع حقول النص. */
input[type="checkbox"], input[type="radio"] {
  width: 16px;
  height: 16px;
  min-height: 0;
  padding: 0;
  margin: 0;
  border-radius: 4px;
  accent-color: var(--accent-2);
  cursor: pointer;
  vertical-align: middle;
}
input[type="checkbox"]:focus, input[type="radio"]:focus { box-shadow: none; }

/* ---------------------------------------------------------------------
   التخطيط العام (v1.4 §7): قائمة جانبية ثابتة يمين + عمود رئيسي (شريط
   علوي + محتوى). aside#sidebar أول ابن لـ #layout فيقع يمينًا تلقائيًا في
   وثيقة RTL؛ ثابت بـ position:fixed ليبقى مرئيًا أثناء التمرير، و#mainCol
   يترك له مساحة عبر margin-right.
--------------------------------------------------------------------- */
#layout {
  display: flex;
  min-height: 100vh;
}

#sidebar {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--card);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 30;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-logo {
  color: var(--accent);
  font-size: 20px;
  line-height: 1;
}

.sidebar-title-text {
  font-weight: 700;
  font-size: 15.5px;
  color: var(--accent);
  white-space: nowrap;
  overflow: hidden;
}

#mainCol {
  flex: 1;
  min-width: 0;
  margin-right: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ---------------------------------------------------------------------
   الشريط العلوي
--------------------------------------------------------------------- */
#topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 10px 20px;
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-right, .topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

#sidebarToggle {
  display: none;
  font-size: 17px;
  padding: 6px 11px;
}

#orgName {
  font-weight: 700;
  font-size: 17px;
  color: var(--accent);
}

#clock {
  color: var(--muted);
  font-size: 13px;
  padding-left: 12px;
  border-left: 1px solid var(--border);
}

#userName {
  color: var(--muted);
  font-size: 14px;
}

#logoutBtn {
  border-color: var(--danger);
  color: var(--danger);
  background: #fff;
}
#logoutBtn:hover { background: #fdecec; }

/* ---------------------------------------------------------------------
   شريط التنقل (قائمة جانبية عمودية)
--------------------------------------------------------------------- */
.nav-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px;
  flex: 1;
  overflow-y: auto;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 14px;
  border-right: 3px solid transparent;
}
.nav-link:hover {
  color: var(--text);
  text-decoration: none;
  background: #f4f7fb;
}
.nav-link.active {
  color: var(--accent);
  background: rgba(30, 58, 95, 0.08);
  border-right-color: var(--accent);
  font-weight: 600;
}

.nav-icon {
  flex-shrink: 0;
  width: 22px;
  text-align: center;
  font-size: 15px;
  color: inherit;
}

.nav-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* شاشات ضيقة (<900px): القائمة تُطوى لأيقونات فقط. */
@media (max-width: 899px) {
  #sidebar { width: var(--sidebar-width-collapsed); }
  #mainCol { margin-right: var(--sidebar-width-collapsed); }
  .sidebar-title-text { display: none; }
  .sidebar-header { justify-content: center; padding: 16px 8px; }
  .nav-label { display: none; }
  .nav-link { justify-content: center; padding: 10px 6px; }
}

/* شاشات محمولة (<640px): القائمة تُخفى بالكامل وتظهر عبر زر همبرغر في
   الشريط العلوي، كطبقة علوية (overlay) عريضة بالتسمية الكاملة. */
@media (max-width: 639px) {
  #sidebarToggle { display: inline-flex; }
  #sidebar {
    width: var(--sidebar-width);
    transform: translateX(100%);
    transition: transform .2s ease;
  }
  #sidebar.open { transform: translateX(0); }
  #sidebar .sidebar-title-text,
  #sidebar .nav-label { display: block; }
  #sidebar .sidebar-header { justify-content: flex-start; padding: 18px 16px; }
  #sidebar .nav-link { justify-content: flex-start; padding: 10px 12px; }
  #mainCol { margin-right: 0; }
}

/* ---------------------------------------------------------------------
   المحتوى الرئيسي
--------------------------------------------------------------------- */
#view {
  flex: 1;
  padding: 20px;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
}

.page-title {
  font-size: 21px;
  margin: 0 0 16px;
}

.loading, .empty-msg {
  color: var(--muted);
  padding: 20px;
  text-align: center;
}

/* ---------------------------------------------------------------------
   بطاقات
--------------------------------------------------------------------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 16px 18px;
  margin-bottom: 16px;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 12px;
}

/* v1.3 §5: روابط «صرف الأتعاب» الثلاثة بعد نجاح الدفع — تبرز عن باقي البطاقات. */
.fees-payout-links {
  border-color: #157347;
  background: #f3fbf6;
}

/* v1.2 §8: section headings inside a screen made of several cards (e.g. the
   documents screen's «السندات» portal, grouping the create/drafts/approved
   cards under one label). */
.section-title {
  font-size: 18px;
  font-weight: 700;
  margin: 8px 0 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.cards-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.stat-card {
  text-align: center;
  margin-bottom: 0;
}

.stat-value {
  font-size: 30px;
  font-weight: 700;
  color: var(--accent-2);
}

.stat-label {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}

.payroll-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

/* ---------------------------------------------------------------------
   التنبيهات
--------------------------------------------------------------------- */
.alerts-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.alert-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #f8f9fb;
  color: var(--text);
}
a.alert-row:hover {
  background: #eef2ff;
  text-decoration: none;
}

.alert-text { font-size: 14px; }

/* ---------------------------------------------------------------------
   ملخص اليوم (day notes — v1.1 §7)
--------------------------------------------------------------------- */
.day-notes-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}

.day-note-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #f8f9fb;
  color: var(--text);
}

.day-note-text { flex: 1; font-size: 14px; }

/* ---------------------------------------------------------------------
   الجداول
--------------------------------------------------------------------- */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th, td {
  text-align: right;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}

th {
  color: var(--muted);
  font-weight: 600;
  background: #f8f9fb;
}

td.num, th.num { text-align: left; }

tbody tr:hover { background: #eef3fb; }

/* صفوف متناوبة (v1.4 §7) — تُقيَّد بـ media screen صراحةً حتى لا تمس مظهر
   أي صفحة طباعة (قسيمة راتب/كشف حساب/...) عند window.print(). */
@media screen {
  tbody tr:nth-child(even) { background: #f8fafc; }
}

.table-wrap { overflow-x: auto; }

/* ---------------------------------------------------------------------
   شارات ملوّنة
--------------------------------------------------------------------- */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  background: #eef0f4;
  color: var(--text);
  white-space: nowrap;
}

.badge-red    { background: #fde2e2; color: #b91c1c; }
.badge-orange { background: #fdead1; color: #b45309; }
.badge-blue   { background: #dbe9fe; color: #1d4ed8; }
.badge-green  { background: #dcf5e3; color: #157347; }
.badge-gray   { background: #e7e9ee; color: #4b5563; }
.badge-purple { background: #ede4fd; color: #6d28d9; }
/* v1.2 §7: applicants — status «موظف» distinct from generic green (bonuses,
   active employees, ...) so it visually reads as a separate/final state. */
.badge-green-dark { background: #c9ecd6; color: #0f5132; }
/* v1.3 §7: applicants — «تخصص غير مناسب» distinct from both «متقدم جديد»
   (neutral gray) and «مرفوض» (red): a muted, slightly darker gray. */
.badge-gray-dark  { background: #d3d6dd; color: #374151; }

/* ---------------------------------------------------------------------
   نافذة التأكيد
--------------------------------------------------------------------- */
dialog#confirmDlg {
  border: none;
  border-radius: 10px;
  padding: 20px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
  max-width: 380px;
  width: 90%;
}
dialog#confirmDlg::backdrop {
  background: rgba(15, 20, 30, 0.45);
}
#confirmMsg {
  margin: 0 0 18px;
  font-size: 15px;
  line-height: 1.6;
}
dialog#confirmDlg menu {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin: 0;
  padding: 0;
}
#confirmOk {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}
#confirmOk:hover { background: #b91c1c; }

/* ---------------------------------------------------------------------
   التنبيه العابر (toast)
--------------------------------------------------------------------- */
#toast {
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 100;
  padding: 10px 18px;
  border-radius: 8px;
  background: var(--text);
  color: #fff;
  font-size: 14px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  max-width: 320px;
}
#toast.show {
  opacity: 1;
  transform: translateY(0);
}
#toast.show.ok { background: var(--ok); }
#toast.show.err { background: var(--danger); }

/* ---------------------------------------------------------------------
   شاشة الدخول
--------------------------------------------------------------------- */
#loginOverlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #eef2f8, #e3e8f2);
}
#loginOverlay.hidden { display: none; }

.login-card {
  background: var(--card);
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(20, 25, 35, 0.15);
  padding: 32px 30px;
  width: 100%;
  max-width: 360px;
  text-align: center;
}

.login-card h1 {
  font-size: 19px;
  margin: 0 0 22px;
  color: var(--accent);
}

.login-card form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: right;
}

.login-card form.hidden { display: none; }

.login-card label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13.5px;
  color: var(--muted);
}

.login-card button[type="submit"] {
  background: var(--accent-2);
  color: #fff;
  border-color: var(--accent-2);
  padding: 9px 14px;
  font-weight: 600;
  margin-top: 4px;
}
.login-card button[type="submit"]:hover { background: var(--accent-dark); }

.login-card .hint {
  font-size: 13px;
  color: var(--muted);
  margin: -8px 0 0;
}

.form-error {
  color: var(--danger);
  font-size: 13px;
  min-height: 16px;
}

.hidden { display: none !important; }

/* ---------------------------------------------------------------------
   مصفوفة صلاحيات المستخدم (شاشة × بلا/عرض/تعديل)
--------------------------------------------------------------------- */
.perm-panel {
  padding: 12px 4px 4px;
  border-top: 1px dashed var(--border);
  margin-top: 6px;
}
.perm-matrix { margin-top: 10px; }
.perm-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}
.perm-row:last-child { border-bottom: none; }
.perm-screen-label { min-width: 130px; font-weight: 600; font-size: 13.5px; }
.perm-radio {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: var(--muted);
}
.perm-detail-row td { background: #f8f9fb; }

/* ---------------------------------------------------------------------
   شريط الأدوات (بحث/فلاتر/نماذج مضغوطة)
--------------------------------------------------------------------- */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.toolbar input, .toolbar select { min-width: 120px; }
.toolbar input[type="checkbox"], .toolbar input[type="radio"] { min-width: 0; }

button.primary {
  background: var(--accent-2);
  color: #fff;
  border-color: var(--accent-2);
  font-weight: 600;
}
button.primary:hover { background: var(--accent-dark); }

button.danger {
  border-color: var(--danger);
  color: var(--danger);
  background: #fff;
}
button.danger:hover { background: #fdecec; }

button.small { padding: 4px 10px; font-size: 12.5px; }

.template-download-link {
  display: inline-flex;
  align-items: center;
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13.5px;
  text-decoration: none;
  white-space: nowrap;
}
.template-download-link:hover { background: #f8f9fb; text-decoration: none; }

/* ---------------------------------------------------------------------
   نماذج (شبكة حقول)
--------------------------------------------------------------------- */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px 22px;
  margin-top: 6px;
}
@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 13px;
  color: var(--muted);
}
.field input, .field select, .field textarea { width: 100%; }

.form-grid.readonly .field > div {
  padding: 6px 0;
  color: var(--text);
  font-size: 14px;
}

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13.5px;
  color: var(--text);
}

.num-input { width: 90px; }

/* ---------------------------------------------------------------------
   صفوف قابلة للنقر (جداول تفتح تفاصيل)
--------------------------------------------------------------------- */
.clickable-row { cursor: pointer; }
/* v1.2 §7: sortable score column headers on the applicants list. */
th.sort-active { color: var(--primary, #1d4ed8); }

/* ---------------------------------------------------------------------
   تبويبات بطاقة الموظف
--------------------------------------------------------------------- */
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.tab-btn {
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  padding: 10px 14px;
  color: var(--muted);
  font-size: 14px;
}
.tab-btn:hover { background: #f8f9fb; color: var(--text); }
.tab-btn.active {
  color: var(--accent-2);
  border-bottom-color: var(--accent-2);
  font-weight: 600;
}

.employee-title {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.employee-title h1 { margin: 0; }

.muted-line {
  color: var(--muted);
  font-size: 13.5px;
  margin: 4px 0 10px;
}

.header-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ---------------------------------------------------------------------
   المرفقات
--------------------------------------------------------------------- */
.attachments-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 14px;
}

.attachment-item {
  width: 130px;
  text-align: center;
}

.thumb {
  width: 120px;
  height: 120px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #f8f9fb;
  display: block;
}
.thumb.file-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
}

.attachment-name {
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
  word-break: break-word;
}

.attachment-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 4px;
  font-size: 12.5px;
}

/* ---------------------------------------------------------------------
   استيراد إكسل (عام — موظفون/حضور)
--------------------------------------------------------------------- */
.import-panel { margin-bottom: 16px; }

.import-errors ul {
  margin: 6px 0 0;
  padding-inline-start: 18px;
  color: var(--danger);
  font-size: 13px;
}

/* ---------------------------------------------------------------------
   نوافذ منبثقة عامة تُبنى ديناميكيًا في app.js (خلية حضور، استثناء شهري)
--------------------------------------------------------------------- */
dialog.app-dialog {
  border: none;
  border-radius: 10px;
  padding: 0;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
  max-width: 380px;
  width: 90%;
}
dialog.app-dialog::backdrop {
  background: rgba(15, 20, 30, 0.45);
}
dialog.app-dialog .card {
  border: none;
  box-shadow: none;
  margin: 0;
}

/* ---------------------------------------------------------------------
   مودال عام (v1.3 §5/T5): يستبدل لوحات التعديل السفلية المتعبة —
   خلفية معتمة متمركزة + صندوق RTL بعرض أقصى ~560px وتمرير عمودي.
--------------------------------------------------------------------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 20, 30, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 16px;
}
.modal-box {
  direction: rtl;
  background: var(--card);
  border-radius: 10px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
  max-width: 560px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
}
.modal-header {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--card);
}
.modal-title { font-weight: 600; font-size: 16px; }
.modal-close {
  background: none;
  border: none;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
  padding: 0 4px;
}
.modal-close:hover { color: var(--text); }
.modal-body { padding: 16px 18px; }
.modal-body .card { border: none; box-shadow: none; margin: 0; padding: 0; }

/* مودال عريض (v1.4.1 T1): لشاشات تفصيل مكتظة (بطاقة المتقدم الكاملة —
   بيانات، تعديل، وثائق، مرفقات، ملاحظات لجنة، تحويل إلى موظف) بدل اللوحة
   السفلية القديمة. */
.modal-box.modal-wide {
  max-width: 860px;
  max-height: 85vh;
  overflow-y: auto;
}
/* المودال العريض يستضيف عدة بطاقات متتالية (بيانات المتقدم، بيانات النموذج،
   الوثائق، المرفقات، ملاحظات اللجنة، تحويل إلى موظف) — على عكس مودال
   النموذج الفردي (`.modal-body .card` أعلاه)، هنا نُبقي حدود/ظل/تباعد كل
   بطاقة حتى تبقى الأقسام مميّزة بصريًا. */
.modal-wide .modal-body .card {
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 16px 18px;
  margin: 0 0 16px;
}
.modal-wide .modal-body .card:last-child { margin-bottom: 0; }

/* ---------------------------------------------------------------------
   فقاعة بيانات الموظف (v1.4 §3)
--------------------------------------------------------------------- */
.emp-link {
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  font-weight: 600;
  border-radius: 6px;
  padding: 1px 4px;
  margin: -1px -4px;
}
.emp-link:hover { background: rgba(30, 94, 255, .08); color: var(--accent-2); }
.employee-info-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 14px;
  margin-bottom: 14px;
}
.employee-info-grid .info-label {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}
.employee-info-grid .info-value { font-size: 14px; color: var(--text); }

/* ---------------------------------------------------------------------
   بوابة التقارير (v1.3 §5/§8/T5): قائمة جانبية + محتوى.
--------------------------------------------------------------------- */
.reports-layout {
  display: flex;
  gap: 18px;
  align-items: flex-start;
}
.reports-sidebar {
  flex: 0 0 220px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px;
}
.reports-nav-item {
  text-align: right;
  background: none;
  border: none;
  border-radius: 6px;
  padding: 8px 10px;
  cursor: pointer;
  color: var(--text);
  font-size: 14px;
}
.reports-nav-item:hover { background: var(--bg); }
.reports-nav-item.active {
  background: var(--accent);
  color: #fff;
}
.reports-content { flex: 1; min-width: 0; }

@media (max-width: 720px) {
  .reports-layout { flex-direction: column; }
  .reports-sidebar {
    flex-direction: row;
    flex-wrap: wrap;
    flex-basis: auto;
  }
}

/* ---------------------------------------------------------------------
   شبكة الحضور الشهرية
--------------------------------------------------------------------- */
/* v1.11: the grid scrolls inside its own box (both axes) so the day header
   row and the employee-name column stay visible while scrolling. */
.attendance-grid-wrap {
  max-width: 100%;
  max-height: calc(100vh - 230px);
  overflow: auto;
}

@media print {
  .attendance-grid-wrap { max-height: none; overflow: visible; }
  table.attendance-grid thead th { position: static; }
}

table.attendance-grid {
  font-size: 12px;
  border-collapse: separate;
  border-spacing: 0;
}

table.attendance-grid thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f8f9fb;
  white-space: nowrap;
  padding: 5px 4px;
}

table.attendance-grid th.sticky-col,
table.attendance-grid td.sticky-col {
  position: sticky;
  right: 0;
  background: var(--card);
  z-index: 2;
  text-align: right;
  min-width: 140px;
  box-shadow: -1px 0 0 var(--border);
  padding: 4px 8px;
}
/* corner cell: above both the header row and the name column */
table.attendance-grid thead th.sticky-col { z-index: 3; background: #f8f9fb; }

table.attendance-grid th.day-col,
table.attendance-grid td.att-cell {
  min-width: 28px;
  text-align: center;
  padding: 3px 2px;
  cursor: pointer;
  user-select: none;
}
table.attendance-grid td.att-cell:hover {
  outline: 2px solid var(--accent-2);
  outline-offset: -2px;
}

.att-weekend { background: #eceff3; color: var(--muted); }
.att-workday { background: #e7f6ec; color: #15803d; }
.att-holiday { background: #dbeafe; color: #1d4ed8; font-weight: 700; }
.att-remote { background: repeating-linear-gradient(45deg, #e7f6ec, #e7f6ec 4px, #d1efdc 4px, #d1efdc 8px); color: #15803d; font-weight: 700; }
.att-absent { background: #fde2e2; color: #b91c1c; font-weight: 700; }
.att-late { background: #fdead1; color: #b45309; font-weight: 700; }
.att-leave { background: #fef3c7; color: #a16207; font-weight: 700; }
.att-mission { background: #ece1fb; color: #6d28d9; font-weight: 700; }
.att-present { background: #bbf7d0; color: #166534; font-weight: 700; }
.att-legend { display: flex; flex-wrap: wrap; gap: 10px; margin: 8px 0; font-size: 13px; }
.att-legend-item { display: inline-flex; align-items: center; gap: 4px; }
.att-legend-swatch { display: inline-flex; width: 22px; height: 22px; align-items: center; justify-content: center; border-radius: 4px; border: 1px solid #d6dbe4; }
@media print { .att-workday, .att-holiday, .att-remote, .att-absent, .att-late, .att-leave, .att-mission, .att-present, .att-weekend, .att-legend-swatch { -webkit-print-color-adjust: exact; print-color-adjust: exact; } }

/* v1.2 T4: pending absence — dashed border + diagonal stripes over the
   normal absent fill, so it reads as "still needs a decision". */
table.attendance-grid td.att-pending {
  outline: 2px dashed #b91c1c;
  outline-offset: -2px;
  background-image: repeating-linear-gradient(
    45deg, rgba(185, 28, 28, 0.18), rgba(185, 28, 28, 0.18) 4px,
    transparent 4px, transparent 8px
  );
}

/* شريط الغيابات المعلّقة أعلى شبكة الحضور */
.pending-bar { margin-bottom: 10px; }
.pending-bar-header { display: flex; align-items: center; gap: 10px; }
.pending-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.pending-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  flex-wrap: wrap;
}
.pending-item-name { flex: 1; min-width: 160px; font-weight: 600; }

/* ---------------------------------------------------------------------
   أرصدة الإجازات (شبكة موظفين × أنواع)
--------------------------------------------------------------------- */
table.balances-table th, table.balances-table td { white-space: nowrap; }

.balance-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 12px;
}
.balance-cell .bal-part { color: var(--muted); }
.balance-cell .bal-remaining { font-weight: 700; color: var(--text); }
.balance-cell .bal-remaining.bal-low { color: var(--danger); }

/* ---------------------------------------------------------------------
   طباعة
--------------------------------------------------------------------- */
@media print {
  /* v1.4 §7: الشريط الجانبي الجديد يُخفى عند الطباعة تمامًا مثل الشريط
     العلوي القديم؛ #nav فرع منه فيُخفى تبعًا لكن أُبقي عليه صراحةً كسابقًا.
     #mainCol كان يترك مساحة للـsidebar الثابت عبر margin-right — يجب
     تصفيرها هنا وإلا انزاحت كل صفحات الطباعة (قسيمة الراتب، كشف الحساب،
     العقود، ...) عن مركز الصفحة. */
  #topbar, #sidebar, #nav, .no-print { display: none !important; }
  #layout, #mainCol { display: block; margin: 0; }
  #view { max-width: none; padding: 0; }
  body { background: #fff; }
  .print-page { box-shadow: none; border: 1px solid #000; margin: 0 auto; }
  .page-break { page-break-after: always; }
}

/* طباعة قائمة واحدة (جدول) من شاشة فيها عناصر أخرى (فلاتر/أزرار) لا يجب
   طباعتها: printElement() يستنسخ الجدول المستهدف داخل #printArea المخفي
   ويضيف .list-printing على body قبل window.print(). */
#printArea { display: none; }

@media print {
  body.list-printing #topbar,
  body.list-printing #nav,
  body.list-printing #view { display: none !important; }
  body.list-printing #printArea { display: block !important; }
}

/* طباعة أفقية للقوائم العريضة (مثل سطور المسيّر بكل أعمدتها) —
   printElement(node, title, landscape=true) يضيف .print-landscape على body
   (وقاعدة @page المطابقة تُحقن ديناميكيًا في app.js لأنها لا تُقيَّد بصنف). */
@media print {
  body.list-printing.print-landscape #printArea table {
    font-size: 10px;
  }
  body.list-printing.print-landscape #printArea th,
  body.list-printing.print-landscape #printArea td {
    padding: 2px 4px;
  }
}

/* ---------------------------------------------------------------------
   شاشة الرواتب (المسيّر)
--------------------------------------------------------------------- */
.empty-payroll {
  text-align: center;
  padding: 40px 20px;
}
.empty-payroll .empty-msg { margin-bottom: 16px; }

.big-btn { font-size: 16px; padding: 14px 28px; }

.late-settlement-banner {
  margin-top: 8px;
  padding: 8px 14px;
  border-radius: 6px;
  background: #fdead1;
  color: #b45309;
  font-weight: 700;
}

/* إدخال الحضور اليومي (v1.2 §10) */
table.day-entry-table td, table.day-entry-table th { white-space: nowrap; }
.day-radio-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.day-radio-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13.5px;
  font-weight: 400;
  cursor: pointer;
}
.day-entry-err {
  color: var(--danger);
  font-size: 12.5px;
}

table.payroll-table th, table.payroll-table td { white-space: nowrap; }

td.editable-cell { cursor: pointer; }
td.editable-cell:hover { outline: 2px solid var(--accent-2); outline-offset: -2px; }

.reason-input { width: 150px; font-size: 13px; }

.net-cell { font-weight: 700; }

/* لوحة دفعات الراتب المضمّنة (سطر مسيّر معتمد/مدفوع) */
tr.salary-payments-row > td {
  background: #f8f9fb;
  white-space: normal;
  padding: 12px 16px;
}
.salary-payments-panel .table-wrap { margin-bottom: 10px; }
table.salary-payments-table th, table.salary-payments-table td {
  border: 1px solid var(--border);
  padding: 4px 8px;
}

/* ---------------------------------------------------------------------
   صفحات الطباعة (قسيمة راتب / قسيمة سنوية)
--------------------------------------------------------------------- */
.print-page {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 4px;
  max-width: 800px;
  margin: 0 auto 24px;
  padding: 32px;
  box-shadow: var(--shadow);
}

.payslip-header { text-align: center; margin-bottom: 12px; }
.org-name-ar { font-size: 20px; font-weight: 700; }
.org-name-en { font-size: 14px; color: var(--muted); }
.org-national { font-size: 12px; color: var(--muted); }

.doc-logo { display: block; max-height: 80px; max-width: 240px; margin: 0 auto 8px; }

.logo-preview-host { margin-bottom: 10px; }
.logo-preview-host .doc-logo { margin: 0 0 10px; }

.divider { border-top: 1px solid var(--border); margin: 16px 0; }

.payslip-title { text-align: center; margin: 12px 0 20px; }

/* v1.2 §4: prominent draft marker on printable/word voucher documents */
.draft-marker {
  text-align: center;
  color: #c00;
  font-weight: 700;
  font-size: 1.2em;
  margin: -12px 0 16px;
}

.payslip-employee {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 24px;
  margin-bottom: 16px;
  font-size: 14px;
}

.payslip-table { width: 100%; border-collapse: collapse; margin-bottom: 16px; }
.payslip-table th, .payslip-table td { border: 1px solid var(--border); padding: 6px 10px; }
.payslip-table .net-row td { font-weight: 700; background: #f5f7fa; }

.payslip-tafqit { font-weight: 600; margin-bottom: 8px; }
.payslip-advances { color: var(--muted); margin-bottom: 20px; }

.payslip-ack p { margin: 0 0 20px; }
.signature-row { display: flex; justify-content: space-between; margin-top: 40px; gap: 12px; flex-wrap: wrap; }
.signature-block { display: flex; align-items: flex-end; gap: 8px; }
.sig-line { display: inline-block; width: 160px; border-bottom: 1px solid var(--text); }

.sign-cell { font-weight: 700; }

/* v1.10: قسيمة الراتب A4 طولية على ورق مروَّس (فراغ علوي 7 سم). */
.payslip-a4 { max-width: 21cm; font-size: 12.5px; }
.payslip-a4 .doc-body { line-height: 1.55; }
.payslip-a4 .letterhead-space {
  height: 4cm;
  border: 1px dashed var(--border);
  border-radius: 4px;
  margin-bottom: 10px;
}
.payslip-a4 .payslip-title { margin: 0 0 10px; font-size: 17px; }
.payslip-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px 16px;
  margin-bottom: 8px;
}
.payslip-section-title {
  font-weight: 700;
  border-bottom: 1px solid var(--text);
  margin: 8px 0 4px;
  padding-bottom: 2px;
}
.payslip-a4 .payslip-table { margin-bottom: 4px; font-size: 12px; }
.payslip-a4 .payslip-table th, .payslip-a4 .payslip-table td { padding: 2px 8px; }
.payslip-notes > div { margin-bottom: 2px; }
.payslip-notes .note-line { border-bottom: 1px dotted var(--text); height: 18px; }
.payslip-a4 .payslip-ack { font-size: 12.5px; margin-bottom: 6px; }
.payslip-terms {
  font-size: 10.5px;
  line-height: 1.5;
  color: #333;
  border-top: 1px solid var(--border);
  padding-top: 4px;
  margin-bottom: 0;
}
@media print {
  .print-page.payslip-a4 {
    border: none;
    border-radius: 0;
    box-shadow: none;
    max-width: none;
    width: 21cm;
    padding: 0 1.6cm 1cm;
    margin: 0;
    box-sizing: border-box;
  }
  .payslip-a4 .letterhead-space { height: 7cm; border: none; margin: 0; }
  .payslip-a4.page-break { page-break-after: always; break-after: page; }
}

.payslip-cash-row {
  border: 2px solid var(--text);
  border-radius: 4px;
  padding: 10px 16px;
  margin: 16px 0;
}
.cash-label { font-weight: 700; font-size: 16px; margin-bottom: 4px; }

/* ---------------------------------------------------------------------
   نص عقد العمل (يحافظ على فواصل الأسطر الأصلية)
--------------------------------------------------------------------- */
.doc-body {
  white-space: pre-wrap;
  line-height: 1.8;
  font-size: 14px;
  margin-bottom: 28px;
}

/* ---------------------------------------------------------------------
   عناصر نموذج بعرض كامل (قوالب/قوائم في شاشة الإعدادات)
--------------------------------------------------------------------- */
.full-width { width: 100%; }

/* ---------------------------------------------------------------------
   أيقونات + حيوية الواجهة (v1.4.1 — «الواجهة أكثر حيوية»)
   رموز SVG مضمّنة (icon() في app.js) + حركات/انتقالات خفيفة الكلفة على
   البطاقات/الأزرار/الصفوف/المودال/التنبيه العابر. لا تغيير في التخطيط أو
   المنطق — تنسيق فقط.
--------------------------------------------------------------------- */
.icon { flex-shrink: 0; vertical-align: middle; }

.page-title, .card-title {
  display: flex;
  align-items: center;
}
.title-icon { color: var(--accent-2); margin-inline-end: 8px; }

.nav-icon svg { width: 18px; height: 18px; }

.topbar-icon {
  display: inline-flex;
  align-items: center;
  color: var(--muted);
}
.topbar-icon svg { width: 15px; height: 15px; }

#logoutBtn { display: inline-flex; align-items: center; gap: 6px; }

/* أزرار مع أيقونة (iconBtn/طباعة/تصدير/رجوع...) */
button > .icon + span { margin-inline-start: 2px; }

/* شرائح إحصاءات لوحة اليوم (dashboardCard) — دائرة خلفية بلون خافت مميّز
   لكل بطاقة. */
.stat-icon-chip {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 8px;
}
.stat-icon-chip.chip-blue   { background: #dbe9fe; color: #1d4ed8; }
.stat-icon-chip.chip-orange { background: #fdead1; color: #b45309; }
.stat-icon-chip.chip-green  { background: #dcf5e3; color: #157347; }
.stat-icon-chip.chip-purple { background: #ede4fd; color: #6d28d9; }

/* حركة/انتقالات خفيفة عامة: بطاقات ترتفع قليلًا عند المرور، الأزرار
   تنكمش قليلًا عند الضغط، عناصر التنقل تنزلق. */
button, .card, tbody tr, .reports-nav-item, .attachment-item .thumb {
  transition: background-color .15s ease, border-color .15s ease,
    transform .15s ease, box-shadow .15s ease;
}
button:active { transform: scale(.98); }

.card:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(20, 25, 35, 0.12);
}

.nav-link {
  transition: background-color .15s ease, color .15s ease, padding-inline-start .15s ease;
}
.nav-link:hover { padding-inline-start: 16px; }

/* شريط تمييز يساري عند مرور الفأرة فوق صف جدول (فوق تلوين الخلفية القائم). */
tbody tr:hover { box-shadow: inset 3px 0 0 var(--accent-2); }

/* حالة فارغة موحّدة (emptyState() في app.js): أيقونة كبيرة باهتة + رسالة
   وسط البطاقة، بدل نص .empty-msg المجرد. */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 34px 16px;
  color: var(--muted);
  text-align: center;
}
.empty-state-icon { color: #c3cad6; }
.empty-state-msg { font-size: 14px; }

/* دخول المودال بتلاشٍ + تكبير خفيف (~180ms). */
@keyframes modalBackdropIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalBoxIn {
  from { opacity: 0; transform: scale(.96) translateY(6px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-backdrop { animation: modalBackdropIn .18s ease; }
.modal-box { animation: modalBoxIn .18s ease; }

/* دخول التنبيه العابر (toast) بانزلاق بسيط (يضاف فوق transition الأصلية). */
@keyframes toastSlideIn {
  from { opacity: 0; transform: translate(-14px, 10px); }
  to { opacity: 1; transform: translate(0, 0); }
}
#toast.show { animation: toastSlideIn .2s ease; }

/* أمان الطباعة: تأكيد صريح أن أي أيقونة داخل الشريط العلوي/الجانبي/أدوات
   القائمة لا تظهر عند الطباعة — هذا تحسّب إضافي فوق display:none الموروث
   من #topbar/#sidebar/#nav/.no-print (كتلة الطباعة الأصلية أعلاه، غير
   معدَّلة)؛ لا يمسّ صفحات الطباعة (.print-page/#printArea) التي أصلًا لا
   تحوي أيقونات. */
@media print {
  #topbar svg, #sidebar svg, #nav svg, .no-print svg { display: none !important; }
}

/* v1.7 T10: مصغّرات صور التسجيل اليومي */
.checkin-thumb { width: 48px; height: 48px; object-fit: cover; border-radius: 6px; margin-inline-end: 4px; vertical-align: middle; }

/* v1.8: جدول المناوبات */
.duty-week { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.duty-day-title.clickable { cursor: pointer; }
.duty-day-title.clickable:hover { color: var(--accent-2); text-decoration: underline; }
.duty-chip { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin: 2px 0; }
.duty-emp-list { max-height: 240px; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; padding: 2px; margin-bottom: 10px; }
.inline-check {
  display: inline-flex; align-items: center; gap: 6px;
  margin: 0 0 6px 6px; padding: 5px 10px;
  border: 1px solid var(--border); border-radius: 999px;
  background: #fff; font-size: 13px; cursor: pointer; user-select: none;
  transition: background .15s ease, border-color .15s ease;
}
.inline-check:hover { background: #f4f7fb; }
.inline-check:has(input:checked) { background: #eaf1fd; border-color: #b9cdf3; color: var(--accent); }

/* ---------------------------------------------------------------------
   v1.11: summary chips (totals above a table) + «عرض المزيد» row
--------------------------------------------------------------------- */
.summary-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 10px; }
.chip {
  display: inline-block; padding: 4px 12px; border-radius: 999px;
  background: #eef1f6; color: #374151; font-size: 13px;
}
.chip-strong { background: #dbe9fe; color: #1d4ed8; font-weight: 700; }
tr.show-more-row td { text-align: center; padding: 8px; background: #f8f9fb; }

/* ---------------------------------------------------------------------
   v1.11: تخطيط موحّد لكل صفحة — جزء علوي (تبويبات / أدوات / ملخص) في لوح
   واحد، ثم جزء سفلي (الجدول / البطاقات). يطبَّق على العناصر المباشرة في
   #view فقط، فلا يمسّ شرائط الأدوات داخل البطاقات.
--------------------------------------------------------------------- */
#view > .tabs,
#view > .toolbar,
#view > .summary-chips,
#view > .advances-summary,
#view > .muted-line,
#view > .late-settlement-banner {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 12px 16px;
  margin: 0 0 16px;
}
#view > .tabs { padding-bottom: 0; border-bottom: 1px solid var(--border); }
#view > .tabs .tab-btn { margin-bottom: -1px; }
#view > .muted-line { padding-top: 8px; padding-bottom: 8px; }
#view > .advances-summary .summary-chips { margin: 0; }
#view > .late-settlement-banner.hidden { display: none; }

/* عناصر الجزء العلوي المتتالية تندمج في لوح واحد */
#view > :is(.tabs, .toolbar, .summary-chips, .advances-summary, .muted-line, .late-settlement-banner)
  + :is(.tabs, .toolbar, .summary-chips, .advances-summary, .muted-line, .late-settlement-banner) {
  margin-top: -17px;
  border-top: none;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
  box-shadow: none;
}
#view > :is(.tabs, .toolbar, .summary-chips, .advances-summary, .muted-line, .late-settlement-banner):has(
  + :is(.tabs, .toolbar, .summary-chips, .advances-summary, .muted-line, .late-settlement-banner)) {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}
#view > .tabs:has(+ .toolbar) { border-bottom: none; }
#view > .tabs + .toolbar { padding-top: 14px; }

/* الجزء السفلي: الجدول في لوح مستقل */
#view > .table-wrap {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 6px 12px 10px;
  margin-bottom: 16px;
}
#view > .table-wrap > .empty-msg { padding: 24px; }
#view > .attendance-grid-wrap { padding: 6px 8px 8px; }
#view > .hidden { display: none; }
@media print {
  #view > .tabs, #view > .toolbar, #view > .summary-chips, #view > .advances-summary,
  #view > .muted-line, #view > .table-wrap { border: none; box-shadow: none; padding: 0; }
}

/* ---------------------------------------------------------------------
   v1.11: إعادة التصميم على نمط mt.laith.cloud — ترويسة زرقاء متدرّجة،
   شريط تنقّل أفقي بأزرار مستديرة، لوحات بزوايا 14px وظل ناعم، أزرق
   ساطع للعناصر النشطة. تُعرَّف فوق القيم السابقة.
--------------------------------------------------------------------- */
:root {
  --bg: #eef2f7;
  --card: #ffffff;
  --border: #e3e8ef;
  --text: #1f2a37;
  --muted: #6b7280;
  --accent: #1746c0;
  --accent-2: #1e5eff;
  --accent-dark: #1746c0;
  --accent-soft: #eef4ff;
  --good: #0f9d58;
  --bad: #d63a3a;
  --warn: #e8a400;
  --info: #6b46c1;
  --radius: 14px;
  --shadow: 0 6px 22px rgba(20, 40, 80, 0.08);
  --content-width: 1150px;
}
body { font-size: 15px; line-height: 1.55; }

/* ----- الهيكل: عمود واحد (ترويسة ← شريط تنقّل ← محتوى) ----- */
#layout { display: block; }
#mainCol { margin-right: 0; min-height: 100vh; display: flex; flex-direction: column; }

#topbar {
  background: linear-gradient(120deg, var(--accent-2), #3b7bff);
  color: #fff;
  border-bottom: none;
  box-shadow: var(--shadow);
  padding: 12px 16px;
  position: sticky; top: 0; z-index: 50;
}
#topbar .topbar-right, #topbar .topbar-left { gap: 10px; }
#topbar .brand-mark {
  background: rgba(255, 255, 255, 0.22);
  width: 40px; height: 40px; border-radius: 11px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 20px; color: #fff;
}
#orgName { color: #fff; font-size: 20px; font-weight: 800; }
#clock, #userName { color: rgba(255, 255, 255, 0.92); font-size: 13.5px; }
#topbar .topbar-icon { color: rgba(255, 255, 255, 0.85); }
#logoutBtn {
  background: rgba(255, 255, 255, 0.16); color: #fff; border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 10px; font-weight: 700; padding: 7px 12px;
}
#logoutBtn:hover { background: rgba(255, 255, 255, 0.28); border-color: rgba(255, 255, 255, 0.5); }
#logoutBtn .topbar-icon { color: #fff; }
#sidebarToggle { display: none; }

#sidebar {
  position: sticky; top: 64px; right: auto; bottom: auto;
  width: 100%; height: auto;
  background: var(--card); border-left: none; border-bottom: 1px solid var(--border);
  box-shadow: none; z-index: 40; overflow: visible; transform: none;
}
#sidebar { display: block; }
#sidebar .nav-list {
  min-width: 0; width: auto; box-sizing: border-box;
  max-width: var(--content-width); margin: 0 auto;
  display: flex; gap: 4px; overflow-x: auto; padding: 6px 10px;
  flex-direction: row;
}
#sidebar .nav-link {
  padding: 10px 15px; border-radius: 10px; border-right: none;
  color: var(--muted); font-size: 14.5px; font-weight: 600; white-space: nowrap;
  display: flex; align-items: center; gap: 7px; justify-content: center;
}
#sidebar .nav-link:hover { background: var(--bg); color: var(--text); padding-inline-start: 15px; }
#sidebar .nav-link.active { background: var(--accent-2); color: #fff; }
#sidebar .nav-icon { width: auto; color: inherit; }
#sidebar .nav-label { display: block; }

#view { max-width: var(--content-width); padding: 18px 14px 60px; }

/* ----- العناوين واللوحات ----- */
.page-title { color: var(--text); font-size: 20px; font-weight: 800; margin-bottom: 14px; }
.card, #view > .table-wrap, #view > .tabs, #view > .toolbar, #view > .summary-chips,
#view > .advances-summary, #view > .muted-line, #view > .late-settlement-banner {
  border-radius: var(--radius); box-shadow: var(--shadow); border-color: var(--border);
}
.card { padding: 18px; }
.card:hover { transform: none; box-shadow: var(--shadow); }
.card-title { font-size: 17px; font-weight: 700; color: var(--text); }
.title-icon { color: var(--accent-2); }

/* ----- الأزرار ----- */
button { border-radius: 10px; font-weight: 600; border-color: var(--border); color: #374151; }
button:hover { background: #e2e7f0; border-color: #d0d7e2; }
button.primary { background: var(--accent-2); border-color: var(--accent-2); color: #fff; font-weight: 700; }
button.primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
button.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
button.danger:hover { background: #b92f2f; border-color: #b92f2f; }
button.small { border-radius: 8px; }
a { color: var(--accent-2); }

/* ----- الحقول ----- */
input, select, textarea { border-radius: 10px; border-color: var(--border); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent-2); box-shadow: 0 0 0 3px rgba(30, 94, 255, 0.15); }

/* ----- التبويبات داخل الصفحات ----- */
.tabs { border-bottom: 2px solid #e5e7eb; gap: 2px; }
.tab-btn { font-weight: 700; color: var(--muted); border-bottom-width: 3px; margin-bottom: -2px; }
.tab-btn.active { color: var(--accent-2); border-bottom-color: var(--accent-2); }
#view > .tabs { border-bottom: 1px solid var(--border); }

/* ----- الجداول ----- */
th { background: #f6f8fc; color: #4b5563; font-size: 12.5px; font-weight: 700; border-bottom: 1px solid var(--border); padding: 10px 12px; }
td { padding: 10px 12px; border-bottom-color: var(--border); }
tbody tr:hover { background: #f6f8fc; box-shadow: none; }
table.attendance-grid thead th, table.payroll-table thead th, table.payroll-table thead th.sticky-col,
table.attendance-grid thead th.sticky-col { background: #f6f8fc; }
table.attendance-grid th.day-col, table.attendance-grid td.att-cell { padding: 3px 2px; }

/* ----- الشارات والرقائق ----- */
.badge { border-radius: 20px; font-size: 11.5px; font-weight: 700; padding: 3px 9px; }
.badge-blue { background: var(--accent-soft); color: var(--accent-2); }
.badge-green { background: #e6f6ee; color: var(--good); }
.badge-red { background: #fbe9e9; color: var(--bad); }
.badge-orange { background: #fdf4e0; color: #a87400; }
.badge-purple { background: #efe9fb; color: var(--info); }
.chip { border-radius: 20px; background: #fff; border: 1px solid var(--border); color: #374151; font-weight: 600; }
.chip-strong { background: var(--accent-2); border-color: var(--accent-2); color: #fff; }

/* ----- بطاقات لوحة اليوم ----- */
.stat-card { border-radius: var(--radius); }
.stat-value { font-size: 30px; font-weight: 800; color: var(--text); }
.stat-icon-chip.chip-blue { background: var(--accent-soft); color: var(--accent-2); }
.stat-icon-chip.chip-green { background: #e6f6ee; color: var(--good); }
.stat-icon-chip.chip-orange { background: #fdf4e0; color: var(--warn); }
.stat-icon-chip.chip-purple { background: #efe9fb; color: var(--info); }

/* ----- شبكة الحضور ----- */
.att-holiday { background: var(--accent-soft); color: var(--accent-2); font-weight: 700; }
.att-workday { background: #e6f6ee; color: #0f7a46; }
.att-present { background: #c9ecd8; color: #0b6b3a; }

/* ----- صفحة الدخول ----- */
#loginOverlay { background: linear-gradient(135deg, #1e5eff 0%, #1746c0 100%); }
#loginOverlay .login-card { border-radius: 18px; box-shadow: 0 20px 60px rgba(10, 30, 80, 0.35); }
#loginOverlay .login-card h1 { color: var(--text); font-size: 20px; }
#loginOverlay button[type="submit"] { background: var(--accent-2); color: #fff; border-color: var(--accent-2); font-weight: 700; width: 100%; }

/* ----- الشاشات الضيقة: الشريط يتمرّر أفقيًا بدل الطي ----- */
@media (max-width: 899px) {
  #sidebar { width: 100%; }
  #mainCol { margin-right: 0; }
  #sidebar .nav-link { justify-content: center; padding: 9px 12px; }
}
@media (max-width: 639px) {
  #sidebarToggle { display: none; }
  #sidebar { width: 100%; transform: none; transition: none; }
  #sidebar .nav-link { padding: 9px 12px; }
  #topbar { padding: 10px 12px; }
  #orgName { font-size: 16px; }
}

/* v1.11: كشف الرواتب — رأس الأعمدة وعمود الموظف ثابتان أثناء التمرير */
.payroll-table-wrap { max-height: calc(100vh - 260px); overflow: auto; }
table.payroll-table { border-collapse: separate; border-spacing: 0; }
table.payroll-table thead th { position: sticky; top: 0; z-index: 2; background: #f1f4f8; }
table.payroll-table th.sticky-col, table.payroll-table td.sticky-col {
  position: sticky; right: 0; z-index: 2; background: var(--card);
  min-width: 160px; box-shadow: -1px 0 0 var(--border);
}
table.payroll-table thead th.sticky-col { z-index: 3; background: #f1f4f8; }
table.payroll-table tbody tr:hover td.sticky-col { background: #f5f8fb; }
@media print {
  .payroll-table-wrap { max-height: none; overflow: visible; }
  table.payroll-table thead th, table.payroll-table td.sticky-col { position: static; }
}

/* v1.11: شاشة الدخول — شعار، إظهار كلمة المرور، تذكرني، نسيت كلمة المرور */
.login-logo { width: 84px; height: 84px; object-fit: contain; border-radius: 50%; margin: 0 auto 10px; display: block; background: #fff; }
.login-logo.hidden { display: none; }
.login-sub { color: var(--muted); font-size: 13px; margin: -16px 0 18px; }
.password-wrap { position: relative; display: block; }
.password-wrap input { width: 100%; padding-inline-end: 40px; box-sizing: border-box; }
.eye-btn { position: absolute; top: 50%; left: 6px; transform: translateY(-50%); border: none; background: none; padding: 4px 6px; font-size: 16px; color: var(--muted); cursor: pointer; }
.eye-btn:hover { color: var(--accent-2); background: none; }
.login-remember { flex-direction: row !important; align-items: center; gap: 8px !important; font-size: 13px; color: var(--text); }
.forgot-link { display: block; text-align: center; font-size: 13px; margin-top: 2px; }
.forgot-hint { margin: 0 !important; background: var(--accent-soft); border-radius: 10px; padding: 10px 12px; line-height: 1.6; }
.forgot-hint.hidden { display: none; }

.muted-line.small { font-size: 11.5px; font-weight: normal; margin-top: 2px; }

/* v1.12: صورة ترويسة قسيمة الراتب (21×7 سم = نسبة 3:1). */
.payslip-a4 .letterhead-space.has-image { border: none; height: auto; aspect-ratio: 3 / 1; }
.payslip-a4 .letterhead-space.has-image img { display: block; width: 100%; height: 100%; object-fit: contain; }
.letterhead-settings { margin-bottom: 14px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.letterhead-preview img { display: block; width: 100%; max-width: 630px; aspect-ratio: 3 / 1;
  border: 1px solid var(--border); border-radius: 6px; margin: 6px 0; background: #fff; }
@media print {
  /* الصورة بعرض الصفحة كاملًا (تتجاوز الهامشين الجانبيين 1.6 سم) وارتفاع 7 سم. */
  .payslip-a4 .letterhead-space.has-image { width: 21cm; height: 7cm; aspect-ratio: auto; margin: 0 -1.6cm; }
}

/* v1.12: بيانات الشهر بأربعة أعمدة، وتذييل القسيمة أربعة أسطر بخط أصغر. */
.payslip-month-grid { grid-template-columns: repeat(4, 1fr); gap: 3px 10px; }
.payslip-a4 .payslip-terms { font-size: 9px; line-height: 1.35; }

/* v1.12: مربع اختيار القسائم أمام كل موظف في كشف الرواتب. */
.payroll-table input.payslip-pick { margin-inline-end: 6px; vertical-align: middle; cursor: pointer; }
@media print { .payroll-table input.payslip-pick { display: none; } }

/* v1.12: مغادرة مبكرة يدوية ليوم واحد في شبكة الحضور. */
.att-early { background: #ede4fb; color: #6d28d9; font-weight: 700; }
@media print { .att-early { -webkit-print-color-adjust: exact; print-color-adjust: exact; } }

/* Madrasa+ slice 12: group labels inside the one menu (المالية / التحصيل / شؤون الموظفين) */
.nav-group {
  align-self: center;
  font-size: 12px;
  font-weight: 700;
  opacity: 0.6;
  padding: 0 8px 0 4px;
  white-space: nowrap;
  border-inline-start: 1px solid currentColor;
  margin-inline-start: 6px;
}

/* =====================================================================
   Madrasa+ slice 16 — design B (from the finance prototype): school-logo
   palette (maroon + gold), right-side collapsible sidebar with groups,
   dark mode, giraffe mascot, animated login. Appended last so it wins over
   the v1.11 block; every id/class the JS uses is unchanged.
   Font sizes in use: 12 / 13 / 15 / 17 / 22 px. Spacing in steps of 4.
===================================================================== */
:root {
  --bg: #faf6f1;
  --card: #ffffff;
  --border: #ece3d9;
  --text: #2a1d1a;
  --muted: #6e5d56;
  --accent: #7a1f2b;
  --accent-2: #7a1f2b;
  --accent-dark: #5e1621;
  --accent-soft: #f6e6e8;
  --on-accent: #ffffff;
  --gold: #d9a400;
  --gold-soft: #fbf1cf;
  --good: #2f7d4f;
  --ok: #2f7d4f;
  --bad: #9c2e3c;
  --danger: #9c2e3c;
  --warn: #b5560f;
  --info: #6b46c1;
  --side: #5e1621;
  --side-fg: #f7e9ea;
  --field: #ffffff;
  --hover: #f6efe7;
  --th: #fbf7f2;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(60, 30, 20, .05), 0 4px 14px rgba(60, 30, 20, .05);
  --sidebar-width: 248px;
  --sidebar-width-collapsed: 72px;
  --content-width: 1320px;
  --motion: .2s;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #1a1311;
  --card: #241a17;
  --border: #3a2b26;
  --text: #f4ebe6;
  --muted: #b9a79f;
  --accent: #e38795;
  --accent-2: #e38795;
  --accent-dark: #f0a0ac;
  --accent-soft: #3a2125;
  --on-accent: #1a1311;
  --gold: #ecc544;
  --gold-soft: #3a311a;
  --good: #7cc79a;
  --ok: #7cc79a;
  --bad: #f0a0ac;
  --danger: #f0a0ac;
  --warn: #f0b070;
  --info: #b9a2f0;
  --side: #120c0b;
  --side-fg: #f0dfe1;
  --field: #1e1614;
  --hover: #2e221e;
  --th: #2a1f1c;
  --shadow: none;
  color-scheme: dark;
}

html, body { background: var(--bg); color: var(--text); }
body { font-family: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, Arial, sans-serif; font-size: 15px; line-height: 1.6; }
a { color: var(--accent-2); }

/* ----- الإطار: قائمة جانبية يمين + عمود رئيسي ----- */
#layout { display: flex; min-height: 100vh; }
#mainCol { flex: 1; min-width: 0; margin-right: var(--sidebar-width); transition: margin var(--motion) ease; }
#sidebar {
  position: fixed; top: 0; right: 0; bottom: 0; left: auto;
  width: var(--sidebar-width); height: auto;
  display: flex; flex-direction: column; gap: 4px;
  background: var(--side); color: var(--side-fg);
  border: none; border-bottom: none; box-shadow: none;
  padding: 16px 12px; overflow-y: auto; z-index: 60; transform: none;
  transition: width var(--motion) ease, transform var(--motion) ease;
}
.side-brand { display: flex; align-items: center; gap: 8px; padding: 0 4px 16px; margin-bottom: 8px; border-bottom: 1px solid rgba(255, 255, 255, .08); }
.side-logo {
  width: 40px; height: 40px; flex: none; border-radius: 50%; overflow: hidden;
  background: #fff; border: 3px solid var(--gold); display: grid; place-items: center;
  color: #7a1f2b; font-size: 13px; font-weight: 700;
}
.side-logo img { width: 100%; height: 100%; object-fit: contain; }
.side-logo:has(img:not(.hidden)) b { display: none; }
.side-brand-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.4; }
.side-brand-text b { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-brand-text small { font-size: 12px; opacity: .75; }
.side-collapse {
  margin-inline-start: auto; flex: none; background: transparent; color: var(--side-fg);
  border: 1px solid rgba(255, 255, 255, .18); border-radius: 8px; padding: 0 8px; min-height: 28px;
  font-size: 17px; line-height: 1; transition: transform var(--motion) ease;
}
.side-collapse:hover { background: rgba(255, 255, 255, .08); border-color: rgba(255, 255, 255, .3); }

#sidebar .nav-list {
  display: flex; flex-direction: column; gap: 2px; padding: 0; margin: 0;
  max-width: none; width: auto; overflow: visible;
}
#sidebar .nav-group {
  display: flex; align-items: center; gap: 8px; width: 100%;
  margin: 8px 0 0; padding: 8px 12px; border: none; border-radius: 8px;
  background: transparent; color: var(--side-fg); opacity: .7;
  font-size: 12px; font-weight: 700; letter-spacing: .2px; text-align: right; cursor: pointer;
  align-self: stretch; white-space: nowrap;
}
#sidebar .nav-group:hover { opacity: 1; background: rgba(255, 255, 255, .06); }
#sidebar .nav-group .nav-group-chev { margin-inline-start: auto; transition: transform var(--motion) ease; font-size: 13px; }
#sidebar .nav-group[aria-expanded="false"] .nav-group-chev { transform: rotate(90deg); }
#sidebar .nav-group-items { display: flex; flex-direction: column; gap: 2px; }
#sidebar .nav-group-items.collapsed { display: none; }
#sidebar .nav-link {
  display: flex; align-items: center; gap: 12px; justify-content: flex-start;
  padding: 8px 12px; border-radius: 10px; border: none;
  color: var(--side-fg); opacity: .88; background: none;
  font-size: 15px; font-weight: 500; white-space: nowrap; text-decoration: none;
  transition: background var(--motion) ease, opacity var(--motion) ease;
}
#sidebar .nav-link:hover { background: rgba(255, 255, 255, .07); opacity: 1; color: var(--side-fg); padding-inline-start: 12px; text-decoration: none; }
#sidebar .nav-link.active { background: rgba(255, 255, 255, .12); opacity: 1; color: #fff; font-weight: 700; box-shadow: inset -3px 0 0 var(--gold); }
#sidebar .nav-link:focus-visible, #sidebar .nav-group:focus-visible, .side-collapse:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }
#sidebar .nav-icon { width: 20px; display: inline-flex; justify-content: center; color: inherit; }
#sidebar .nav-label { display: block; }
.side-foot { margin-top: auto; padding: 12px 4px 0; border-top: 1px solid rgba(255, 255, 255, .08); display: flex; align-items: flex-end; gap: 8px; font-size: 13px; }
.side-mascot { width: 56px; height: 56px; object-fit: contain; flex: none; }
.side-user { opacity: .85; line-height: 1.5; }

/* القائمة المصغّرة: أيقونات فقط */
:root.side-mini #mainCol { margin-right: var(--sidebar-width-collapsed); }
:root.side-mini #sidebar { width: var(--sidebar-width-collapsed); padding: 16px 8px; align-items: stretch; }
:root.side-mini .side-brand { flex-direction: column; padding: 0 0 12px; }
:root.side-mini .side-brand-text, :root.side-mini #sidebar .nav-label, :root.side-mini #sidebar .nav-group-label,
:root.side-mini #sidebar .nav-group-chev, :root.side-mini .side-user, :root.side-mini .side-mascot { display: none; }
:root.side-mini .side-collapse { margin: 0; transform: rotate(180deg); }
:root.side-mini #sidebar .nav-group { justify-content: center; padding: 4px; min-height: 8px; }
:root.side-mini #sidebar .nav-group::before { content: ""; display: block; width: 24px; border-top: 1px solid rgba(255, 255, 255, .2); }
:root.side-mini #sidebar .nav-group-items.collapsed { display: flex; }
:root.side-mini #sidebar .nav-link { justify-content: center; padding: 12px 8px; }

/* ----- الشريط العلوي ----- */
#topbar {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--card) 92%, transparent);
  backdrop-filter: blur(8px);
  color: var(--text); border-bottom: 1px solid var(--border); box-shadow: none;
  padding: 8px 24px;
}
#topbar .brand-mark { display: none; }
#orgName { color: var(--text); font-size: 17px; font-weight: 700; }
#clock, #userName { color: var(--muted); font-size: 13px; }
#topbar .topbar-icon { color: var(--muted); }
#logoutBtn, .theme-btn {
  background: transparent; color: var(--text); border: 1px solid var(--border);
  border-radius: 10px; padding: 4px 12px; font-weight: 600; min-height: 32px;
}
#logoutBtn:hover, .theme-btn:hover { background: var(--hover); border-color: var(--border); }
#logoutBtn .topbar-icon { color: var(--muted); }
.theme-btn { font-size: 15px; padding: 4px 8px; min-width: 32px; }
#sidebarToggle { display: none; background: transparent; color: var(--text); border: 1px solid var(--border); border-radius: 10px; padding: 4px 8px; }
.side-scrim { display: none; }

#view { max-width: var(--content-width); width: 100%; margin: 0 auto; padding: 24px 24px 64px; }

/* ----- لوحات وبطاقات وعناصر ----- */
.card, #view > .table-wrap, #view > .tabs, #view > .toolbar, #view > .summary-chips,
#view > .advances-summary, #view > .muted-line, #view > .late-settlement-banner, .stat-card {
  background: var(--card); border-color: var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.page-title { color: var(--text); font-size: 22px; font-weight: 700; }
.card-title { color: var(--text); font-size: 17px; }
.title-icon { color: var(--accent-2); }
.stat-value { color: var(--text); font-size: 22px; letter-spacing: -.2px; }

button { background: var(--card); color: var(--text); border-color: var(--border); border-radius: 10px; transition: background var(--motion) ease, border-color var(--motion) ease, transform var(--motion) ease; }
button:hover { background: var(--hover); border-color: var(--border); }
button.primary, .login-card button[type="submit"], #loginOverlay button[type="submit"] {
  background: var(--accent-2); border-color: var(--accent-2); color: var(--on-accent);
}
button.primary:hover, .login-card button[type="submit"]:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
button.danger { background: var(--bad); border-color: var(--bad); color: var(--on-accent); }
button.danger:hover { background: color-mix(in srgb, var(--bad) 85%, #000); border-color: var(--bad); }
button:focus-visible, a:focus-visible { outline: 2px solid color-mix(in srgb, var(--accent-2) 55%, transparent); outline-offset: 1px; }

input, select, textarea { background: var(--field); color: var(--text); border-color: var(--border); border-radius: 9px; }
input:focus, select:focus, textarea:focus { border-color: var(--accent-2); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-2) 18%, transparent); }

.tabs { border-bottom-color: var(--border); }
.tab-btn { color: var(--muted); }
.tab-btn:hover { background: var(--hover); color: var(--text); }
.tab-btn.active { color: var(--accent-2); border-bottom-color: var(--accent-2); }

th, table.attendance-grid thead th, table.payroll-table thead th, table.payroll-table thead th.sticky-col,
table.attendance-grid thead th.sticky-col { background: var(--th); color: var(--muted); border-bottom-color: var(--border); }
td { border-bottom-color: var(--border); }
tbody tr:hover, table.payroll-table tbody tr:hover td.sticky-col { background: var(--hover); }
table.payroll-table td.sticky-col { background: var(--card); }
tr.show-more-row td, .perm-detail-row td, .payslip-table .net-row td { background: var(--th); }

.badge-blue { background: var(--accent-soft); color: var(--accent-2); }
.badge-gray { background: var(--hover); color: var(--muted); }
.chip { background: var(--card); border-color: var(--border); color: var(--text); }
.chip-strong { background: var(--accent-2); border-color: var(--accent-2); color: var(--on-accent); }
.stat-icon-chip.chip-blue { background: var(--accent-soft); color: var(--accent-2); }
.inline-check { background: var(--card); }
.inline-check:hover { background: var(--hover); }
.inline-check:has(input:checked) { background: var(--accent-soft); border-color: var(--accent-2); color: var(--accent-2); }
.modal-box { background: var(--card); color: var(--text); border-radius: 16px; }
#toast { border-radius: 12px; }
.empty-msg, .muted, .hint { color: var(--muted); }

/* الوضع الليلي: الألوان الفاتحة الثابتة القديمة تصبح نسخًا داكنة */
:root[data-theme="dark"] .badge-red, :root[data-theme="dark"] .att-absent { background: #3a2125; color: #f0a0ac; }
:root[data-theme="dark"] .badge-orange, :root[data-theme="dark"] .att-late, :root[data-theme="dark"] .stat-icon-chip.chip-orange { background: #3b2a1b; color: #f0b070; }
:root[data-theme="dark"] .badge-green, :root[data-theme="dark"] .att-workday, :root[data-theme="dark"] .stat-icon-chip.chip-green { background: #1f3326; color: #7cc79a; }
:root[data-theme="dark"] .att-present, :root[data-theme="dark"] .badge-green-dark { background: #234a31; color: #a6e3bd; }
:root[data-theme="dark"] .badge-purple, :root[data-theme="dark"] .att-mission, :root[data-theme="dark"] .att-early, :root[data-theme="dark"] .stat-icon-chip.chip-purple { background: #2c2440; color: #c9b6f5; }
:root[data-theme="dark"] .att-leave { background: #3a311a; color: #ecc544; }
:root[data-theme="dark"] .att-holiday { background: #22283a; color: #a9bdf5; }
:root[data-theme="dark"] .att-weekend, :root[data-theme="dark"] .badge-gray-dark { background: #2e221e; color: #b9a79f; }
:root[data-theme="dark"] tbody tr:nth-child(even) { background: color-mix(in srgb, var(--card) 85%, var(--bg)); }
/* معاينة الورق تبقى بيضاء في الوضع الليلي */
:root[data-theme="dark"] .print-page, :root[data-theme="dark"] .payslip-a4 {
  --card: #fff; --text: #1f1a18; --muted: #555; --border: #ddd; --th: #f5f5f5; --field: #fff;
  background: #fff; color: #1f1a18;
}

/* ----- التميمة (الزرافة) ----- */
.mascot { object-fit: contain; flex: none; }
.hello { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; }
.hello .mascot { width: 72px; height: 72px; }
.hello h2 { margin: 0; font-size: 22px; }
.hello p { margin: 0; color: var(--muted); font-size: 13px; }

/* ----- شاشة الدخول (تصميم ب) ----- */
#loginOverlay { display: grid; grid-template-columns: 1.1fr 1fr; align-items: stretch; justify-content: stretch; background: var(--bg); padding: 0; z-index: 70; }
#loginOverlay.hidden { display: none; }
.lg-brand {
  position: relative; overflow: hidden; color: #fbeff0; text-align: center;
  background: radial-gradient(120% 90% at 85% 10%, #9c2e3c 0%, #7a1f2b 45%, #4a1019 100%);
  display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 16px; padding: 40px;
}
.lg-brand::before, .lg-brand::after { content: ""; position: absolute; border-radius: 50%; border: 2px solid rgba(233, 196, 74, .35); }
.lg-brand::before { width: 520px; height: 520px; top: -180px; left: -160px; animation: mp-spin 60s linear infinite; }
.lg-brand::after { width: 340px; height: 340px; bottom: -140px; right: -90px; border-color: rgba(240, 162, 92, .35); animation: mp-spin 45s linear infinite reverse; }
.lg-logo {
  width: 120px; height: 120px; border-radius: 50%; background: #fff; border: 5px solid #e9c44a;
  display: grid; place-items: center; overflow: hidden; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); animation: mp-pop .3s ease-out both;
}
.lg-logo .login-logo { width: 100%; height: 100%; margin: 0; border-radius: 0; }
.lg-logo:has(img:not(.hidden)) .lg-logo-fallback { display: none; }
.lg-logo-fallback { color: #7a1f2b; font-size: 30px; }
.lg-name { font-size: 22px; font-weight: 700; animation: mp-rise .3s .1s ease-out both; }
.lg-tag { display: flex; flex-direction: column; align-items: center; gap: 4px; margin: 0; line-height: 1.5; }
.lg-tag b { font-size: 17px; color: #e9c44a; }
.lg-tag span { font-size: 15px; }
.lg-rot { color: #f6d6db; font-weight: 600; min-height: 1.5em; transition: opacity var(--motion), transform var(--motion); }
.lg-rot.out { opacity: 0; transform: translateY(6px); }
.lg-dots { display: flex; gap: 8px; }
.lg-dots span { width: 8px; height: 8px; border-radius: 50%; background: #e9c44a; opacity: .35; transition: all .25s; }
.lg-dots span.on { opacity: 1; transform: scale(1.35); }
.lg-gir { position: absolute; bottom: 16px; inset-inline-start: 24px; width: 148px; filter: drop-shadow(0 8px 16px rgba(0, 0, 0, .3)); animation: mp-bob 2.4s ease-in-out infinite; }
.lg-form { position: relative; display: flex; align-items: center; justify-content: center; padding: 24px; overflow: auto; }
.lg-theme { position: absolute; top: 16px; inset-inline-end: 16px; }
#loginOverlay .login-card {
  background: transparent; box-shadow: none; border-radius: 0; max-width: 400px; padding: 8px; text-align: right;
  animation: mp-rise .3s .1s ease-out both;
}
#loginOverlay .login-card h1 { color: var(--text); font-size: 22px; margin: 0 0 4px; }
#loginOverlay .login-sub { margin: 0 0 16px; font-size: 13px; color: var(--muted); }
#loginOverlay .login-card label { color: var(--muted); }
#loginOverlay .login-card input[type="text"], #loginOverlay .login-card input[type="password"] { height: 48px; border-radius: 12px; font-size: 15px; }
#loginOverlay button[type="submit"] { height: 48px; border-radius: 12px; font-size: 15px; font-weight: 700; width: 100%; }
#loginOverlay button[type="submit"]:hover { transform: translateY(-1px); box-shadow: 0 8px 20px color-mix(in srgb, var(--accent-2) 35%, transparent); }
#loginOverlay .forgot-hint { background: var(--accent-soft); }
@keyframes mp-spin { to { transform: rotate(360deg); } }
@keyframes mp-bob { 50% { transform: translateY(-6px); } }
@keyframes mp-pop { from { opacity: 0; transform: scale(.7); } to { opacity: 1; transform: none; } }
@keyframes mp-rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* ----- الجوال: القائمة درج يمين ----- */
@media (max-width: 900px) {
  #mainCol, :root.side-mini #mainCol { margin-right: 0; }
  #sidebar, :root.side-mini #sidebar { width: 272px; transform: translateX(105%); padding: 16px 12px; }
  #sidebar.open { transform: none; box-shadow: -10px 0 40px rgba(0, 0, 0, .3); }
  .side-scrim.open { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 55; }
  .side-collapse { display: none; }
  :root.side-mini .side-brand { flex-direction: row; }
  :root.side-mini .side-brand-text, :root.side-mini #sidebar .nav-label, :root.side-mini #sidebar .nav-group-label,
  :root.side-mini #sidebar .nav-group-chev, :root.side-mini .side-user, :root.side-mini .side-mascot { display: initial; }
  :root.side-mini #sidebar .nav-group::before { display: none; }
  :root.side-mini #sidebar .nav-link { justify-content: flex-start; padding: 8px 12px; }
  #sidebarToggle { display: inline-flex; }
  #topbar { padding: 8px 12px; }
  #clock { display: none; }
  #view { padding: 16px 12px 48px; }
}
@media (max-width: 820px) {
  #loginOverlay { grid-template-columns: 1fr; grid-template-rows: auto 1fr; overflow: auto; }
  .lg-brand { padding: 24px 16px 64px; gap: 8px; }
  .lg-logo { width: 84px; height: 84px; }
  .lg-gir { width: 76px; bottom: 4px; inset-inline-start: auto; inset-inline-end: 8px; }
  .lg-form { align-items: flex-start; padding-top: 24px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ----- الطباعة: ورق أبيض بلا إطار ----- */
@media print {
  :root, :root[data-theme="dark"] {
    --bg: #fff; --card: #fff; --text: #000; --muted: #444; --border: #ccc; --th: #f3f3f3; --field: #fff; --hover: #fff;
    color-scheme: light;
  }
  #sidebar, #sideScrim, #topbar, .side-scrim { display: none !important; }
  #mainCol, :root.side-mini #mainCol { margin: 0 !important; }
  #view { max-width: none; padding: 0; }
}

/* =====================================================================
   Madrasa+ UI slice 17 — العائلات والطلاب (#/families, #/family/{id}).
   Tokens only (works in dark mode). Spacing in steps of 4.
===================================================================== */
.fam-search { flex: 1; min-width: 220px; height: 40px; }
.fam-quick { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; }
.fam-quick button small { color: inherit; opacity: .8; }
.fam-cls { margin-inline-start: 8px; }
.fam-kids { font-size: 13px; color: var(--muted); max-width: 320px; }
.phone-cell { text-align: right; font-variant-numeric: tabular-nums; }
.data-table.compact td, .data-table.compact th { padding: 8px 12px; }
.num.credit, .credit { color: var(--good); }
.fam-empty { display: flex; align-items: center; gap: 16px; justify-content: center; padding: 16px; }
.fam-empty .mascot { width: 88px; height: auto; }
.fam-head .page-title { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 8px; }
.fam-head .fam-no { font-size: 15px; color: var(--muted); font-weight: 600; }
.fam-total { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; padding: 12px 16px;
  border-radius: 10px; background: var(--th); border: 1px solid var(--border); }
.fam-total b { font-size: 17px; }
.fam-actions { flex-wrap: wrap; gap: 8px; }
.fam-guardian { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.kv-table { width: 100%; border-collapse: collapse; }
.kv-table th, .kv-table td { text-align: start; padding: 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.kv-table th { width: 44%; color: var(--muted); font-weight: 600; background: transparent; }
.note-box { margin: 8px 0; padding: 12px 16px; border-radius: 10px; border: 1px solid var(--border); background: var(--th); color: var(--text); }
.note-box.ok { border-color: var(--good); background: color-mix(in srgb, var(--good) 10%, var(--card)); }
.note-box.warn { border-color: var(--gold); background: color-mix(in srgb, var(--gold) 14%, var(--card)); }
.note-box.bad { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 10%, var(--card)); }
.fam-match-card { margin-top: 4px; font-size: 13px; }
.radio-line { display: flex; gap: 8px; align-items: flex-start; margin: 8px 0; cursor: pointer; }
.fam-form .form-grid { margin-bottom: 8px; }
.fam-more-fields { margin: 8px 0; padding: 8px 12px; border: 1px dashed var(--border); border-radius: 10px; }
.fam-more-fields summary { cursor: pointer; color: var(--accent-2); font-weight: 600; }
.phone-field { display: flex; gap: 4px; direction: ltr; }
.phone-field input { flex: 1; min-width: 0; }
.phone-field select { width: auto; }
.modal-actions { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.fam-pick-list { margin-top: 8px; }
.fam-pick-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.fam-pick-list + *, .modal-body input[type="search"] { width: 100%; }
@media print { .fam-actions, .fam-quick { display: none !important; } }
button.quiet-danger { background: transparent; color: var(--bad); border-color: var(--border); }
button.quiet-danger:hover { background: color-mix(in srgb, var(--bad) 10%, var(--card)); border-color: var(--bad); }

/* =====================================================================
   Madrasa+ UI slice 18 — الفوترة والفواتير (#/billing/<tab>).
   Tokens only (works in dark mode). Spacing in steps of 4.
===================================================================== */
.tabs a.tab-btn { text-decoration: none; display: inline-flex; align-items: center; }
.tabs .tab-year { display: inline-flex; align-items: center; gap: 8px; margin-inline-start: auto; color: var(--muted); font-size: 13px; }
.tabs .tab-year select { width: auto; }
.bill-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 0 0 16px; }
.bill-card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 12px 16px; }
.bill-card-k { color: var(--muted); font-size: 13px; }
.bill-card-v { font-size: 22px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; margin-top: 4px; }
.bill-card small { color: var(--muted); font-size: 12px; }
.bill-filters { flex-wrap: wrap; gap: 8px; align-items: flex-end; }
.bill-filters input[type="search"] { min-width: 200px; flex: 1; }
.bill-filters .field { margin: 0; }
.bill-warn { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.data-table tr.row-cancelled td { color: var(--muted); text-decoration: line-through; }
.data-table tr.row-cancelled td .badge { text-decoration: none; }
.num.owed { color: var(--bad); font-weight: 700; }
.bill-table .bill-fam-row td { background: var(--th); }
.bill-table .bill-lines small { color: var(--muted); }
.bill-table .b_disc { width: 96px; }
.bill-table .b_why { display: block; width: 160px; margin-top: 4px; }
.bill-err { display: block; color: var(--bad); }
.bill-grades { display: flex; flex-wrap: wrap; gap: 8px 16px; margin: 8px 0; }
.check-line { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }
.bill-add { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.bill-add h3 { margin: 0 0 8px; font-size: 15px; }
.fin-lines { display: flex; flex-direction: column; gap: 8px; margin: 8px 0; }
.fin-line { display: grid; grid-template-columns: 1.2fr 1fr 2fr 1fr auto; gap: 8px; align-items: center; }
.fin-line[data-kind] { grid-template-columns: 1fr 120px auto; }
.fin-line-name { color: var(--text); }
.fin-quick { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0; }
.fin-quick .muted { font-size: 13px; }
.fin-doc-sum { margin-top: 12px; max-width: 360px; }
.fam-bill-link { align-self: center; padding: 0 8px; }
@media (max-width: 640px) {
  .fin-line { grid-template-columns: 1fr 1fr; }
  .tabs .tab-year { margin-inline-start: 0; }
}
@media print { .bill-filters, .tabs .tab-year { display: none !important; } }

/* =====================================================================
   Madrasa+ UI slice 19 — سندات القبض، كشف الحساب، الأقساط والجدولة.
   Tokens only (works in dark mode). Spacing in steps of 4.
===================================================================== */
.rc-form .rc-h { margin: 16px 0 8px; font-size: 15px; }
.rc-form .rc-h small { font-weight: 400; font-size: 13px; }
.rc-cheque { padding: 12px; border: 1px dashed var(--border); border-radius: 12px; margin: 8px 0; }
.rc-alloc input.alloc { width: 140px; }
.rc-warn { color: var(--bad); font-weight: 700; }
.data-table td.num.credit { color: var(--ok); }
.stmt-table tfoot td { font-weight: 700; background: var(--th); }
.sched-rows .fin-line { grid-template-columns: 160px 140px 1fr auto auto; }
.sched-tpl { flex-wrap: wrap; align-items: flex-end; gap: 8px; }
.sched-tpl .field { margin: 0; }
.rs-modes { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.rs-mode { display: flex; gap: 8px; align-items: flex-start; cursor: pointer; }
.data-table tr.inst-overdue td:first-child { box-shadow: inset -3px 0 0 var(--bad); }
.data-table tr.muted td { color: var(--muted); }
@media (max-width: 640px) {
  .sched-rows .fin-line { grid-template-columns: 1fr 1fr; }
  .rc-alloc input.alloc { width: 100%; }
}
@media print { .rc-cheque, .sched-tpl { display: none !important; } }

/* =====================================================================
   Madrasa+ UI slice 20 — سجل الشيكات (الواردة، المجيَّرة).
   Tokens only (works in dark mode). Spacing in steps of 4.
===================================================================== */
.chq-cards .chq-card { text-align: start; cursor: pointer; font: inherit; transition: border-color 200ms ease, box-shadow 200ms ease; }
.chq-cards .chq-card:hover { border-color: var(--accent-2); }
.chq-cards .chq-card.on { border-color: var(--accent-2); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent-2) 25%, transparent); }
.chq-cards .chq-card.bad .bill-card-v { color: var(--bad); }
.chq-cal { margin: 12px 0; }
.chq-cal summary { cursor: pointer; padding: 4px 0; }
.chq-cal table { margin-top: 8px; }
.chq-bar-cell { width: 45%; }
.chq-bar { height: 8px; border-radius: 4px; background: var(--th); overflow: hidden; }
.chq-bar span { display: block; height: 100%; background: var(--accent-2); }
.chq-table .chq-sub { display: block; color: var(--muted); font-size: 12px; margin-top: 4px; }
.chq-table td.chq-acts { white-space: nowrap; }
.chq-table td.chq-acts > * { margin-inline-end: 4px; vertical-align: middle; }
.chq-table tr.chq-bounced td:first-child + td { box-shadow: inset -3px 0 0 var(--bad); }
.chq-more { display: inline-block; position: relative; }
.chq-more summary { list-style: none; cursor: pointer; padding: 4px 12px; border: 1px solid var(--border); border-radius: 8px; color: var(--text); background: var(--card); }
.chq-more summary::-webkit-details-marker { display: none; }
/* opens inside the cell (not floating): table-wrap scrolls and would clip a floating menu */
.chq-more[open] { display: block; margin-top: 4px; }
.chq-more-menu { display: flex; flex-direction: column; gap: 4px; margin-top: 4px; min-width: 160px;
  padding: 8px; background: var(--card); border: 1px solid var(--border); border-radius: 12px; }
.chq-more-menu button { width: 100%; text-align: start; }
.chq-card-box .kv-table th { width: 32%; color: var(--muted); font-weight: 600; }
@media (max-width: 640px) {
  .chq-bar-cell { width: 30%; }
}
@media print { .chq-cal, .chq-more { display: none !important; } }

/* =====================================================================
   Madrasa+ UI slice 21 — الصندوق والخزنة (اليوم، الخزنة والتحويلات،
   العجز والزيادة، سجل الإقفالات). Tokens only (works in dark mode).
   Spacing in steps of 4.
===================================================================== */
.cash-tools { align-items: flex-end; gap: 8px; }
.cash-tools .field { margin: 0; }
.cash-cards .cash-big { grid-column: span 2; }
.cash-cards .cash-big .bill-card-v { font-size: 28px; }
.cash-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.cash-card-head h3 { margin: 0; }
.cash-hand { border-color: var(--gold); }
.cash-hand-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 0; border-top: 1px solid var(--border); }
.cash-hand-row:first-of-type { border-top: 0; }
.cash-hand-acts { display: inline-flex; gap: 8px; }
.cash-unclosed { border-color: var(--gold); }
.cash-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.cash-chip { font: inherit; padding: 4px 12px; border-radius: 16px; border: 1px solid var(--border); background: var(--field); color: var(--text); cursor: pointer;
  transition: border-color 200ms ease; }
.cash-chip:hover { border-color: var(--accent-2); }
.cash-chip.old { border-color: var(--bad); color: var(--bad); }
.cash-boxes td.cash-acts { white-space: nowrap; }
.cash-boxes td.cash-acts > * { margin-inline-end: 4px; }
.cash-denoms { display: grid; grid-template-columns: repeat(auto-fill, minmax(184px, 1fr)); gap: 8px; margin-bottom: 12px; }
.cash-dn { display: grid; grid-template-columns: 44px 1fr 56px; align-items: center; gap: 4px; }
.cash-denoms .cash-dn input.dn { width: 100%; min-width: 0; }
.cash-out .card > h3:first-child, .cash-card-head h3 { margin-top: 0; }
.cash-dn .dn-t { color: var(--muted); font-size: 12px; }
.cash-diff { display: inline-block; margin-top: 24px; font-weight: 700; }
.cash-diff.ok { color: var(--ok); }
.cash-diff.bad, .cash-neg { color: var(--bad); }
.cash-diff.warn, .cash-pos { color: var(--text); }
.cash-line { grid-template-columns: repeat(4, 1fr); align-items: end; }
.cash-go { display: flex; align-items: flex-end; }
.cash-opening summary { cursor: pointer; padding: 4px 0; }
.cash-opening .cash-line { margin-top: 12px; grid-template-columns: repeat(5, 1fr); }
.cash-sig { display: flex; justify-content: space-between; margin-top: 32px; }
@media (max-width: 640px) {
  .cash-cards .cash-big { grid-column: auto; }
  .cash-line, .cash-opening .cash-line { grid-template-columns: 1fr 1fr; }
  .cash-dn { grid-template-columns: 40px 1fr 56px; }
}
@media print { .cash-tools, .cash-form, .cash-hand-acts { display: none !important; } }

/* =====================================================================
   Madrasa+ UI slice 22 — البنك (كشف الحساب، المطابقة، سجل المطابقات،
   التحويلات غير المحددة، حسابات المدرسة). Tokens only (works in dark mode).
   Spacing in steps of 4.
===================================================================== */
.bank-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.bank-acts { display: inline-flex; gap: 8px; flex-wrap: wrap; }
.bank-cards .bank-card { font: inherit; color: var(--text); background: var(--card); border-radius: 12px; padding: 12px 16px; text-align: start; cursor: pointer; border: 1px solid var(--border);
  transition: border-color 200ms ease, box-shadow 200ms ease; }
.bank-cards .bank-card:hover { border-color: var(--accent-2); }
.bank-cards .bank-card.sel { border-color: var(--accent-2); box-shadow: 0 0 0 2px var(--accent-2) inset; }
.bank-cards .bank-card small { color: var(--muted); }
.bank-cards .bank-card small.bank-late { color: var(--bad); }
.bank-line { grid-template-columns: repeat(4, 1fr); align-items: end; }
.bank-in, .bank-outv { font-variant-numeric: tabular-nums; }
.bank-ok { color: var(--ok); font-weight: 700; }
.bank-of { display: block; }
.bank-open-row td { background: var(--th); }
.bank-recon-tools { gap: 8px; margin: 8px 0; }
.bank-calc { margin: 8px 0 12px; }
.bank-calc-table { border-collapse: collapse; max-width: 520px; width: 100%; }
.bank-calc-table td { padding: 4px 8px; border-bottom: 1px solid var(--border); }
.bank-diff.ok { color: var(--ok); }
.bank-diff.bad { color: var(--bad); }
.bank-help { margin-top: 8px; }
.bank-help ul { margin: 4px 0; padding-inline-start: 24px; }
.bank-save { justify-content: flex-start; }
.bank-row-acts { white-space: nowrap; }
.bank-row-acts > * { margin-inline-end: 4px; }
.bank-report h4 { margin: 16px 0 4px; }
@media (max-width: 640px) {
  .bank-line { grid-template-columns: 1fr 1fr; }
  .bank-acts { width: 100%; }
}
@media print { .bank-acts, .bank-form, .bank-recon-tools, .bank-save { display: none !important; } }

/* =====================================================================
   Madrasa+ UI slice 23 — المصروفات والموردون (السندات، الموردون، الشيكات
   الصادرة، التقرير، الفئات والسقوف). Tokens only (works in dark mode).
   Spacing in steps of 4.
===================================================================== */
.exp-link { font: inherit; background: none; border: 0; padding: 0; color: var(--accent-2); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.exp-link:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; border-radius: 4px; }
.exp-q { flex: 1 1 240px; }
.exp-q input { width: 100%; }
.exp-ask { margin: 0 0 8px; }
.exp-types { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 12px; }
.exp-type { font: inherit; color: var(--text); background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 12px; text-align: start;
  cursor: pointer; display: flex; flex-direction: column; gap: 4px; transition: border-color 200ms ease, box-shadow 200ms ease; }
.exp-type small { color: var(--muted); line-height: 1.5; }
.exp-type:hover { border-color: var(--accent-2); }
.exp-type.on { border-color: var(--accent-2); box-shadow: 0 0 0 2px var(--accent-2) inset; }
.exp-line { grid-template-columns: repeat(4, 1fr); align-items: end; }
.exp-hint:empty { display: none; }
.exp-hint { margin: 4px 0 8px; }
.exp-bud { display: grid; gap: 8px; margin-top: 8px; }
.exp-bud-r { display: grid; grid-template-columns: 160px 1fr auto; align-items: center; gap: 8px; }
.exp-bar { height: 8px; border-radius: 4px; background: var(--th); overflow: hidden; }
.exp-bar span { display: block; height: 100%; background: var(--accent-2); transition: width 200ms ease; }
.exp-bar.near span { background: var(--warn); }
.exp-bar.over span { background: var(--bad); }
.exp-budgets summary { cursor: pointer; padding: 4px 0; }
.exp-subs { display: block; }
.exp-sub { padding-inline-start: 24px; }
.exp-budget-in { width: 120px; }
.exp-up { color: var(--bad); }
.exp-down { color: var(--ok); }
.exp-doc table th { width: 32%; text-align: start; }
.exp-void { color: var(--bad); font-weight: 700; font-size: 20px; margin: 4px 0; }
.exp-sig { display: flex; justify-content: space-between; gap: 16px; margin-top: 32px; }
.exp-bankwarn { margin-bottom: 12px; }
@media (max-width: 640px) {
  .exp-types { grid-template-columns: 1fr 1fr; }
  .exp-line { grid-template-columns: 1fr 1fr; }
  .exp-bud-r { grid-template-columns: 1fr; gap: 4px; }
}
@media print { .exp-out .bill-filters { display: none !important; } .exp-sig { margin-top: 48px; } }

/* =====================================================================
   Madrasa+ UI slice 24 — التحصيل (طابور اليوم، السجل، الوعود، معاودة
   الاتصال، الأداء، التقرير الأسبوعي) ونموذج المكالمة. Tokens only (works
   in dark mode). Spacing in steps of 4.
===================================================================== */
.coll-target { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 16px; margin-bottom: 12px; }
.coll-bar { flex: 1 1 160px; max-width: 320px; }
.coll-tools { align-items: end; }
.coll-tools > small { flex: 1 1 240px; }
.coll-fam small { font-variant-numeric: tabular-nums; }
.coll-rate { font-size: 14px; }
.coll-why { color: var(--muted); max-width: 280px; }
.coll-tel { display: inline-block; padding: 4px 8px; border: 1px solid var(--border); border-radius: 8px; color: var(--text); text-decoration: none; white-space: nowrap; }
.coll-tel:hover { border-color: var(--accent-2); }
.coll-tel:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }
.coll-due, .coll-done { margin-top: 16px; }
.coll-done summary { cursor: pointer; padding: 4px 0; }
.coll-form { display: grid; gap: 8px; min-width: min(520px, 100%); }
.coll-session { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 12px;
  border-radius: 10px; background: var(--accent-soft); color: var(--text); }
.coll-who { font-size: 18px; }
.coll-bal { margin: 0; }
.coll-contact { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.coll-choices { display: flex; gap: 8px; flex-wrap: wrap; }
.coll-chip { border-radius: 999px; transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease; }
.coll-chip.on { background: var(--accent-2); border-color: var(--accent-2); color: var(--on-accent); }
.coll-promise { grid-template-columns: 1fr 1fr; }
.coll-cb { display: flex; gap: 8px; align-items: end; flex-wrap: wrap; }
.coll-hist ul { margin: 4px 0 0; padding-inline-start: 20px; color: var(--muted); }
.coll-hist summary { cursor: pointer; }
.coll-weekly h3 { margin-top: 0; }
.coll-weekly h3 + .bill-cards { margin-top: 8px; }
@media (max-width: 640px) {
  .coll-promise { grid-template-columns: 1fr; }
  .coll-why { max-width: none; }
}
@media print { .coll-out .bill-filters, .coll-target { display: none !important; } }

/* =====================================================================
   Madrasa+ UI slice 25 — «اليوم» الموحّد (بطاقات حسب الدور قابلة للتخصيص،
   يحتاج انتباهك اليوم) و«الاعتمادات» (بانتظار/السجل/الإحصاءات/التفويض،
   محضر الاعتماد). ألوان من المتغيّرات فقط حتى يعمل الوضع الليلي.
   ===================================================================== */
.today-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 8px; }
.today-head .hello { margin-bottom: 0; }
.today-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.today-cust-bar { display: flex; justify-content: flex-end; margin: 0 0 8px; }
.today-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(176px, 1fr)); gap: 12px; margin: 0 0 16px; }
.today-card { display: block; background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 16px;
  color: var(--text); text-decoration: none; box-shadow: var(--shadow); transition: border-color 150ms ease, transform 150ms ease; }
.today-card:hover { border-color: var(--accent-2); transform: translateY(-2px); }
.today-card:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }
.today-card-k { color: var(--muted); font-size: 13px; }
.today-card-v { font-size: 24px; font-weight: 700; margin: 4px 0; font-variant-numeric: tabular-nums; }
.today-card small { color: var(--muted); font-size: 12px; }
.today-card.hero { background: var(--accent-2); border-color: var(--accent-2); color: var(--on-accent); }
.today-card.hero .today-card-k, .today-card.hero small { color: var(--on-accent); }
.today-card.warn { border-inline-start: 4px solid var(--warn); }
.today-card.bad { border-inline-start: 4px solid var(--bad); }
.today-card.hero.warn, .today-card.hero.bad { border-inline-start-width: 1px; }
.today-att h3, .today-queue h3, .today-promises h3 { margin-top: 0; }
.today-att-list { display: grid; gap: 4px; }
.today-att-row { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 10px; color: var(--text); text-decoration: none;
  transition: background-color 150ms ease; }
.today-att-row:hover, .today-att-row:focus-visible { background: var(--th); outline: none; }
.today-att-row b { font-variant-numeric: tabular-nums; min-width: 24px; }
.today-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent-2); flex: none; }
.today-dot.warn { background: var(--warn); }
.today-dot.bad { background: var(--bad); }
.today-cust { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.today-cust h4 { margin: 8px 0 4px; }
.today-cust-check { display: flex; gap: 8px; align-items: center; margin: 4px 0; }
.today-cust-row { display: flex; gap: 8px; align-items: center; padding: 4px 0; }
.today-cust-row span { flex: 1; }
.apr-rejected { display: grid; gap: 4px; }
.apr-rej-row { font-size: 13px; }
.apr-filter-card { text-align: start; cursor: pointer; font: inherit; transition: border-color 150ms ease; }
.apr-filter-card.on { border-color: var(--accent-2); box-shadow: 0 0 0 1px var(--accent-2); }
.apr-click { cursor: pointer; }
.apr-click:hover td, .apr-click:focus-visible td { background: var(--th); }
.apr-table td small, .apr-log td small { color: var(--muted); }
.apr-minute-title { margin: 0 0 8px; font-size: 20px; }
.apr-kv th { width: 120px; background: var(--th); }
.apr-payload { margin: 8px 0; }
.apr-payload summary { cursor: pointer; }
.apr-sig { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-top: 32px; }
@media (max-width: 640px) {
  .today-cust { grid-template-columns: 1fr; }
  .today-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .today-card-v { font-size: 20px; }
}
@media print {
  .today-cust-bar, .today-actions { display: none !important; }
  .apr-sig { margin-top: 48px; }
}

/* ===================================================================
   Madrasa+ UI slice 26 — finance reports (#/fin-reports): report cards
   in groups with ★ favourites, filters, summary cards, SVG charts,
   bars and tables with totals. Tokens only (dark mode follows).
   =================================================================== */
.frep-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); gap: 12px; margin: 0 0 24px; }
.frep-card { display: flex; flex-direction: column; gap: 4px; padding: 12px 16px; background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; color: var(--text); text-decoration: none; transition: border-color 150ms ease, box-shadow 150ms ease; }
.frep-card:hover, .frep-card:focus-visible { border-color: var(--accent-2); box-shadow: 0 0 0 1px var(--accent-2); outline: none; }
.frep-card small { color: var(--muted); line-height: 1.6; }
.frep-card-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.frep-star { background: none; border: 0; padding: 0 4px; min-width: 32px; min-height: 32px; font-size: 20px; line-height: 1; color: var(--muted);
  cursor: pointer; transition: color 150ms ease; }
.frep-star.on, .frep-star:hover { color: var(--gold); }
.frep-star:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; border-radius: 8px; }
.frep-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 0 8px; }
.frep-nav .frep-star { font-size: 24px; }
.frep-title { margin: 8px 0 12px; }
.frep-check { flex-direction: row; align-items: center; gap: 8px; }
.frep-table td.num, .frep-table tfoot td { font-variant-numeric: tabular-nums; }
.frep-table tfoot td { font-weight: 700; background: var(--th); }
.frep-click { cursor: pointer; }
.frep-click:hover td, .frep-click:focus-visible td { background: var(--hover); }
.frep-click:focus-visible { outline: 2px solid var(--accent-2); outline-offset: -2px; }
.frep-pct { display: flex; align-items: center; gap: 8px; min-width: 112px; }
.frep-bar { flex: 1; min-width: 56px; height: 8px; border-radius: 4px; background: var(--th); overflow: hidden; }
.frep-bar span { display: block; height: 100%; background: var(--accent-2); transition: width 200ms ease; }
.frep-bar span.warn { background: var(--warn); }
.frep-bar span.bad { background: var(--bad); }
.frep-hbars { display: grid; gap: 8px; }
.frep-hbar { display: grid; grid-template-columns: 112px 1fr 96px; gap: 8px; align-items: center; font-size: 13px; }
.frep-hbar small { text-align: end; font-variant-numeric: tabular-nums; color: var(--muted); }
.frep-chart-box { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 12px 16px; margin: 0 0 16px; }
.frep-chart { width: 100%; height: 136px; display: block; }
.frep-s1 { fill: var(--muted); opacity: .45; }
.frep-s2 { fill: var(--accent-2); }
.frep-s3 { stroke: var(--warn); stroke-width: 1.5; fill: none; }
.frep-legend { display: flex; flex-wrap: wrap; gap: 16px; margin: 8px 0 0; }
.frep-legend span { display: inline-flex; align-items: center; gap: 4px; }
.frep-key { display: inline-block; width: 12px; height: 12px; border-radius: 2px; }
.frep-key.frep-s1 { background: var(--muted); opacity: .45; }
.frep-key.frep-s2 { background: var(--accent-2); }
.frep-key.frep-s3 { background: var(--warn); height: 3px; }
.frep-neg { color: var(--bad); }
.frep-pos { color: var(--good); }
.frep-forecast td { color: var(--muted); font-style: italic; }
.frep-two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.frep-two h3 { margin-top: 0; }
.frep-filter-card { text-align: start; cursor: pointer; font: inherit; color: var(--text); transition: border-color 150ms ease; }
.frep-filter-card.on { border-color: var(--accent-2); box-shadow: 0 0 0 1px var(--accent-2); }
.frep-ok { font-size: 18px; color: var(--good); margin: 8px 0; }
.frep-settings { margin-top: 8px; }
.frep-settings summary { cursor: pointer; }
.frep-settings-body { display: grid; gap: 12px; max-width: 560px; margin-top: 12px; }
.frep-pack-list { margin: 0 0 12px; padding-inline-start: 24px; line-height: 1.8; }
@media (max-width: 640px) {
  .frep-two { grid-template-columns: 1fr; }
  .frep-grid { grid-template-columns: 1fr; }
  .frep-hbar { grid-template-columns: 80px 1fr 72px; }
}
@media print {
  .frep-chart-box { break-inside: avoid; border-color: var(--border); }
  .frep-two { grid-template-columns: 1fr 1fr; }
  .frep-click { cursor: default; }
}

/* ===== Madrasa+ UI slice 26b: accounting (#/accounting) ===== */
.acc-cards .bill-card-v { font-size: 18px; }
.acc-lines { display: flex; flex-direction: column; gap: 2px; }
.acc-lines .acc-dr { color: var(--text); }
.acc-lines .acc-cr { color: var(--muted); padding-inline-start: 16px; }
.acc-reversed td { color: var(--muted); text-decoration: line-through; }
.acc-reversed td:last-child, .acc-reversed td .acc-lines { text-decoration: none; }
.acc-je-lines { display: flex; flex-direction: column; gap: 8px; margin: 8px 0; }
.acc-je-line { display: grid; grid-template-columns: minmax(0, 1fr) 112px 112px auto; gap: 8px; align-items: center; }
.acc-je-line > select, .acc-je-line > input { min-width: 0; width: 100%; box-sizing: border-box; }
.acc-warn { font-weight: 600; color: var(--good); }
.acc-warn.bad { color: var(--bad); }
.acc-checklist { list-style: none; padding: 0; margin: 8px 0; display: flex; flex-direction: column; gap: 4px; }
.acc-checklist .acc-ok { color: var(--good); }
.acc-checklist .acc-bad { color: var(--bad); font-weight: 600; }
.acc-statements { display: flex; flex-direction: column; gap: 16px; }
.acc-stmt .acc-total td { font-weight: 700; border-top: 1px solid var(--border); }
.acc-sign { display: none; }
.acc-group > summary { cursor: pointer; padding: 4px 0; }
@media (max-width: 640px) {
  .acc-je-line { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; }
  .acc-je-line select { grid-column: 1 / -1; }
}
@media print {
  #printArea .acc-sheet { break-inside: avoid; box-shadow: none; border: 1px solid var(--border); margin-bottom: 12px; }
  #printArea .acc-stmt td, #printArea .acc-stmt th { color: black; }
  #printArea .acc-sign { display: flex; justify-content: space-between; margin-top: 32px; font-size: 14px; }
}

/* ===== Madrasa+ UI slice 27: finance settings (#/fin-settings) ===== */
.fset-steps { list-style: none; display: flex; gap: 8px; padding: 0; margin: 0 0 16px; flex-wrap: wrap; }
.fset-step { display: flex; align-items: center; gap: 8px; padding: 8px 16px; border-radius: 999px; background: var(--card);
  border: 1px solid var(--border); color: var(--muted); transition: background 200ms ease, color 200ms ease; }
.fset-step-n { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 50%;
  background: var(--hover); color: var(--text); font-weight: 700; font-size: 13px; }
.fset-step.active { border-color: var(--accent-2); color: var(--text); font-weight: 600; }
.fset-step.active .fset-step-n { background: var(--accent-2); color: var(--card); }
.fset-step.done { color: var(--good); }
.fset-preview, .fset-result { display: flex; flex-direction: column; gap: 16px; }
.fset-problem { border-inline-start: 4px solid var(--bad); }
.fset-ok { border-inline-start: 4px solid var(--good); }
.fset-warn ul { margin: 0; padding-inline-start: 24px; line-height: 1.8; }
.fset-bad td { color: var(--bad); font-weight: 600; }
.fset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px 16px; margin-bottom: 8px; }
.fset-calls h4 { margin: 16px 0 8px; }
.fset-calls textarea { width: 100%; box-sizing: border-box; }
.fset-switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.fset-limits input { width: 128px; }
@media (max-width: 640px) {
  .fset-steps { flex-direction: column; }
  .fset-grid { grid-template-columns: 1fr; }
  .fset-limits input { width: 96px; }
}

/* ===== Madrasa+ UI slice 28: paper documents, phone layout, accessibility ===== */
/* Paper documents (finDocPaper / statementPaper / schedulePaper) are built for
   A4 paper: black on white, real borders, no shadows or theme colours, so they
   print the same in light and dark mode. Shown only inside #printArea. */
#printArea .paper-doc { font-family: "IBM Plex Sans Arabic", Tahoma, Arial, sans-serif; color: black; background: white;
  font-size: 12pt; line-height: 1.5; max-width: 182mm; margin: 0 auto; }
#printArea .paper-doc + .paper-doc { break-before: page; }
#printArea .paper-head { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px 16px; align-items: center;
  border-bottom: 2px solid black; padding-bottom: 8px; margin-bottom: 12px; }
#printArea .paper-org-name { font-size: 15pt; font-weight: 700; }
#printArea .paper-org-en { font-size: 10pt; direction: ltr; text-align: right; }
#printArea .paper-logo img { max-height: 64px; max-width: 120px; display: block; margin: 0 auto; }
#printArea .paper-org-left { text-align: left; font-size: 10pt; }
#printArea .paper-title { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; }
#printArea .paper-title h1 { font-size: 18pt; margin: 0; padding: 4px 16px; border: 2px solid black; border-radius: 4px; }
#printArea .paper-info { display: flex; flex-wrap: wrap; gap: 4px 16px; justify-content: flex-end; }
#printArea .paper-meta { display: flex; flex-wrap: wrap; gap: 4px 24px; margin: 8px 0; }
#printArea .paper-k { color: rgb(51 51 51); }
#printArea .paper-table { width: 100%; border-collapse: collapse; margin: 12px 0; font-size: 11pt; }
#printArea .paper-table th, #printArea .paper-table td { border: 1px solid rgb(85 85 85); padding: 4px 8px; text-align: start; color: black; background: white; }
#printArea .paper-table thead th { background: rgb(238 238 238); -webkit-print-color-adjust: exact; print-color-adjust: exact; }
#printArea .paper-table thead { display: table-header-group; }
#printArea .paper-table tfoot { display: table-row-group; }
#printArea .paper-table tr { break-inside: avoid; }
#printArea .paper-table .num { direction: ltr; text-align: left; font-variant-numeric: tabular-nums; white-space: nowrap; }
#printArea .paper-words { border: 1px dashed rgb(85 85 85); padding: 8px 12px; margin: 8px 0; }
#printArea .paper-note { margin: 8px 0; }
#printArea .paper-muted { color: rgb(68 68 68); font-size: 10pt; margin: 8px 0; }
#printArea .paper-stamp { display: inline-block; color: black; font-size: 18pt; font-weight: 700; border: 3px double black;
  padding: 4px 16px; transform: rotate(-6deg); margin: 4px 0 8px; }
#printArea .paper-void .paper-table td { text-decoration: line-through; }
#printArea .paper-sign { display: flex; justify-content: space-between; gap: 24px; margin-top: 40px; break-inside: avoid; }
#printArea .paper-sign > div { flex: 1; text-align: center; }
#printArea .paper-sign-line { border-bottom: 1px dotted black; height: 32px; margin-bottom: 4px; }
#printArea .paper-foot { margin-top: 24px; border-top: 1px solid rgb(153 153 153); padding-top: 4px; font-size: 9pt; color: rgb(68 68 68); }
@media print {
  /* Anything outside #printArea (sidebar, open modals, toasts) stays off paper. */
  body.list-printing > :not(#printArea) { display: none !important; }
  body.paper-printing, body.paper-printing #printArea { background: white !important; color: black !important; }
  body.paper-printing #printArea { padding: 0; }
}

/* Contrast fixes found by the slice-28 browser check (text ≥ 4.5:1). */
:root:not([data-theme="dark"]) .badge-orange { color: rgb(138 95 0); }
.reports-nav-item.active { color: var(--on-accent); }

/* Accessibility: a visible keyboard focus ring everywhere (contrast ≥ 3:1 on
   both themes), screen-reader-only text, and no motion for people who ask
   their device for less. */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 3px solid var(--accent-2); outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; top: -48px; inset-inline-start: 8px; z-index: 1000; background: var(--card); color: var(--text);
  padding: 8px 16px; border-radius: 8px; border: 2px solid var(--accent-2); transition: top 150ms ease; }
.skip-link:focus { top: 8px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01s !important; animation-iteration-count: 1 !important;
    transition-duration: 0.01s !important; scroll-behavior: auto !important; }
}

/* Phone layout: no sideways page scroll — wide tables scroll inside their
   own box, toolbars and card rows wrap, modals use the full width, and touch
   targets are at least 40px tall. */
@media (max-width: 640px) {
  html, body { overflow-x: hidden; }
  #view { padding-inline: 16px; }
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
  .toolbar { flex-wrap: wrap; gap: 8px; }
  .toolbar > * { max-width: 100%; }
  .toolbar input, .toolbar select { min-width: 0; max-width: 100%; }
  .bill-cards, .summary-chips { flex-wrap: wrap; }
  .modal-backdrop { padding: 8px; align-items: flex-end; }
  .modal-box, .modal-box.modal-wide { width: 100%; max-width: 100%; max-height: calc(100dvh - 16px); border-radius: 16px 16px 8px 8px; }
  .modal-body { overflow-x: hidden; }
  .modal-actions { flex-wrap: wrap; }
  .modal-actions > button { flex: 1 1 auto; }
  button, select, input:not([type="checkbox"]):not([type="radio"]) { min-height: 40px; }
  .fin-line { flex-wrap: wrap; }
  .fin-line > * { min-width: 0; }
  .tabs { overflow-x: auto; flex-wrap: nowrap; scrollbar-width: thin; }
  .tabs .tab-btn { flex: 0 0 auto; }
  /* numbers, dates and doc numbers stay on one line; the table scrolls in its box */
  .table-wrap th, .table-wrap td.num, .table-wrap td:first-child, .table-wrap td:nth-child(2) { white-space: nowrap; }
}

/* =====================================================================
   Madrasa+ UI slice 29 — الموظفون (القائمة ببطاقات وفلاتر، ملف الموظف بتبويبات).
   Tokens only (works in dark mode). Spacing in steps of 4.
===================================================================== */
.emp-toolbar .emp-search { min-width: 200px; flex: 1; }
.emp-view-toggle { display: inline-flex; gap: 4px; }
.emp-view-toggle button.on { border-color: var(--accent-2); color: var(--accent-2); font-weight: 700; }
.emp-cards .chq-card { text-align: start; cursor: pointer; font: inherit; transition: border-color 200ms ease, box-shadow 200ms ease; }
.emp-cards .chq-card:hover { border-color: var(--accent-2); }
.emp-cards .chq-card.on { border-color: var(--accent-2); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent-2) 25%, transparent); }
.emp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(256px, 1fr)); gap: 12px; }
.emp-card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 16px;
  display: flex; flex-direction: column; gap: 12px; transition: border-color 200ms ease, box-shadow 200ms ease; }
.emp-card:hover { border-color: var(--accent-2); }
.emp-card-head { display: flex; align-items: center; gap: 12px; }
.emp-card-name { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 0; }
.emp-card-name a { font-weight: 700; font-size: 16px; overflow-wrap: anywhere; }
.emp-card-name small { color: var(--muted); font-size: 13px; }
.emp-card-kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0; font-size: 14px; }
.emp-card-kv dt { color: var(--muted); }
.emp-card-kv dd { margin: 0; color: var(--text); font-variant-numeric: tabular-nums; }
.emp-card-acts { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: auto; }
.emp-avatar { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 40px; height: 40px;
  border-radius: 50%; font-weight: 700; font-size: 16px; color: var(--accent-2);
  background: color-mix(in srgb, var(--accent-2) 14%, var(--card)); }
.emp-avatar.big { width: 56px; height: 56px; font-size: 20px; }
.emp-row-acts { white-space: nowrap; }
.emp-head-top { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; }
.emp-head-main { min-width: 0; }
.emp-head .employee-title { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.emp-head .employee-title .page-title { margin: 0; }
.emp-head .header-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start; }
.emp-sum { margin-bottom: 16px; }
.emp-more summary { padding: 8px 12px; }
.emp-more[open] { display: inline-block; }
.emp-tabs { overflow-x: auto; flex-wrap: nowrap; }
.emp-tabs .tab-btn { white-space: nowrap; }
.emp-doc-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(208px, 1fr)); gap: 12px; margin: 12px 0; }
.emp-doc-tile { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 16px; width: 100%;
  text-align: start; background: var(--card); border: 1px solid var(--border); border-radius: 12px; cursor: pointer; font: inherit;
  color: var(--text); transition: border-color 200ms ease; }
.emp-doc-tile:hover { border-color: var(--accent-2); }
.emp-doc-tile b { font-size: 15px; }
.emp-doc-tile small { color: var(--muted); font-size: 13px; }
.emp-doc-tile-wrap { display: flex; flex-direction: column; gap: 8px; }
@media (max-width: 640px) {
  .emp-grid { grid-template-columns: 1fr; }
  .emp-head-top { gap: 12px; }
  .emp-toolbar .emp-search { min-width: 0; width: 100%; }
}
@media print { .emp-view-toggle, .emp-cards, .emp-card-acts, .emp-more { display: none !important; } }

/* =====================================================================
   Madrasa+ UI slice 30 — الحضور (تبويبات في الرابط، بطاقات ملخّص، بحث وفلاتر،
   صور التسجيل في نافذة). Tokens only (works in dark mode). Spacing in steps of 4.
===================================================================== */
.att-tabs { overflow-x: auto; flex-wrap: nowrap; }
.att-tabs .tab-btn { white-space: nowrap; text-decoration: none; }
.att-out { display: flex; flex-direction: column; gap: 12px; }
.att-toolbar .att-search { min-width: 180px; flex: 1; }
.att-week-label { color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }
.att-cards .chq-card { text-align: start; cursor: pointer; font: inherit; transition: border-color 200ms ease, box-shadow 200ms ease; }
.att-cards .chq-card:hover { border-color: var(--accent-2); }
.att-cards .chq-card.on { border-color: var(--accent-2); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent-2) 25%, transparent); }
.att-out .pending-bar { margin-bottom: 0; }
.att-out .pending-item { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 0;
  border-top: 1px solid var(--border); }
.att-out .pending-item-name { flex: 1; min-width: 160px; }
.checkin-photos { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.checkin-photo { margin: 0; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.checkin-photo img { max-width: 100%; max-height: 60vh; border-radius: 12px; border: 1px solid var(--border); }
.checkin-photo figcaption { color: var(--muted); font-size: 14px; }
@media (max-width: 640px) {
  .att-toolbar .att-search { min-width: 0; width: 100%; }
  .att-out .pending-item-name { min-width: 0; width: 100%; }
}
@media print { .att-tabs, .att-cards, .att-toolbar { display: none !important; } }

/* =====================================================================
   Madrasa+ UI slice 31 — الإجازات (تبويبات في الرابط، بطاقات تصفّي، بحث وفلاتر،
   الإضافة والتعديل في نافذة، التقويم والأجندة). Tokens only (works in dark mode).
===================================================================== */
.lv-out .link-btn { background: none; border: 0; padding: 0; color: var(--accent-2); font: inherit; cursor: pointer;
  text-align: start; text-decoration: underline; text-underline-offset: 4px; }
.lv-out .link-btn:hover { color: var(--accent); }
.lv-note { color: var(--muted); max-width: 240px; }
.lv-past td { color: var(--muted); }
.lv-bal-btn { background: none; border: 1px solid transparent; border-radius: 8px; padding: 4px 8px; font: inherit;
  color: inherit; cursor: pointer; text-align: start; transition: border-color 200ms ease, background-color 200ms ease; }
.lv-bal-btn:hover, .lv-bal-btn:focus-visible { border-color: var(--accent-2); }
.lv-form { display: flex; flex-direction: column; gap: 12px; }
@media (max-width: 640px) {
  .lv-note { max-width: none; }
}
@media print { .lv-tabs, .lv-cards, .lv-toolbar { display: none !important; } }

/* =====================================================================
   Madrasa+ UI slice 32 — الرواتب (تبويبات في الرابط: كشف الشهر، كل الكشوف،
   صرف الرواتب؛ بطاقات تصفّي، بحث، زر أساسي واحد حسب الحالة، الصرف من المالية
   في نافذة). Tokens only (works in dark mode).
===================================================================== */
.pay-out .link-btn { background: none; border: 0; padding: 0; color: var(--accent-2); font: inherit; cursor: pointer;
  text-align: start; text-decoration: underline; text-underline-offset: 4px; }
.pay-out .link-btn:hover { color: var(--accent); }
.pay-month select { min-width: 96px; }
.pay-status .bill-card-v .badge { font-size: 14px; }
.pay-count { margin-inline-start: 4px; }
.pay-out .form-error, .pay-out .late-settlement-banner { margin: 8px 0; }
.payroll-table tbody tr.hidden { display: none; }
.pay-fin .table-wrap { max-height: 320px; overflow: auto; }
.pay-fin-total { font-weight: 600; }
.pay-voucher { display: flex; flex-direction: column; gap: 12px; }
.pay-voucher .fin-line { display: flex; flex-wrap: wrap; gap: 16px; }
@media (max-width: 640px) {
  .pay-month { flex-wrap: nowrap; }
  .pay-month select { min-width: 0; flex: 1 1 auto; }
}
@media print { .pay-tabs, .pay-cards, .pay-toolbar, .pay-month { display: none !important; } }

/* =====================================================================
   Madrasa+ UI slice 33 — السلف (سجل/حساب المالية/طلبات)، المخالفات والمكافآت
   (مستويات التصعيد)، المخالصات: بطاقات تصفّي، بحث، زر أساسي واحد لكل تبويب،
   النماذج في نافذة. Tokens only (works in dark mode).
===================================================================== */
.adv-out .row-actions, .disc-out .row-actions, .clr-table .row-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.adv-note { margin: 8px 0; }
.adv-count { margin-inline-start: 4px; }
.adv-table tfoot th { background: var(--th); }
.adv-statement { display: flex; flex-direction: column; gap: 12px; }
.adv-statement .muted-row td { color: var(--muted); text-decoration: line-through; }
.adv-move .fin-line { display: flex; flex-wrap: wrap; gap: 16px; }
.disc-hint { margin: 0; }
.disc-steps { display: inline-flex; gap: 4px; direction: rtl; }
.disc-step { width: 16px; height: 8px; border-radius: 4px; background: var(--hover); border: 1px solid var(--border, var(--th));
  transition: background-color 200ms ease; }
.disc-step.on { background: var(--accent-2); }
.disc-step.on.l4, .disc-step.on.l5 { background: var(--danger, var(--gold)); }
.clr-bar { display: block; height: 4px; margin-top: 4px; border-radius: 4px; background: var(--hover); overflow: hidden; }
.clr-bar > span { display: block; height: 100%; background: var(--accent-2); transition: width 250ms ease; }
@media (max-width: 640px) {
  .adv-move .fin-line { flex-direction: column; gap: 8px; }
  .disc-step { width: 12px; }
}
@media print {
  .adv-tabs, .adv-cards, .adv-toolbar, .disc-tabs, .disc-cards, .disc-toolbar, .clr-cards, .clr-toolbar { display: none !important; }
  .clr-bar { display: none; }
}

/* =====================================================================
   Madrasa+ UI slice 34 — المتقدمون (بنك المتقدمين/مسار التوظيف) والمستندات
   (مستندات موظف، السندات، سجل السندات، النماذج والترويسة) + خيار «ورق مروَّس»
   للكتب المطبوعة. Tokens only (works in dark mode).
===================================================================== */
.apl-out .row-actions, .doc-out .row-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.apl-note { margin: 8px 0; }
.apl-board-host { overflow-x: auto; }
.apl-board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(208px, 1fr); gap: 12px; padding-bottom: 8px; }
.apl-col { background: var(--hover); border-radius: 12px; padding: 8px; display: flex; flex-direction: column; gap: 8px; min-height: 120px; }
.apl-col-title { display: flex; justify-content: space-between; align-items: center; margin: 0; font-size: 14px; }
.apl-col-n { font-weight: 700; color: var(--muted); }
.apl-empty { margin: 0; text-align: center; }
.apl-card { background: var(--card); border: 1px solid var(--border, var(--th)); border-radius: 8px; padding: 8px;
  display: flex; flex-direction: column; gap: 4px; transition: box-shadow 200ms ease; }
.apl-card:hover { box-shadow: var(--shadow); }
.apl-card small { color: var(--muted); }
.apl-card-open { background: none; border: 0; padding: 0; text-align: start; font-weight: 700; color: var(--accent-2); cursor: pointer; font-size: 15px; }
.apl-card-open:hover { text-decoration: underline; }
.apl-move { font-size: 13px; }
.doc-emp-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin: 8px 0 16px; }
.doc-emp-head:empty { display: none; }
.doc-emp-head > div { display: flex; flex-direction: column; }
.doc-emp-head small { color: var(--muted); }
.doc-emp-avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-weight: 700;
  background: var(--accent-2); color: var(--card); }
.doc-emp-file { margin-inline-start: auto; }
.doc-tiles, .doc-tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.doc-tile { background: var(--card); border: 1px solid var(--border, var(--th)); border-radius: 12px; padding: 16px;
  display: flex; flex-direction: column; gap: 8px; transition: box-shadow 200ms ease; }
.doc-tile:hover { box-shadow: var(--shadow); }
.doc-tile small { color: var(--muted); }
.doc-tile-t { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; }
.doc-tile-i { font-size: 20px; }
.doc-tile-go { margin-top: auto; align-self: flex-start; }
.doc-warnings { display: flex; flex-direction: column; gap: 4px; }
.doc-tpl { display: flex; flex-direction: column; gap: 8px; margin: 0; }
.doc-tpl-preview { white-space: pre-wrap; color: var(--muted); font-size: 13px; max-height: 96px; overflow: hidden; }
.doc-ph { display: flex; flex-wrap: wrap; gap: 4px; }
.doc-ph code, .doc-ph button { unicode-bidi: isolate; }
.doc-ph code { background: var(--hover); border-radius: 4px; padding: 0 4px; font-size: 12px; }
.doc-tpl-area { min-height: 240px; line-height: 1.8; }
.doc-letterhead { margin-bottom: 16px; }
.doc-table tfoot th { background: var(--th); }
.doc-lh-toggle { margin-inline-start: 8px; }
.print-page .letter-lh { height: 7cm; margin: -32px -32px 16px; border-bottom: 1px dashed var(--border, var(--th)); overflow: hidden; }
.print-page .letter-lh img { width: 100%; height: 100%; object-fit: contain; }
.print-page.on-letterhead .payslip-header { display: none; }
@media (max-width: 640px) {
  .apl-board { grid-auto-flow: row; grid-auto-columns: auto; }
  .doc-tiles, .doc-tpl-grid { grid-template-columns: 1fr; }
  .doc-emp-file { margin-inline-start: 0; }
  .print-page .letter-lh { margin: -32px -32px 16px; height: 4cm; }
}
@media print {
  .apl-tabs, .apl-cards, .apl-toolbar, .apl-note, .doc-tabs, .doc-cards, .doc-toolbar, .apl-move { display: none !important; }
  .apl-board { grid-auto-flow: row; }
  .print-page .letter-lh { height: 7cm; margin: -32px -32px 16px; border: 0; }
}

/* =====================================================================
   Madrasa+ UI slice 35 — التقارير (بطاقات + تقرير لكل رابط)، الإعدادات
   (تبويبات في الرابط)، المستخدمون والصلاحيات، النسخ الاحتياطي، سجل النشاط
   ===================================================================== */
.rep-toolbar { margin-bottom: 8px; }
.rep-card { text-decoration: none; color: var(--text); transition: box-shadow 200ms ease, border-color 200ms ease; }
.rep-nav-r { display: flex; align-items: center; gap: 8px; }
.rep-pick { min-width: 200px; }
.rep-desc { margin: 0 0 8px; }
.set-out { display: flex; flex-direction: column; gap: 16px; }
.set-out > .card { margin: 0; }
.usr-card .bank-head, .bak-card .bank-head { margin-bottom: 8px; }
.usr-who { display: inline-flex; align-items: center; gap: 8px; }
.usr-who > span:last-child { display: flex; flex-direction: column; }
.usr-who small { font-size: 12px; unicode-bidi: isolate; }
.usr-av { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 50%;
  background: var(--hover); color: var(--accent-2); font-weight: 700; font-size: 13px; flex: none; }
.usr-perms { color: var(--muted); font-size: 13px; }
.usr-pass { display: flex; gap: 8px; align-items: center; }
.usr-pass input { flex: 1; min-width: 0; font-family: ui-monospace, monospace; unicode-bidi: isolate; }
.usr-form { display: flex; flex-direction: column; gap: 8px; }
.row-actions { white-space: nowrap; }
.row-actions > * + * { margin-inline-start: 4px; }
.bak-file { color: var(--muted); font-size: 12px; unicode-bidi: isolate; direction: ltr; text-align: end; }
.aud-time { white-space: nowrap; }
.aud-action { color: var(--muted); font-size: 12px; unicode-bidi: isolate; }
.aud-details-cell { max-width: 420px; }
.aud-entry { display: flex; flex-direction: column; gap: 8px; }
.aud-kv b { unicode-bidi: plaintext; }
.aud-kv { display: flex; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--border); padding: 4px 0; }
.aud-details { white-space: pre-wrap; line-height: 1.8; margin: 8px 0 0; }
/* the danger hover stays a darker red, written as the token + a filter so its computed colour is plain rgb
   (a color-mix() value is not readable by the contrast check while the pointer rests on it) */
button.danger:hover { background: var(--bad); border-color: var(--bad); filter: brightness(0.88); }
@media (max-width: 640px) {
  .rep-nav { flex-direction: column; align-items: stretch; }
  .rep-nav-r { justify-content: space-between; }
  .rep-pick { min-width: 0; flex: 1; }
  .row-actions { white-space: normal; }
  .row-actions > * { margin: 2px; }
  .aud-details-cell { max-width: none; }
}
@media print {
  .set-tabs, .usr-cards, .usr-toolbar, .bak-cards, .aud-cards, .aud-toolbar, .rep-nav { display: none !important; }
}
/* ==========================================================================
   Madrasa+ UI slice 37 — المصروفات المتكررة (تبويب «🔁 المتكررة» في المصروفات،
   بطاقات تصفّي، شريط «مستحقة هذا الشهر» في السندات). ألوان المتغيّرات فقط.
   ========================================================================== */
.rec-cards { margin-bottom: 16px; }
.rec-card { all: unset; display: block; cursor: pointer; border-radius: 12px; transition: box-shadow 200ms ease, transform 200ms ease; }
.rec-card:focus-visible { outline: 3px solid var(--accent-2); outline-offset: 2px; }
.rec-card:hover .bill-card { border-color: var(--accent-2); }
.rec-card.on .bill-card { border-color: var(--accent-2); box-shadow: 0 0 0 2px var(--accent-2) inset; }
.rec-due { margin-bottom: 16px; border-inline-start: 4px solid var(--gold); }
.rec-due-list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.rec-due-list li { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 0; border-bottom: 1px solid var(--border); }
.rec-due-list li:last-child { border-bottom: 0; }
.rec-acts { white-space: nowrap; }
.rec-acts > button { margin-inline-start: 4px; }
.rec-table td .badge { white-space: normal; }
@media (prefers-reduced-motion: reduce) { .rec-card { transition: none; } }
@media (max-width: 640px) {
  .rec-acts { white-space: normal; }
  .rec-acts > button { margin: 2px; }
}
@media print {
  .rec-cards, .rec-due { display: none !important; }
}

/* ==========================================================================
   Madrasa+ UI slice 38 — طلبات الشراء (صفحة #/purchases، تبويب «🛒 طلبات الشراء»
   في المصروفات، بطاقة القرار في «الاعتمادات»). ألوان المتغيّرات فقط.
   ========================================================================== */
.apr-purchases { margin-top: 16px; border-inline-start: 4px solid var(--gold); }
.pur-table td .badge { white-space: normal; }
.pur-table .row-actions > button, .apr-purchases .row-actions > button { margin-inline-start: 4px; }
.pur-table .row-actions { white-space: nowrap; }
@media (max-width: 640px) {
  .pur-table .row-actions { white-space: normal; }
  .pur-table .row-actions > button, .apr-purchases .row-actions > button { margin: 2px; }
}
@media print {
  .apr-purchases { display: none !important; }
}

/* ==========================================================================
   Madrasa+ UI slice 39 — قوالب واتساب ونصوص المكالمة (الإعدادات المالية ← «الرسائل
   ونصوص المكالمة»، و«📝 ماذا أقول؟» ونافذة اختيار القالب في نموذج المكالمة).
   ألوان المتغيّرات فقط.
   ========================================================================== */
.coll-script { margin: 8px 0; padding: 8px 12px; border-radius: 10px; border-inline-start: 4px solid var(--accent-2); background: var(--accent-soft); }
.coll-script summary { cursor: pointer; font-weight: 600; }
.coll-script p { margin: 8px 0 0; line-height: 1.7; }
.coll-wa textarea, .fset-messages textarea { width: 100%; box-sizing: border-box; line-height: 1.6; }
.coll-wa-tpls { margin-bottom: 8px; }
.fset-wa-list { display: grid; gap: 8px; margin: 8px 0; }
.fset-wa-row { padding: 12px; }
.fset-wa-head { display: flex; gap: 8px; align-items: flex-end; }
.fset-wa-head > label { flex: 1; }
.fset-wa-preview { margin-top: 4px; font-size: 0.9em; line-height: 1.6; white-space: pre-wrap; }
.fset-wa-ph { margin: 8px 0; }
.fset-scripts { display: grid; gap: 8px; margin: 8px 0; }
@media print {
  .fset-wa-ph, [data-act="wa-remove"], [data-act="wa-add"] { display: none !important; }
}

/* ==========================================================================
   Madrasa+ slice 43 — صفحة «لا تملك صلاحية» (حارس المسارات). ألوان المتغيّرات فقط.
   ========================================================================== */
.no-access { max-width: 520px; margin: 48px auto; padding: 32px 24px; text-align: center; }
.no-access .page-title { justify-content: center; margin: 8px 0; }
.no-access p { margin: 8px 0; line-height: 1.7; }
.no-access .no-access-icon { color: var(--muted); }
.no-access button { margin-top: 16px; }

/* ---- Madrasa+ slice 47b: named letterheads («الكليشات») ---- */
.lh-section .lh-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.lh-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; margin: 16px 0; }
.lh-card { border: 1px solid var(--border); border-radius: 12px; padding: 12px; background: var(--card); display: flex; flex-direction: column; gap: 8px; }
.lh-card.is-default { border-color: var(--accent-2); }
.lh-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.lh-card .lh-preview img { display: block; width: 100%; aspect-ratio: 3 / 1; object-fit: contain; background: white; border-radius: 8px; }
.lh-card .lh-file { display: none; }
.lh-card .lh-acts { flex-wrap: wrap; gap: 8px; margin: 0; }
.lh-assign select { min-width: 180px; }
.lh-pick { display: flex; flex-direction: column; gap: 12px; min-width: min(360px, 100%); }
.doc-lh-wrap { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.lh-select { max-width: 220px; }
#printArea .paper-head.with-lh .paper-org, #printArea .paper-head.with-lh .paper-logo,
#printArea .paper-head.with-lh .paper-org-left { display: none; }
#printArea .paper-lh { grid-column: 1 / -1; }
#printArea .paper-lh img { display: block; width: 100%; height: auto; max-height: 60mm; object-fit: contain; }
@media (max-width: 640px) {
  .lh-grid { grid-template-columns: 1fr; }
  .lh-select, .lh-assign select { max-width: 100%; min-width: 0; width: 100%; }
}

/* ---- Madrasa+ slice 48: one hub for reports and settings — the Finance / Staff switch ---- */
.hub-switch { display: inline-flex; gap: 4px; padding: 4px; margin: 0 0 16px; border: 1px solid var(--border);
  border-radius: 12px; background: var(--card); flex-wrap: wrap; }
.hub-switch .hub-link { padding: 8px 16px; border-radius: 8px; color: var(--text); text-decoration: none; font-weight: 600;
  transition: background var(--motion), color var(--motion); }
.hub-switch .hub-link:hover { background: var(--hover); }
.hub-switch .hub-link.active { background: var(--accent); color: var(--on-accent); }
.today-staff { margin-top: 16px; }
.today-staff > .toolbar { margin: 8px 0 16px; }
@media (max-width: 640px) {
  .hub-switch { display: flex; }
  .hub-switch .hub-link { flex: 1 1 0; text-align: center; }
}

/* ===================================================================
   Madrasa+ UI slice 49 — financial reports 22 → 10 (Madrasa+ mode).
   A merged report: its name beside «← كل التقارير», a «عرض حسب» tab row,
   and on the home card the list of its views. Tokens only.
   =================================================================== */
.frep-rep-name { flex: 1 1 auto; font-size: 16px; }
.frep-viewby { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; }
.frep-viewby .tabs { margin: 0; }
.frep-card .frep-views { color: var(--muted); font-size: 12px; font-weight: 600; transition: color 200ms ease; }
@media (max-width: 640px) {
  .frep-viewby { align-items: stretch; flex-direction: column; gap: 4px; }
  .frep-viewby .tabs { overflow-x: auto; flex-wrap: nowrap; }
}

/* ===== UI slice 50 (owner decision 19): numbers and dates ===== */
/* Numeric cells sit under their header: in RTL both start at the right edge,
   so units line up and an amount never drifts under the next column's title. */
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table td.num, .frep-table td.num, table td.num { unicode-bidi: plaintext; }
/* typed date fields (makeDateInput): DD/MM/YYYY reads left to right */
input.date-in { direction: ltr; text-align: right; min-width: 8.5em; font-variant-numeric: tabular-nums; }
input.date-in::placeholder { direction: rtl; }
input.date-in.date-bad { border-color: var(--bad); box-shadow: 0 0 0 2px color-mix(in srgb, var(--bad) 25%, transparent); }

/* ===== UI slice 50b (owner decision 19): Arabic month / time / file fields ===== */
/* month «11/2026» and 24-hour time «08:30» boxes share the date-field look */
input.time-in { text-align: center; }
/* file field: Arabic button + chosen name; the real input lies on top, transparent */
.file-pick { position: relative; display: inline-flex; align-items: center; gap: 8px; max-width: 100%;
  padding: 4px; border: 1px dashed var(--border); border-radius: 10px; background: var(--field);
  transition: border-color 200ms ease, background-color 200ms ease; }
.file-pick-btn { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 4px; padding: 4px 12px; border-radius: 8px; font-weight: 600; font-size: 14px;
  background: var(--accent-2); color: var(--on-accent); white-space: nowrap; }
.file-pick-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 14px; }
.file-pick.has-file .file-pick-name { color: var(--text); font-weight: 600; }
.file-pick input.file-native { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; padding: 0;
  opacity: 0; cursor: pointer; font-size: 0; }
.file-pick:hover, .file-pick:focus-within { border-color: var(--accent-2); }
.file-pick:focus-within { outline: 2px solid var(--accent-2); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .file-pick { transition: none; } }
/* calendar button beside a typed date field + the Arabic month grid (dateCalUi/openDateCal) */
.date-box { display: inline-flex; align-items: stretch; gap: 4px; max-width: 100%; vertical-align: middle; }
.date-box.date-box-block { display: flex; width: 100%; }
.date-box > input { flex: 1 1 auto; min-width: 0; }
.date-cal-btn { flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; min-width: 36px; padding: 0 8px; line-height: 1; }
.date-cal { position: fixed; z-index: 400; width: 272px; padding: 8px; border: 1px solid var(--border);
  border-radius: 12px; background: var(--card); color: var(--text); box-shadow: var(--shadow);
  animation: dateCalIn 150ms ease; }
@keyframes dateCalIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.date-cal-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.date-cal-title { font-weight: 700; font-size: 15px; }
.date-cal-nav { min-width: 32px; padding: 4px 8px; font-size: 18px; line-height: 1; }
.date-cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.date-cal-dow { text-align: center; font-size: 12px; font-weight: 700; color: var(--muted); padding: 4px 0; }
.date-cal-day { padding: 4px 0; min-height: 32px; font-size: 14px; font-variant-numeric: tabular-nums;
  border-radius: 8px; border: 1px solid transparent; background: transparent; color: var(--text); }
.date-cal-day:hover { background: var(--hover); }
.date-cal-day.is-today { border-color: var(--accent-2); }
.date-cal-day.is-sel { background: var(--accent-2); color: var(--on-accent); }
.date-cal-foot { display: flex; justify-content: center; margin-top: 8px; }
@media (prefers-reduced-motion: reduce) { .date-cal { animation: none; } }
@media print { .date-cal-btn, .date-cal { display: none !important; } }

/* ===== UI slice 50c: display review, part 1 ===== */
/* quiet row buttons: delete / restore in a table row are outlined, filled red only on hover */
button.danger.small { background: transparent; color: var(--bad); border-color: var(--border); }
button.danger.small:hover, button.danger.small:focus-visible { background: color-mix(in srgb, var(--bad) 10%, var(--card)); border-color: var(--bad); color: var(--bad); filter: none; }
/* an empty numeric cell reads as «—», never as a blank or a dot */
td.num:empty::after { content: "—"; color: var(--muted); }
/* a row of summary cards that are all zero (empty screen) shrinks to a quiet compact row */
.bill-cards.kpi-all-zero .bill-card { padding: 8px 12px; min-height: 0; box-shadow: none; }
.bill-cards.kpi-all-zero .bill-card-v { font-size: 16px; line-height: 1.4; }
.bill-cards.kpi-all-zero .bill-card small { display: none; }
/* one status palette: green = done, blue = approved / next step pending, orange = waiting,
   red = rejected or a problem, gray = cancelled. The «blue» badge used the school accent
   (maroon) and read as red, so it gets a real blue. */
.badge-blue { background: rgb(219 233 254); color: rgb(29 78 216); }
:root[data-theme="dark"] .badge-blue { background: rgb(30 41 66); color: rgb(147 180 245); }
/* applicants board: seven status columns fit the desktop content width (no hidden last
   column); narrower screens still scroll sideways inside the board, phones stack */
.apl-board { grid-auto-columns: minmax(136px, 1fr); gap: 8px; }
/* duty rota day title: the date stays one left-to-right run «04/12/2026» */
.duty-day-title bdi { unicode-bidi: isolate; }
/* Today alerts: the row background followed the light theme only (dark mode read 1.1:1) */
.alert-row { background: var(--hover); }
a.alert-row:hover { background: color-mix(in srgb, var(--accent-2) 8%, var(--card)); }

/* ===== UI slice 50d: display review, the last part ===== */
/* one icon set: a colour emoji in UI text is drawn as a line icon placed beside the text;
   the text keeps the emoji (labels unchanged) but .emo-host draws it with a blank font
   first: no width, no ink. Rating emoji become plain dots. */
@font-face { font-family: "MP Emoji Blank"; src: url("fonts/mp-emoji-blank.woff") format("woff"); font-display: block;
  unicode-range: U+200D, U+FE0F, U+23ED, U+23F0, U+2600, U+263E, U+2699, U+26A0, U+270D, U+1F300-1F6FF, U+1F7E0-1F7EB, U+1F900-1F9FF; }
.emo-host { font-family: "MP Emoji Blank", "IBM Plex Sans Arabic", "Segoe UI", Tahoma, Arial, sans-serif; }
.emo-host input, .emo-host textarea, .emo-host select, .emo-host option { font-family: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, Arial, sans-serif; }
.emo { display: inline-flex; align-items: center; vertical-align: -3px; margin-inline: 0 4px; color: currentColor; }
.emo .emo-i { width: 16px; height: 16px; flex: none; }
.emo-dot { width: 10px; height: 10px; border-radius: 50%; vertical-align: 0; margin-inline-end: 4px; }
.emo-dot.emo-good { background: var(--good); }
.emo-dot.emo-warn { background: var(--warn); }
.emo-dot.emo-bad { background: var(--bad); }
/* payroll sheet: a compact table (headers wrap on two lines, narrow reason / notes boxes),
   so more columns fit and the rest scroll sideways under the fixed name column */
table.payroll-table thead th { white-space: normal; min-width: 56px; max-width: 92px; line-height: 1.3; vertical-align: bottom; }
table.payroll-table th, table.payroll-table td { padding: 8px 8px; }
table.payroll-table input.reason-input, table.payroll-table input.notes-input { width: 112px; min-width: 0; }
/* the totals row stays visible at the bottom of the scrolling sheet */
table.payroll-table tfoot td { position: sticky; bottom: 0; z-index: 2; background: var(--hover); font-weight: 700; border-top: 2px solid var(--border); }
table.payroll-table tfoot td.sticky-col { z-index: 3; }
@media print { table.payroll-table tfoot td { position: static; } }
/* the three payslip buttons in one «القسائم» menu: the toolbar stays one row */
.pay-docs { position: relative; display: inline-block; align-self: center; }
.pay-docs > summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 14px; min-height: 39px; box-sizing: border-box; border: 1px solid var(--border); border-radius: 10px; background: var(--card); color: var(--text); font-weight: 600; }
.pay-docs > summary::-webkit-details-marker { display: none; }
.pay-docs > summary::after { content: "▾"; font-size: 12px; color: var(--muted); }
.pay-docs[open] > summary { border-color: var(--accent-2); }
.pay-docs-list { position: absolute; inset-inline-start: 0; top: calc(100% + 4px); z-index: 30; min-width: 248px; display: flex;
  flex-direction: column; gap: 4px; padding: 8px; background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16); animation: payDocsIn 160ms ease-out; }
.pay-docs-list button { justify-content: flex-start; text-align: start; width: 100%; }
@keyframes payDocsIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .pay-docs-list { animation: none; } }
/* phone: toolbar selects never push the page sideways (long workplace names) */
@media (max-width: 640px) {
  .toolbar select, .bill-filters select { max-width: 100%; min-width: 0; }
  .pay-docs-list { inset-inline-start: auto; inset-inline-end: 0; min-width: min(248px, calc(100vw - 32px)); }
}
/* kiosk greetings: one text box per group, one phrase per line, two columns on desktop */
.greeting-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-top: 8px; }
@media (max-width: 720px) { .greeting-grid { grid-template-columns: minmax(0, 1fr); } }
.greeting-group { display: flex; flex-direction: column; gap: 4px; }
.greeting-group label { font-weight: 600; }
.greeting-text { width: 100%; min-height: 168px; resize: vertical; line-height: 1.7; }
.greeting-count.is-bad { color: var(--bad); }

/* =====================================================================
   Madrasa+ UI slice 51 — سند قبض واحد بعدة طرق دفع (نقد + تحويل + دفع
   إلكتروني + حتى 6 شيكات)، رقم السند اليدوي، «إدخال متأخر».
   Tokens only (works in dark mode). Spacing in steps of 4.
===================================================================== */
.rc-pay { margin-top: 8px; padding: 12px 16px; border: 1px solid var(--border); border-radius: 12px; background: var(--card); }
.rc-pay .rc-h { margin-top: 0; }
.rc-pay-grid { display: flex; flex-direction: column; gap: 8px; }
.rc-pay-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px 16px; align-items: end; }
.rc-pay-row .field { margin: 0; }
.rc-pay input.rc-cash { font-weight: 700; background: var(--hover); color: var(--text); }
.rc-cheques .rc-cheque { position: relative; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px 16px; }
.rc-cheques .rc-cheque legend { padding: 0 4px; font-weight: 700; color: var(--muted); font-size: 13px; }
.rc-cheques .rc-del-cheque { align-self: end; justify-self: start; }
.rc-late-note { margin: 8px 0; }
.rc-pay-warn { color: var(--bad); font-weight: 700; }
.rc-facts { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; margin: 4px 0 8px; }
.rc-group { margin: 8px 0 12px; }
.rc-parts tr.rc-part-void td { color: var(--muted); text-decoration: line-through; }
.paper-doc .paper-manual { font-weight: 700; border: 1px solid currentColor; padding: 2px 8px; border-radius: 4px; }
.paper-doc .paper-parts { margin-bottom: 12px; }
@media (max-width: 640px) {
  .rc-pay { padding: 12px; }
  .rc-pay-row, .rc-cheques .rc-cheque { grid-template-columns: minmax(0, 1fr); }
}

/* =====================================================================
   Madrasa+ UI slice 51b — دفاتر السندات الورقية لكل أمين صندوق و«أرقام لم
   تُدخل». Tokens only (works in dark mode). Spacing in steps of 4.
===================================================================== */
.rc-books-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.rc-books-switch { display: flex; align-items: flex-start; gap: 8px; margin: 8px 0; }
.rc-books-switch small { display: inline; }
.rc-manual-check { margin-top: 4px; font-size: 14px; }
.rc-books-table tr.rc-book-closed td { color: var(--muted); }
.rc-book-acts { white-space: nowrap; }
.rc-book-acts > button + button { margin-inline-start: 4px; }
.rc-book-hint { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin: 8px 0; padding: 8px 12px;
  border: 1px dashed var(--border); border-radius: 12px; background: var(--hover); }
.rc-num-chips { display: flex; flex-wrap: wrap; gap: 4px 8px; margin: 4px 0 12px; max-height: 240px; overflow: auto; }
.rc-num { display: inline-block; padding: 2px 8px; border: 1px solid var(--border); border-radius: 8px; font-weight: 700;
  font-variant-numeric: tabular-nums; }
.rc-num.rc-num-gap { border-color: var(--warn); }
.rc-num.rc-num-void { color: var(--muted); text-decoration: line-through; font-weight: 400; }
@media (max-width: 640px) {
  .rc-book-acts { white-space: normal; }
  .rc-book-acts > button { margin: 2px 0; }
}

/* =====================================================================
   Madrasa+ UI slice 52 — قائمة سندات القبض بفلاتر، والبحث العام في
   الشريط العلوي. Tokens only (works in dark mode). Spacing in steps of 4.
===================================================================== */
.rc-list-filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; margin: 8px 0 12px; }
.rc-list-filters .fam-search { flex: 1 1 260px; }
.rc-list-custom { display: inline-flex; gap: 8px; flex-wrap: wrap; }
.rc-list-custom.hidden { display: none; }
.rc-list-acts { display: inline-flex; gap: 8px; flex-wrap: wrap; }
.rc-list-sums { margin-bottom: 8px; }
.rc-list .rc-void-badge { margin-inline-start: 4px; }
.rc-list tr.rc-part-void td { color: var(--muted); }

.topbar { gap: 12px; }
.gsearch { position: relative; flex: 1 1 320px; max-width: 480px; margin: 0 8px; }
.gsearch.hidden { display: none; }
.gsearch input { width: 100%; height: 36px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--card); color: var(--text); padding: 4px 12px; font-size: 14px; }
.gsearch input:focus { border-color: var(--accent-2); }
.gsearch-results { position: absolute; inset-inline: 0; top: calc(100% + 4px); z-index: 60; max-height: 70vh; overflow: auto;
  background: var(--card); color: var(--text); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); padding: 4px; }
.gsearch-results.hidden { display: none; }
.gs-group + .gs-group { border-top: 1px solid var(--border); margin-top: 4px; padding-top: 4px; }
.gs-title { font-size: 12px; font-weight: 700; color: var(--muted); padding: 4px 8px; }
.gs-item { display: flex; flex-direction: column; align-items: flex-start; gap: 0; width: 100%; text-align: start;
  border: 0; border-radius: 8px; background: transparent; padding: 8px; min-height: 40px; cursor: pointer;
  transition: background var(--motion, 200ms) ease; }
.gs-item:hover, .gs-item.active { background: var(--hover); }
.gs-main { font-weight: 600; }
.gs-sub { font-size: 12px; }
.gs-empty { margin: 0; padding: 8px; font-size: 14px; }
@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; }
  .gsearch { order: 3; flex: 1 1 100%; max-width: none; margin: 0; }
}
@media print { .gsearch { display: none !important; } }

/* ===== UI slice 54: واتساب لولي الأمر (سند قبض، كشف حساب، شيك مرتجع) ===== */
.wa-send { display: flex; flex-direction: column; gap: 8px; }
.wa-send textarea { width: 100%; box-sizing: border-box; line-height: 1.6; }
.wa-send input[type=tel] { max-width: 240px; }
.wa-phones { margin: 0; }
.fset-wa-doc h4 { margin: 0 0 4px; }
.fset-wa-doc .fset-wa-ph { margin: 8px 0; }
@media print { .wa-btn, .stmt-wa { display: none !important; } }

/* ===== Madrasa+ UI slice 55: small receipt printer (80/58 mm) and «نسخة» ===== */
/* The small receipt is one narrow column, black on white; its @page (roll
   width, measured height, no margin) comes from print-receipt-80|58.css and
   paperRollPage(). .paper-measure is an off-screen box used only to measure. */
.paper-measure { position: fixed; inset-inline-start: -10000px; top: 0; visibility: hidden; pointer-events: none; }
.paper-small { font-family: "IBM Plex Sans Arabic", Tahoma, Arial, sans-serif; color: black; background: white;
  line-height: 1.4; margin: 0 auto; padding: 4mm 0 6mm; box-sizing: border-box; }
.paper-small.w80 { width: 72mm; font-size: 10pt; }
.paper-small.w58 { width: 48mm; font-size: 8.5pt; }
.paper-small .ps-head { text-align: center; border-bottom: 1px dashed black; padding-bottom: 4px; margin-bottom: 4px; }
.paper-small .ps-org { font-size: 1.2em; font-weight: 700; }
.paper-small .ps-title { font-size: 1.1em; font-weight: 700; margin-top: 4px; }
.paper-small .ps-kv, .paper-small .ps-line, .paper-small .ps-total { display: flex; justify-content: space-between; gap: 8px; }
.paper-small .ps-kv span { color: black; }
.paper-small .ps-lines { border-top: 1px dashed black; margin-top: 4px; padding-top: 4px; }
.paper-small .ps-line span { overflow-wrap: anywhere; }
.paper-small .num { direction: ltr; white-space: nowrap; font-variant-numeric: tabular-nums; }
.paper-small .ps-total { border-top: 2px solid black; border-bottom: 2px solid black; margin-top: 4px; padding: 4px 0; font-size: 1.2em; font-weight: 700; }
.paper-small .ps-words { margin-top: 4px; }
.paper-small .ps-note { margin-top: 4px; }
.paper-small .ps-sign { margin-top: 8px; }
.paper-small .ps-foot { margin-top: 8px; border-top: 1px dashed black; padding-top: 4px; font-size: 0.85em; text-align: center; }
.paper-small .paper-stamp { display: block; text-align: center; font-size: 1.4em; font-weight: 700; border: 3px double black;
  margin: 4px 0; padding: 2px 0; }
.paper-small.paper-void .ps-line span, .paper-small.paper-void .ps-total b { text-decoration: line-through; }
section.paper-doc .paper-copy-stamp { margin-inline-start: 8px; }
.fset-widths { display: flex; flex-wrap: wrap; gap: 8px 24px; margin: 8px 0 16px; }
.fset-width { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; cursor: pointer; }
@media print {
  body.small-printing { margin: 0 !important; }
}

/* ===== Madrasa+ checklist 56: registration wizard (route register) ===== */
.reg-steps { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; padding: 0; counter-reset: none; }
.reg-step { flex: 1 1 140px; min-width: 0; }
.reg-step-label { display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 4px 12px; border: 1px solid var(--border);
  border-radius: 10px; background: var(--card); color: var(--muted); transition: background var(--motion, 200ms), color var(--motion, 200ms); }
.reg-step-link { text-decoration: none; display: block; }
.reg-step-link:hover .reg-step-label { background: var(--hover); color: var(--text); }
.reg-step-no { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 50%;
  border: 1px solid currentColor; font-size: 0.85em; flex: none; }
.reg-step.done .reg-step-label { color: var(--text); }
.reg-step.current .reg-step-label { background: var(--accent-2); border-color: var(--accent-2); color: var(--on-accent); font-weight: 700; }
.reg-body { display: flex; flex-direction: column; gap: 12px; }
.reg-fam { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.reg-choices { display: flex; flex-wrap: wrap; gap: 8px; }
.reg-nav { justify-content: space-between; margin-top: 16px; }
.reg-done { display: flex; align-items: center; gap: 16px; }
.reg-done img { width: 72px; height: auto; }
@media (max-width: 640px) {
  .reg-step { flex: 1 1 100%; }
}

/* ===== Madrasa+ checklist 56b: registration documents (student docs modal + settings list) ===== */
.stu-docs { display: flex; flex-direction: column; gap: 12px; }
.stu-docs-btn.docs-missing { border-color: var(--warn); color: var(--text); }
.stu-docs-btn.docs-complete { border-color: var(--good); color: var(--text); }
.stu-docs-table td { vertical-align: middle; }
.stu-docs-table input[type="text"] { width: 100%; min-width: 120px; }
.stu-docs-table input[type="checkbox"] { width: 24px; height: 24px; }
.stu-docs-table tr.doc-out td:first-child { border-inline-start: 3px solid var(--warn); }
.stu-docs-table tr.doc-in td:first-child { border-inline-start: 3px solid var(--good); }
.stu-doc-file { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.stu-doc-thumb img { display: block; width: 56px; height: 56px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border);
  background: var(--field); }
.reg-docs-add { align-items: flex-end; gap: 8px; }
.reg-docs-table tr.muted td { color: var(--muted); }
@media (max-width: 640px) {
  .stu-docs-table input[type="text"] { min-width: 0; }
}

/* ===== Madrasa+ checklist 57: month-end checklist screen ===== */
.me-bar { align-items: flex-end; gap: 8px; }
.me-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.me-item { display: flex; align-items: flex-start; gap: 12px; padding: 12px 16px; border: 1px solid var(--border);
  border-inline-start-width: 4px; border-radius: 12px; background: var(--card); }
.me-item.me-ok { border-inline-start-color: var(--good); }
.me-item.me-warn { border-inline-start-color: var(--warn); }
.me-item.me-block { border-inline-start-color: var(--bad); }
.me-mark { flex: none; width: 28px; height: 28px; border-radius: 50%; display: inline-flex; align-items: center;
  justify-content: center; font-weight: 700; border: 2px solid currentColor; }
.me-ok .me-mark { color: var(--good); }
.me-warn .me-mark { color: var(--warn); }
.me-block .me-mark { color: var(--bad); }
.me-body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.me-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
.me-amt { color: var(--muted); }
.me-detail { color: var(--muted); }
.me-sub { margin: 4px 0 0; padding-inline-start: 20px; color: var(--muted); }
.me-sub li.me-sub-bad { color: var(--text); }
.me-go { flex: none; align-self: center; white-space: nowrap; }
.me-close textarea { width: 100%; }
@media (max-width: 640px) {
  .me-item { flex-wrap: wrap; padding: 12px; }
  .me-go { flex-basis: 100%; }
}
@media print {
  .me-item { break-inside: avoid; background: none; }
}

/* ---- checklist 57b: services & sales (owner decision 32) ---- */
.sale-form .sale-info { margin-bottom: 8px; }
.sale-form .sale-total, .sale-bulk .sale-total { font-weight: 700; margin: 8px 0; }
.sale-form .sale-price-warn { margin: 8px 0; }
.sale-cat-table td.sale-out-stock, .data-table tr.sale-low td { color: var(--danger); font-weight: 700; }
.sale-bulk .modal-actions { align-items: center; justify-content: space-between; gap: 16px; }
.sale-bulk-list .table-wrap { max-height: 360px; overflow: auto; }
.sales-entry { margin: 4px 0 8px; }

/* ---- checklist 58: «لم يصل بعد», bulk resolve, PIN slips ---- */
.today-na .cash-card-head { flex-wrap: wrap; gap: 4px 16px; }
.today-na .na-updated { font-size: 0.875rem; }
.today-na tr.na-late td:first-child { border-inline-start: 4px solid var(--bad); }
.today-na .badge + .badge { margin-inline-start: 4px; }
.pending-bulk { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 0 12px;
  border-bottom: 1px solid var(--border); margin-bottom: 8px; }
.pending-bulk .pend-all { display: inline-flex; align-items: center; gap: 4px; }
.pending-item .pend-pick { flex: none; }
.pin-slip-modal .pin-cell { font-size: 1.25rem; font-weight: 700; letter-spacing: 0.25em; }
.pin-slips { display: grid; grid-template-columns: 1fr 1fr; gap: 0; }
.pin-slip { border: 1px dashed currentColor; padding: 16px; text-align: center; break-inside: avoid;
  display: flex; flex-direction: column; gap: 4px; }
.pin-slip-org { font-weight: 700; }
.pin-slip-name { font-size: 1.125rem; font-weight: 700; margin-top: 8px; }
.pin-slip-pin { font-size: 2rem; font-weight: 700; letter-spacing: 0.4em; margin: 8px 0; }
.pin-slip-help { font-size: 0.875rem; }
@media (max-width: 640px) {
  .pending-bulk select { flex: 1 1 100%; }
}
.sub-bar { align-items: flex-end; gap: 8px; }
.data-table tr.sub-open td:first-child { border-inline-start: 4px solid var(--warn); }
.subs-paper .paper-table td:last-child { min-width: 30mm; }

/* checklist 59: عناوين أقسام داخل نموذج الموظف (العقد، المؤهل، البنك) */
.form-grid .form-sub {
  grid-column: 1 / -1;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
}
.iban-text { font-family: ui-monospace, Menlo, Consolas, monospace; letter-spacing: 0.5px; }

/* checklist 60: طلبات الإجازة (قراركم 29ط) وسنة الإجازات والترحيل (29ي) */
.lr-card .lr-table td { vertical-align: middle; }
.lr-card .row-actions, .apr-leaves .row-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.lr-over { color: var(--bad); }
.data-table tr.lr-row-over td:first-child { border-inline-start: 4px solid var(--bad); }
.lr-over-box { border: 1px solid var(--bad); border-radius: 8px; padding: 8px 12px; margin: 8px 0; }
.lr-over-box p { margin: 0 0 8px; color: var(--bad); font-weight: 600; }
.lr-sum th { width: 40%; }
.lr-done { margin-top: 8px; }
.lr-done summary { cursor: pointer; padding: 8px 0; color: var(--muted); }
.balance-cell .bal-carried { color: var(--good); }
.balance-cell .bal-senior { color: var(--accent-2); }
.balance-cell .bal-pending { color: var(--warn); }
.leave-year-card .check-line { align-self: end; padding-bottom: 8px; }
@media (max-width: 640px) {
  .lr-card .row-actions button { flex: 1 1 auto; }
}

/* checklist 61: مخالصة نهاية الخدمة — تنبيهات واعتماد */
.settlement-warnings { border: 1px solid var(--warn); border-radius: 8px; padding: 8px 12px; margin: 8px 0; }
.settlement-warnings.hidden { display: none; }
.settlement-warnings p { margin: 0 0 4px; color: var(--text); font-weight: 600; }
.settlement-warnings ul { margin: 4px 0 0; padding-inline-start: 24px; }
.settlement-panel { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.settlement-panel .settlement-warnings { flex: 1 1 100%; }
.payslip-table .settlement-detail { font-size: 12px; font-weight: 400; }
.eos-settings-card .check-line { align-self: end; padding-bottom: 8px; }

/* checklist 62: القسائم عبر واتساب وملف تحويل البنك */
.pay-wa .data-table td { vertical-align: top; }
.pay-wa input[name="wa_phone"] { max-width: 160px; }
.pay-wa .pay-wa-text summary { cursor: pointer; color: var(--muted); font-size: 12px; padding: 4px 0; }
.pay-wa .pay-wa-text textarea { width: 100%; min-width: 200px; }
.pay-wa tr.pay-wa-done td { background: var(--hover); }
.pay-wa .pay-wa-status { color: var(--good); margin-inline-start: 8px; font-size: 13px; }
.pay-wa .pay-wa-count { display: block; margin: 8px 0; }
@media (max-width: 640px) {
  .pay-wa .data-table th:nth-child(3), .pay-wa .data-table td:nth-child(3) { display: none; }
}

/* ===== checklist 63: certificates, letter templates, salary history ===== */
.cert-tiles { margin-top: 16px; }
.cert-tile { background: var(--card); border: 1px solid var(--border, var(--th)); border-radius: 12px; padding: 16px;
  display: flex; flex-direction: column; gap: 8px; transition: box-shadow 200ms ease; }
.cert-tile:hover { box-shadow: var(--shadow); }
.cert-tile small { color: var(--muted); }
.cert-tpl, .letter-tpl { display: flex; flex-direction: column; gap: 8px; margin: 0; }
.letter-tpl-card { margin-top: 16px; }
.letter-tpl-head { justify-content: space-between; align-items: center; }
.cert-form { grid-template-columns: 1fr; }
.cert-form label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 13px; }
.cert-show-label { display: inline-flex; align-items: center; gap: 8px; }
.cert-lines { width: auto; min-width: 50%; margin: 16px 0; border-collapse: collapse; }
.cert-lines th, .cert-lines td { padding: 4px 16px; border-bottom: 1px solid var(--border, var(--th)); }
.cert-lines .cert-total td { font-weight: 700; }
.salary-hist-bar { margin: 8px 0; }
.raise-preview { font-weight: 700; color: var(--text); }
@media print {
  .cert-lines th, .cert-lines td { border-bottom: 1px solid black; color: black; }
}

/* ===== checklist 64: hiring flow (onboarding) and penalty signature/approval ===== */
.onboard-card { margin: 16px 0; }
.onboard-bar { height: 8px; border-radius: 8px; background: var(--hover); overflow: hidden; margin: 8px 0 16px; }
.onboard-bar span { display: block; height: 100%; background: var(--good); transition: width 200ms ease; }
.onboard-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.onboard-list li { display: flex; align-items: center; gap: 8px; padding: 8px; border-radius: 8px; border: 1px solid var(--border, var(--th)); }
.onboard-list li.done { opacity: 0.8; }
.onboard-label { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.onboard-mark { width: 24px; text-align: center; color: var(--muted); }
.onboard-list li.done .onboard-mark { color: var(--good); }
.pen-state { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.pen-state .pen-src { font-size: 12px; }
.apl-hire-hint { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.disc-flow-hint, .disc-source { grid-column: 1 / -1; }
@media print {
  .onboard-card { display: none; }
}

/* ===== checklist 65: new school year (rollover) ===== */
.ny-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 16px; }
.ny-step { display: flex; align-items: flex-start; gap: 16px; padding: 16px; border: 1px solid var(--border);
  border-radius: 12px; border-inline-start: 4px solid var(--accent-2); }
.ny-step.ny-done { border-inline-start-color: var(--good); }
.ny-num { flex: none; width: 32px; height: 32px; border-radius: 50%; display: inline-flex; align-items: center;
  justify-content: center; font-weight: 700; background: var(--hover); color: var(--text); }
.ny-step.ny-done .ny-num { color: var(--good); }
.ny-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.ny-body h3 { margin: 0; font-size: 16px; }
.ny-promo .toolbar { flex-wrap: wrap; }
.ny-table select { max-width: 200px; }
.ny-table tr.ny-leaving td { color: var(--muted); }
.ny-table td.ny-debt { color: var(--bad); }
.ny-leavers { margin-top: 16px; }
.ny-leavers h3 { margin: 0; }
.stmt-table tr.stmt-previous td { background: var(--hover); font-weight: 600; }
@media (max-width: 640px) {
  .ny-step { padding: 12px; gap: 8px; }
  .ny-table select { max-width: 140px; }
}
@media print {
  .ny-steps .toolbar, .ny-steps button { display: none; }
}

/* ===== checklist 66: mid-year withdrawal ===== */
.wd-facts { display: flex; flex-direction: column; gap: 4px; padding: 12px 16px; border: 1px solid var(--border);
  border-radius: 12px; background: var(--hover); }
.wd-line { display: flex; justify-content: space-between; gap: 16px; }
.wd-line.wd-suggested { border-top: 1px solid var(--border); padding-top: 8px; margin-top: 4px; font-size: 16px; }
.wd-warn { margin: 4px 0 0; color: var(--bad); font-weight: 600; }
.wd-note { color: var(--muted); }
@media (max-width: 640px) {
  .wd-line { flex-direction: column; gap: 0; }
}

/* ---- checklist 67: bank-statement import (bankImportModal) + family / cheque no. on bank lines ---- */
.bank-party { display: block; margin-top: 2px; }
.bimp .bimp-map { flex-wrap: wrap; gap: 8px 16px; }
.bimp .bimp-sample td, .bimp .bimp-sample th { white-space: nowrap; font-size: 0.85em; }
.bimp .bimp-lines tr.bimp-none td { color: var(--muted); }
.bimp .bimp-lines tr.bimp-check td:first-child { box-shadow: inset -3px 0 0 var(--warn); }
.bimp .bimp-lines tr.bimp-check { background: var(--gold-soft); }

/* ---- checklist 68: owner summary page ---- */
.os-bar { flex-wrap: wrap; gap: 8px; }
.os-card h3 { margin-bottom: 8px; }
.os-over { color: var(--good); }
.os-short { color: var(--bad); }
.os-wa textarea { width: 100%; font-family: inherit; }
.owner-summary-paper h4 { margin: 12px 0 4px; }
/* checklist 68b: automatic Telegram summary (manager card) */
.os-tg-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 8px 16px; align-items: end; margin: 8px 0; }
.os-tg-grid input[name="tg_token"], .os-tg-grid input[name="tg_chat_id"] { width: 100%; }
.os-tg-ok { color: var(--good); }
.os-tg-bad { color: var(--bad); }

/* checklist 72: carried items on a payroll row */
.carry-badge { margin-inline-start: 4px; font-size: 0.75rem; }

/* ===== checklist 73: «تأكيد العودة» (return-confirm page) + debt approval in the rollover ===== */
.rt-cards .rt-card { display: flex; flex-direction: column; align-items: flex-start; text-align: start; cursor: pointer;
  font: inherit; transition: border-color var(--motion), box-shadow var(--motion); }
.rt-cards .rt-card:hover { border-color: var(--accent-2); }
.rt-cards .rt-card.active { border-color: var(--accent-2); box-shadow: inset 0 0 0 1px var(--accent-2); }
.rt-seg { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.rt-seg .rt-opt { padding: 4px 12px; border-radius: 8px; font-size: 13px; }
.rt-seg .rt-opt.active { color: var(--on-accent); background: var(--accent-2); border-color: var(--accent-2); }
.rt-seg .rt-opt-not_back.active { background: var(--bad); border-color: var(--bad); }
.rt-seg .rt-opt-maybe.active { background: var(--hover); border-color: var(--warn); color: var(--text); box-shadow: inset 0 0 0 1px var(--warn); }
.rt-table input[name=rt_note] { min-width: 160px; }
.rt-table td.ny-debt { color: var(--bad); }
.rt-grades { margin-top: 16px; }
.rt-grades h3 { margin: 0 0 8px; }
.ny-extra { flex-wrap: wrap; gap: 8px 16px; }
.ny-approval { margin-top: 4px; display: flex; justify-content: flex-end; }
.ny-ok { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: var(--text); }
.ny-conf { white-space: nowrap; }
.ny-conf-back { color: var(--good); }
.ny-conf-not_back { color: var(--bad); }
@media (max-width: 640px) {
  .rt-table input[name=rt_note] { min-width: 100px; }
}
@media print {
  .rt-seg .rt-opt:not(.active) { display: none; }
}

/* ---- checklist 77 (owner decision 39b): two-factor login ---- */
.tfa-qr { display: block; width: 216px; height: 216px; margin: 8px auto; background: white; border-radius: 8px; }
.tfa-secret { font-size: 15px; letter-spacing: 1px; word-break: break-all; user-select: all; }
.tfa-steps { margin: 8px 0; padding-inline-start: 24px; line-height: 1.7; }
.tfa-codes { columns: 2; gap: 24px; margin: 8px 0; padding-inline-start: 24px; font-family: monospace; font-size: 15px; line-height: 1.9; }
.tfa-card .toolbar { gap: 8px; flex-wrap: wrap; }
.tfa-code-input { letter-spacing: 4px; text-align: center; font-size: 18px; }
@media (max-width: 640px) { .tfa-codes { columns: 1; } }
