/* ===== أنماط الشاشات المحددة ===== */

/* ─── شاشة تسجيل الدخول ────────────────────────────────────── */
.login-screen {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: var(--space-md);
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-secondary) 100%);
  overflow-y: auto;
}
.login-theme-toggle {
  position: absolute;
  top: 12px;
  left: 12px;
  background: var(--color-primary, #3d5a80);
  border: none;
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(61,90,128,0.4);
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
  z-index: 10;
}
.login-theme-toggle:hover {
  background: var(--color-secondary, #2c4a6e);
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(61,90,128,0.5);
}
.login-card {
  position: relative;
  background: var(--bg-card);
  border-radius: var(--border-radius-xl);
  padding: 48px 20px 20px;
  width: 100%;
  max-width: 340px;
  box-shadow: var(--shadow-lg);
}
@media (min-width: 768px) {
  .login-screen {
    padding: var(--space-xl);
  }
  .login-card {
    max-width: 360px;
    padding: 24px 24px;
  }
}
.login-logo {
  text-align: center;
  margin-bottom: 10px;
  overflow: visible;
}
.login-logo img {
  width: auto;
  max-width: 80px;
  height: auto;
  object-fit: contain;
  display: block;
  margin: 0 auto;
}
.login-logo-placeholder {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--color-primary-light);
  color: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  margin: 0 auto;
}
@media (min-width: 768px) {
  .login-logo img {
    max-width: 90px;
  }
}
.login-title {
  font-size: 15px;
  font-weight: 800;
  color: var(--text-primary);
  text-align: center;
  margin-bottom: 4px;
  line-height: 1.3;
}
.login-subtitle {
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
  text-align: center;
  margin-bottom: 12px;
}
.login-footer {
  text-align: center;
  margin-top: 12px;
  font-size: 10px;
  color: var(--text-muted);
}

/* ─── بطاقة تثبيت التطبيق في صفحة الدخول ─────────────────────── */
.login-pwa-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-md);
  color: var(--text-primary);
  max-width: 340px;
  width: 100%;
  animation: loginPwaSlideUp 0.4s ease;
}
@keyframes loginPwaSlideUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
.login-pwa-icon {
  font-size: 32px;
  flex-shrink: 0;
}
.login-pwa-info {
  flex: 1;
  min-width: 0;
}
.login-pwa-title {
  font-size: var(--font-size-sm);
  font-weight: 700;
  line-height: 1.3;
}
.login-pwa-desc {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
  line-height: 1.3;
}
.login-pwa-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.login-pwa-share-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: var(--bg-tertiary, #e8eef5);
  border: 1px solid var(--border-color, #d0d8e4);
  border-radius: var(--border-radius-md);
  color: var(--text-secondary, #5a6b82);
  cursor: pointer;
  transition: background var(--transition), transform var(--transition), color var(--transition);
}
.login-pwa-share-btn:hover {
  background: var(--border-color, #d0d8e4);
  color: var(--text-primary, #2c3e50);
  transform: scale(1.08);
}
.login-pwa-install-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--color-primary);
  border: none;
  border-radius: var(--border-radius-md);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(61,90,128,0.35);
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
}
.login-pwa-install-btn:hover {
  background: var(--color-secondary);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(61,90,128,0.45);
}
.login-pwa-install-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 6px rgba(61,90,128,0.35);
}

/* ─── التبويبات في صفحة الدخول ────────────────────────────────── */
.login-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 12px;
  border-bottom: 2px solid var(--border-color);
  width: 100%;
}
.login-tab {
  flex: 1;
  padding: 8px 6px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition);
  text-align: center;
  white-space: nowrap;
}
.login-tab:hover {
  color: var(--text-primary);
}
.login-tab-active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}
.login-tab-content {
  width: 100%;
}

/* ─── صفحة نتائج الاستعلام (شاشة كاملة) ──────────────────────── */
.track-result-page {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  background: var(--bg-page, #f1f5f9);
  overflow-y: auto;
}
.track-result-page-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  z-index: 1;
  position: sticky;
  top: 0;
}
.track-result-page-header h2 {
  margin: 0;
  font-size: var(--font-size-lg);
  font-weight: 700;
  color: var(--text-primary);
}
.track-result-back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 8px 16px;
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: var(--border-radius-md);
  font-size: var(--font-size-sm);
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
  white-space: nowrap;
}
.track-result-back:hover {
  background: var(--color-primary-dark);
  transform: scale(1.02);
}
.track-result-print {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 8px 16px;
  background: var(--color-success, #10b981);
  color: #fff;
  border: none;
  border-radius: var(--border-radius-md);
  font-size: var(--font-size-sm);
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
  white-space: nowrap;
  margin-right: auto;
}
.track-result-print:hover {
  background: var(--color-success-dark, #059669);
  transform: scale(1.02);
}
.track-result-page-content {
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.track-result-page-content .track-result {
  width: 100%;
  max-width: 600px;
  margin: 0;
}

/* ─── نموذج الاستعلام عن طلب ─────────────────────────────────── */
.track-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}
.track-form-desc {
  font-size: 11px;
  color: var(--text-secondary);
  text-align: center;
  margin: 0;
  line-height: 1.4;
}
.track-form .form-group {
  margin-bottom: 0;
  width: 100%;
}
.track-form .form-input {
  padding: 10px 14px;
  font-size: 14px;
  border-radius: var(--border-radius-md);
  width: 100%;
  box-sizing: border-box;
  direction: ltr;
  text-align: left;
}
.track-form .form-label {
  font-size: 12px;
  margin-bottom: 4px;
}
.form-label-optional {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 400;
}
.track-form-hint {
  display: block;
  font-size: 11px;
  color: var(--color-primary, #2563eb);
  margin-top: 4px;
  text-align: right;
  font-weight: 500;
  background: var(--color-primary-light, #e8f0fe);
  padding: 6px 10px;
  border-radius: var(--border-radius-sm, 6px);
  line-height: 1.4;
}

/* ─── بطاقة معلومات المواطن (الخطوة 2) - تصميم مضغوط ──────────── */
.track-citizen-info {
  margin-bottom: 0;
}
.track-citizen-bar {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  padding: 10px 14px;
  background: var(--color-primary-light, #e8f0fe);
  border: 1px solid var(--color-primary, #2563eb);
  border-radius: var(--border-radius-md, 8px);
  direction: rtl;
}
.track-citizen-bar-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.track-citizen-bar-icon {
  font-size: 18px;
  flex-shrink: 0;
}
.track-citizen-bar-name {
  font-size: 16px;
  font-weight: 800;
  color: var(--color-primary, #2563eb);
}
.track-citizen-bar-id {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-secondary, #64748b);
  direction: ltr;
  text-align: right;
}
.track-citizen-bar-mobile {
  font-size: 15px;
  color: var(--color-primary, #2563eb);
  font-weight: 700;
  direction: ltr;
  text-align: right;
}
[data-theme="dark"] .track-citizen-bar {
  background: rgba(37, 99, 235, 0.12);
  border-color: rgba(37, 99, 235, 0.4);
}
[data-theme="dark"] .track-citizen-bar-name {
  color: #60a5fa;
}
[data-theme="dark"] .track-citizen-bar-mobile {
  color: #60a5fa;
  background: rgba(0,0,0,0.2);
}

/* ─── التحميل ─────────────────────────────────────────────────── */
.track-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: var(--space-md);
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
}
.track-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-color);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: track-spin 0.7s linear infinite;
}
@keyframes track-spin {
  to { transform: rotate(360deg); }
}

/* ─── نتائج الاستعلام ─────────────────────────────────────────── */
.track-result {
  margin-top: var(--space-md);
  border-radius: var(--border-radius-md);
  overflow: hidden;
}
.track-result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-card-alt, #f8fafc);
  border-radius: var(--border-radius-md) var(--border-radius-md) 0 0;
  border: 1px solid var(--border-color);
  border-bottom: none;
}
.track-result-citizen {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.track-result-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.track-result-icon {
  font-size: 22px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-primary-light, #e8f0fe);
  border-radius: 50%;
  flex-shrink: 0;
}
.track-result-name {
  font-size: var(--font-size-md);
  font-weight: 700;
  color: var(--text-primary);
}
.track-result-id-row {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  padding-right: 44px;
  direction: ltr;
  text-align: right;
}
.track-result-mobile-row {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  padding-right: 44px;
  direction: ltr;
  text-align: right;
}
.track-result-summary {
  display: flex;
  align-items: center;
  gap: 6px;
}
.track-result-badge {
  background: var(--color-primary);
  color: #fff;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: var(--font-size-xs);
  font-weight: 600;
  white-space: nowrap;
}
.track-result-divider {
  height: 1px;
  background: var(--border-color);
  margin: 0;
}

/* ─── بطاقات الطلبات في النتائج ───────────────────────────────── */
.track-request-card {
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-top: none;
}
.track-request-card-border {
  border-top: 1px solid var(--border-color);
}
.track-request-card:last-child {
  border-radius: 0 0 var(--border-radius-md) var(--border-radius-md);
}
.track-request-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  direction: rtl;
}
.track-request-number {
  font-size: var(--font-size-sm);
  font-weight: 700;
  color: var(--text-primary);
  direction: ltr;
  unicode-bidi: plaintext;
}
.track-request-status {
  font-size: var(--font-size-xs);
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  white-space: nowrap;
}
.track-request-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.track-request-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: var(--font-size-sm);
  direction: rtl;
}
.track-request-label {
  color: var(--text-secondary);
  font-size: var(--font-size-xs);
  text-align: right;
  flex-shrink: 0;
  margin-left: 12px;
}
.track-request-value {
  color: var(--text-primary);
  font-weight: 500;
  text-align: right;
}

/* ─── ألوان الحالات ───────────────────────────────────────────── */
.track-status-pending {
  background: #fef3c7;
  color: #92400e;
}
.track-status-approved {
  background: #d1fae5;
  color: #065f46;
}
.track-status-ready {
  background: #dbeafe;
  color: #1e40af;
}
.track-status-paid {
  background: #d1fae5;
  color: #065f46;
}
.track-status-delivered {
  background: #e0e7ff;
  color: #3730a3;
}
.track-status-rejected {
  background: #fee2e2;
  color: #991b1b;
}
.track-status-cancelled {
  background: #f3f4f6;
  color: #6b7280;
}

/* ─── تذييل النتائج ───────────────────────────────────────────── */
.track-result-footer {
  padding: 10px 16px;
  background: var(--bg-card-alt, #f8fafc);
  border: 1px solid var(--border-color);
  border-top: none;
  border-radius: 0 0 var(--border-radius-md) var(--border-radius-md);
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  text-align: center;
}

/* ─── سجل الإشعارات في نتائج الاستعلام ────────────────────────── */
.track-result-notif-history {
  border: 1px solid var(--border-color);
  border-top: none;
  background: var(--bg-card);
}
.track-result-notif-header {
  padding: 10px 16px;
  cursor: pointer;
  user-select: none;
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card-alt, #f8fafc);
  border-bottom: 1px solid var(--border-color);
}
.track-result-notif-header:hover {
  background: var(--bg-subtle);
}

/* ─── الوضع الداكن للنتائج ────────────────────────────────────── */
[data-theme="dark"] .track-result-header,
[data-theme="dark"] .track-result-footer {
  background: var(--bg-card-alt, #1e293b);
}
[data-theme="dark"] .track-result-icon {
  background: rgba(59, 130, 246, 0.2);
}
[data-theme="dark"] .track-status-pending {
  background: #78350f40;
  color: #fbbf24;
}
[data-theme="dark"] .track-status-approved {
  background: #064e3b40;
  color: #34d399;
}
[data-theme="dark"] .track-status-ready {
  background: #1e3a5f40;
  color: #60a5fa;
}
[data-theme="dark"] .track-status-paid {
  background: #064e3b40;
  color: #34d399;
}
[data-theme="dark"] .track-status-delivered {
  background: #312e8140;
  color: #818cf8;
}
[data-theme="dark"] .track-status-rejected {
  background: #7f1d1d40;
  color: #f87171;
}
[data-theme="dark"] .track-status-cancelled {
  background: #37415140;
  color: #9ca3af;
}

/* تحسين نموذج تسجيل الدخول */
#login-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  width: 100%;
}
#login-form .form-group {
  margin-bottom: 0;
  width: 100%;
}
#login-form .form-input {
  padding: 12px 16px;
  font-size: var(--font-size-md);
  border-radius: var(--border-radius-md);
  width: 100%;
  box-sizing: border-box;
}
#login-form .btn-block {
  margin-top: var(--space-xs);
  padding: 12px 24px;
  border-radius: var(--border-radius-md);
  width: 100%;
  box-sizing: border-box;
}
@media (min-width: 768px) {
  #login-form .form-input {
    padding: 14px 20px;
    font-size: var(--font-size-lg);
  }
  #login-form .btn-block {
    padding: 14px 28px;
    font-size: var(--font-size-lg);
  }
}

/* ─── لوحة التحكم ──────────────────────────────────────────── */
.dashboard-screen { padding: var(--space-md); }

/* ─── صف الإجراءات السريعة + التنبيهات ────────────────────── */
.dashboard-top-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}
@media (min-width: 769px) {
  .dashboard-top-row {
    grid-template-columns: 380px 1fr;
    align-items: start;
  }
  .dashboard-top-row .quick-actions {
    margin-bottom: 0;
    flex-shrink: 0;
  }
}

/* ─── الإجراءات السريعة ───────────────────────────────────── */
.quick-actions {
  display: flex;
  gap: 8px;
  margin-bottom: var(--space-md);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 4px 0;
}
.quick-actions::-webkit-scrollbar { display: none; }
.quick-action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 80px;
}
.quick-action-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.quick-action-icon {
  font-size: 22px;
  line-height: 1;
}
.quick-action-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
}
@media (max-width: 480px) {
  .quick-actions { gap: 6px; }
  .quick-action-btn {
    padding: 8px 12px;
    min-width: 70px;
  }
  .quick-action-icon { font-size: 18px; }
  .quick-action-label { font-size: 10px; }
}

/* ─── بطاقة الترحيب ────────────────────────────────────────── */
.welcome-card {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-md);
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-secondary) 100%);
  color: #fff;
  border-radius: var(--border-radius-lg);
  padding: var(--space-md) var(--space-lg);
  margin-bottom: var(--space-md);
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}
.welcome-card::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -20%;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: rgba(255,255,255,0.05);
  pointer-events: none;
}
.welcome-card::after {
  content: '';
  position: absolute;
  bottom: -30%;
  left: -10%;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: rgba(255,255,255,0.05);
  pointer-events: none;
}
.welcome-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: var(--font-size-lg);
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}
.welcome-text {
  flex: 1;
  min-width: 0;
  position: relative;
  z-index: 1;
}
.welcome-greeting {
  font-size: var(--font-size-lg);
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.welcome-role {
  font-size: var(--font-size-sm);
  opacity: 0.85;
  margin-top: 2px;
}
.welcome-stats {
  display: flex;
  gap: 8px;
  width: 100%;
  position: relative;
  z-index: 1;
  margin-top: 4px;
}
/* شاشة كبيرة: الإحصائيات بجانب النص في صف واحد */
@media (min-width: 769px) {
  .welcome-stats {
    width: auto;
    flex: 0 0 auto;
    margin-top: 0;
    margin-right: auto;
  }
  .welcome-text {
    max-width: 40%;
  }
  .welcome-card {
    padding: var(--space-lg) var(--space-xl);
  }
  .welcome-stat {
    min-width: 90px;
    padding: 12px 14px;
  }
}
.welcome-stat {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: rgba(255,255,255,0.12);
  border-radius: var(--border-radius-md);
  padding: 10px 6px;
  backdrop-filter: blur(4px);
  transition: background var(--transition), transform var(--transition);
}
.welcome-stat:hover {
  background: rgba(255,255,255,0.2);
  transform: translateY(-1px);
}
.welcome-stat-icon {
  font-size: 20px;
  line-height: 1;
}
.welcome-stat-value {
  font-size: var(--font-size-lg);
  font-weight: 800;
  line-height: 1.2;
  direction: ltr;
}
.welcome-stat-label {
  font-size: 10px;
  opacity: 0.85;
  line-height: 1.2;
}
.welcome-stat-ring {
  position: relative;
  overflow: visible;
}
.welcome-stat-ring .welcome-ring-svg {
  width: 28px;
  height: 28px;
  display: block;
  margin: 0 auto;
}
.welcome-stat-ring .welcome-ring-pct {
  font-size: 10px !important;
  line-height: 1;
}
@media (max-width: 480px) {
  .welcome-card {
    padding: var(--space-sm) var(--space-md);
  }
  .welcome-avatar {
    width: 40px;
    height: 40px;
    font-size: var(--font-size-md);
  }
  .welcome-greeting {
    font-size: var(--font-size-md);
  }
  .welcome-stat {
    padding: 8px 4px;
  }
  .welcome-stat-value {
    font-size: var(--font-size-md);
  }
  .welcome-stat-label {
    font-size: 9px;
  }
  .welcome-stat-ring .welcome-ring-svg {
    width: 24px;
    height: 24px;
  }
  .welcome-stat-ring .welcome-ring-pct {
    font-size: 9px !important;
  }
}

.dashboard-grid {
  display: grid;
  /* 3 أعمدة على الجوال، 4-6 على الشاشات الكبيرة */
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}
@media (min-width: 769px) {
  .dashboard-grid { grid-template-columns: repeat(4, 1fr); }
}
@media (min-width: 1200px) {
  .dashboard-grid { grid-template-columns: repeat(6, 1fr); }
}
.stat-card {
  background: var(--bg-card);
  border-radius: var(--border-radius-md);
  padding: var(--space-sm);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
  border-right: 4px solid var(--color-primary);
  min-width: 0;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-card.success { border-color: var(--color-success); }
.stat-card.warning { border-color: var(--color-warning); }
.stat-card.danger  { border-color: var(--color-danger); }
.stat-card.info    { border-color: var(--color-info); }
.stat-icon {
  font-size: 22px;
  margin-bottom: var(--space-xs);
}
.stat-value {
  font-size: var(--font-size-xl);
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
}
.stat-label {
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* تصغير البطاقات على الجوال */
@media (max-width: 480px) {
  .dashboard-grid {
    gap: 8px;
  }
  .stat-card {
    padding: 8px;
    gap: 4px;
    border-right-width: 2px;
  }
  .stat-icon {
    font-size: 16px;
    margin-bottom: 2px;
  }
  .stat-value {
    font-size: var(--font-size-md);
  }
  .stat-label {
    font-size: 10px;
  }
}

/* ─── المخططات الدائرية في لوحة التحكم ─────────────────────── */
.dashboard-charts-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}
@media (min-width: 481px) {
  .dashboard-charts-row { grid-template-columns: 1fr 1fr; }
}
.dashboard-chart-card .card-header {
  padding-bottom: 0;
}
.dashboard-pie-wrap {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
}
.dashboard-pie-svg {
  flex-shrink: 0;
}
.dashboard-pie-svg svg {
  display: block;
}
.dashboard-pie-legend {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.pie-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  line-height: 1.3;
}
.pie-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.pie-legend-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-primary);
  font-weight: 600;
}
.pie-legend-value {
  font-weight: 700;
  color: var(--text-primary);
  direction: ltr;
}
.pie-legend-pct {
  color: var(--text-muted);
  width: 36px;
  text-align: right;
  direction: ltr;
}

/* ─── التنبيهات الذكية ─────────────────────────────────────── */
.dashboard-alerts-card {
  margin-bottom: var(--space-md);
}
.dashboard-alerts-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: var(--space-xs) var(--space-md) var(--space-sm);
}
.dashboard-alert-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--border-radius-sm);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
}
.dashboard-alert-icon {
  font-size: 14px;
  flex-shrink: 0;
}
.dashboard-alert-text {
  flex: 1;
  min-width: 0;
}
.dashboard-alert-danger {
  background: rgba(231, 76, 60, 0.1);
  color: var(--color-danger, #e74c3c);
}
.dashboard-alert-warning {
  background: rgba(243, 156, 18, 0.1);
  color: var(--color-warning, #f39c12);
}
.dashboard-alert-info {
  background: rgba(52, 152, 219, 0.1);
  color: var(--color-info, #3498db);
}
.dashboard-alert-success {
  background: rgba(39, 174, 96, 0.1);
  color: var(--color-success, #27ae60);
}

/* ─── تنبيهات قابلة للنقر ───────────────────────────────────── */
.dashboard-alert-item.clickable {
  cursor: pointer;
  transition: all var(--transition, 0.2s) ease;
  position: relative;
}
.dashboard-alert-item.clickable:hover {
  transform: translateX(-3px);
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.dashboard-alert-item.clickable:active {
  transform: translateX(-1px);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.dashboard-alert-item.clickable.dashboard-alert-danger:hover {
  background: rgba(231, 76, 60, 0.18);
}
.dashboard-alert-item.clickable.dashboard-alert-warning:hover {
  background: rgba(243, 156, 18, 0.18);
}
.dashboard-alert-item.clickable.dashboard-alert-info:hover {
  background: rgba(52, 152, 219, 0.18);
}
.dashboard-alert-arrow {
  font-size: 12px;
  opacity: 0.4;
  flex-shrink: 0;
  transition: opacity var(--transition, 0.2s) ease;
}
.dashboard-alert-item.clickable:hover .dashboard-alert-arrow {
  opacity: 0.8;
}

/* ─── شريط ملخص التنبيهات ──────────────────────────────────── */
.dashboard-alerts-summary {
  padding: 8px 16px 10px;
  font-size: 13px;
  color: var(--text-muted, #888);
  border-top: 1px solid var(--border-color, #eee);
  margin-top: 2px;
  line-height: 1.5;
  transition: background 0.2s;
}
.dashboard-alerts-summary[onclick]:hover {
  background: rgba(59,130,246,0.06);
  color: var(--color-primary, #3d5a80);
}

/* ─── التنبيهات المضغوطة للجوال ───────────────────────────── */
@keyframes alert-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.12); }
}
@keyframes alert-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.4); }
  50% { box-shadow: 0 0 0 8px rgba(220, 53, 69, 0); }
}
@keyframes alert-badge-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}
.dashboard-alerts-compact {
  background: linear-gradient(135deg, #fff5f5 0%, #fff 100%);
  border: 1px solid #fecaca;
  border-right: 4px solid #ef4444;
  border-radius: var(--border-radius-md, 10px);
  box-shadow: var(--shadow, 0 2px 8px rgba(0,0,0,0.08));
  margin-bottom: 12px;
  overflow: hidden;
  animation: alert-glow 2.5s ease-in-out infinite;
}
.dashboard-alerts-compact.no-critical {
  background: linear-gradient(135deg, #f0fdf4 0%, #fff 100%);
  border-color: #bbf7d0;
  border-right-color: #22c55e;
  animation: none;
}
.dashboard-alerts-compact-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 14px; cursor: pointer;
  direction: rtl;
}
.dashboard-alerts-compact-icon {
  font-size: 22px; flex-shrink: 0;
  animation: alert-pulse 1.5s ease-in-out infinite;
}
.dashboard-alerts-compact.no-critical .dashboard-alerts-compact-icon {
  animation: none;
}
.dashboard-alerts-compact-text {
  flex: 1; font-size: 13px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: #991b1b;
}
.dashboard-alerts-compact.no-critical .dashboard-alerts-compact-text {
  color: var(--text-primary, #293241);
}
.dashboard-alerts-compact-badge {
  background: #ef4444; color: #fff;
  font-size: 12px; padding: 3px 10px; border-radius: 12px;
  font-weight: 700; flex-shrink: 0;
  animation: alert-badge-pulse 2s ease-in-out infinite;
}
.dashboard-alerts-compact-arrow {
  font-size: 18px; color: var(--text-muted, #888);
  transition: transform 0.2s; flex-shrink: 0;
  width: 32px; height: 32px; display: flex;
  align-items: center; justify-content: center;
  background: rgba(0,0,0,0.04); border-radius: 50%;
}
.dashboard-alerts-compact-info {
  font-size: 14px; flex-shrink: 0;
  width: 28px; height: 28px; display: flex;
  align-items: center; justify-content: center;
  background: rgba(59,130,246,0.1); border-radius: 50%;
  cursor: pointer; transition: background 0.2s;
  color: #3b82f6;
}
.dashboard-alerts-compact-info:hover {
  background: rgba(59,130,246,0.25);
}
.dashboard-alerts-compact.expanded .dashboard-alerts-compact-arrow {
  transform: rotate(180deg);
}
.dashboard-alerts-compact-list {
  display: none; border-top: 1px solid var(--border-color, #eee);
}
.dashboard-alerts-compact.expanded .dashboard-alerts-compact-list {
  display: block;
}

/* ─── V503: تكبير خط التنبيهات على الجوال ─────────────────── */
@media (max-width: 768px) {
  .dashboard-alert-item {
    font-size: 14px;
    padding: 10px 12px;
    gap: 10px;
  }
  .dashboard-alert-icon {
    font-size: 16px;
  }
  .dashboard-alerts-summary {
    font-size: 14px;
    padding: 10px 16px 12px;
  }
  /* V509: تقليل هوامش بطاقة فلاتر المواطنين على الجوال */
  .citizens-filter-card {
    padding: var(--space-sm) !important;
    margin-left: 0;
    margin-right: 0;
    border-radius: 0;
  }
}

/* ─── شارة فلتر التنبيهات (تظهر في صفحات القوائم) ──────────── */
.alert-filter-tag {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  margin: 0 0 var(--space-sm, 8px) 0;
  background: linear-gradient(135deg, #fff3cd, #ffeaa7);
  border: 1px solid #ffc107;
  border-radius: var(--border-radius-md, 8px);
  font-size: var(--font-size-sm, 13px);
  color: #856404;
  direction: rtl;
  text-align: right;
}
.alert-filter-tag-icon {
  font-size: 16px;
  flex-shrink: 0;
}
.alert-filter-tag-label {
  font-weight: 600;
  text-align: right;
  direction: rtl;
}
.alert-filter-tag-desc {
  font-size: var(--font-size-xs, 11px);
  color: #856404;
  opacity: 0.8;
  margin: 0 4px;
  text-align: right;
  direction: rtl;
}
.alert-filter-tag-count {
  font-size: var(--font-size-xs, 11px);
  color: #856404;
  font-weight: 700;
  margin: 0 4px;
  white-space: nowrap;
  direction: rtl;
}
.alert-filter-tag-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 50%;
  background: rgba(0,0,0,0.08);
  color: #856404;
  font-size: 12px;
  cursor: pointer;
  flex-shrink: 0;
  transition: all var(--transition, 0.2s) ease;
}
.alert-filter-tag-close:hover {
  background: rgba(0,0,0,0.15);
  transform: scale(1.1);
}

/* ─── زر شرح التنبيهات ──────────────────────────────────────── */
.btn-alert-info {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;
  background: var(--bg-hover, rgba(0,0,0,0.05));
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  transition: all var(--transition, 0.2s);
  flex-shrink: 0;
}
.btn-alert-info:hover {
  background: var(--color-primary-light, rgba(52, 152, 219, 0.15));
  color: var(--color-primary, #3498db);
  transform: scale(1.1);
}

/* ─── نافذة شرح التنبيهات (Modal) ──────────────────────────── */
.alert-info-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-md);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
  /* منع وصول أي أحداث لمس للخلفية */
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}
.alert-info-overlay.visible {
  opacity: 1;
  visibility: visible;
}
.alert-info-overlay.hidden {
  opacity: 0;
  visibility: hidden;
}
.alert-info-modal {
  background: var(--bg-card, #fff);
  border-radius: var(--border-radius-lg, 12px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  width: 100%;
  max-width: 400px;
  direction: rtl;
  animation: alertInfoSlideUp 0.3s ease;
}
@keyframes alertInfoSlideUp {
  from {
    opacity: 0;
    transform: translateY(30px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
.alert-info-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-color);
}
.alert-info-header h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
}
.btn-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: var(--bg-hover, rgba(0,0,0,0.05));
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  transition: all var(--transition, 0.2s);
  flex-shrink: 0;
}
.btn-close:hover {
  background: rgba(231, 76, 60, 0.15);
  color: var(--color-danger, #e74c3c);
}
.alert-info-body {
  padding: 16px 18px;
}
.alert-info-body > p {
  margin: 0 0 14px;
  font-size: 14px;
  color: #000;
  line-height: 1.6;
}
.alert-info-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}
.alert-info-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-hover, rgba(0,0,0,0.03));
  border-radius: var(--border-radius-sm);
  border-right: 3px solid transparent;
}
.alert-info-item:nth-child(1) { border-right-color: var(--color-danger, #e74c3c); }
.alert-info-item:nth-child(2) { border-right-color: var(--color-warning, #f39c12); }
.alert-info-item:nth-child(3) { border-right-color: var(--color-info, #3498db); }
.alert-info-item:nth-child(4) { border-right-color: var(--color-danger, #e74c3c); }
.alert-info-item:nth-child(5) { border-right-color: var(--color-success, #27ae60); }
.alert-info-icon {
  font-size: 18px;
  flex-shrink: 0;
  margin-top: 1px;
}
.alert-info-item div {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.alert-info-item strong {
  font-size: 14px;
  color: #000;
}
.alert-info-item span {
  font-size: 13px;
  color: #333;
  line-height: 1.4;
}
.alert-info-note {
  padding: 10px 12px;
  background: rgba(52, 152, 219, 0.08);
  border-radius: var(--border-radius-sm);
  font-size: 13px;
  color: #000;
  line-height: 1.5;
}
.alert-info-note a {
  color: var(--color-primary, #3498db);
  text-decoration: none;
  font-weight: 600;
}
.alert-info-note a:hover {
  text-decoration: underline;
}

/* ─── الرسم البياني الأسبوعي ───────────────────────────────── */
.dashboard-weekly-card {
  margin-bottom: var(--space-md);
}
.dashboard-weekly-body {
  padding: var(--space-sm) var(--space-md) var(--space-md);
}
.weekly-chart-svg {
  width: 100%;
  height: auto;
  display: block;
}
.weekly-bar-group {
  cursor: default;
}
.weekly-bar-group:hover .weekly-bar {
  filter: brightness(1.1);
}
@media (max-width: 480px) {
  .dashboard-weekly-body {
    padding: var(--space-xs) var(--space-sm) var(--space-sm);
  }
  .weekly-bar-date {
    display: none;
  }
}

/* ─── العناصر الحديثة (آخر الطلبات / المواطنين) ──────────────── */
#dashboard-recent {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-md);
}
@media (min-width: 769px) {
  #dashboard-recent {
    grid-template-columns: 1fr 1fr;
  }
}

/* ─── طباعة احترافية للوحة التحكم ───────────────────────────── */
@media print {
  /* إخفاء العناصر غير المرغوب فيها */
  #app-header,
  #sidebar,
  #bottom-nav,
  .action-bar,
  .quick-actions,
  #toast-container,
  .ptr-indicator,
  .header-back,
  .header-actions,
  .sidebar-overlay,
  .modal-overlay,
  .modal,
  .fab,
  .notif-bell {
    display: none !important;
  }

  /* إعادة تعيين التخطيط */
  #app {
    display: block !important;
    grid-template-columns: none !important;
    gap: 0 !important;
  }

  #main-content {
    margin: 0 !important;
    padding: 0 !important;
    max-width: 100% !important;
  }

  .dashboard-screen {
    padding: 0 !important;
  }

  /* بطاقة الترحيب — طباعة بدون خلفية متدرجة */
  .welcome-card {
    background: #f0f4f8 !important;
    color: #1a1a2e !important;
    border: 1px solid #ccc !important;
    border-radius: 6px !important;
    padding: 16px 20px !important;
    margin-bottom: 12px !important;
    break-inside: avoid;
    page-break-inside: avoid;
  }
  .welcome-ring-bg { stroke: #d0d0d0 !important; }
  .welcome-ring-fg { stroke: #2c7a4d !important; }
  .welcome-stat-value { color: #1a1a2e !important; }
  .welcome-stat-label { color: #555 !important; }
  .welcome-greeting { color: #1a1a2e !important; }
  .welcome-role { color: #555 !important; }
  .welcome-avatar { background: #2c4a6e !important; color: #fff !important; }

  /* شبكة البطاقات الإحصائية */
  .dashboard-grid {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 8px !important;
    margin-bottom: 12px !important;
  }

  .stat-card {
    background: #fff !important;
    border: 1px solid #ddd !important;
    border-radius: 6px !important;
    padding: 10px 8px !important;
    box-shadow: none !important;
    break-inside: avoid;
    page-break-inside: avoid;
  }
  .stat-card .stat-icon { font-size: 18px !important; }
  .stat-card .stat-value { font-size: 16px !important; color: #1a1a2e !important; }
  .stat-card .stat-label { font-size: 10px !important; color: #555 !important; }

  /* المخططات — عرض جنباً إلى جنب */
  .dashboard-charts-row {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 12px !important;
    margin-bottom: 12px !important;
  }
  .dashboard-chart-card {
    break-inside: avoid;
    page-break-inside: avoid;
    border: 1px solid #ddd !important;
    border-radius: 6px !important;
    box-shadow: none !important;
  }
  .dashboard-chart-card .card-header {
    padding: 8px 12px !important;
    border-bottom: 1px solid #eee !important;
  }
  .dashboard-pie-wrap {
    padding: 8px 12px 12px !important;
    gap: 8px !important;
  }
  .dashboard-pie-svg svg {
    width: 100px !important;
    height: 100px !important;
  }
  .pie-legend-item {
    font-size: 10px !important;
    gap: 4px !important;
  }
  .pie-legend-dot {
    width: 8px !important;
    height: 8px !important;
  }
  .pie-legend-value {
    font-size: 10px !important;
  }
  .pie-legend-pct {
    font-size: 9px !important;
  }

  /* الرسم البياني الأسبوعي */
  .dashboard-weekly-card {
    break-inside: avoid;
    page-break-inside: avoid;
    border: 1px solid #ddd !important;
    border-radius: 6px !important;
    box-shadow: none !important;
    margin-bottom: 12px !important;
  }
  .dashboard-weekly-card .card-header {
    padding: 8px 12px !important;
    border-bottom: 1px solid #eee !important;
  }
  .dashboard-weekly-body {
    padding: 8px 12px 12px !important;
  }
  .weekly-chart-svg {
    max-height: 160px !important;
  }
  /* إزالة تأثيرات التحويم والرسوم المتحركة */
  .weekly-bar-group:hover .weekly-bar { filter: none !important; }
  .weekly-bar { opacity: 1 !important; }
  .weekly-bar-group animate { display: none !important; }
  .weekly-bar-value { opacity: 1 !important; }
  .weekly-bar-value animate { display: none !important; }

  /* التنبيهات الذكية */
  #dashboard-alerts {
    margin-bottom: 12px !important;
  }
  #dashboard-alerts .card {
    break-inside: avoid;
    page-break-inside: avoid;
    border: 1px solid #ddd !important;
    border-radius: 6px !important;
    box-shadow: none !important;
  }
  #dashboard-alerts .card-header {
    padding: 8px 12px !important;
    border-bottom: 1px solid #eee !important;
  }
  #dashboard-alerts .card-body {
    padding: 8px 12px !important;
  }
  .alert-item {
    padding: 6px 8px !important;
    border: 1px solid #eee !important;
    border-radius: 4px !important;
    margin-bottom: 4px !important;
  }
  .alert-item .alert-icon { font-size: 16px !important; }
  .alert-item .alert-text { font-size: 12px !important; color: #333 !important; }
  .alert-item .alert-sub { font-size: 10px !important; color: #666 !important; }

  /* العناصر الحديثة (آخر الطلبات / المواطنين) */
  #dashboard-recent {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 12px !important;
  }
  #dashboard-recent .card {
    break-inside: avoid;
    page-break-inside: avoid;
    border: 1px solid #ddd !important;
    border-radius: 6px !important;
    box-shadow: none !important;
  }
  #dashboard-recent .card-header {
    padding: 8px 12px !important;
    border-bottom: 1px solid #eee !important;
  }
  #dashboard-recent .card-body {
    padding: 8px 12px !important;
  }
  #dashboard-recent .list-item {
    padding: 6px 0 !important;
    gap: 8px !important;
    border-bottom: 1px solid #f0f0f0 !important;
    align-items: center !important;
  }
  #dashboard-recent .list-item:last-child {
    border-bottom: none !important;
  }
  #dashboard-recent .list-item-avatar {
    width: 28px !important;
    height: 28px !important;
    font-size: 12px !important;
  }
  #dashboard-recent .list-item-title {
    font-size: 11px !important;
    color: #333 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }
  #dashboard-recent .list-item-subtitle {
    font-size: 10px !important;
    color: #666 !important;
  }
  #dashboard-recent .list-item-meta {
    flex-shrink: 0 !important;
    flex-wrap: nowrap !important;
    gap: 4px !important;
  }
  #dashboard-recent .list-item-meta .status-badge {
    font-size: 9px !important;
    padding: 1px 6px !important;
  }
  #dashboard-recent .list-item-meta span[style] {
    font-size: 9px !important;
  }

  /* إخفاء العناصر غير الضرورية داخل البطاقات */
  .card-actions,
  #dashboard-recent .btn {
    display: none !important;
  }

  /* إعدادات الصفحة العامة */
  @page {
    margin: 10mm 8mm;
    size: A4 portrait;
  }

  body {
    background: #fff !important;
    color: #000 !important;
    font-size: 12px !important;
    line-height: 1.4 !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  /* روابط قابلة للطباعة */
  a[href]:after { content: none !important; }
}

/* ─── بطاقات إحصائية تلخيصية ───────────────────────────────── */
.stats-summary-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}
@media (min-width: 481px) {
  .stats-summary-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 769px) {
  .stats-summary-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ─── شبكة الرسوم البيانية ─────────────────────────────────── */
/* ترتيب عمودي دائماً: 🥧 توزيع الفئات فوق 📊 توزيع الكميات حسب النوع */
.stats-charts-grid {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}

/* ─── الرسم البياني الشريطي ────────────────────────────────── */
.chart-body {
  padding: var(--space-md);
}
.bar-chart-item {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.bar-chart-label {
  width: 120px;
  font-size: 12px;
  font-weight: 600;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex-shrink: 0;
}
.bar-chart-track {
  flex: 1;
  height: 22px;
  background: var(--bg-secondary);
  border-radius: 4px;
  overflow: hidden;
}
.bar-chart-fill {
  display: flex;
  height: 100%;
  border-radius: 4px;
  overflow: hidden;
  transition: width 0.3s ease;
  position: relative;
}
.bar-fill-used {
  height: 100%;
  background: #e74c3c;
  transition: width 0.3s ease;
  position: relative;
}
.bar-fill-remaining {
  height: 100%;
  background: #27ae60;
  transition: width 0.3s ease;
  position: relative;
}
.bar-fill-text {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
  direction: ltr;
  white-space: nowrap;
}
.bar-chart-numbers {
  display: flex;
  flex-direction: row;
  gap: 16px;
  margin: 2px 0 0 0;
  padding-right: 128px;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
}
@media (max-width: 480px) {
  .bar-chart-numbers {
    padding-right: 0;
    gap: 8px;
    font-size: 11px;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0 2px;
  }
}
.bar-chart-value {
  width: 60px;
  font-size: 11px;
  text-align: right;
  direction: ltr;
  color: var(--text-secondary);
  flex-shrink: 0;
}

/* ─── وسيلة إيضاح المخطط الدائري ───────────────────────────── */
.chart-legend {
  display: flex;
  gap: 12px;
  margin-top: 8px;
  flex-wrap: wrap;
  justify-content: center;
}
.chart-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}
.chart-legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  display: inline-block;
  flex-shrink: 0;
}

/* ─── تبويبات أنواع المساعدات (خلفية ممتلئة) ─────────────────── */
.tabs-bar .tab-btn {
  background: transparent;
  color: var(--text-color);
}
.tabs-bar .tab-btn.active {
  background: var(--color-primary) !important;
  color: #fff !important;
}

/* ─── تحسينات الجوال للرسوم البيانية والتبويبات ─────────────── */
@media (max-width: 480px) {
  .tabs-bar {
    flex-wrap: wrap;
    gap: 4px !important;
  }
  .tabs-bar .tab-btn {
    font-size: 12px !important;
    padding: 8px 10px !important;
  }
  .bar-chart-label {
    width: 80px;
    font-size: 10px;
  }
  .bar-chart-value {
    width: 40px;
    font-size: 10px;
  }
  .bar-chart-track {
    height: 18px;
  }
  .bar-chart-numbers {
    padding-left: 88px !important;
    font-size: 10px !important;
  }
  .stats-summary-grid {
    gap: var(--space-sm);
  }
  .stat-card {
    padding: var(--space-xs);
  }
  .stat-value {
    font-size: var(--font-size-lg);
  }
  /* إخفاء الجدول وإظهار البطاقات في الجوال */
  .stats-table { display: none !important; }
  .stats-cards { display: flex !important; }
}

/* ─── بطاقات إحصائيات الجوال ────────────────────────────────── */
.stats-cards {
  display: none;
  flex-direction: column;
  gap: 10px;
}
.stats-card-item {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  padding: 12px;
  box-shadow: var(--shadow-sm);
}
.stats-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
}
.stats-card-name {
  font-weight: 700;
  font-size: 14px;
  color: var(--text-primary);
}
.stats-card-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.stats-card-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
}
.stats-card-label {
  color: var(--text-secondary);
  font-weight: 600;
}
.stats-card-value {
  color: var(--text-primary);
  font-weight: 600;
}

/* شاشات متوسطة وكبيرة: إظهار الجدول وإخفاء البطاقات */
@media (min-width: 769px) {
  .stats-table { display: table; }
  .stats-cards { display: none; }
}
/* شاشات صغيرة جداً (481px-768px): إظهار الجدول بحجم أصغر */
@media (min-width: 481px) and (max-width: 768px) {
  .stats-table { display: table; font-size: 12px !important; }
  .stats-table th,
  .stats-table td { padding: 5px 8px !important; }
  .stats-cards { display: none; }
}

/* ─── شاشة القائمة ─────────────────────────────────────────── */
.list-screen { padding: var(--space-md); }
.list-screen .card { margin-bottom: 0; }

/* ─── شاشة النموذج ─────────────────────────────────────────── */
.form-screen { padding: var(--space-md); }
.form-section {
  background: var(--bg-card);
  border-radius: var(--border-radius-md);
  padding: var(--space-lg);
  margin-bottom: var(--space-md);
  box-shadow: var(--shadow-sm);
}
.form-section-title {
  font-size: var(--font-size-md);
  font-weight: 700;
  color: var(--color-primary);
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-sm);
  border-bottom: 2px solid var(--color-primary-light);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

/* ─── شاشة التفاصيل ────────────────────────────────────────── */
.detail-screen { padding: var(--space-md); }
.detail-header {
  background: var(--bg-card);
  border-radius: var(--border-radius-md);
  padding: var(--space-lg);
  margin-bottom: var(--space-md);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: flex-start;
  gap: var(--space-lg);
  flex-wrap: wrap;
}
.detail-header-main {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
  flex: 1;
  min-width: 0;
}
.detail-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--color-primary-light);
  color: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-2xl);
  font-weight: 800;
  flex-shrink: 0;
  overflow: hidden;
}
.detail-avatar img { width: 100%; height: 100%; object-fit: cover; }
.detail-header-info { flex: 1; min-width: 0; }
.detail-header-name {
  font-size: var(--font-size-xl);
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: var(--space-xs);
  word-break: break-word;
  line-height: 1.3;
}
.detail-header-meta {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
}
.detail-header-actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  flex-shrink: 0;
}
@media (max-width: 480px) {
  .detail-header {
    gap: var(--space-sm);
    padding: var(--space-sm);
  }
  .detail-header-main {
    width: 100%;
    gap: var(--space-sm);
  }
  .detail-avatar {
    width: 48px;
    height: 48px;
    font-size: var(--font-size-lg);
  }
  .detail-header-name {
    font-size: var(--font-size-md);
  }
  .detail-header-meta {
    font-size: var(--font-size-xs);
    gap: 4px;
  }
  .detail-header-meta span {
    font-size: var(--font-size-xs);
  }
  .detail-header-actions {
    flex-direction: row;
    flex-wrap: wrap;
    width: 100%;
    gap: 4px;
  }
  .detail-header-actions .btn {
    flex: 1;
    min-width: 0;
    font-size: var(--font-size-xs);
    padding: 6px 8px;
  }
  /* تحسين detail-grid على الموبايل */
  .detail-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: var(--space-sm);
  }
  .detail-value {
    font-size: var(--font-size-sm);
    word-break: break-word;
    overflow-wrap: break-word;
  }
  .detail-label {
    font-size: 10px;
  }
}

/* ─── شاشة الإعدادات ───────────────────────────────────────── */
.settings-screen { padding: var(--space-md); }
.settings-group {
  background: var(--bg-card);
  border-radius: var(--border-radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  margin-bottom: var(--space-md);
}
.settings-group-title {
  padding: var(--space-md) var(--space-lg);
  font-size: var(--font-size-sm);
  font-weight: 700;
  color: var(--text-secondary);
  background: var(--bg-hover);
  border-bottom: 1px solid var(--border-color);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.settings-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  transition: background var(--transition);
}
.settings-item:last-child { border-bottom: none; }
.settings-item:hover { background: var(--bg-hover); }
.settings-item-label {
  font-size: var(--font-size-md);
  font-weight: 600;
  color: var(--text-primary);
}
.settings-item-desc {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  margin-top: 2px;
}
.settings-item-value {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

/* ─── شاشة الإدارة ─────────────────────────────────────────── */
.admin-screen { padding: var(--space-md); }
.admin-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-md);
}
@media (min-width: 481px) {
  .admin-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 769px) {
  .admin-grid { grid-template-columns: repeat(4, 1fr); }
}
@media (min-width: 1200px) {
  .admin-grid { grid-template-columns: repeat(6, 1fr); }
}
.admin-card {
  background: var(--bg-card);
  border-radius: var(--border-radius-md);
  padding: var(--space-md);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-xs);
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
  text-align: center;
}
.admin-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.admin-card-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--border-radius-md);
  background: var(--color-primary-light);
  color: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}
.admin-card-title {
  font-size: var(--font-size-sm);
  font-weight: 700;
  color: var(--text-primary);
}

/* ─── شاشة التقارير ────────────────────────────────────────── */
.reports-screen { padding: var(--space-md); }

/* ─── شاشة الإشعارات ───────────────────────────────────────── */
.notifications-screen { padding: var(--space-md); }
.notification-item {
  display: flex;
  gap: var(--space-md);
  padding: var(--space-md);
  border-bottom: 1px solid var(--border-color);
  transition: background var(--transition);
  border-right: 3px solid transparent;
}
.notification-item:hover { background: var(--bg-hover); }
.notification-item.clickable { cursor: pointer; }
.notification-item.clickable:hover { background: var(--color-primary-light); }
.notification-item.unread {
  background: var(--color-primary-light);
  border-right-color: var(--color-primary);
}
.notification-item.read {
  opacity: 0.8;
}
.notification-status-icon {
  font-size: 18px;
  flex-shrink: 0;
  margin-top: 2px;
  line-height: 1;
}
.notification-content { flex: 1; }
.notification-title { font-weight: 700; font-size: var(--font-size-sm); }
.notification-item.unread .notification-title { font-weight: 800; }
.notification-message { font-size: var(--font-size-sm); color: var(--text-secondary); margin-top: 2px; }
.notification-time { font-size: var(--font-size-xs); color: var(--text-muted); margin-top: 4px; }

/* ─── مجموعة الإشعارات (حسب السجل) ──────────────────────────── */
.notif-group {
  border-bottom: 1px solid var(--border-color);
  transition: background var(--transition);
}
.notif-group:last-child {
  border-bottom: none;
}
.notif-group.all-read {
  opacity: 0.7;
}
.notif-group:not(.all-read) .notif-group-header {
  background: var(--color-primary-light);
  border-right: 3px solid var(--color-primary);
}

.notif-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md);
  cursor: pointer;
  transition: background var(--transition);
  user-select: none;
}
.notif-group-header:hover {
  background: var(--bg-hover);
}
.notif-group-header.expanded {
  background: var(--bg-hover);
  border-bottom: 1px solid var(--border-color);
}

.notif-group-info {
  flex: 1;
  min-width: 0;
}
.notif-group-title {
  font-weight: 700;
  font-size: var(--font-size-sm);
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.notif-group-meta {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-top: 4px;
  font-size: var(--font-size-xs);
  color: var(--text-muted);
}

.notif-group-unread-badge {
  display: inline-block;
  background: var(--color-primary);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 10px;
  line-height: 1.5;
}

.notif-group-arrow {
  font-size: 20px;
  color: var(--text-muted);
  transition: transform var(--transition);
  flex-shrink: 0;
  margin-right: var(--space-sm);
}
.notif-group-header.expanded .notif-group-arrow {
  transform: rotate(90deg);
}

.notif-group-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}
.notif-group-actions .btn-icon {
  width: 26px;
  height: 26px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  opacity: 0.6;
  transition: opacity var(--transition);
}
.notif-group-actions .btn-icon:hover {
  opacity: 1;
}
.notif-group-header:hover .notif-group-actions .btn-icon {
  opacity: 0.8;
}

.notif-group-body {
  display: none;
  background: var(--bg-body);
}

/* ─── التايم لاين (التسلسل الزمني) داخل المجموعة ────────────── */
.notif-timeline-item {
  display: flex;
  position: relative;
  padding: var(--space-md) var(--space-md) var(--space-md) 0;
  margin-right: 20px;
  transition: background var(--transition);
}
.notif-timeline-item:hover {
  background: var(--bg-hover);
}
.notif-timeline-item.unread {
  background: var(--color-primary-light);
  border-right: 3px solid var(--color-primary);
}
.notif-timeline-item.read {
  background: transparent;
  opacity: 0.75;
}
.notif-timeline-item:last-child {
  padding-bottom: var(--space-md);
}

.notif-timeline-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 4px;
  margin-left: var(--space-sm);
  position: relative;
  z-index: 1;
}
.notif-timeline-dot.unread {
  background: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-light);
}
.notif-timeline-dot.read {
  background: var(--border-color);
}

.notif-timeline-line {
  position: absolute;
  right: 4px;
  top: 18px;
  bottom: -16px;
  width: 2px;
  background: var(--border-color);
  z-index: 0;
}
.notif-timeline-item:last-child .notif-timeline-line {
  display: none;
}

.notif-timeline-content {
  flex: 1;
  min-width: 0;
}
.notif-timeline-content.clickable {
  cursor: pointer;
}
.notif-timeline-content.clickable:hover {
  opacity: 0.85;
}
.notif-timeline-title {
  font-weight: 700;
  font-size: var(--font-size-sm);
  color: var(--text-primary);
}
.notif-timeline-item.unread .notif-timeline-title {
  font-weight: 800;
}
.notif-timeline-message {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  margin-top: 2px;
  line-height: 1.4;
}
.notif-timeline-time {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  margin-top: 4px;
}

/* ─── عناصر الإشعار المنظمة ────────────────────────────────── */
.notif-status-change {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  font-size: var(--font-size-sm);
  flex-wrap: nowrap;
}
.notif-status-label { white-space: nowrap; }
.notif-status-old {
  color: var(--text-muted);
  text-decoration: line-through;
  background: var(--bg-hover);
  padding: 2px 8px;
  border-radius: var(--border-radius-sm);
  white-space: nowrap;
}
.notif-status-arrow {
  color: var(--color-primary);
  font-weight: 700;
  font-size: 14px;
  white-space: nowrap;
}
.notif-status-new {
  color: var(--color-success);
  font-weight: 700;
  background: rgba(24, 128, 56, 0.08);
  padding: 2px 8px;
  border-radius: var(--border-radius-sm);
  white-space: nowrap;
}
.notif-notes {
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
  margin-top: 6px;
  padding: 6px 10px;
  background: var(--bg-hover);
  border-radius: var(--border-radius-sm);
  border-right: 3px solid var(--color-warning);
  line-height: 1.4;
}
.notif-actor {
  color: var(--text-muted);
  font-size: var(--font-size-xs);
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.notif-timeline-actions {
  display: flex;
  align-items: flex-start;
  gap: 4px;
  flex-shrink: 0;
  margin-right: var(--space-sm);
}
.notif-timeline-actions .btn-icon {
  width: 28px;
  height: 28px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}


/* ===== نمط شاشة طباعة طلب المساعدة ===== */

.print-mode #app {
  display: block !important;
  width: 100% !important;
  max-width: 100% !important;
  padding: 0 !important;
  margin: 0 !important;
}
.print-mode #main-content {
  display: block !important;
  width: 100% !important;
  max-width: 100% !important;
  overflow: visible !important;
  padding: 0 !important;
  margin: 0 !important;
}
.print-mode #screen-container {
  display: block !important;
  width: 100% !important;
  max-width: 100% !important;
  padding: 0 !important;
  margin: 0 !important;
}

.print-controls {
  display: flex;
  gap: var(--space-md);
  justify-content: center;
  padding: var(--space-md);
  background: var(--bg-body);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
}

.print-view {
  background: #fff;
  min-height: 100vh;
}
.print-loading {
  text-align: center;
  padding: var(--space-2xl);
  font-size: var(--font-size-lg);
  color: var(--text-secondary);
}

/* حاوية شاشة الطباعة (print-citizen) */
.print-screen {
  min-height: 100vh;
  background: #fff;
}

/* أزرار التحكم بالطباعة */
.print-controls {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-header);
  color: #fff;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.print-controls .btn {
  font-size: 14px;
  padding: 8px 16px;
}
.print-controls .btn-primary {
  background: var(--color-accent);
  border: none;
  color: #fff;
  border-radius: var(--border-radius-sm);
}
.print-controls .btn-ghost {
  background: rgba(255,255,255,0.15);
  border: none;
  color: #fff;
  border-radius: var(--border-radius-sm);
}
.print-controls label {
  color: rgba(255,255,255,0.9);
  font-size: 13px;
}

/* صفحة الطباعة - responsive للعرض على الشاشة */
.print-page {
  max-width: 100%;
  margin: 0 auto;
  padding: 16px;
  background: #fff;
  font-size: 14px;
  line-height: 1.6;
  color: #000;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* تحسين الجداول في الطباعة على الموبايل */
.print-page .print-table {
  font-size: 12px;
  min-width: 600px; /* يضمن تمرير أفقي للجداول الكبيرة */
}
.print-page .print-table th,
.print-page .print-table td {
  padding: 4px 6px;
  white-space: nowrap;
}

/* شبكة الإحصائيات في الطباعة - responsive */
.print-page .stats-grid {
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
}
.print-page .stat-box {
  padding: 8px;
}
.print-page .stat-value {
  font-size: 1.1rem;
}

/* عنوان صفحة الطباعة */
.print-title {
  text-align: center;
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--color-primary-dark);
  margin-bottom: var(--space-lg);
  padding-bottom: var(--space-sm);
  border-bottom: 2px solid var(--color-primary);
}

/* تذييل الطباعة */
.print-footer {
  text-align: center;
  font-size: 0.75rem;
  color: #666;
  margin-top: 30px;
  padding-top: 10px;
  border-top: 1px solid #999;
}

/* توقيعات الطباعة */
.print-signatures {
  display: flex;
  justify-content: space-around;
  margin: 40px 0 30px;
  gap: var(--space-xl);
}
.signature-line {
  text-align: center;
  min-width: 160px;
  font-size: 0.9rem;
}
.signature-line > div:first-child {
  font-weight: 700;
  margin-bottom: 4px;
}


/* Header */
.print-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-md);
  border-bottom: 2px solid var(--color-primary);
  padding-bottom: var(--space-md);
  margin-bottom: var(--space-lg);
}
.print-logo img {
  width: 90px;
  height: 90px;
  object-fit: contain;
}
.print-header-text {
  flex: 1;
  text-align: center;
}
.print-inst-name {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--color-primary-dark);
}
.print-inst-sub {
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin-top: 2px;
}
.print-inst-detail {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}
.print-request-box {
  border: 1px solid #333;
  padding: 8px 12px;
  min-width: 140px;
  font-size: 0.85rem;
}
.print-request-box-title {
  font-weight: 700;
  text-align: center;
  border-bottom: 1px solid #333;
  margin-bottom: 4px;
  padding-bottom: 2px;
}

/* Filter info in print reports */
.print-filter-info {
  background: #f0f4ff;
  border: 1px solid #ccd;
  border-radius: 6px;
  padding: 8px 12px;
  margin-bottom: 12px;
  font-size: 0.85rem;
  color: #333;
  direction: rtl;
  text-align: right;
}

/* Sections */
.print-section {
  margin-bottom: var(--space-lg);
}
.print-section-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--color-primary-dark);
  border-right: 4px solid var(--color-primary);
  padding-right: 10px;
  margin-bottom: var(--space-sm);
}

/* Notification print styles */
.print-notif-body {
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--color-text);
  padding: var(--space-xs) 0;
}
.print-notif-body .notif-status-change {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0;
  font-size: 0.85rem;
  flex-wrap: nowrap;
}
.print-notif-body .notif-status-label {
  color: var(--color-text-muted);
  font-weight: 500;
  white-space: nowrap;
}
.print-notif-body .notif-status-old {
  color: #888;
  text-decoration: line-through;
  background: #f5f5f5;
  padding: 2px 8px;
  border-radius: 4px;
  white-space: nowrap;
}
.print-notif-body .notif-status-arrow {
  color: var(--color-primary);
  font-weight: 700;
  font-size: 0.9rem;
  white-space: nowrap;
}
.print-notif-body .notif-status-new {
  color: #188038;
  font-weight: 700;
  background: rgba(24, 128, 56, 0.08);
  padding: 2px 8px;
  border-radius: 4px;
  white-space: nowrap;
}
.print-notif-body .notif-notes {
  color: #555;
  font-size: 0.85rem;
  margin-top: 6px;
  padding: 6px 10px;
  background: #f8f9fa;
  border-radius: 4px;
  border-right: 3px solid #f9ab00;
}
.print-notif-body .notif-actor {
  color: var(--color-text-muted);
  font-size: 0.85rem;
  margin-top: 6px;
}
.print-notif-body .notif-timeline-message {
  font-size: 0.9rem;
  color: #555;
  margin-top: 4px;
}
.print-notif-time {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin-top: 4px;
}
.print-notif-divider {
  border: none;
  border-top: 1px dashed var(--color-border);
  margin: var(--space-md) 0;
}

/* Tables */
.print-data-table,
.print-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.print-data-table td,
.print-table th,
.print-table td {
  border: 1px solid #444;
  padding: 6px 8px;
}
.print-data-table .label {
  background: #f5f5f5;
  font-weight: 600;
  width: 18%;
  white-space: nowrap;
}
.print-data-table .value {
  width: 32%;
}
.print-table thead th {
  background: #333;
  color: #fff;
  font-weight: 600;
  font-size: 0.8rem;
  text-align: center;
}
.print-table tbody td {
  text-align: center;
  font-size: 0.8rem;
}
.print-table tbody tr:nth-child(even) {
  background: #f8f9fa;
}
/* Column width classes for print report tables */
.print-table-aid .col-id      { width: 5%; }
.print-table-aid .col-name    { width: 18%; }
.print-table-aid .col-nid     { width: 11%; }
.print-table-aid .col-mobile  { width: 10%; }
.print-table-aid .col-type    { width: 14%; }
.print-table-aid .col-qty     { width: 10%; }
.print-table-aid .col-status  { width: 10%; }
.print-table-aid .col-gov     { width: 12%; }
.print-table-aid .col-date    { width: 10%; }

.print-table-citizen .col-id      { width: 6%; }
.print-table-citizen .col-name    { width: 22%; }
.print-table-citizen .col-nid     { width: 13%; }
.print-table-citizen .col-mobile  { width: 12%; }
.print-table-citizen .col-gov     { width: 15%; }
.print-table-citizen .col-family  { width: 10%; }
.print-table-citizen .col-reqs    { width: 10%; }
.print-table-citizen .col-status  { width: 12%; }

.highlight-row {
  background: #fff3cd !important;
  font-weight: 700;
}
.family-note {
  font-size: 0.8rem;
  color: #856404;
  background: #fff3cd;
  padding: 4px 8px;
  margin-top: 4px;
  border-radius: var(--border-radius-sm);
}

/* Notes boxes */
.print-notes-box {
  border: 1px solid #999;
  padding: 10px;
  min-height: 60px;
  background: #fafafa;
  border-radius: var(--border-radius-sm);
  white-space: pre-wrap;
}

/* Stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: var(--space-sm);
}
.stat-card {
  border: 1px solid #444;
  padding: 8px;
  text-align: center;
}
.stat-title {
  font-weight: 700;
  font-size: 0.8rem;
  margin-bottom: 4px;
}
.stat-count {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--color-primary);
}
.stat-break {
  font-size: 0.7rem;
  margin-top: 4px;
  display: flex;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
}
.stat-fin { color: #2a9d8f; }
.stat-ink { color: #e09f3e; }
.stat-edu { color: #457b9d; }

/* Status badges in print */
.status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}
.status-pending   { background: #fff3cd; color: #856404; }
.status-approved  { background: #d4edda; color: #155724; }
.status-delivered { background: #cce5ff; color: #004085; }
.status-rejected  { background: #f8d7da; color: #721c24; }
.status-cancelled { background: #e2e3e5; color: #383d41; }

/* Signature & Decision Page */
.signatures-row {
  display: flex;
  justify-content: space-around;
  align-items: flex-start;
  gap: var(--space-xl);
  margin: 40px 0 30px;
}
.signature-box {
  text-align: center;
  flex: 1;
}
.signature-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 20px;
}
.signature-line {
  font-size: 1.2rem;
  letter-spacing: 2px;
  margin-bottom: 8px;
}
.signature-name {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.decision-box {
  border: 1px solid #333;
  padding: 20px;
  margin-top: 30px;
}
.decision-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 16px;
}
.decision-options {
  display: flex;
  gap: var(--space-xl);
  justify-content: center;
  margin-bottom: 20px;
}
.decision-option {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 1rem;
}
.decision-checkbox {
  font-size: 1.3rem;
}
.decision-notes-area {
  margin-bottom: 30px;
}
.decision-notes-label {
  font-weight: 600;
  margin-bottom: 6px;
}
.decision-notes-lines {
  border: 1px solid #999;
  min-height: 80px;
  background: #fff;
}

.governor-signature {
  text-align: center;
  margin-top: 20px;
}
.governor-sig-title {
  font-weight: 700;
  margin-bottom: 12px;
}
.governor-sig-line {
  font-size: 1.2rem;
  letter-spacing: 2px;
  margin-bottom: 6px;
}
.governor-sig-name {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--color-primary-dark);
}
.governor-sig-title2 {
  font-size: 0.8rem;
  color: var(--text-secondary);
}
.governor-sig-image img {
  max-height: 60px;
  margin-top: 4px;
}

.print-footer {
  text-align: center;
  font-size: 0.75rem;
  color: #666;
  margin-top: 30px;
  padding-top: 10px;
  border-top: 1px solid #ccc;
}

/* Print Citizen specific */
.print-citizen-header {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
  padding-bottom: var(--space-md);
  border-bottom: 2px solid var(--color-primary);
}
.print-citizen-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--color-primary);
}
.print-signatures {
  display: flex;
  justify-content: space-around;
  margin-top: 40px;
  gap: var(--space-xl);
}
.signature-line {
  text-align: center;
  flex: 1;
}
.attachments-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: var(--space-sm);
  margin-top: var(--space-sm);
}
.attach-item {
  border: 1px solid #ddd;
  border-radius: var(--border-radius-sm);
  overflow: hidden;
  text-align: center;
  background: #fff;
}
.attach-item img {
  width: 100%;
  height: 120px;
  object-fit: contain;
  background: #f8f9fa;
}
.attach-icon {
  width: 100%;
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  background: #f8f9fa;
}
.attach-name {
  padding: 6px;
  font-size: 0.75rem;
  color: #555;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stat-box {
  border: 1px solid #444;
  padding: 10px;
  text-align: center;
  background: #fff;
}
.stat-value {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--color-primary);
}
.stat-label {
  font-size: 0.75rem;
  color: #555;
  margin-top: 4px;
}
.stat-cash .stat-value { color: #2a9d8f; }
.stat-inkind .stat-value { color: #e09f3e; }

/* Print media query - merged for all print screens */
@media print {
  /* إعداد الصفحة — يتم ضبط الاتجاه تلقائياً بواسطة PrintUtils.setOrientation()
     في كل شاشة طباعة (landscape للتقارير، portrait للنماذج الفردية).
     هذا القاعدة تعمل كاحتياطي للهامش فقط. */
  @page {
    margin: 12mm;
  }

  /* Hide UI elements */
  .no-print,
  #app-header,
  #sidebar,
  #bottom-nav,
  .print-controls,
  #toast-container {
    display: none !important;
  }
  #app,
  #main-content,
  #screen-container {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow: visible !important;
  }

  /* Print screen background */
  .print-screen {
    background: #fff;
  }

  /* Page layout - force full width on all containers */
  .print-page {
    padding: 0;
    margin: 0;
    max-width: 100%;
    width: 100% !important;
    overflow: visible;
    page-break-after: always;
  }
  .print-page:last-child {
    page-break-after: auto;
  }

  /* Body */
  body {
    background: #fff;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  /* Force all containers to fill width */
  .print-view,
  .print-screen,
  #print-reports-view,
  #print-view,
  #print-bulk-view,
  #print-citizen-view,
  #print-notifications-view {
    width: 100% !important;
    max-width: 100% !important;
  }
  .print-section {
    width: 100% !important;
    margin-bottom: 8px;
  }
  .print-header {
    width: 100% !important;
    padding-bottom: 4px;
    margin-bottom: 6px;
    gap: 8px;
  }

  /* ─── PRINT TABLES ─── */
  /* Use fixed layout so percentage column widths are strictly respected.
     Override min-width:600px from base CSS so the table fills the full page width.
     The base CSS column widths (e.g. .col-name { width: 18% }) add up to 100%
     and are preserved so the table stretches across the entire page. */
  .print-page .print-table,
  .print-table {
    width: 100% !important;
    min-width: 100% !important;
    table-layout: fixed !important;
    font-size: 0.7rem;
  }
  .print-page .print-table th,
  .print-page .print-table td,
  .print-table th,
  .print-table td {
    padding: 2px 4px;
    white-space: nowrap;
  }
  .print-page .print-table th,
  .print-table th {
    font-size: 0.65rem;
  }
  .print-page .print-table td,
  .print-table td {
    font-size: 0.65rem;
  }

  /* Data table (label/value pairs) - fixed layout */
  .print-page .print-data-table,
  .print-data-table {
    width: 100% !important;
    min-width: 100% !important;
    table-layout: fixed !important;
  }
  .print-page .print-data-table td,
  .print-data-table td {
    padding: 2px 5px;
    font-size: 0.65rem;
    white-space: nowrap;
  }
  .print-page .print-data-table td.label,
  .print-data-table .label {
    width: 18% !important;
    background: #f5f5f5;
    font-weight: 600;
    white-space: nowrap;
  }
  .print-page .print-data-table td.value,
  .print-data-table .value {
    width: 32% !important;
    white-space: nowrap;
  }

  /* Header */
  .print-logo img {
    width: 90px;
    height: 90px;
    object-fit: contain;
  }
  .print-inst-name {
    font-size: 0.9rem;
  }
  .print-inst-sub {
    font-size: 0.7rem;
  }
  .print-inst-detail {
    font-size: 0.6rem;
  }

  /* Request box */
  .print-request-box {
    padding: 3px 6px;
    min-width: auto !important;
    font-size: 0.65rem;
    white-space: nowrap;
  }
  .print-request-box-title {
    font-size: 0.65rem;
  }

  /* Filter info */
  .print-filter-info {
    padding: 3px 6px;
    margin-bottom: 4px;
    font-size: 0.65rem;
  }

  /* Section title */
  .print-section-title {
    font-size: 0.8rem;
    margin-bottom: 3px;
  }

  /* Footer */
  .print-footer {
    margin-top: 6px;
    padding-top: 4px;
    font-size: 0.6rem;
  }

  /* Signatures */
  .signatures-row {
    margin: 15px 0 10px;
    gap: 15px;
  }
  .signature-box {
    font-size: 0.65rem;
  }
  .signature-line {
    width: 160px;
  }

  /* Stats grid */
  .print-page .stats-grid,
  .stats-grid {
    gap: 4px;
  }
  .print-page .stat-card,
  .stat-card {
    padding: 4px;
  }
  .print-page .stat-count,
  .stat-count {
    font-size: 1rem;
  }
}
.modal-tabs .tab-btn {
  flex: 1;
  padding: 10px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  font-weight: 600;
  cursor: pointer;
  font-size: var(--font-size-sm);
  transition: color var(--transition), border-color var(--transition);
}
.modal-tabs .tab-btn.active {
  border-bottom-color: var(--color-primary);
  color: var(--color-primary);
}

/* ─── طباعة المرفقات: كل مرفق في صفحة منفصلة ─── */
@media print {
  #print-attachments-section {
    page-break-before: always;
  }
  .attachments-grid {
    display: block;
  }
  .attachments-grid .attach-item {
    width: 100%;
    height: 85vh;
    break-inside: avoid;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 1px solid #ccc;
    margin-bottom: 0;
  }
  .attachments-grid .attach-item:not(:first-child) {
    page-break-before: always;
  }
  .attachments-grid .attach-item img {
    width: 100%;
    height: 75vh;
    object-fit: contain;
    background: #f8f9fa;
  }
  .attachments-grid .attach-icon {
    width: 100%;
    height: 75vh;
    font-size: 6rem;
  }
  .attachments-grid .attach-name {
    margin-top: 8px;
    font-size: 14px;
    text-align: center;
  }
}

/* ─── شاشة الجغرافيا (Accordion) ─────────────────────────────── */
.gov-accordion { display: flex; flex-direction: column; gap: var(--space-sm); padding: var(--space-md); }
.gov-card { background: var(--bg-card); border-radius: var(--border-radius-lg); box-shadow: var(--shadow-sm); overflow: hidden; border: 1px solid var(--color-border); }
.gov-header { display: flex; align-items: center; justify-content: space-between; padding: var(--space-md); cursor: pointer; transition: background 0.15s; user-select: none; }
.gov-header:hover { background: var(--bg-hover); }
.gov-title { display: flex; align-items: center; gap: var(--space-sm); flex: 1; min-width: 0; }
.gov-icon { font-size: 1.5rem; flex-shrink: 0; }
.gov-name { font-weight: 700; font-size: var(--font-size-lg); color: var(--color-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gov-badge { background: var(--color-primary-light); color: var(--color-primary); font-size: var(--font-size-xs); padding: 2px 8px; border-radius: var(--border-radius-sm); font-weight: 600; flex-shrink: 0; }
.gov-actions { display: flex; align-items: center; gap: var(--space-xs); }
.gov-toggle-icon { font-size: var(--font-size-sm); color: var(--color-muted); margin-right: var(--space-xs); transition: transform 0.2s; }
.gov-body { border-top: 1px solid var(--color-border); padding: var(--space-sm) var(--space-md); background: var(--bg-body); }
.town-add-bar { margin-bottom: var(--space-sm); }
.town-item { display: flex; align-items: center; justify-content: space-between; padding: var(--space-sm) var(--space-md); border-radius: var(--border-radius-md); background: var(--bg-card); margin-bottom: var(--space-xs); border: 1px solid var(--color-border); transition: background 0.15s; }
.town-item:hover { background: var(--bg-hover); }
.town-item:last-child { margin-bottom: 0; }
.town-name { font-size: var(--font-size-md); color: var(--color-text); }
.town-empty { text-align: center; padding: var(--space-lg); color: var(--color-muted); font-size: var(--font-size-sm); }

@media (max-width: 480px) {
  .gov-header { align-items: flex-start; gap: var(--space-xs); }
  .gov-title { align-items: flex-start; }
  .gov-name {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    word-break: break-word;
    font-size: var(--font-size-md);
    line-height: 1.4;
  }
  .gov-actions { flex-direction: column; gap: 4px; }
}

.geo-search-bar {
  padding: var(--space-sm) var(--space-md);
}
.geo-search-bar input {
  width: 100%;
}

.bulk-delete-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) var(--space-md);
  background: #fff3f3;
  border: 1px solid var(--color-danger);
  border-radius: var(--border-radius-md);
  margin: var(--space-sm) var(--space-md);
  color: var(--color-danger);
  font-weight: 600;
}
.bulk-delete-bar.hidden { display: none; }
.bulk-actions { display: flex; gap: var(--space-sm); }

.town-toolbar {
  display: flex;
  align-items: center;
  padding: var(--space-xs) var(--space-md);
  border-bottom: 1px dashed var(--color-border);
  margin-bottom: var(--space-xs);
}
.town-checkall {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  cursor: pointer;
}
.town-checkall input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--color-primary);
  cursor: pointer;
}
.town-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--border-radius-md);
  background: var(--bg-card);
  margin-bottom: var(--space-xs);
  border: 1px solid var(--color-border);
  transition: background 0.15s;
}
.town-item:hover { background: var(--bg-hover); }
.town-item:last-child { margin-bottom: 0; }
.town-checkbox {
  width: 18px;
  height: 18px;
  accent-color: var(--color-primary);
  cursor: pointer;
  flex-shrink: 0;
}
.town-name { flex: 1; font-size: var(--font-size-md); color: var(--color-text); }

.bulk-delete-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--border-radius-md);
  border: 1px solid var(--color-border);
  margin-bottom: var(--space-xs);
  background: var(--bg-card);
  transition: opacity 0.2s, background 0.2s;
  cursor: pointer;
}
.bulk-delete-item:hover { background: var(--bg-hover); }
.bulk-delete-item.unchecked { opacity: 0.4; background: #f8f9fa; text-decoration: line-through; }
.bulk-delete-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--color-danger);
  cursor: pointer;
  flex-shrink: 0;
}
.bulk-delete-item span { font-size: var(--font-size-md); color: var(--color-text); }

/* ============================================================
   Roles Management Screen
   ============================================================ */
.roles-screen {
  padding: var(--space-md);
}

.roles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: var(--space-md);
}

.role-card {
  background: var(--bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-lg);
  padding: var(--space-md);
  transition: box-shadow 0.2s, transform 0.2s;
}

.role-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.role-card.role-system {
  border-right: 4px solid var(--color-primary);
}

.role-card-header {
  margin-bottom: var(--space-sm);
}

.role-card-title {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--color-text);
}

.role-card-label {
  flex: 1;
}

.role-badge-system {
  font-size: 10px;
  background: var(--color-primary-light, #dbeafe);
  color: var(--color-primary);
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 500;
}

.role-badge-superadmin {
  font-size: 10px;
  background: var(--color-danger-light, #fce4ec);
  color: var(--color-danger);
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 500;
}

.role-card-name {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  direction: ltr;
  text-align: left;
  font-family: monospace;
  margin-top: 2px;
}

.role-card-desc {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-sm);
  line-height: 1.4;
}

.role-card-stats {
  font-size: var(--font-size-xs);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-sm);
}

.role-card-actions {
  display: flex;
  gap: var(--space-xs);
  padding-top: var(--space-sm);
  border-top: 1px solid var(--color-border);
}

/* محرر الصلاحيات في نافذة تعديل/إنشاء الدور */
#role-perms-editor .perm-group {
  margin-bottom: var(--space-md);
  padding: var(--space-sm);
  background: var(--bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-md);
}

#role-perms-editor .perm-group-header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-xs);
}

#role-perms-editor .perm-resource-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 6px 0;
  border-bottom: 1px solid var(--color-border-light, #f0f0f0);
}

#role-perms-editor .perm-resource-row:last-child {
  border-bottom: none;
}

#role-perms-editor .perm-resource-label {
  min-width: 120px;
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--color-text);
}

#role-perms-editor .perm-actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
}

#role-perms-editor .perm-action-label {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}

#role-perms-editor .perm-action-label input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: var(--color-primary);
  cursor: pointer;
}

#role-perms-editor .perm-action-info {
  font-size: 14px;
  color: var(--color-primary, #007bff);
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.2s;
  user-select: none;
}
#role-perms-editor .perm-action-label:hover .perm-action-info {
  opacity: 1;
}

/* ─── نافذة شرح الصلاحية المنبثقة ──────────────────────────── */
.perm-info-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  touch-action: none;
}
.perm-info-modal {
  background: var(--color-surface, #fff);
  border-radius: 12px;
  max-width: 400px;
  width: 100%;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  direction: rtl;
  overflow: hidden;
}
.perm-info-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--color-border, #e0e0e0);
}
.perm-info-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--color-text, #000);
}
.perm-info-close {
  background: none;
  border: none;
  font-size: 22px;
  color: var(--color-text-secondary, #666);
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}
.perm-info-close:hover {
  color: var(--color-text, #000);
}
.perm-info-body {
  padding: 16px 18px;
  font-size: 14px;
  line-height: 1.7;
  color: var(--color-text, #333);
}

/* ─── زر شرح قصة الصلاحيات ────────────────────────────────── */
.perm-story-btn {
  font-size: 20px;
  cursor: pointer;
  user-select: none;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
  animation: permStoryPulse 2s ease-in-out infinite;
  transition: transform 0.2s, box-shadow 0.2s;
  position: relative;
}
.perm-story-btn::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 2px solid rgba(102, 126, 234, 0.3);
  animation: permStoryRing 2s ease-in-out infinite;
}
.perm-story-btn:hover {
  transform: scale(1.2);
  box-shadow: 0 4px 16px rgba(102, 126, 234, 0.6);
  animation: none;
}
.perm-story-btn:hover::after {
  animation: none;
  opacity: 0;
}

@keyframes permStoryPulse {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
  }
  50% {
    transform: scale(1.1);
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.7);
  }
}
@keyframes permStoryRing {
  0%, 100% {
    transform: scale(1);
    opacity: 0.5;
  }
  50% {
    transform: scale(1.15);
    opacity: 0;
  }
}

/* ─── نافذة شرح قصة الصلاحيات ─────────────────────────────── */
.perm-story-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  touch-action: none;
}
.perm-story-modal {
  background: var(--color-surface, #fff);
  border-radius: 14px;
  max-width: 520px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  direction: rtl;
}
.perm-story-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-border, #e0e0e0);
  position: sticky;
  top: 0;
  background: var(--color-surface, #fff);
  z-index: 1;
}
.perm-story-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--color-text, #000);
}
.perm-story-close {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--color-text-secondary, #666);
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}
.perm-story-close:hover {
  color: var(--color-text, #000);
}
.perm-story-body {
  padding: 16px 20px 20px;
}
.perm-story-section {
  display: flex;
  gap: 12px;
  margin-bottom: 18px;
  align-items: flex-start;
}
.perm-story-icon {
  font-size: 24px;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-bg-secondary, #f5f5f5);
  border-radius: 8px;
}
.perm-story-content {
  flex: 1;
}
.perm-story-content strong {
  display: block;
  font-size: 14px;
  margin-bottom: 4px;
  color: var(--color-text, #000);
}
.perm-story-content p {
  font-size: 13px;
  line-height: 1.6;
  color: var(--color-text-secondary, #555);
  margin: 0 0 6px;
}
.perm-story-example {
  background: var(--color-bg-secondary, #f9f9f9);
  border-radius: 6px;
  padding: 8px 10px;
  margin-top: 4px;
}
.perm-story-example code {
  display: block;
  font-size: 12px;
  color: var(--color-text, #333);
  direction: ltr;
  text-align: left;
  padding: 2px 0;
}
.perm-story-summary {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--color-border, #e0e0e0);
}
.perm-story-summary > strong {
  display: block;
  font-size: 14px;
  margin-bottom: 10px;
  text-align: center;
  color: var(--color-text, #000);
}
.perm-story-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.perm-story-table th,
.perm-story-table td {
  padding: 6px 10px;
  text-align: center;
  border-bottom: 1px solid var(--color-border, #eee);
}
.perm-story-table th {
  background: var(--color-bg-secondary, #f5f5f5);
  font-weight: 600;
  color: var(--color-text, #000);
}
.perm-story-table td:first-child {
  text-align: right;
  font-weight: 500;
}
.perm-story-table .yes {
  color: #27ae60;
  font-size: 16px;
}
.perm-story-table .no {
  color: #e74c3c;
  font-size: 16px;
}
.perm-story-chapter {
  margin: 20px 0 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--color-primary, #3498db);
}
.perm-story-chapter h3 {
  font-size: 15px;
  margin: 0;
  color: var(--color-text, #222);
}
.perm-story-chapter-badge {
  display: inline-block;
  background: var(--color-primary, #3498db);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 10px;
  margin-bottom: 6px;
  letter-spacing: 0.5px;
}
.perm-story-note {
  background: #eef6ff;
  border-right: 3px solid var(--color-primary, #3498db);
  padding: 8px 12px;
  margin-top: 8px;
  border-radius: 4px;
  font-size: 12px;
  color: #2c3e50;
  line-height: 1.5;
}
.perm-story-tip {
  background: linear-gradient(135deg, #fef9e7, #fdebd0);
  border: 1px solid #f5cba7;
  border-radius: 8px;
  padding: 12px 16px;
  margin-top: 16px;
  font-size: 13px;
  color: #7e5109;
  line-height: 1.6;
}
.perm-story-tip strong {
  display: block;
  margin-bottom: 4px;
  font-size: 14px;
}

/* ─── معاينة الطباعة داخل نافذة الشرح ─────────────────── */
.perm-story-modal .perm-print-header {
  background: linear-gradient(135deg, #2c3e50, #3498db);
  color: #fff;
  padding: 20px 24px;
  text-align: center;
}
.perm-story-modal .perm-print-title {
  font-size: 20px;
  margin: 0 0 4px;
  color: #fff;
}
.perm-story-modal .perm-print-subtitle {
  font-size: 13px;
  opacity: 0.85;
  margin: 0 0 10px;
}
.perm-story-modal .perm-print-meta {
  font-size: 12px;
  opacity: 0.7;
  margin-bottom: 14px;
}
.perm-story-modal .perm-print-meta span {
  margin: 0 8px;
}
.perm-story-modal .perm-print-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
}
.perm-story-modal .perm-print-actions .btn {
  font-size: 13px;
  padding: 8px 20px;
}
.perm-story-modal .perm-print-actions .btn-ghost {
  color: #555;
  border-color: #bbb;
  background: #f5f5f5;
}
.perm-story-modal .perm-print-actions .btn-ghost:hover {
  background: #e8e8e8;
  color: #333;
}
.perm-story-modal .perm-print-body {
  padding: 20px 24px;
  background: #fff;
  color: #222;
  max-height: 55vh;
  overflow-y: auto;
}
.perm-story-modal .perm-print-body .perm-story-chapter {
  border-bottom-color: #3498db;
}
.perm-story-modal .perm-print-body .perm-story-chapter h3 {
  color: #2c3e50;
}
.perm-story-modal .perm-print-body .perm-story-section {
  background: #f8f9fa;
  border-right: 4px solid #3498db;
}
.perm-story-modal .perm-print-body .perm-story-content strong {
  color: #2c3e50;
}
.perm-story-modal .perm-print-body .perm-story-content p {
  color: #444;
}
.perm-story-modal .perm-print-body .perm-story-example {
  background: #eef2f7;
}
.perm-story-modal .perm-print-body .perm-story-note {
  background: #eef6ff;
  color: #2c3e50;
}
.perm-story-modal .perm-print-body .perm-story-tip {
  background: linear-gradient(135deg, #fef9e7, #fdebd0);
  border-color: #f5cba7;
  color: #7e5109;
}
.perm-story-modal .perm-print-body .perm-story-summary {
  border-color: #3498db;
}
.perm-story-modal .perm-print-footer {
  text-align: center;
  padding: 12px 24px;
  border-top: 1px solid #eee;
  font-size: 11px;
  color: #95a5a6;
  background: #fafafa;
}
.perm-story-modal .perm-print-footer p {
  margin: 2px 0;
}

#role-perms-editor .perm-group-toggle {
  width: 14px;
  height: 14px;
  accent-color: var(--color-primary);
  cursor: pointer;
}

.form-hint {
  display: block;
  font-size: var(--font-size-xs);
  color: var(--color-text-secondary);
  margin-top: 4px;
}

.form-divider {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: var(--space-md) 0;
}

/* ─── شريط مستوى الدور (Role Level Bar) ─────────────────── */
.role-level-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: var(--space-sm);
  padding: 4px 0;
}
.role-level-icon {
  font-size: 14px;
  flex-shrink: 0;
}
.role-level-track {
  display: flex;
  gap: 3px;
  flex: 1;
  max-width: 120px;
}
.role-level-seg {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: var(--color-border);
  transition: background 0.3s;
}
.role-level-seg.active {
  background: var(--color-primary);
}
.role-level-label {
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ─── أزرار القوالب (Preset Templates) ──────────────────── */
.perm-templates {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: var(--space-md);
  padding: var(--space-sm);
  background: var(--color-bg-secondary, #f8f9fa);
  border-radius: var(--border-radius-md);
  border: 1px dashed var(--color-border);
}
.perm-templates-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-secondary);
  margin-left: 4px;
}
.perm-templates .btn-outline {
  font-size: 11px;
  padding: 3px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-sm);
  background: var(--bg-card);
  color: var(--color-text);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

/* ─── تحذير الصلاحيات غير المنطقية (بدون قراءة) ──────────── */
.perm-warning-msg {
  font-size: 11px;
  color: #e74c3c;
  padding: 4px 8px;
  margin-top: 4px;
  margin-bottom: 4px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--border-radius-sm);
  line-height: 1.4;
  animation: permWarningFadeIn 0.3s ease;
}

@keyframes permWarningFadeIn {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.perm-templates .btn-outline:hover {
  border-color: var(--color-primary);
  background: var(--color-primary-light, #dbeafe);
  color: var(--color-primary);
}

/* ─── تلميحات المجموعات (Group Hints) ───────────────────── */
.perm-group-hint {
  font-size: 11px;
  color: var(--color-text-secondary);
  padding: 4px 8px;
  margin-bottom: var(--space-xs);
  background: var(--color-bg-secondary, #f0f4f8);
  border-radius: var(--border-radius-sm);
  line-height: 1.4;
}

/* ─── شاشة المحادثة المكبرة ──────────────────────────────── */
.chat-view-screen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  direction: rtl;
  background: var(--bg-primary, #f5f5f5);
  z-index: 150;
}
/* شاشة كبيرة: نافذة منبثقة بدلاً من full screen */
@media (min-width: 769px) {
  .chat-view-screen {
    top: 50%;
    left: 50%;
    right: auto;
    bottom: auto;
    transform: translate(-50%, -50%);
    width: 85vw;
    max-width: 900px;
    height: 85vh;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.35);
    overflow: hidden;
  }
  /* خلفية معتمة */
  .chat-view-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 149;
  }
}

/* ─── رسائل النظام (رد تلقائي) ──────────────────────────────── */
.system-message {
  text-align: center;
  margin: 8px 16px;
  padding: 6px 12px;
  background: var(--bg-subtle, #f0f4f8);
  border-radius: 12px;
  border: 1px dashed var(--border-color, #ddd);
}
.system-badge {
  font-size: 10px;
  color: var(--text-muted, #888);
  margin-bottom: 4px;
}
.system-text {
  font-size: 13px;
  color: var(--text-secondary, #555);
  line-height: 1.5;
  white-space: pre-wrap;
}

/* ─── تفاصيل الطلب الموسعة ───────────────────────────────────── */
.track-request-detail {
  animation: trackDetailIn 0.2s ease;
}
@keyframes trackDetailIn {
  from { opacity: 0; max-height: 0; }
  to { opacity: 1; max-height: 500px; }
}
.track-detail-section {
  padding: 0;
}
.track-detail-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--color-primary, #3d5a80);
  margin-bottom: 4px;
}
.track-detail-text {
  font-size: 11px;
  color: var(--text-secondary, #555);
  line-height: 1.7;
  white-space: pre-wrap;
}
.track-request-expand-icon {
  font-size: 11px;
  color: var(--text-muted);
  transition: transform 0.2s;
}

/* ─── شارات البطاقات (غير مقروء، محادثة مغلقة) ─────────────── */
.track-unread-badge {
  font-size: 10px;
  font-weight: 700;
  background: #3b82f6;
  color: #fff;
  padding: 2px 7px;
  border-radius: 10px;
  white-space: nowrap;
  animation: unreadPulse 2s infinite;
}
@keyframes unreadPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}
.track-chat-closed-badge {
  font-size: 11px;
  opacity: 0.7;
}
.track-chat-readonly-badge {
  font-size: 11px;
  opacity: 0.7;
}
.track-reopen-badge {
  font-size: 11px;
  animation: spin 2s linear infinite;
  display: inline-block;
}
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* ─── تحسينات الجوال لبطاقات الطلبات ────────────────────────── */
@media (max-width: 576px) {
  .track-request-card {
    padding: 10px 12px;
  }
  .track-request-header {
    flex-wrap: wrap;
    gap: 6px;
  }
  .track-request-number {
    font-size: 13px;
  }
  .track-request-status {
    font-size: 10px;
    padding: 2px 8px;
  }
  .track-request-row {
    font-size: 12px;
  }
  .track-request-label {
    font-size: 10px;
    margin-left: 8px;
  }
  .track-request-value {
    font-size: 12px;
  }
  .track-request-expand-icon {
    margin-left: auto;
    margin-right: 0;
  }
}

/* ─── تحسينات الجوال لشاشة المحادثة ──────────────────────────── */
@media (max-width: 768px) {
  .chat-view-screen {
    /* full screen على الجوال */
    top: 0; left: 0; right: 0; bottom: 0;
    transform: none;
    width: 100%;
    height: 100%;
    border-radius: 0;
  }
  .chat-view-backdrop {
    display: none;
  }
  /* تصغير أزرار الإجراءات في المحادثة للجوال */
  #citizen-chat-input {
    font-size: 14px !important;
    padding: 6px 4px !important;
  }
  #citizen-chat-send {
    width: 38px !important;
    height: 38px !important;
    min-width: 38px !important;
  }
}

/* ─── شاشة كبيرة: تحسينات إضافية ────────────────────────────── */
@media (min-width: 1200px) {
  .track-request-card {
    padding: 16px 24px;
  }
  .track-request-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 24px;
  }
  .track-request-chat {
    grid-column: 1 / -1;
  }
  .track-request-detail {
    grid-column: 1 / -1;
  }
  .chat-view-screen {
    max-width: 1000px;
  }
}

/* ─── مؤشر الرد (Reply Preview) ──────────────────────────────── */
#citizen-chat-reply-preview {
  display: none;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: rgba(61, 90, 128, 0.08);
  border-right: 3px solid var(--color-primary, #3d5a80);
  margin: 0 0 4px 0;
  font-size: 11px;
  color: var(--text-secondary);
  border-radius: 0 4px 4px 0;
}

