:root {
  /* ===== الألوان — الوضع الداكن هو الافتراضي (مطابق للتصميم المرجعي) =====
     ⚠️ ليه هنا في :root نفسها، مش [data-theme="dark"]: عشان أول تحميل
     للصفحة (قبل ما JS يتنفّذ ويحطّ data-theme الفعلي المحفوظ) يبان
     بالوضع الداكن مباشرة بلا أي "وميض" لوني - الافتراضي هنا نفسه
     الافتراضي في ThemeService.CurrentTheme. */
  --bg: #0b101a;
  --surface: #131a28;
  --surface-raised: #1a2233;
  --surface-hover: #212b40;
  --border: #2a3346;
  --border-soft: #202839;

  --text-primary: #e9edf5;
  --text-secondary: #97a1b8;
  --text-muted: #626e88;

  /* إشارة "حيّة" — لحركة المركبات النشطة والاتصال اللحظي */
  --accent-live: #12b89f;
  --accent-live-dim: rgba(18, 184, 159, 0.16);

  /* تنبيهات سلوك القيادة (سرعة، تسارع مفاجئ) */
  --accent-amber: #e3a53a;
  --accent-amber-dim: rgba(227, 165, 58, 0.16);

  /* تنبيهات حرجة (سرقة وقود، خروج من نطاق محظور) */
  --accent-danger: #e2555a;
  --accent-danger-dim: rgba(226, 85, 90, 0.15);

  /* طبقة التسييج الجغرافي */
  --accent-violet: #8c7ef0;
  --accent-violet-dim: rgba(140, 126, 240, 0.16);

  /* حالة التوقف/الخمول */
  --accent-idle: #6b7690;

  --btn-text-on-live: #06231f;

  /* ===== الطباعة ===== */
  --font-display: 'IBM Plex Sans Arabic', 'IBM Plex Sans', sans-serif;
  --font-data: 'IBM Plex Mono', monospace;

  /* ===== القياسات ===== */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --topbar-h: 64px;
}

/* ===== الوضع الفاتح — Override صريح، مش الافتراضي بعد كده ===== */
[data-theme="light"] {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-raised: #f1f3f6;
  --surface-hover: #e8ebf0;
  --border: #dfe3ea;
  --border-soft: #eaedf2;

  --text-primary: #16202e;
  --text-secondary: #5b6579;
  --text-muted: #98a0b0;

  --accent-live: #0d9c8a;
  --accent-live-dim: rgba(13, 156, 138, 0.12);

  --accent-amber: #c47a0e;
  --accent-amber-dim: rgba(196, 122, 14, 0.12);

  --accent-danger: #d13f3f;
  --accent-danger-dim: rgba(209, 63, 63, 0.1);

  --accent-violet: #6d5fd8;
  --accent-violet-dim: rgba(109, 95, 216, 0.12);

  --accent-idle: #8791a3;
}

* {
  box-sizing: border-box;
}

html, body, #root {
  height: 100%;
  margin: 0;
}

html {
  font-size: 16.5px; /* أكبر من افتراضي المتصفح (16px) عشان القراءة تبقى أوضح */
}

body {
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font-display);
  -webkit-font-smoothing: antialiased;
}

button, input, select {
  font-family: inherit;
}

::selection {
  background: var(--accent-live-dim);
}

/* شريط تمرير هادئ يتماشى مع لوحة الألوان */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent-idle); }

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--accent-live);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* ===== الوضع الداكن هو الافتراضي (راجع :root فوق) - [data-theme="light"] بتبدّله ===== */
.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.app-body {
  flex: 1;
  display: flex;
  min-height: 0;
  min-width: 0;
}

.app-main {
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  background: var(--bg);
}

/* ===== شريط علوي ===== */
.topbar {
  height: var(--topbar-h);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border-soft);
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 17px;
  white-space: nowrap;
}

.topbar-brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: block;
  position: relative;
  flex-shrink: 0;
}

.topbar-brand-mark img {
  width: 100%;
  height: 100%;
  border-radius: 8px;
  display: block;
}

.topbar-brand-mark::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 10px;
  border: 2px solid var(--accent-live);
  opacity: 0;
  animation: pulse-ring 2.4s ease-out infinite;
}

.topbar-stats {
  display: flex;
  gap: 8px;
  flex: 1;
  overflow-x: auto;
}

.stat-chip {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
  border: 1px solid var(--border-soft);
  white-space: nowrap;
}

.stat-chip .num {
  font-family: var(--font-data);
  font-size: 15px;
  font-weight: 600;
}

.stat-chip .label {
  font-size: 13px;
  color: var(--text-secondary);
}

.dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.dot-active { background: var(--accent-live); box-shadow: 0 0 0 3px var(--accent-live-dim); }
.dot-idle { background: var(--accent-amber); box-shadow: 0 0 0 3px var(--accent-amber-dim); }
.dot-stopped { background: var(--accent-idle); }
.dot-offline { background: var(--text-muted); }
.dot-maintenance { background: var(--accent-violet); box-shadow: 0 0 0 3px var(--accent-violet-dim); }

/* ===== قائمة إجراءات منسدلة (⋮) - بديل صف أزرار مزدحم ===== */
.actions-menu-wrapper { position: relative; display: inline-block; }
.actions-menu-trigger {
  background: none;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  width: 32px;
  height: 32px;
  font-size: 18px;
  cursor: pointer;
  color: var(--text-primary);
}
.actions-menu-trigger:hover { background: var(--surface-hover); }
.actions-menu-panel {
  position: absolute;
  inset-inline-end: 0;
  top: 36px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.22);
  min-width: 200px;
  z-index: 50;
  padding: 6px;
  animation: toast-in 0.12s ease-out;
}
.actions-menu-item {
  display: block;
  width: 100%;
  text-align: start;
  background: none;
  border: none;
  padding: 8px 10px;
  font-size: 13px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-primary);
  text-decoration: none;
}
.actions-menu-item:hover { background: var(--surface-hover); }
.actions-menu-item.danger { color: var(--accent-danger); }
.actions-menu-divider { height: 1px; background: var(--border-soft); margin: 4px 0; }

.connection-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-family: var(--font-data);
  color: var(--text-secondary);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-soft);
  flex-shrink: 0;
}

.connection-badge .dot-connected {
  background: var(--accent-live);
  box-shadow: 0 0 0 3px var(--accent-live-dim);
  animation: pulse-dot 1.8s ease-in-out infinite;
}
.connection-badge .dot-connecting { background: var(--accent-amber); }
.connection-badge .dot-disconnected { background: var(--accent-danger); }

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

@keyframes pulse-ring {
  0% { transform: scale(1); opacity: 0.9; }
  100% { transform: scale(1.9); opacity: 0; }
}

/* ===== شريط التنقل الجانبي ===== */
.nav-rail {
  width: 230px;
  flex-shrink: 0;
  background: var(--surface);
  border-left: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  padding: 12px 10px;
  gap: 4px;
  overflow-y: auto;
}

/* ⚠️ عمود التنقل يرجع لشكل مصغَّر (أيقونات بس) على شاشات اللابتوب العادية
   (أقل من 1600px) - يحرر مساحة كافية عشان الأعمدة الأربعة في صفحة الخريطة
   تظهر كاملة عند 100% zoom على أي لابتوب/ديسك توب شائع، بدل الاعتماد على
   إخفاء عمود منها. */
@media (max-width: 1600px) {
  .nav-rail {
    width: 64px;
    padding: 12px 6px;
    align-items: center;
  }
  .nav-group-title {
    display: none;
  }
  .nav-item {
    justify-content: center;
    padding: 10px 6px;
  }
  .nav-item span {
    display: none;
  }
}

.nav-group {
  margin-bottom: 6px;
}
.nav-group-title {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 6px 10px 4px;
}

/* ⚠️ تمييز بصري لكل موديول رئيسي - لون خلفية خفيف مختلف لكل قسم، يعزز
   الإحساس بنظام مستقل عند التنقل بين Fleet وWaste رغم أنهما نفس المنصة. */
.nav-module-fleet {
  background: linear-gradient(180deg, rgba(13, 156, 138, 0.05), transparent);
  border-radius: var(--radius-md);
}
.nav-module-waste {
  background: linear-gradient(180deg, rgba(30, 136, 200, 0.05), transparent);
  border-radius: var(--radius-md);
}
.nav-item-home {
  font-weight: 700;
}
.nav-item-more {
  opacity: 0.75;
  border-top: 1px dashed var(--border-soft);
  margin-top: 4px;
  padding-top: 10px;
}

/* شبكة الكروت في صفحات "المزيد"/الإعدادات/لوحة تحكم النفايات */
.more-links-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.more-link-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 20px 12px;
  text-decoration: none;
  color: var(--text-primary);
  text-align: center;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.more-link-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
}
.more-link-icon {
  font-size: 28px;
}
.more-link-label {
  font-size: 13px;
  font-weight: 600;
}

.nav-item {
  width: 100%;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13px;
  font-family: var(--font-display);
  transition: background 0.15s, color 0.15s;
}

.nav-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  transition: color 0.15s;
}

.nav-item:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--accent-live-dim);
  color: var(--accent-live);
  font-weight: 600;
}

/* ===== لوحة القيادة: عمود Saved Views + الفلاتر + الطبقات ===== */
.views-filters-panel .panel-body {
  overflow-y: auto;
}
.panel-section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-soft);
}
.saved-view-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 8px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s;
}
.saved-view-row:hover {
  background: var(--surface-hover);
}
.toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 2px;
  font-size: 12px;
}
.switch {
  position: relative;
  display: inline-block;
  width: 34px;
  height: 18px;
  flex-shrink: 0;
}
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.switch-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--surface-raised);
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  transition: background 0.15s;
}
.switch-slider::before {
  content: "";
  position: absolute;
  height: 12px;
  width: 12px;
  left: 2px;
  top: 2px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: transform 0.15s, background 0.15s;
}
.switch input:checked + .switch-slider {
  background: var(--accent-live-dim);
  border-color: var(--accent-live);
}
.switch input:checked + .switch-slider::before {
  transform: translateX(16px);
  background: var(--accent-live);
}
[dir='rtl'] .switch input:checked + .switch-slider::before {
  transform: translateX(-16px);
}
.switch input:disabled + .switch-slider {
  opacity: 0.4;
  cursor: not-allowed;
}
.saved-view-delete {
  opacity: 0.5;
  font-size: 11px;
  padding: 0 2px;
}
.saved-view-delete:hover {
  opacity: 1;
  color: var(--accent-danger);
}
.saved-view-name-input {
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--accent-live);
  background: var(--surface);
  color: var(--text-primary);
  font-size: 12px;
  width: 160px;
}

.investigation-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 12px;
}
@media (max-width: 900px) {
  .investigation-grid { grid-template-columns: 1fr; }
}
.investigation-timeline {
  max-height: 320px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.alert-cards-strip {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
  flex-wrap: wrap;
  align-items: stretch;
}
.alert-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-soft);
  background: var(--surface);
  min-width: 200px;
}
.alert-card-icon { font-size: 20px; }
.alert-card-body { flex: 1; }
.alert-card-value { font-size: 20px; font-weight: 700; font-family: var(--font-data); line-height: 1.1; }
.alert-card-label { font-size: 11px; color: var(--text-secondary); }
.alert-card-btn {
  background: none;
  border: none;
  color: inherit;
  font-size: 11px;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
  align-self: flex-start;
}
.alert-card.critical { border-color: var(--accent-danger); background: linear-gradient(135deg, var(--accent-danger-dim), var(--surface) 70%); }
.alert-card.critical .alert-card-value { color: var(--accent-danger); }
.alert-card.amber { border-color: var(--accent-amber); background: linear-gradient(135deg, var(--accent-amber-dim), var(--surface) 70%); }
.alert-card.amber .alert-card-value { color: var(--accent-amber); }
.alert-card.live { border-color: var(--accent-live); background: linear-gradient(135deg, var(--accent-live-dim), var(--surface) 70%); }
.alert-card.live .alert-card-value { color: var(--accent-live); }
.alert-card.skeleton { min-width: 200px; height: 56px; background: var(--surface-raised); border-color: transparent; }

.kpi-chip-row {
  display: flex;
  gap: 16px;
  align-items: center;
  padding: 6px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-soft);
  background: var(--surface);
}
.kpi-chip { text-align: center; }
.kpi-chip-value { font-size: 16px; font-weight: 700; font-family: var(--font-data); }
.kpi-chip-label { font-size: 10px; color: var(--text-secondary); }

.dashboard-shell {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  min-width: 0;
  gap: 10px;
  padding: 10px;
  background: radial-gradient(circle at 50% 0%, var(--accent-live-dim), transparent 45%), var(--bg);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 260px 230px 1fr 280px;
  flex: 1;
  min-height: 0;
  min-width: 0;
  gap: 10px;
}

@media (max-width: 1250px) {
  .dashboard-grid {
    grid-template-columns: 240px 1fr 260px;
  }
  .dashboard-grid .views-filters-panel { display: none; }
}

@media (max-width: 1100px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
    grid-template-rows: auto 60vh auto;
  }
}

.dashboard-bottom-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
  height: 220px;
  flex-shrink: 0;
}

@media (max-width: 1500px) {
  .dashboard-bottom-grid {
    grid-template-columns: repeat(3, 1fr);
    height: auto;
  }
}

@media (max-width: 1100px) {
  .dashboard-bottom-grid {
    grid-template-columns: 1fr;
    height: auto;
  }
}

.panel {
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.panel + .panel {
  border-right: 1px solid var(--border-soft);
}

.panel-header {
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.panel-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
}

.panel-body {
  flex: 1;
  overflow: auto;
  padding: 8px;
}

/* ===== قائمة المركبات ===== */
.vehicle-search {
  width: 100%;
  padding: 8px 10px;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  margin-bottom: 8px;
}

.vehicle-card {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid transparent;
  margin-bottom: 4px;
  transition: background 0.12s, border-color 0.12s, transform 0.12s;
}

.vehicle-card:hover {
  background: var(--surface-hover);
  transform: translateX(2px);
}
[dir='rtl'] .vehicle-card:hover {
  transform: translateX(-2px);
}

.vehicle-card.selected {
  background: var(--accent-live-dim);
  border-color: var(--accent-live);
}

.vehicle-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.vehicle-plate {
  font-family: var(--font-data);
  font-weight: 600;
  font-size: 14px;
}

.vehicle-meta {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-secondary);
}

.vehicle-speed {
  font-family: var(--font-data);
}

.empty-state {
  padding: 32px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.7;
}

/* ===== الخريطة ===== */
.map-wrap {
  position: relative;
  flex: 1;
  min-height: 260px;
}

.nearest-panel {
  position: absolute;
  bottom: 12px;
  left: 12px;
  right: 12px;
  max-width: 520px;
  z-index: 500;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  overflow: hidden;
}
.nearest-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  font-weight: 600;
  font-size: 13px;
  border-bottom: 1px solid var(--border-soft);
}
.nearest-panel table { margin: 0; }
.nearest-panel td, .nearest-panel th { padding: 6px 10px; font-size: 12px; }

.map-toolbar {
  position: absolute;
  /* ⚠️ إصلاح: كانت top: 10px - نفس موضع مربع بحث الموقع (fleet-map-search،
     Leaflet Control بـ position: topright في map.js). بما إن MapToolbar
     خارج نظام Leaflet Controls (تكديس تلقائي)، الاتنين كانا يتراكبان بصريًا
     - MapToolbar تظهر تحت/جوا مربع البحث، مش واضحة للمستخدم. المسافة
     الجديدة (56px) تترك مساحة كافية لمربع البحث فوقها (هامش Leaflet
     العلوي 10px + ارتفاع الحقل ~34px + هامش فاصل)، فيتكدسا بترتيب واضح.
  */
  top: 56px;
  right: 10px;
  z-index: 500;
  display: flex;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 6px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
}
.map-toolbar-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  font-family: var(--font-display);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.map-toolbar-btn:hover:not(:disabled) {
  background: var(--surface-hover);
  color: var(--text-primary);
}
.map-toolbar-btn.active {
  background: var(--accent-live-dim);
  border-color: var(--accent-live);
  color: var(--accent-live);
}
.map-toolbar-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.map-wrap .leaflet-container {
  width: 100%;
  height: 100%;
  background: #e9edf1;
}

.vehicle-marker {
  position: relative;
  width: 18px;
  height: 18px;
}

.vehicle-marker-core {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  position: absolute;
  top: 3px;
  right: 3px;
  border: 2px solid var(--bg);
  z-index: 2;
}

.vehicle-marker-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid currentColor;
  animation: pulse-ring 2.2s ease-out infinite;
  z-index: 1;
}

.vehicle-marker.status-active { color: var(--accent-live); }
.vehicle-marker.status-active .vehicle-marker-core { background: var(--accent-live); }
.vehicle-marker.status-idle { color: var(--accent-amber); }
.vehicle-marker.status-idle .vehicle-marker-core { background: var(--accent-amber); }
.vehicle-marker.status-stopped { color: var(--accent-idle); }
.vehicle-marker.status-stopped .vehicle-marker-core { background: var(--accent-idle); }
.vehicle-marker.status-stopped .vehicle-marker-ring { display: none; }

/* ⚠️ إصلاح فجوة تصميمية: Leaflet Popup الافتراضية بيضاء بشكل صريح بلا
   Override خالص - كانت بتظهر كـ"جزيرة بيضاء" مفاجئة وسط الثيم الداكن
   بالكامل. Override كامل يستخدم متغيرات الثيم، فيشتغل صح تلقائيًا في
   الوضعين الداكن والفاتح بلا تكرار. */
.leaflet-popup-content-wrapper {
  background: var(--surface);
  color: var(--text-primary);
  border-radius: var(--radius-md);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}
.leaflet-popup-content {
  margin: 12px 14px;
}
.leaflet-popup-tip {
  background: var(--surface);
}
.leaflet-popup-close-button {
  color: var(--text-secondary) !important;
}
.leaflet-popup-close-button:hover {
  color: var(--text-primary) !important;
}

.map-popup {
  font-family: var(--font-display);
  min-width: 220px;
}

.map-popup .plate { font-family: var(--font-data); font-weight: 600; }

.map-popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 2px;
}
.map-popup-header .plate { font-size: 14px; }
.map-popup-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--text-secondary);
}
.map-popup-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.map-popup-grid {
  display: flex;
  flex-direction: column;
  gap: 4px;
  border-top: 1px solid var(--border-soft);
  padding-top: 6px;
}
.map-popup-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
}
.map-popup-row > span:first-child {
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 5px;
}
.map-popup-row > span:last-child {
  color: var(--text-primary);
  font-weight: 500;
  text-align: end;
}

/* ===== تغذية الأحداث اللحظية ===== */
.mini-stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-soft);
  font-size: 13px;
}
.mini-stat-row:last-child {
  border-bottom: none;
}

.mini-stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  height: 100%;
}
.mini-stat-card {
  background: var(--surface-raised);
  border-radius: var(--radius-sm);
  padding: 10px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
}
.mini-stat-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  font-family: var(--font-data);
}
.mini-stat-label {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.vd-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.vd-thumb {
  font-size: 40px;
  line-height: 1;
}
.vd-title {
  margin-bottom: 14px;
}
.vd-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border-soft);
}
.vd-tabs button {
  flex: 1;
  padding: 7px 4px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  font-size: 11px;
  font-family: var(--font-display);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.vd-tabs button:hover {
  color: var(--text-primary);
}
.vd-tabs button.active {
  color: var(--accent-live);
  border-bottom-color: var(--accent-live);
  font-weight: 600;
}
.vd-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}
.vd-plate {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}
.vd-rows {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.vd-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 0;
  border-bottom: 1px solid var(--border-soft);
  font-size: 13px;
}
.vd-row span:first-child {
  color: var(--text-secondary);
}
.vd-row span:last-child {
  color: var(--text-primary);
}
.vd-active-task {
  background: var(--accent-amber-dim);
  border: 1px solid var(--accent-amber);
  border-radius: var(--radius-sm);
  padding: 10px;
  margin-top: 12px;
}
.vd-active-task-header {
  font-weight: 600;
  font-size: 13px;
}

.vd-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
}
.vd-actions .btn,
.vd-actions .btn.secondary {
  width: 100%;
}

.feed-item {
  display: flex;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 4px;
  animation: feed-in 0.35s ease-out;
  border-inset-inline-start: 2px solid transparent;
}

.timeline-item {
  display: flex;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 4px;
  animation: feed-in 0.35s ease-out;
  border-inset-inline-start: 2px solid transparent;
  cursor: pointer;
  transition: background 0.15s;
}
.timeline-item:hover {
  background: var(--surface-hover);
}

@keyframes feed-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.feed-icon {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.feed-icon.sev-danger { background: var(--accent-danger-dim); color: var(--accent-danger); }
.feed-icon.sev-amber { background: var(--accent-amber-dim); color: var(--accent-amber); }
.feed-icon.sev-violet { background: var(--accent-violet-dim); color: var(--accent-violet); }
.feed-icon.sev-idle { background: var(--surface-raised); color: var(--text-secondary); }

.feed-label { font-size: 14px; font-weight: 500; }
.feed-sub {
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--font-data);
  margin-top: 2px;
}

/* ===== صفحات عامة (التسييج، التقارير) ===== */
.page {
  padding: 24px 32px;
  max-width: 1400px;
  margin: 0 auto; /* توسيط على الشاشات الكبيرة بدل ما يفضل المحتوى ملزّق ناحية وسايب فراغ ضخم */
  width: 100%;
  min-height: 100%;
}

@media (min-width: 1600px) {
  .page { max-width: 1600px; }
}

/* خلفيات مميِّزة لكل قسم - تدرّج خفيف جدًا بلون العلامة المرتبطة بطبيعة الصفحة،
   بحيث القسم يتعرّف عليه المستخدم بصريًا فورًا من غير ما يأثر على وضوح القراءة. */
.page-map {
  background: radial-gradient(circle at 100% 0%, var(--accent-live-dim), transparent 45%), var(--bg);
}
.page-operations {
  background: radial-gradient(circle at 100% 0%, var(--accent-amber-dim), transparent 45%), var(--bg);
}
.page-geofences {
  background: radial-gradient(circle at 100% 0%, var(--accent-violet-dim), transparent 45%), var(--bg);
}
.page-trips, .page-replay {
  background: radial-gradient(circle at 100% 0%, var(--accent-live-dim), transparent 45%), var(--bg);
}
.page-reports {
  background: radial-gradient(circle at 100% 0%, rgba(109, 95, 216, 0.06), transparent 45%), var(--bg);
}
.page-vehicles {
  background: radial-gradient(circle at 100% 0%, rgba(13, 156, 138, 0.06), transparent 45%), var(--bg);
}
.page-devices {
  background: radial-gradient(circle at 100% 0%, rgba(196, 122, 14, 0.06), transparent 45%), var(--bg);
}
.page-drivers {
  background: radial-gradient(circle at 100% 0%, rgba(30, 136, 200, 0.06), transparent 45%), var(--bg);
}
.page-users {
  background: radial-gradient(circle at 100% 0%, rgba(109, 95, 216, 0.06), transparent 45%), var(--bg);
}
.page-wasl {
  background: radial-gradient(circle at 100% 0%, rgba(13, 156, 138, 0.07), transparent 45%), var(--bg);
}
.page-scores {
  background: radial-gradient(circle at 100% 0%, var(--accent-amber-dim), transparent 45%), var(--bg);
}
.page-kpis {
  background: radial-gradient(circle at 100% 0%, rgba(13, 156, 138, 0.06), transparent 45%), var(--bg);
}

.page-header {
  margin-bottom: 20px;
}

.page-title {
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 4px;
}

.page-subtitle {
  color: var(--text-secondary);
  font-size: 14px;
  margin: 0;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 18px;
  margin-bottom: 16px;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.field label {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

/* علامة الحقل الإلزامي: أضف class="req" على الـ label */
label.req::after {
  content: " *";
  color: var(--danger, #e5484d);
  font-weight: 700;
}

.field input, .field select {
  width: 100%;
  padding: 9px 10px;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
}

.btn {
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--accent-live);
  color: var(--btn-text-on-live);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: filter 0.15s;
}

.btn:hover { filter: brightness(1.08); }
.btn.secondary {
  background: var(--surface-raised);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th {
  text-align: right;
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 13px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-soft);
}

td {
  padding: 10px;
  border-bottom: 1px solid var(--border-soft);
}

td.mono, th.mono { font-family: var(--font-data); }

.tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border-soft);
}

.tab {
  padding: 9px 16px;
  font-size: 14px;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
}

.tab.active {
  color: var(--text-primary);
  border-bottom-color: var(--accent-live);
}

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 12px;
  font-family: var(--font-data);
}

.badge.on { background: var(--accent-live-dim); color: var(--accent-live); }
.badge.off { background: var(--surface-raised); color: var(--text-muted); }
.badge.warn { background: var(--accent-amber-dim); color: var(--accent-amber); }
.badge.critical { background: rgba(239,68,68,.12); color: #ef4444; }
.badge.high { background: rgba(249,115,22,.12); color: #f97316; }
.badge.medium { background: rgba(234,179,8,.12); color: #eab308; }
.badge.low { background: rgba(59,130,246,.12); color: #3b82f6; }
.badge.purple { background: rgba(168,85,247,.12); color: #a855f7; }

/* قائمة إجراءات أوامر الشغل (⋮) */
.wo-actions-menu { position: relative; display: inline-block; }
.wo-actions-menu summary::-webkit-details-marker { display: none; }
.wo-actions-menu summary { font-size: 18px; line-height: 1; padding: 4px 10px; }
.wo-actions-dropdown {
    position: absolute;
    inset-inline-end: 0;
    top: 100%;
    z-index: 50;
    background: var(--surface-raised, #fff);
    border: 1px solid var(--border-color, #eee);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,.12);
    min-width: 160px;
    padding: 4px;
    display: flex;
    flex-direction: column;
}
.wo-actions-dropdown button {
    background: none;
    border: none;
    text-align: start;
    padding: 8px 10px;
    font-size: 13px;
    border-radius: 4px;
    cursor: pointer;
    white-space: nowrap;
}
.wo-actions-dropdown button:hover { background: var(--surface-hover, #f5f5f5); }

/* قائمة الفلاتر المتقدمة المنسدلة - موحَّدة عبر المركبات والسائقين والرحلات */
.advanced-filters-dropdown {
    position: absolute;
    inset-inline-end: 0;
    top: 100%;
    margin-top: 6px;
    z-index: 60;
    background: var(--surface-raised, #fff);
    border: 1px solid var(--border-color, #eee);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,.16);
    padding: 16px;
    width: min(600px, 92vw);
    max-width: calc(100vw - 32px);
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 10px;
}
.advanced-filters-dropdown .field { max-width: none; }

.replay-marker-animated { transition: transform 0.18s linear; }

.map-type-switch {
    display: flex;
    background: var(--surface-raised, #fff);
    border: 1px solid var(--border-color, #eee);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
.map-type-switch button {
    border: none;
    background: transparent;
    padding: 6px 12px;
    font-size: 12px;
    cursor: pointer;
    color: var(--text-secondary, #5b6579);
    border-inline-start: 1px solid var(--border-color, #eee);
}
.map-type-switch button:first-child { border-inline-start: none; }
.map-type-switch button.active { background: var(--accent-primary, #2dd4bf); color: #fff; font-weight: 600; }
.advanced-filters-actions {
    grid-column: 1 / -1;
    display: flex;
    gap: 8px;
    padding-top: 10px;
    margin-top: 4px;
    border-top: 1px solid var(--border-color, #eee);
}

/* Timeline صفحة تفاصيل أمر الشغل */
.wo-timeline { display: flex; flex-direction: column; }
.wo-timeline-step { display: flex; align-items: flex-start; gap: 10px; position: relative; padding-bottom: 20px; }
.wo-timeline-step:last-child { padding-bottom: 0; }
.wo-timeline-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent-primary, #2dd4bf); margin-top: 4px; flex-shrink: 0; position: relative; z-index: 1; }
.wo-timeline-step:not(:last-child)::before {
    content: '';
    position: absolute;
    inset-inline-start: 4px;
    top: 14px;
    bottom: 0;
    width: 2px;
    background: var(--border-color, #e5e5e5);
}
.wo-timeline-content { font-size: 13px; }

/* ===== صفحة تسجيل الدخول ===== */
.login-shell {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 30% 20%, rgba(45, 212, 191, 0.08), transparent 55%), var(--bg);
  position: relative;
  overflow: hidden;
}

.login-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
}
.login-bg svg {
  width: 100%;
  height: 100%;
}

.login-card {
  position: relative;
  z-index: 1;
  width: 340px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 28px;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 18px;
  margin-bottom: 6px;
}

.login-subtitle {
  color: var(--text-secondary);
  font-size: 14px;
  margin: 0 0 20px;
}

.login-error {
  background: var(--accent-danger-dim);
  color: var(--accent-danger);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 14px;
}

.theme-toggle {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-soft);
  background: var(--surface-raised);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.theme-toggle:hover { color: var(--text-primary); }

.logout-btn {
  background: none;
  border: 1px solid var(--border-soft);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
  flex-shrink: 0;
}
.logout-btn:hover { color: var(--accent-danger); border-color: var(--accent-danger); }

/* ===== فلتر حالة المركبات ===== */
.status-filter {
  display: flex;
  gap: 4px;
  margin-bottom: 8px;
}

.status-filter button {
  flex: 1;
  padding: 5px 4px;
  font-size: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-soft);
  background: var(--surface-raised);
  color: var(--text-secondary);
  cursor: pointer;
}

.status-filter button.active {
  background: var(--accent-live-dim);
  color: var(--accent-live);
  border-color: var(--accent-live);
}

/* ===== شريط تقدم درجة السائق ===== */
.score-bar-track {
  width: 100%;
  height: 8px;
  border-radius: 4px;
  background: var(--surface-raised);
  overflow: hidden;
}
.score-bar-fill { height: 100%; border-radius: 4px; }

/* ===== بطاقات KPI ===== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 16px;
}

.kpi-value {
  font-family: var(--font-data);
  font-size: 26px;
  font-weight: 600;
}

.kpi-label {
  color: var(--text-secondary);
  font-size: 13px;
  margin-top: 4px;
}

/* ===== شريط تشغيل الرحلة ===== */
.replay-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--surface);
  border-top: 1px solid var(--border-soft);
}

.replay-controls input[type='range'] {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  cursor: pointer;
}

.trip-day-selected {
  background: var(--accent-primary, #2563eb);
  color: #fff;
}

.trip-day-has-trips {
  background: var(--surface-raised);
}
.trip-day-has-trips:hover {
  background: var(--accent-primary, #2563eb);
  color: #fff;
  opacity: .85;
}

/* ⚠️ النقطة القابلة للسحب - دائرة بارزة واضحة بلون مميَّز، بدل النقطة
   الرمادية الافتراضية الصغيرة للمتصفح. تكبير خفيف عند التفاعل يعزّز
   الشعور بأنها تفاعلية فعليًا، لا مجرد خط ثابت. */
.replay-controls input[type='range']::-webkit-slider-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-primary, #2563eb);
  border: 3px solid var(--surface);
  box-shadow: 0 1px 4px rgba(0,0,0,.35);
  cursor: grab;
  transition: transform .12s ease;
}
.replay-controls input[type='range']:active::-webkit-slider-thumb {
  transform: scale(1.25);
  cursor: grabbing;
}
.replay-controls input[type='range']::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-primary, #2563eb);
  border: 3px solid var(--surface);
  box-shadow: 0 1px 4px rgba(0,0,0,.35);
  cursor: grab;
  transition: transform .12s ease;
}
.replay-controls input[type='range']:active::-moz-range-thumb {
  transform: scale(1.25);
  cursor: grabbing;
}

/* ===== شاشة تحميل أولية أثناء استعادة الجلسة ===== */
.boot-screen {
  height: 100vh;
  background: var(--bg);
}

/* ===== أدوات الخريطة الإضافية (بحث، تحديد الموقع، ملء الشاشة) ===== */
.fleet-map-btn {
  background: var(--surface) !important;
  color: var(--text-primary) !important;
  width: 30px;
  height: 30px;
  font-size: 15px;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.fleet-map-btn:hover { background: var(--surface-hover) !important; }

.fleet-map-search {
  background: var(--surface);
  border-radius: var(--radius-sm);
  box-shadow: 0 1px 5px rgba(0,0,0,0.4);
}
.fleet-map-search input {
  border: none;
  background: transparent;
  color: var(--text-primary);
  padding: 7px 10px;
  font-size: 14px;
  width: 190px;
  outline: none;
}

.leaflet-control-layers {
  background: var(--surface) !important;
  color: var(--text-primary) !important;
}
.leaflet-control-scale-line {
  background: var(--surface) !important;
  color: var(--text-primary) !important;
  border-color: var(--border) !important;
}
.leaflet-control-zoom a {
  background: var(--surface) !important;
  color: var(--text-primary) !important;
  border-color: var(--border-soft) !important;
}
.leaflet-control-zoom a:hover {
  background: var(--surface-hover) !important;
}
.leaflet-control-attribution {
  background: color-mix(in srgb, var(--surface) 75%, transparent) !important;
  color: var(--text-muted) !important;
}
.leaflet-control-attribution a {
  color: var(--text-secondary) !important;
}

/* ===== جرس الإشعارات ===== */
.notif-bell-wrap { position: relative; flex-shrink: 0; }
.notif-bell {
  width: 34px; height: 34px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-soft);
  background: var(--surface-raised);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  position: relative;
}
.notif-bell:hover { color: var(--text-primary); }
.notif-badge {
  position: absolute;
  top: -4px; right: -4px;
  background: var(--accent-danger);
  color: white;
  font-size: 11px;
  font-family: var(--font-data);
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 3px;
}
.notif-dropdown {
  position: absolute;
  top: 42px;
  left: 0;
  width: 320px;
  max-height: 400px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  z-index: 1000;
  padding: 8px;
}
.notif-dropdown-header {
  font-size: 13px;
  color: var(--text-secondary);
  padding: 6px 8px 10px;
  display: flex;
  justify-content: space-between;
}

/* ===== شارة عدد المركبات في القائمة ===== */
.vehicle-owner-tag {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.ai-assistant-box {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border-soft);
}
.ai-quick-btn {
  display: block;
  width: 100%;
  text-align: right;
  padding: 7px 10px;
  margin-bottom: 4px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-soft);
  background: var(--surface-raised);
  color: var(--text-secondary);
  font-size: 11px;
  font-family: var(--font-display);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
[dir='ltr'] .ai-quick-btn { text-align: left; }
.ai-quick-btn:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

/* ===== زر تبديل اللغة ===== */
.lang-toggle {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-soft);
  background: var(--surface-raised);
  color: var(--text-secondary);
  cursor: pointer;
  font-family: var(--font-data);
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.lang-toggle:hover {
  color: var(--accent-live);
  border-color: var(--accent-live);
}
.icon-toggle-btn {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-soft);
  background: var(--surface-raised);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, background 0.15s;
}
.icon-toggle-btn:hover {
  border-color: var(--accent-live);
  background: var(--surface-hover);
}

/* ===== لمسات احترافية عامة ===== */

/* انتقالات سلسة على كل التفاعلات بدل التغيّر المفاجئ */
.btn, .btn.secondary, .nav-item, .tab, .vehicle-card, .stat-chip,
.status-filter button, .theme-toggle, .logout-btn {
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, filter 0.15s ease, transform 0.1s ease;
}

.btn:active { transform: scale(0.97); }
.btn.secondary:hover { border-color: var(--accent-live); }

/* ظل خفيف على البطاقات لإحساس أعمق بالطبقات بدل تسطّح كامل */
.card, .kpi-card, .login-card {
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15), 0 4px 16px rgba(0, 0, 0, 0.12);
}

/* صفوف الجدول بتتفاعل مع الماوس - إحساس أكثر احترافية من جدول ساكن */
tbody tr {
  transition: background-color 0.12s ease;
}
tbody tr:hover {
  background: var(--surface-raised);
}

/* عنوان الصفحة بخط أوضح شوية */
.page-title {
  letter-spacing: -0.01em;
}

/* بطاقات KPI بحدود أوضح شوية عند التحويم - تحسّ إنها قابلة للتفاعل */
.kpi-card {
  transition: border-color 0.15s ease, transform 0.15s ease;
  cursor: pointer;
}
.kpi-card:hover {
  border-color: var(--accent-live);
  transform: translateY(-1px);
}
.kpi-card.kpi-card-active {
  border-color: var(--accent-live);
  background: var(--accent-live-dim);
}

/* شاشة الإقلاع بنبضة خفيفة بدل فراغ ساكن تمامًا */
.boot-screen {
  display: flex;
  align-items: center;
  justify-content: center;
}
.boot-screen::after {
  content: '';
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid var(--border);
  border-top-color: var(--accent-live);
  animation: boot-spin 0.9s linear infinite;
}
@keyframes boot-spin {
  to { transform: rotate(360deg); }
}

/* بطاقة تسجيل الدخول بخلفية متدرّجة خفيفة لإحساس أعمق بدل لون مسطّح */
.login-card {
  background: linear-gradient(160deg, var(--surface) 0%, var(--surface-raised) 100%);
}

/* دعم LTR: بعض العناصر تحتاج انعكاس اتجاه الأيقونات/الهوامش عند English */
html[dir='ltr'] .vehicle-card-top,
html[dir='ltr'] .stat-chip {
  direction: ltr;
}

/* ===== تقسيم الصفحات ===== */
.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 14px 0 4px;
}
.pager .btn.secondary {
  padding: 5px 14px;
  font-size: 15px;
  line-height: 1;
}
.pager-info {
  font-size: 12px;
  color: var(--text-secondary);
  font-family: var(--font-data);
}
.pager-total {
  color: var(--text-muted);
}

/* ===== أعمدة جدول قابلة للترتيب ===== */
th.sortable {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
th.sortable:hover {
  color: var(--text-primary);
}
th.sortable .sort-arrow {
  display: inline-block;
  margin-inline-start: 4px;
  font-size: 10px;
  opacity: 0.6;
}

/* ===== إشعارات عائمة (Toast) ===== */
.toast-stack {
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 340px;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid var(--border-soft);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.14);
  font-size: 13px;
  animation: toast-in 0.2s ease-out;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.toast-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}
.toast-success .toast-icon { background: var(--accent-live-dim); color: var(--accent-live); }
.toast-error .toast-icon { background: var(--accent-danger-dim); color: var(--accent-danger); }
.toast-info .toast-icon { background: var(--surface-raised); color: var(--text-secondary); }

.toast-message { flex: 1; color: var(--text-primary); }

.toast-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  padding: 0;
  flex-shrink: 0;
}
.toast-close:hover { color: var(--text-primary); }

/* ===== حوار تأكيد/إدخال مصمَّم ===== */
.dialog-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 24, 32, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2100;
  animation: toast-in 0.15s ease-out;
}

.dialog-box {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 22px;
  width: 340px;
  max-width: 90vw;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}

.dialog-title {
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 8px;
}

.dialog-message {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 14px;
  line-height: 1.6;
}

/* ===== Drawer جانبي - لفورم كبير متعدد الأقسام (بديل Modal المركزي للفورم الطويلة) ===== */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 24, 32, 0.45);
  display: flex;
  justify-content: flex-end;
  z-index: 2100;
  animation: toast-in 0.15s ease-out;
}

.drawer-panel {
  background: var(--surface);
  width: 640px;
  max-width: 94vw;
  height: 100vh;
  overflow-y: auto;
  box-shadow: -12px 0 40px rgba(0, 0, 0, 0.25);
  padding: 20px;
  animation: drawer-slide-in 0.2s ease-out;
}

.drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-soft);
}

@keyframes drawer-slide-in {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

@media (max-width: 720px) {
  .drawer-panel { width: 100vw; }
}

.dialog-input {
  width: 100%;
  padding: 9px 10px;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  margin-bottom: 16px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ================================================================
   تحسينات الجوال (Responsive) - شاشات أصغر من 768px
   ================================================================ */
@media (max-width: 768px) {
  html { font-size: 15px; }

  /* الشريط العلوي: يلف على سطرين بدل ما يتزاحم أفقيًا */
  .topbar {
    height: auto;
    min-height: var(--topbar-h);
    flex-wrap: wrap;
    padding: 8px 12px;
    gap: 8px;
  }
  .topbar-stats {
    order: 3;
    width: 100%;
    flex-basis: 100%;
  }
  .topbar-brand { font-size: 14px; }
  .connection-badge { display: none; } /* مساحة محدودة - الحالة موجودة أصلًا في جرس الإشعارات وشرائح الحالة */

  /* الجسم: المحتوى فوق، شريط التنقل يتحوّل لشريط سفلي أفقي */
  .app-body {
    flex-direction: column;
  }

  .nav-rail {
    order: 2;
    width: 100%;
    flex-direction: row;
    overflow-x: auto;
    padding: 6px 8px;
    border-left: none;
    border-top: 1px solid var(--border-soft);
    gap: 2px;
  }
  .nav-group {
    display: contents; /* المجموعات تنضم مباشرة للصف الأفقي، بلا تكوّم عمودي داخل كل مجموعة */
  }
  .nav-group-title {
    display: none; /* عناوين المجموعات مش منطقية في شريط أفقي رفيع بمساحة محدودة */
  }
  .nav-item {
    flex-direction: column; /* عمودي صراحةً - كانت بترث row من التعريف الأساسي بعد إعادة تصميم Listview */
    flex-shrink: 0;
    width: auto;
    min-width: 60px;
    font-size: 10px;
    padding: 6px 8px;
    gap: 4px;
  }
  .nav-item svg { width: 18px; height: 18px; }

  .app-main { order: 1; }

  /* الصفحات والبطاقات: هوامش أضيق على شاشة صغيرة */
  .page { padding: 14px; }
  .card { padding: 14px; }
  .page-title { font-size: 18px; }

  /* لوحة الخريطة: عمود واحد بدل ثلاثة أعمدة جنب بعض */
  .dashboard-grid {
    grid-template-columns: 1fr;
    grid-template-rows: 45vh 40vh auto;
  }

  /* الجداول: تمرير أفقي بدل تكسير التخطيط */
  .card:has(table) {
    overflow-x: auto;
  }
  table { min-width: 560px; }

  /* الحقول: عمود واحد دايمًا */
  .form-row {
    grid-template-columns: 1fr;
  }

  /* الحوار والإشعارات العائمة: تاخد عرض الشاشة تقريبًا */
  .dialog-box { width: 92vw; }
  .toast-stack {
    left: 10px;
    right: 10px;
    max-width: none;
    bottom: 70px; /* فوق شريط التنقل السفلي */
  }

  /* أزرار الإجراءات في الجداول تتلف بدل ما تتزاحم */
  td[style*="flex"] { flex-wrap: wrap; }
}

/* شاشات صغيرة جدًا (موبايل ضيق) */
@media (max-width: 420px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .topbar-brand span:last-child { display: none; } /* الاسم النصي يختفي، الشعار يفضل بس */
}

/* ===== عناصر تحكم Google Maps الإضافية ===== */
.fleet-gmap-btn {
  background: #fff;
  border: none;
  border-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
  width: 40px;
  height: 40px;
  margin: 10px;
  font-size: 18px;
  cursor: pointer;
}
.fleet-gmap-btn.active {
  background: var(--accent-live-dim);
}

.fleet-gmap-search {
  margin: 10px;
  padding: 8px 12px;
  width: 240px;
  border: none;
  border-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
  font-family: var(--font-display);
  font-size: 13px;
}

/* ===== بانر خطأ موحَّد (Shared/ErrorBanner.razor) ===== */
.error-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: var(--accent-danger-dim);
  border: 1px solid rgba(209, 63, 63, 0.25);
  color: var(--accent-danger);
  font-size: 13px;
  margin-bottom: 16px;
}
.error-banner-icon {
  flex-shrink: 0;
  font-size: 16px;
}
.error-banner-text {
  flex: 1;
  line-height: 1.6;
}

/* ===== بحث عام فوري (Global Search) ===== */
.global-search-wrap {
  position: relative;
  flex-shrink: 0;
  width: 220px;
}
.global-search-icon {
  position: absolute;
  inset-inline-start: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  opacity: 0.5;
  pointer-events: none;
}
.global-search-input {
  width: 100%;
  padding: 7px 10px 7px 30px;
  padding-inline-start: 30px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-raised);
  font-size: 12px;
  color: var(--text-primary);
}
.global-search-input:focus {
  border-color: var(--accent-live);
  background: var(--surface);
}
.global-search-results {
  position: absolute;
  top: calc(100% + 6px);
  inset-inline-start: 0;
  width: 280px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  z-index: 500;
  max-height: 320px;
  overflow-y: auto;
}
.global-search-result {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  font-size: 13px;
  cursor: pointer;
  border-bottom: 1px solid var(--border-soft);
}
.global-search-result:last-child { border-bottom: none; }
.global-search-result:hover { background: var(--surface-hover); }
.global-search-result-sub {
  margin-inline-start: auto;
  color: var(--text-muted);
  font-size: 11px;
}
.global-search-empty {
  padding: 14px;
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
}

/* ===== أفاتار المستخدم ===== */
.user-menu {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-live), #0a7d70);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

/* ===== Skeleton Loader (بديل نص "جارٍ التحميل") ===== */
.skeleton-row td {
  padding: 10px 12px;
}
.skeleton-block {
  height: 14px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--surface-raised) 25%, var(--surface-hover) 50%, var(--surface-raised) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s ease-in-out infinite;
}
@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ===== حالة فراغ محسَّنة (Empty State) ===== */
.empty-state-rich {
  text-align: center;
  padding: 36px 20px;
  color: var(--text-muted);
}
.empty-state-rich-icon {
  font-size: 32px;
  margin-bottom: 10px;
  opacity: 0.5;
}
.empty-state-rich-title {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}
.empty-state-rich-sub {
  font-size: 12px;
  margin-bottom: 14px;
}

/* ===== مبدّل الشركات (للمدير العام) ===== */
.tenant-switcher {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  background: var(--accent-violet-dim);
  border: 1px solid rgba(109, 95, 216, 0.3);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
}
.tenant-switcher-icon { font-size: 13px; }
.tenant-switcher select {
  border: none;
  background: transparent;
  font-size: 12px;
  color: var(--accent-violet);
  font-weight: 600;
  max-width: 140px;
}

/* ===== علامات ثابتة على الخريطة (حاويات النظافة) ===== */
.fixed-marker { background: none; border: none; }
.fixed-marker-inner {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  background: var(--accent-idle);
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}
.fixed-marker.status-full .fixed-marker-inner { background: var(--accent-danger); }
.fixed-marker.status-visitedpending .fixed-marker-inner { background: var(--accent-amber); }
.fixed-marker.status-empty .fixed-marker-inner { background: var(--accent-live); }
.fixed-marker.status-danger .fixed-marker-inner { background: var(--accent-danger); }
.fixed-marker.status-amber .fixed-marker-inner { background: var(--accent-amber); }
.fixed-marker.status-violet .fixed-marker-inner { background: var(--accent-violet); }
.fixed-marker.status-active .fixed-marker-inner { background: var(--accent-live); }
.fixed-marker.status-idle .fixed-marker-inner { background: var(--accent-idle); }

/* ===== حاجز انتهاء الاشتراك (كامل الشاشة) ===== */
.subscription-blocked-shell {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}
.subscription-blocked-card {
  width: 380px;
  max-width: 90vw;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
}
.subscription-blocked-card h2 {
  font-size: 17px;
  margin-bottom: 8px;
  color: var(--text-primary);
}
.subscription-blocked-card p {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.7;
}

/* ===== رابط التسجيل/الدخول أسفل البطاقة ===== */
.signup-hint {
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 14px;
}
.signup-hint a {
  color: var(--accent-live);
  font-weight: 600;
  margin-inline-start: 4px;
}

/* ===== خطط الاشتراك في صفحة الشركات ===== */
.trial-days-left {
  font-size: 10px;
  color: var(--accent-amber);
  margin-top: 3px;
}
.plan-select {
  display: block;
  margin-top: 6px;
  font-size: 11px;
  padding: 2px 4px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-soft);
  background: var(--surface);
}

/* ===== محرّر شجرة القواعد (IF/THEN) ===== */
.rule-node {
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  margin-bottom: 8px;
  background: var(--surface);
}
.rule-node-group {
  border-color: rgba(109, 95, 216, 0.35);
  background: var(--accent-violet-dim);
}
.rule-node-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.rule-node-fields {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 13px;
}
.rule-node-remove {
  margin-inline-start: auto;
  padding: 2px 8px !important;
  font-size: 12px;
}
.rule-node-children {
  margin-inline-start: 20px;
  margin-top: 8px;
  padding-inline-start: 12px;
  border-inline-start: 2px dashed var(--border-soft);
}
.rule-actions-list .rule-node { max-width: 420px; }

/* ===== قائمة اختيار المركبات المتعددة (Multi-Select) - التسييج الجغرافي ===== */
/* ⚠️ إصلاح تصميمي: <select multiple> كانت بلا أي تنسيق خالص (تظهر بالتنسيق
   الافتراضي الأبيض للمتصفح - يتعارض بشكل صارخ مع الـDark Theme)، ومعندهاش
   display:block صريحة (الافتراضي inline-block يخلّيها تحاول تترصف جنب
   العنصر السابق بدل النزول لسطر منفصل). تنسيق مخصَّص هنا لأن احتياجات
   <select multiple> مختلفة عن .field select العادية (ارتفاع لعرض عدة
   صفوف، تنسيق لكل option عند التحديد، Scrollbar متسق مع الـTheme). */
.vehicle-multiselect {
  display: block;
  width: 100%;
  min-height: 160px;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  padding: 6px;
  overflow-y: auto;
}

.vehicle-multiselect option {
  padding: 8px 10px;
  border-radius: 4px;
  margin-bottom: 2px;
  cursor: pointer;
}

.vehicle-multiselect option:checked {
  background: var(--accent-live);
  color: var(--btn-text-on-live);
}

.vehicle-multiselect:focus-visible {
  outline: 2px solid var(--accent-live);
  outline-offset: 1px;
}

/* ===== مفتاح تبديل (Toggle Switch) - إدارة اشتراكات الموديولات ===== */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 24px;
  transition: background 0.2s;
}

.toggle-slider::before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 2px;
  bottom: 2px;
  background: var(--text-secondary);
  border-radius: 50%;
  transition: transform 0.2s, background 0.2s;
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--accent-live);
  border-color: var(--accent-live);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(20px);
  background: var(--btn-text-on-live);
}

.toggle-switch input:disabled + .toggle-slider {
  opacity: 0.5;
  cursor: not-allowed;
}


/* ===== مجموعات القائمة الجانبية القابلة للطي (النفايات: QR / RFID / IoT / تم الجمع) ===== */
.nav-sub-toggle { background: none; border: 0; cursor: pointer; text-align: start; font: inherit; font-size: 13px; font-family: var(--font-display); }
.nav-sub-toggle.open { color: var(--text-primary); font-weight: 600; }
.nav-chev { margin-inline-start: auto; width: 7px; height: 7px; border-right: 1.6px solid currentColor; border-bottom: 1.6px solid currentColor; transform: rotate(45deg); /* حدود فيزيائية: السهم يتجه للأسفل في RTL وLTR */ transition: transform .15s; flex-shrink: 0; }
.nav-sub-toggle.open .nav-chev { transform: rotate(-135deg); }
.nav-sub-toggle:focus-visible { outline: 2px solid var(--accent-live); outline-offset: -2px; }
.nav-sub { margin-inline-start: 14px; padding-inline-start: 4px; border-inline-start: 1px solid var(--border); }
.nav-sub .nav-item { padding-block: 6px; font-size: 12.5px; }
@media (max-width: 1600px) {
  .nav-chev { display: none; }
  .nav-sub { margin-inline-start: 0; padding-inline-start: 0; border-inline-start: 0; }
  .nav-sub-toggle.open { background: var(--surface-hover); }
}

/* ================================================================
   إصلاح عرض الشاشات الصغيرة (يجب أن يبقى في آخر الملف ليغلب القواعد الأقدم)
   - قاعدة ≤1600px كانت تُخفي نصوص القائمة وتُبقي القوائم الفرعية رأسية، فتتلخبط على الجوال.
   - 100vh على متصفحات الجوال يشمل شريط العنوان فيختفي شريط التنقل السفلي؛ 100dvh هو الصحيح.
   ================================================================ */
.app-shell { height: 100vh; height: 100dvh; }

@media (max-width: 768px) {
  .nav-rail {
    align-items: center;
    padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px));
    -webkit-overflow-scrolling: touch;
  }
  .nav-item {
    align-items: center;
    justify-content: center;
    text-align: center;
  }
  .nav-item span { display: block; white-space: nowrap; }          /* نصوص القائمة تظهر تحت الأيقونة */
  .nav-sub { display: contents; margin: 0; padding: 0; border: 0; } /* العناصر الفرعية تنضم للصف الأفقي */
  .nav-sub .nav-item { padding-block: 6px; font-size: 10px; }
  .nav-chev { display: none; }
  .nav-sub-toggle { font-size: 10px; }

  /* شبكات بأعمدة ثابتة في بعض الصفحات (inline) تتحول لعمود واحد / عمودين */
  [style*="grid-template-columns:280px 1fr"] { grid-template-columns: minmax(0, 1fr) !important; }
  .mini-stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }

  /* لا تمرير أفقي للصفحة كلها؛ الجداول لها تمريرها الداخلي */
  .app-main { overflow-x: hidden; }
  .page img, .page canvas { max-width: 100%; }
}


.print-only { display: none; }
/* ===== الطباعة: صفحة المحتوى فقط بألوان فاتحة، بلا قوائم/أزرار، وتتوزع على عدة صفحات ===== */
@media print {
  :root, [data-theme="dark"], [data-theme="light"] {
    --bg: #ffffff; --surface: #ffffff; --surface-raised: #ffffff; --surface-hover: #ffffff;
    --border: #cfd5df; --border-soft: #e3e7ee;
    --text-primary: #111827; --text-secondary: #4b5563; --text-muted: #6b7280;
    --accent-live-dim: #e6f6f3; --accent-amber-dim: #fbf1dc; --accent-danger-dim: #fbe6e7;
  }
  html, body { background: #fff !important; color: #111827 !important; height: auto !important; overflow: visible !important; }
  .topbar, .nav-rail, .mobile-nav, .toast-stack, .boot-screen, .no-print, .pl-tabs,
  .page-header button, .page-header select, .page-header .btn, .error-banner { display: none !important; }
  .print-only { display: block !important; }
  .app-shell, .app-body, .app-main { display: block !important; height: auto !important; min-height: 0 !important; overflow: visible !important; }
  .card, .rfd-kpi, table, tr { break-inside: avoid; page-break-inside: avoid; }
  .card, .rfd-kpi { box-shadow: none !important; }
  .rfd-kpis { grid-template-columns: repeat(5, minmax(0, 1fr)) !important; gap: 8px !important; }
  div[style*="overflow:auto"] { overflow: visible !important; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  @page { margin: 12mm; }
}
