/* نظام الموارد البشرية — تنسيقات الواجهة (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: "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);
}

/* ---------------------------------------------------------------------
   التخطيط العام (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; }

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: var(--accent-2);
  text-decoration: underline dotted;
  cursor: pointer;
}
.emp-link:hover { text-decoration: underline; }
.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;
  }
}

/* ---------------------------------------------------------------------
   شبكة الحضور الشهرية
--------------------------------------------------------------------- */
.attendance-grid-wrap { max-width: 100%; }

table.attendance-grid {
  font-size: 13px;
  border-collapse: collapse;
}

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: 150px;
  box-shadow: -1px 0 0 var(--border);
}

table.attendance-grid th.day-col,
table.attendance-grid td.att-cell {
  min-width: 32px;
  text-align: center;
  padding: 4px 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-absent { background: #fde2e2; color: #b91c1c; font-weight: 700; }
.att-late { background: #fdead1; color: #b45309; font-weight: 700; }
.att-leave { background: #dbe9fe; color: #1d4ed8; font-weight: 700; }
.att-mission { background: #ece1fb; color: #6d28d9; font-weight: 700; }
.att-present { background: #dcfce7; color: #15803d; font-weight: 700; }

/* 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; }

.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; }
