/* =====================================================================
   منصة النقل البري - ملف التنسيقات الرئيسي
   Land Transport Platform - Main Stylesheet
   ---------------------------------------------------------------------
   البنية:
     1) المتغيرات والهوية البصرية (Design Tokens)
     2) الوضع الليلي (Dark Mode)
     3) الأساسيات (Base)
     4) صفحة تسجيل الدخول (Login)
     5) هيكل لوحة التحكم (Layout: Header / Sidebar / Main / Footer)
     6) بطاقات المكاتب الحدودية (Office Cards)
     7) أدوات التحكم (حجم الخط / الوضع الليلي / الدعم)
     8) الاستجابة (Responsive)
   ===================================================================== */

/* ============================ 1) Tokens ============================ */
:root {
  /* الهوية البصرية الرسمية */
  --brand-900: #0b2545;   /* أزرق داكن مؤسسي */
  --brand-800: #10315c;
  --brand-700: #16457e;
  --brand-600: #1b5299;   /* أزرق تفاعلي */
  --gold:      #c9a227;   /* لمسة ذهبية رسمية (خط رفيع فقط) */

  /* الحالات */
  --status-on:  #16a34a;  /* يعمل - أخضر */
  --status-on-soft:  rgba(22, 163, 74, .12);
  --status-off: #94a3b8;  /* لا يعمل - رمادي */
  --status-off-soft: rgba(148, 163, 184, .16);
  --status-off-strong: #dc2626; /* أحمر للتنبيه القوي عند الحاجة */

  /* الأسطح والخلفيات (الوضع النهاري) */
  --bg:        #eef2f7;
  --surface:   #ffffff;
  --surface-2: #f6f8fb;
  --border:    #dde3ec;
  --text:      #1b2635;
  --text-soft: #5b6b82;
  --shadow:    0 1px 2px rgba(16, 49, 92, .06), 0 8px 24px rgba(16, 49, 92, .06);
  --shadow-sm: 0 1px 2px rgba(16, 49, 92, .08);

  /* القياسات */
  --sidebar-w: 264px;
  --header-h: 68px;
  --radius:   14px;
  --radius-sm: 10px;

  /* مقياس حجم الخط (يتحكم به JavaScript) — نطاق آمن */
  --font-scale: 1;

  color-scheme: light;
}

/* الخطوط العربية */
body,
.font-body { font-family: "Tajawal", "Noto Kufi Arabic", system-ui, sans-serif; }
h1, h2, h3, h4, h5, h6,
.font-display,
.brand-name,
.card-office__name,
.page-title { font-family: "Cairo", "Tajawal", system-ui, sans-serif; }

/* ========================= 2) Dark Mode ========================= */
[data-bs-theme="dark"] {
  --bg:        #0a1120;
  --surface:   #121b2e;
  --surface-2: #0f1728;
  --border:    #22304a;
  --text:      #e6ecf5;
  --text-soft: #93a2bd;
  --brand-900: #0e1c33;
  --shadow:    0 1px 2px rgba(0, 0, 0, .4), 0 10px 28px rgba(0, 0, 0, .35);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35);
  --status-off: #64748b;
  color-scheme: dark;
}

/* ========================== 3) Base ========================== */
html {
  /* التحكم بحجم الخط: كل شيء بوحدة rem يتكيّف تلقائيًا */
  font-size: calc(16px * var(--font-scale));
  scroll-behavior: smooth;
}

body {
  background-color: var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition: background-color .25s ease, color .25s ease;
}

a { color: var(--brand-600); }

::selection { background: var(--brand-600); color: #fff; }

/* حلقة تركيز واضحة لإمكانية الوصول */
:focus-visible {
  outline: 3px solid var(--brand-600);
  outline-offset: 2px;
  border-radius: 6px;
}

.text-soft { color: var(--text-soft) !important; }

/* أزرار المشروع */
.btn-brand {
  background-color: var(--brand-700);
  border-color: var(--brand-700);
  color: #fff;
}
.btn-brand:hover,
.btn-brand:focus {
  background-color: var(--brand-800);
  border-color: var(--brand-800);
  color: #fff;
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  transition: background-color .15s ease, border-color .15s ease, transform .1s ease;
}
.btn-icon:hover { background: var(--surface-2); border-color: var(--brand-600); }
.btn-icon:active { transform: translateY(1px); }

/* ===================== 4) Login Page ===================== */
.login-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
  background:
    radial-gradient(1200px 600px at 100% -10%, rgba(27, 82, 153, .18), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(201, 162, 39, .10), transparent 55%),
    var(--bg);
}

.login-card {
  width: 100%;
  max-width: 520px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.login-card__head {
  text-align: center;
  padding: 40px 36px 12px;
}
.login-card__head img { width: 96px; height: 96px; }
.login-card__head .brand-name {
  color: var(--brand-700);
  font-weight: 800;
  font-size: 1.45rem;
  margin-top: 14px;
  margin-bottom: 4px;
}
[data-bs-theme="dark"] .login-card__head .brand-name { color: #cfe0ff; }

.login-card__body { padding: 16px 36px 36px; }
.login-card__body .form-control,
.login-card__body .input-group-text,
.login-card__body .btn-toggle-pass {
  min-height: 48px;
  font-size: 1rem;
}
.login-card__body .btn-brand {
  min-height: 50px;
  font-size: 1.05rem;
}

.login-card::before {
  content: "";
  display: block;
  height: 4px;
  background: linear-gradient(90deg, var(--brand-700), var(--gold));
}

.form-label { font-weight: 600; font-size: .92rem; }

.input-group .btn-toggle-pass {
  border: 1px solid var(--border);
  border-inline-start: 0;
  background: var(--surface);
  color: var(--text-soft);
}

.form-control {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}
.form-control:focus {
  background: var(--surface);
  color: var(--text);
  border-color: var(--brand-600);
  box-shadow: 0 0 0 .2rem rgba(27, 82, 153, .18);
}

/* ===================== 5) Dashboard Layout ===================== */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--header-h) 1fr auto;
  grid-template-areas:
    "sidebar header"
    "sidebar main"
    "sidebar footer";
  min-height: 100vh;
}

/* ---- Header ---- */
.app-header {
  grid-area: header;
  position: sticky;
  top: 0;
  z-index: 1030;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.app-header .page-title {
  font-size: 1.12rem;
  font-weight: 800;
  margin: 0;
  color: var(--text);
}
.app-header .header-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-inline-start: auto;
}

.sidebar-toggle { display: none; }

/* ---- Sidebar ---- */
.app-sidebar {
  grid-area: sidebar;
  background: var(--brand-900);
  color: #cdd8ea;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  border-inline-end: 1px solid rgba(255, 255, 255, .06);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  height: var(--header-h);
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.sidebar-brand img { width: 48px; height: 48px; object-fit: contain; border-radius: 50%; background: #fff; }
.sidebar-brand .brand-name {
  color: #fff;
  font-weight: 800;
  font-size: 1.02rem;
  line-height: 1.2;
  margin: 0;
}
.sidebar-brand .brand-sub {
  color: #8ea3c6;
  font-size: .72rem;
  display: block;
}

.sidebar-nav {
  list-style: none;
  margin: 0;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}
.sidebar-nav .nav-section {
  color: #6f83a6;
  font-size: .72rem;
  font-weight: 700;
  padding: 14px 12px 6px;
  letter-spacing: .03em;
}
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  color: #cdd8ea;
  text-decoration: none;
  font-weight: 600;
  font-size: .95rem;
  transition: background-color .15s ease, color .15s ease;
}
.sidebar-link i { width: 20px; text-align: center; font-size: 1.02rem; }
.sidebar-link:hover { background: rgba(255, 255, 255, .06); color: #fff; }

.sidebar-link.active {
  background: var(--brand-600);
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .08);
}
.sidebar-link.active i { color: #fff; }

.sidebar-link.is-disabled {
  color: #64769a;
  cursor: not-allowed;
  pointer-events: none;
  opacity: .75;
}
.sidebar-link .badge-soon {
  margin-inline-start: auto;
  font-size: .62rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(201, 162, 39, .18);
  color: var(--gold);
}

.sidebar-foot {
  margin-top: auto;
  padding: 14px;
  border-top: 1px solid rgba(255, 255, 255, .08);
}

/* ---- Main ---- */
.app-main {
  grid-area: main;
  padding: 22px;
}

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 18px;
}
.page-head .page-title { font-size: 1.4rem; font-weight: 800; margin: 0; }
.page-head .page-sub { color: var(--text-soft); margin: 4px 0 0; font-size: .95rem; }

/* شريط ملخص الحالة */
.summary-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}
.summary-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  box-shadow: var(--shadow-sm);
  min-width: 150px;
}
.summary-chip .dot { width: 12px; height: 12px; border-radius: 50%; }
.summary-chip .dot.on { background: var(--status-on); }
.summary-chip .dot.off { background: var(--status-off); }
.summary-chip .dot.total { background: var(--brand-600); }
.summary-chip .n { font-size: 1.3rem; font-weight: 800; font-family: "Cairo", sans-serif; line-height: 1; }
.summary-chip .l { font-size: .82rem; color: var(--text-soft); }

/* أدوات فرز/بحث بسيطة */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 18px;
}

/* ---- Footer ---- */
.app-footer {
  grid-area: footer;
  background: var(--surface);
  border-top: 1px solid var(--border);
  color: var(--text-soft);
  padding: 16px 22px;
  font-size: .86rem;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  justify-content: space-between;
  align-items: center;
}

/* ================== 6) Office Cards ================== */
.offices-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 16px;
}

.card-office {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  transition: transform .12s ease, box-shadow .15s ease, border-color .15s ease;
  overflow: hidden;
}
.card-office:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
  border-color: var(--brand-600);
}

/* الشريط الجانبي الملوّن حسب الحالة (التوقيع البصري) — في RTL على اليمين */
.card-office::before {
  content: "";
  position: absolute;
  inset-block: 0;
  inset-inline-start: 0;
  width: 5px;
}
.card-office.is-on::before  { background: var(--status-on); }
.card-office.is-off::before { background: var(--status-off); }

.card-office__top {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}
.card-office__icon {
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 1.25rem;
  background: var(--surface-2);
  color: var(--brand-600);
  border: 1px solid var(--border);
}
.card-office.is-on .card-office__icon  { color: var(--status-on);  background: var(--status-on-soft);  border-color: transparent; }
.card-office.is-off .card-office__icon { color: var(--status-off); background: var(--status-off-soft); border-color: transparent; }

.card-office__name { font-size: 1.05rem; font-weight: 700; margin: 0; color: var(--text); }
.card-office__meta { font-size: .8rem; color: var(--text-soft); margin: 2px 0 0; }

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: .86rem;
  padding: 7px 12px;
  border-radius: 999px;
}
.status-badge .dot {
  width: 9px; height: 9px; border-radius: 50%;
  position: relative;
}
.status-badge.on  { color: var(--status-on);  background: var(--status-on-soft); }
.status-badge.off { color: var(--status-off); background: var(--status-off-soft); }
.status-badge.on .dot  { background: var(--status-on); }
.status-badge.off .dot { background: var(--status-off); }

/* نبضة خفيفة للحالة "يعمل" */
.status-badge.on .dot::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid var(--status-on);
  opacity: .5;
  animation: ping 1.8s cubic-bezier(0, 0, .2, 1) infinite;
}
@keyframes ping {
  0%   { transform: scale(.6); opacity: .6; }
  80%, 100% { transform: scale(1.6); opacity: 0; }
}

.card-office__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 4px;
}
/* مكان جاهز لأزرار التفاصيل/التقارير مستقبلًا */
.card-office__action {
  font-size: .82rem;
  font-weight: 600;
  color: var(--text-soft);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  cursor: not-allowed;
  opacity: .8;
}

/* =============== 7) WhatsApp Support Button =============== */
.support-fab {
  position: fixed;
  inset-block-end: 22px;
  inset-inline-end: 22px;       /* الجهة اليسرى فعليًا في RTL — بعيدًا عن القائمة الجانبية */
  z-index: 1040;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-radius: 999px;
  background: #25d366;
  color: #fff;
  font-weight: 700;
  text-decoration: none;
  box-shadow: 0 8px 24px rgba(37, 211, 102, .4);
  transition: transform .12s ease, box-shadow .15s ease;
}
.support-fab:hover { color: #fff; transform: translateY(-2px); box-shadow: 0 12px 30px rgba(37, 211, 102, .5); }
.support-fab i { font-size: 1.35rem; }

/* الطبقة المظللة للقائمة الجانبية على الموبايل */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(6, 14, 28, .5);
  z-index: 1035;
}

/* =============== 8) Responsive =============== */
@media (max-width: 992px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-areas:
      "header"
      "main"
      "footer";
  }

  .sidebar-toggle { display: inline-flex; }

  .app-sidebar {
    position: fixed;
    inset-block: 0;
    inset-inline-start: 0;            /* مثبّتة على جهة البداية في RTL (اليمين) */
    width: min(84vw, var(--sidebar-w));
    height: 100vh;
    transform: translateX(100%);      /* مخفية افتراضيًا */
    transition: transform .28s ease;
    z-index: 1050;
    box-shadow: -12px 0 30px rgba(0, 0, 0, .25);
  }
  .app.sidebar-open .app-sidebar { transform: translateX(0); }
  .app.sidebar-open .sidebar-overlay { display: block; }

  .app-header .page-title { font-size: 1rem; }
}

@media (max-width: 576px) {
  .app-main { padding: 16px; }
  .offices-grid { grid-template-columns: repeat(auto-fill, minmax(100%, 1fr)); }
  .header-tools .tool-label { display: none; } /* إبقاء الأيقونات فقط لتوفير المساحة */
  .support-fab .support-label { display: none; }
  .support-fab { padding: 14px; }
}

@media (min-width: 577px) and (max-width: 768px) {
  .offices-grid { grid-template-columns: repeat(2, 1fr); }
}

/* احترام تفضيل تقليل الحركة */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* =====================================================================
   9) قسم التقارير (Reports)
   ===================================================================== */

/* اختيار نوع التقرير (Tabs/Cards) */
.report-tabs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.report-tab {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  text-align: start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  cursor: pointer;
  transition: border-color .15s ease, transform .1s ease, box-shadow .15s ease;
  color: var(--text);
}
.report-tab:hover { border-color: var(--brand-600); transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.report-tab.active {
  border-color: var(--brand-600);
  box-shadow: inset 0 0 0 1px var(--brand-600), var(--shadow-sm);
  background: var(--surface-2);
}
.report-tab__icon {
  flex: 0 0 auto;
  width: 42px; height: 42px;
  border-radius: 11px;
  display: grid; place-items: center;
  font-size: 1.15rem;
  background: rgba(27, 82, 153, .1);
  color: var(--brand-600);
}
.report-tab.active .report-tab__icon { background: var(--brand-600); color: #fff; }
.report-tab__title { display: block; font-weight: 700; font-size: .96rem; margin: 0 0 5px; font-family: "Cairo", sans-serif; line-height: 1.4; }
.report-tab__desc { display: block; font-size: .78rem; color: var(--text-soft); margin: 0; line-height: 1.6; }

/* لوحة الفلترة */
.filter-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
}
.filter-panel__head {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; margin-bottom: 14px;
  font-family: "Cairo", sans-serif;
}
.filter-panel__head i { color: var(--brand-600); }
.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  align-items: end;
}
.filter-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }

/* شريط أدوات النتائج */
.report-toolbar {
  display: flex; flex-wrap: wrap; gap: 8px;
  align-items: center;
  margin-bottom: 14px;
}
.report-toolbar .spacer { margin-inline-start: auto; }

/* شريط معلومات الفترة/المنفذ */
.report-meta {
  display: flex; flex-wrap: wrap; gap: 8px 10px;
  margin-bottom: 14px;
}
.report-meta .meta-item {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 13px;
  font-size: .85rem;
}
.report-meta .meta-item i { color: var(--brand-600); }
.report-meta .meta-item b { font-weight: 700; }

/* بطاقات الملخص الصغيرة */
.report-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
}
.stat-card .stat-label { font-size: .8rem; color: var(--text-soft); display: flex; align-items: center; gap: 6px; }
.stat-card .stat-value { font-family: "Cairo", sans-serif; font-weight: 800; font-size: 1.5rem; margin-top: 4px; line-height: 1.1; }
.stat-card.accent { border-color: var(--brand-600); }
.stat-card.accent .stat-value { color: var(--brand-600); }
[data-bs-theme="dark"] .stat-card.accent .stat-value { color: #7fb0f0; }

/* عنوان التقرير */
.report-title {
  font-family: "Cairo", sans-serif;
  font-weight: 800;
  font-size: 1.25rem;
  margin: 0 0 12px;
  display: flex; align-items: center; gap: 10px;
}
.report-title i { color: var(--brand-600); }

/* الجداول */
.report-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.rtable {
  width: 100%;
  border-collapse: collapse;
  min-width: 620px;
  font-size: .92rem;
}
.rtable thead th {
  position: sticky;
  top: 0;
  background: var(--brand-900);
  color: #fff;
  font-family: "Cairo", sans-serif;
  font-weight: 700;
  font-size: .88rem;
  text-align: start;
  padding: 12px 14px;
  white-space: nowrap;
}
[data-bs-theme="dark"] .rtable thead th { background: #16233d; }
.rtable tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  white-space: nowrap;
}
.rtable tbody tr:nth-child(even) { background: var(--surface-2); }
.rtable tbody tr:hover { background: rgba(27, 82, 153, .06); }
.rtable .num { font-variant-numeric: tabular-nums; font-weight: 600; }

/* جدول التقارير التفصيلية — مدمج ومقسّم بالأيام */
.detail-table-wrap {
  max-height: 72vh;
  overflow: auto;
}
.rtable.rtable--dense {
  min-width: 1100px;
  font-size: .72rem;
}
.rtable.rtable--dense thead th {
  font-size: .7rem;
  padding: 6px 8px;
  letter-spacing: 0;
}
.rtable.rtable--dense tbody td,
.rtable.rtable--dense tfoot td {
  padding: 5px 8px;
  font-size: .72rem;
  line-height: 1.35;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rtable.rtable--dense td.cell-clip {
  max-width: 120px;
  white-space: nowrap;
}
.rtable tr.day-group-head td {
  background: var(--brand-900);
  color: #fff;
  font-family: "Cairo", sans-serif;
  font-weight: 700;
  font-size: .78rem;
  padding: 7px 10px;
  border-bottom: none;
  white-space: nowrap;
}
[data-bs-theme="dark"] .rtable tr.day-group-head td { background: #16233d; }
.rtable tr.day-group-head .day-group-count {
  display: inline-block;
  margin-inline-start: .6rem;
  opacity: .85;
  font-weight: 600;
  font-size: .7rem;
}

/* صف مجموع يومي */
.rtable tr.day-subtotal td {
  background: rgba(201, 162, 39, .1);
  font-weight: 700;
  color: var(--text);
  border-bottom: 2px solid var(--gold);
}
[data-bs-theme="dark"] .rtable tr.day-subtotal td { background: rgba(201, 162, 39, .12); }

/* صف المجاميع الكلية */
.rtable tfoot td {
  padding: 12px 14px;
  background: var(--surface-2);
  font-family: "Cairo", sans-serif;
  font-weight: 800;
  border-top: 2px solid var(--brand-600);
  white-space: nowrap;
}
.rtable tfoot tr.grand-total td {
  background: var(--brand-600);
  color: #fff;
}

/* شارات التغيّر لتقرير التباين */
.change-badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-weight: 700; font-size: .84rem;
  padding: 4px 10px; border-radius: 999px;
}
.change-badge.up   { color: var(--status-on);  background: var(--status-on-soft); }
.change-badge.down { color: #dc2626;            background: rgba(220, 38, 38, .12); }
.change-badge.none { color: var(--text-soft);   background: var(--status-off-soft); }
td.val-up   { color: var(--status-on); font-weight: 700; }
td.val-down { color: #dc2626; font-weight: 700; }
td.val-none { color: var(--text-soft); font-weight: 700; }

/* حالة فارغة */
.report-empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-soft);
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}
.report-empty i { font-size: 2.4rem; margin-bottom: 10px; color: var(--status-off); }
.report-empty p { margin: 0; font-weight: 600; }

/* حالة التحميل */
.report-loading {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-soft);
}
.report-loading .spinner-border { color: var(--brand-600); }

/* حالة أولية قبل عرض أي تقرير */
.report-placeholder {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-soft);
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}
.report-placeholder i { font-size: 2.2rem; color: var(--brand-600); opacity: .7; margin-bottom: 10px; }

/* تنبيه تجريبي (Toast) */
.toast-note {
  position: fixed;
  inset-block-end: 22px;
  inset-inline-start: 22px;
  z-index: 1060;
  background: var(--brand-900);
  color: #fff;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 10px;
  font-size: .9rem;
  opacity: 0; transform: translateY(10px);
  transition: opacity .2s ease, transform .2s ease;
  pointer-events: none;
}
.toast-note.show { opacity: 1; transform: translateY(0); }
.toast-note i { color: var(--gold); }

/* =============== طباعة =============== */
@media print {
  .app-sidebar, .app-header, .app-footer,
  .report-tabs, .filter-panel, .report-toolbar,
  .support-fab, .toast-note, .sidebar-overlay { display: none !important; }

  html, body, .app, .app-main {
    overflow: visible !important;
    height: auto !important;
    max-height: none !important;
  }

  .app { display: block !important; }
  .app-main { padding: 0 !important; }
  body { background: #fff !important; }

  .report-table-wrap,
  .detail-table-wrap {
    overflow: visible !important;
    max-height: none !important;
    border: none;
    box-shadow: none;
  }
  .rtable,
  .rtable.rtable--dense {
    min-width: 0 !important;
    width: 100% !important;
  }
  .rtable thead th { position: static !important; }
  .rtable tbody td,
  .rtable.rtable--dense tbody td,
  .rtable.rtable--dense thead th,
  .rtable.rtable--dense tfoot td {
    max-width: none !important;
    overflow: visible !important;
    text-overflow: clip !important;
    white-space: normal !important;
    word-break: break-word !important;
  }
  .rtable.rtable--dense {
    font-size: 7.5pt !important;
  }
  .rtable.rtable--dense thead th,
  .rtable.rtable--dense tbody td,
  .rtable.rtable--dense tfoot td {
    padding: 3px 4px !important;
    font-size: 7.5pt !important;
  }
  .cell-clip {
    max-width: none !important;
    overflow: visible !important;
    white-space: normal !important;
  }

  .stat-card, .report-table-wrap, .rtable thead th,
  .rtable tfoot td, .change-badge {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
  .report-stats { display: grid !important; }
}

/* أداة إخفاء احتياطية (تعمل حتى بدون Bootstrap) */
.d-none { display: none !important; }

/* =====================================================================
   10) قسم صحة الصدور (Verify)
   ===================================================================== */

/* تبويبات مقسّمة (بحث / سجل) */
.seg-tabs {
  display: inline-flex;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px;
  gap: 4px;
  margin-bottom: 20px;
}
.seg-tab {
  border: none;
  background: transparent;
  color: var(--text-soft);
  font-weight: 700;
  font-family: "Cairo", sans-serif;
  font-size: .9rem;
  padding: 8px 18px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: background-color .15s ease, color .15s ease;
}
.seg-tab.active { background: var(--brand-600); color: #fff; }
.seg-tab:not(.active):hover { color: var(--text); }

/* زر طباعة داخل الجدول */
.btn-print {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--brand-700);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 6px 14px;
  font-weight: 700;
  font-size: .84rem;
  cursor: pointer;
  white-space: nowrap;
}
.btn-print:hover { background: var(--brand-800); }

/* منطقة نموذج الطباعة المؤقت (مخفية على الشاشة، تظهر عند الطباعة) */
.verify-print-area { display: none; }

.print-doc { color: #000; font-family: "Cairo", "Tajawal", sans-serif; padding: 24px; max-width: 760px; margin: 0 auto; width: 100%; }
.print-doc, .print-doc * { box-sizing: border-box; }
.print-doc__head {
  text-align: center;
  border-bottom: 3px double #0b2545;
  padding-bottom: 14px;
  margin-bottom: 20px;
}
.print-doc__head img { width: 68px; height: 68px; }
.print-doc__platform { font-size: 1.1rem; font-weight: 800; color: #0b2545; margin: 8px 0 2px; }
.print-doc__title { font-size: 1.35rem; font-weight: 800; margin: 14px 0 0; }
.print-doc__placeholder-note {
  font-size: .8rem; color: #666; margin-top: 4px; font-weight: 600;
}
.print-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2px;
  margin-top: 8px;
}
.print-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 4px;
  border-bottom: 1px dashed #bbb;
}
.print-row .k { font-weight: 700; color: #333; }
.print-row .v { font-weight: 600; color: #000; }
.print-doc__foot {
  margin-top: 28px;
  display: flex;
  justify-content: space-between;
  font-size: .85rem;
  color: #333;
  border-top: 1px solid #999;
  padding-top: 12px;
}
.print-doc__sign { text-align: center; margin-top: 40px; }
.print-doc__sign span { display: block; border-top: 1px solid #000; width: 200px; margin: 40px auto 0; padding-top: 6px; }

/* تنبيه داخل النموذج */
.verify-alert { margin-bottom: 16px; }

/* =============== طباعة صحة الصدور فقط =============== */
@media print {
  body.printing-verify * { visibility: hidden !important; }
  body.printing-verify .verify-print-area,
  body.printing-verify .verify-print-area * { visibility: visible !important; }
  body.printing-verify .verify-print-area {
    display: block !important;
    position: absolute;
    inset-block-start: 0;
    inset-inline: 0;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  body.printing-verify .support-fab,
  body.printing-verify .toast-note { display: none !important; }
}

/* =====================================================================
   11) تحسين طباعة التقارير — خلفية بيضاء + رأس/تذييل + QR
   ===================================================================== */
.report-print-head, .report-print-foot { display: none; }

@media print {
  /* فرض الوضع الفاتح عند الطباعة مهما كان وضع العرض */
  [data-bs-theme="dark"] {
    --bg:#ffffff; --surface:#ffffff; --surface-2:#ffffff; --border:#cfd6e0;
    --text:#111111; --text-soft:#444444; --brand-900:#0b2545;
  }
  html, body { background:#ffffff !important; color:#000 !important; overflow:visible !important; height:auto !important; }
  .app-main { color:#000 !important; overflow:visible !important; }
  .page-head, .seg-tabs, .report-choose-label { display:none !important; }

  .report-table-wrap,
  .detail-table-wrap {
    background:#fff !important;
    overflow: visible !important;
    max-height: none !important;
  }
  .rtable,
  .rtable.rtable--dense {
    min-width: 0 !important;
    width: 100% !important;
  }
  .rtable thead th { background:#eef2f7 !important; color:#0b2545 !important; position:static !important; }
  .rtable tbody td { color:#000 !important; white-space:normal !important; max-width:none !important; overflow:visible !important; }
  .rtable.rtable--dense thead th,
  .rtable.rtable--dense tbody td,
  .rtable.rtable--dense tfoot td {
    white-space: normal !important;
    max-width: none !important;
    overflow: visible !important;
    text-overflow: clip !important;
    word-break: break-word !important;
    font-size: 7.5pt !important;
    padding: 3px 4px !important;
  }
  .rtable tbody tr:nth-child(even) { background:#f6f8fb !important; }
  .rtable tr.day-subtotal td { background:#f4edd7 !important; color:#000 !important; }
  .rtable tr.day-group-head td { background:#0b2545 !important; color:#fff !important; }
  .rtable tfoot td { background:#eef2f7 !important; color:#000 !important; }
  .rtable tfoot tr.grand-total td { background:#dbe4f0 !important; color:#0b2545 !important; }
  .stat-card { background:#fff !important; border:1px solid #cfd6e0 !important; }
  .stat-card .stat-value { color:#0b2545 !important; }
  .report-meta .meta-item { background:#fff !important; border:1px solid #cfd6e0 !important; color:#000 !important; }
  .change-badge.up   { color:#0a7d33 !important; background:#e7f6ec !important; }
  .change-badge.down { color:#b91c1c !important; background:#fdeaea !important; }
  .change-badge.none { color:#444 !important; background:#eee !important; }
  td.val-up { color:#0a7d33 !important; } td.val-down { color:#b91c1c !important; }

  /* رأس الطباعة */
  .report-print-head {
    display:block !important;
    text-align:center;
    margin:0 0 16px;
    padding-bottom:12px;
    border-bottom:2px solid #0b2545;
    color:#000;
  }
  .report-print-head .rp-platform { font-weight:800; color:#0b2545; font-size:15px; font-family:"Cairo",sans-serif; }
  .report-print-head .rp-type { font-weight:800; font-size:19px; margin-top:4px; font-family:"Cairo",sans-serif; }

  /* تذييل الطباعة */
  .report-print-foot {
    display:flex !important;
    justify-content:space-between;
    align-items:center;
    gap:18px;
    margin-top:24px;
    padding-top:12px;
    border-top:1px solid #999;
    color:#000;
    font-size:12px;
    line-height:1.9;
  }
  .report-print-foot .rp-info b { font-weight:800; }
  .report-print-foot .rp-qr { width:92px; height:92px; flex:0 0 auto; }
  .report-print-foot .rp-qr img, .report-print-foot .rp-qr canvas { width:92px !important; height:92px !important; }

  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
}

/* =====================================================================
   12) القائمة الفرعية داخل Sidebar (أنواع التقارير)
   ===================================================================== */
.sidebar-link.has-sub { justify-content: flex-start; }
.sidebar-link .caret {
  margin-inline-start: auto;
  font-size: .78rem;
  transition: transform .2s ease;
  opacity: .8;
}
.sidebar-link.has-sub[aria-expanded="true"] .caret { transform: rotate(-180deg); }

.sidebar-sub {
  list-style: none;
  margin: 2px 0 4px;
  padding: 0;
  overflow: hidden;
  max-height: 0;
  transition: max-height .28s ease;
  /* خط إرشادي على جهة البداية (اليمين في RTL) */
  border-inline-start: 0;
}
.sidebar-sub.open { max-height: 420px; }

.sidebar-sub li { position: relative; }

.sidebar-sublink {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 14px 9px 12px;
  margin-inline-start: 26px;
  border-inline-start: 2px solid rgba(255, 255, 255, .12);
  color: #a9b8d4;
  text-decoration: none;
  font-size: .85rem;
  font-weight: 600;
  line-height: 1.4;
  border-radius: 0 8px 8px 0;
  transition: background-color .15s ease, color .15s ease, border-color .15s ease;
  cursor: pointer;
}
.sidebar-sublink i { font-size: .8rem; width: 14px; text-align: center; opacity: .85; }
.sidebar-sublink:hover {
  background: rgba(255, 255, 255, .05);
  color: #fff;
  border-inline-start-color: var(--gold);
}
.sidebar-sublink.active {
  background: rgba(27, 82, 153, .35);
  color: #fff;
  border-inline-start-color: var(--gold);
}


.loading-overlay { position:fixed; inset:0; background:rgba(6,14,28,.45); z-index:2000; display:none; align-items:center; justify-content:center; color:#fff; }
.loading-overlay.show { display:flex; }
.select2-container { width:100%!important; }
.card-office__action:not(:disabled) { cursor: pointer; opacity: 1; pointer-events: auto; }
.card-office a.card-office__action { color: var(--brand-600); border-color: var(--brand-600); }
.card-office a.card-office__action:hover { background: var(--surface-2); }