/* ============================================
   نظام مركز قدرات العطاء - التنسيق الرئيسي
   ============================================ */

:root {
  --primary: #0f766e;
  --primary-light: #14b8a6;
  --primary-dark: #0d4f4a;
  --secondary: #6366f1;
  --accent: #f59e0b;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --info: #3b82f6;
  --bg: #f3f6f9;
  --bg-card: #ffffff;
  --bg-sidebar: #ffffff;
  --text: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --border-soft: #f1f5f9;
  --shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 16px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 8px 32px rgba(15, 23, 42, 0.12);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --sidebar-width: 260px;
  --sidebar-collapsed: 76px;
  --topbar-h: 64px;
  --childbar-h: 88px;
  --transition: 0.2s ease;

  /* Display Mode Variables - يتغير حسب اختيار المستخدم */
  --ui-scale: 1;            /* حجم الخط الأساسي */
  --ui-gap: 16px;           /* المسافات بين العناصر */
  --ui-card-padding: 20px;  /* padding البطاقات */
  --ui-input-h: 40px;       /* ارتفاع حقول الإدخال */
  --ui-table-cell-pad: 8px; /* padding خلايا الجداول */
  --ui-form-grid-cols: 3;   /* عدد أعمدة النماذج */
  --ui-sidebar-w: 260px;    /* عرض القائمة الجانبية */
  --ui-section-title: 16px; /* حجم خط عناوين الأقسام */
  --ui-content-max-w: 100%; /* أقصى عرض للمحتوى */
  --ui-base-font: 14px;     /* حجم الخط الأساسي */
}

/* ==== Display Mode: Normal (افتراضي) ==== */
body.display-mode-normal {
  --ui-scale: 1;
  --ui-gap: 16px;
  --ui-card-padding: 20px;
  --ui-input-h: 40px;
  --ui-table-cell-pad: 8px;
  --ui-form-grid-cols: 3;
  --ui-sidebar-w: 260px;
  --ui-section-title: 16px;
  --ui-base-font: 14px;
}

/* ==== Display Mode: Fit (ملاءمة الشاشة) ==== */
body.display-mode-fit {
  --ui-scale: 0.95;
  --ui-gap: 12px;
  --ui-card-padding: 14px;
  --ui-input-h: 34px;
  --ui-table-cell-pad: 5px;
  --ui-form-grid-cols: 2;
  --ui-sidebar-w: 220px;
  --ui-section-title: 15px;
  --ui-base-font: 13px;
}

/* ==== Display Mode: Auto (تلقائي حسب الشاشة) ==== */
@media (max-width: 1366px) {
  body.display-mode-auto {
    --ui-scale: 0.95;
    --ui-gap: 12px;
    --ui-card-padding: 14px;
    --ui-input-h: 34px;
    --ui-table-cell-pad: 5px;
    --ui-form-grid-cols: 2;
    --ui-sidebar-w: 220px;
    --ui-section-title: 15px;
    --ui-base-font: 13px;
  }
}
@media (max-width: 1024px) {
  body.display-mode-auto {
    --ui-scale: 0.9;
    --ui-gap: 10px;
    --ui-card-padding: 12px;
    --ui-input-h: 32px;
    --ui-table-cell-pad: 4px;
    --ui-form-grid-cols: 1;
    --ui-sidebar-w: 200px;
    --ui-section-title: 14px;
    --ui-base-font: 13px;
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }

@font-face {
  font-family: "Cairo";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/Cairo-Regular.ttf") format("truetype");
}
@font-face {
  font-family: "Cairo";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("fonts/Cairo-Bold.ttf") format("truetype");
}

html, body {
  font-family: "Cairo", "Segoe UI Arabic", "Tahoma", "Arial", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  direction: rtl;
}

body { min-height: 100vh; }

.hidden { display: none !important; }

/* ============================================
   شاشة تسجيل الدخول
   ============================================ */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f766e 0%, #14b8a6 50%, #6366f1 100%);
  padding: 20px;
  position: relative;
  overflow: auto;
}
.login-screen::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 20%, rgba(255,255,255,0.08) 0, transparent 40%),
    radial-gradient(circle at 80% 80%, rgba(255,255,255,0.06) 0, transparent 40%);
  pointer-events: none;
}
.login-card {
  position: relative;
  z-index: 1;
  background: white;
  border-radius: 18px;
  padding: 36px 32px 28px;
  width: 100%;
  max-width: 420px;
  height: auto;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.28), 0 2px 6px rgba(15, 23, 42, 0.08);
  display: flex;
  flex-direction: column;
}

/* === Logo === */
.login-logo {
  text-align: center;
  margin-bottom: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.login-logo-img {
  width: 68px;
  height: 68px;
  object-fit: contain;
  display: block;
  border-radius: 12px;
  background: #f8fafc;
  padding: 4px;
}
.login-logo h1 {
  font-size: 25px;
  font-weight: 700;
  color: #0f172a;
  margin: 0;
  letter-spacing: -0.2px;
  line-height: 1.3;
}
.login-logo p {
  color: #64748b;
  font-size: 13px;
  margin: 0;
  line-height: 1.5;
  font-weight: 500;
}

/* === Form === */
.login-form {
  display: flex;
  flex-direction: column;
}
.login-form .form-group {
  margin-bottom: 16px;
}
.login-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  margin-bottom: 8px;
  color: #1e293b;
  font-size: 13px;
}
.login-label i {
  color: var(--primary);
  font-size: 13px;
  width: 14px;
  text-align: center;
}
.login-input {
  width: 100%;
  height: 50px;
  padding: 0 16px;
  border: 1.5px solid #e2e8f0;
  border-radius: 11px;
  font-family: inherit;
  font-size: 14px;
  color: #0f172a;
  background: #fff;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
  direction: rtl;
  text-align: right;
}
.login-input::placeholder {
  color: #94a3b8;
  font-weight: 400;
}
.login-input:hover {
  border-color: #cbd5e1;
}
.login-input:focus {
  outline: none;
  border-color: var(--primary);
  background: #f0fdfa;
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}
.login-input:disabled {
  background: #f8fafc;
  color: #94a3b8;
  cursor: not-allowed;
}

/* === Password toggle === */
.login-password-wrap {
  position: relative;
}
.login-input-password {
  padding-left: 48px;
  padding-right: 16px;
}
[dir="rtl"] .login-input-password {
  padding-left: 16px;
  padding-right: 48px;
}
.login-password-toggle {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  transition: color 0.15s ease, background-color 0.15s ease;
  left: 6px;
}
[dir="rtl"] .login-password-toggle {
  left: auto;
  right: 6px;
}
.login-password-toggle:hover {
  color: var(--primary);
  background: rgba(15, 118, 110, 0.08);
}
.login-password-toggle:focus {
  outline: none;
  color: var(--primary);
  box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.2);
}

/* === Error message === */
.login-error {
  display: none;
  align-items: flex-start;
  gap: 8px;
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 14px;
  font-size: 13px;
  line-height: 1.5;
  text-align: right;
  direction: rtl;
}
.login-error.show {
  display: flex;
}
.login-error::before {
  content: "\f071";
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  color: #dc2626;
  font-size: 14px;
  margin-top: 1px;
  flex-shrink: 0;
}
.login-error[data-type="network"]::before {
  content: "\f127";
}
.login-error[data-type="network"] {
  background: #fffbeb;
  color: #92400e;
  border-color: #fde68a;
}
.login-error[data-type="network"]::before {
  color: #b45309;
}

/* === Login button === */
.btn-login {
  width: 100%;
  height: 50px;
  min-height: 50px;
  border-radius: 11px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0;
  background: var(--primary);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background-color 0.18s ease, transform 0.1s ease, box-shadow 0.18s ease;
  box-shadow: 0 4px 12px rgba(15, 118, 110, 0.18);
  margin-top: 4px;
}
.btn-login:hover:not(:disabled) {
  background: var(--primary-dark);
  box-shadow: 0 6px 16px rgba(15, 118, 110, 0.25);
}
.btn-login:active:not(:disabled) {
  transform: translateY(1px);
}
.btn-login:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.3), 0 4px 12px rgba(15, 118, 110, 0.18);
}
.btn-login:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}
.btn-login-content,
.btn-login-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn-login-loading {
  display: none;
}
.btn-login.is-loading .btn-login-content {
  display: none;
}
.btn-login.is-loading .btn-login-loading {
  display: flex;
}

/* === DB Status indicator === */
.login-db-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 16px;
  font-size: 12px;
  color: #64748b;
  font-weight: 500;
  line-height: 1;
}
.login-db-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #cbd5e1;
  display: inline-block;
  flex-shrink: 0;
  transition: background-color 0.2s ease, box-shadow 0.2s ease;
}
.login-db-status[data-status="checking"] .login-db-dot {
  background: #f59e0b;
  animation: loginDbPulse 1.4s ease-in-out infinite;
}
.login-db-status[data-status="connected"] {
  color: #047857;
}
.login-db-status[data-status="connected"] .login-db-dot {
  background: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.18);
}
.login-db-status[data-status="disconnected"],
.login-db-status[data-status="error"] {
  color: #b91c1c;
}
.login-db-status[data-status="disconnected"] .login-db-dot,
.login-db-status[data-status="error"] .login-db-dot {
  background: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.18);
}
.login-db-status[data-status="no_internet"] {
  color: #b45309;
}
.login-db-status[data-status="no_internet"] .login-db-dot {
  background: #f59e0b;
}
.login-db-status[data-status="not_configured"] {
  color: #64748b;
}
@keyframes loginDbPulse {
  0%, 100% { opacity: 0.4; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1.1); }
}

/* === Responsive === */
@media (max-height: 760px) {
  .login-card { padding: 28px 28px 22px; }
  .login-logo { margin-bottom: 18px; gap: 6px; }
  .login-logo-img { width: 60px; height: 60px; }
  .login-logo h1 { font-size: 22px; }
  .login-form .form-group { margin-bottom: 13px; }
}
@media (max-height: 640px) {
  .login-card { padding: 22px 24px 18px; }
  .login-logo { margin-bottom: 14px; gap: 4px; }
  .login-logo-img { width: 52px; height: 52px; }
  .login-logo h1 { font-size: 20px; }
  .login-logo p { font-size: 12px; }
  .login-input { height: 46px; }
  .btn-login { height: 46px; }
}
@media (max-width: 480px) {
  .login-screen { padding: 12px; }
  .login-card { padding: 26px 22px 20px; border-radius: 16px; }
  .login-logo-img { width: 60px; height: 60px; }
  .login-logo h1 { font-size: 22px; }
  .login-logo p { font-size: 12px; }
  .login-input { height: 48px; font-size: 14px; }
  .btn-login { height: 48px; }
}
@media (prefers-reduced-motion: reduce) {
  .login-db-status[data-status="checking"] .login-db-dot { animation: none; }
  .login-password-toggle,
  .login-input,
  .btn-login { transition: none; }
}
}

/* ============================================
   التطبيق الرئيسي
   ============================================ */
.app {
  display: flex;
  min-height: 100vh;
}

/* القائمة الجانبية */
.sidebar {
  width: var(--ui-sidebar-w, var(--sidebar-width));
  background: var(--bg-sidebar);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  right: 0;
  z-index: 100;
  transition: width var(--transition);
  box-shadow: -2px 0 8px rgba(0, 0, 0, 0.04);
}
.sidebar.collapsed { width: var(--sidebar-collapsed); }

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 16px;
  border-bottom: 1px solid var(--border);
  min-height: var(--topbar-h);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand i {
  font-size: 28px;
  color: var(--primary);
}
.brand-text h2 { font-size: 16px; color: var(--text); }
.brand-text span { font-size: 11px; color: var(--text-muted); }
.sidebar.collapsed .brand-text,
.sidebar.collapsed .nav-item span,
.sidebar.collapsed .user-info,
.sidebar.collapsed .nav-divider { display: none; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 12px 0; }
.sidebar.collapsed .user-card { justify-content: center; }

.sidebar-toggle {
  background: var(--border-soft);
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}
.sidebar-toggle:hover { background: var(--primary); color: white; }
.sidebar.collapsed .sidebar-toggle i { transform: rotate(180deg); }

.sidebar-nav { flex: 1; padding: 12px 8px; overflow-y: auto; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 10px;
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
  font-size: 14px;
  margin-bottom: 4px;
  transition: var(--transition);
}
.nav-item i { width: 20px; text-align: center; color: var(--text-muted); transition: var(--transition); }
.nav-item:hover { background: var(--border-soft); }
.nav-item:hover i { color: var(--primary); }
.nav-item.active { background: var(--primary); color: white; }
.nav-item.active i { color: white; }
.nav-divider {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  padding: 16px 14px 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border);
}
.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 10px;
  background: var(--border-soft);
}
.user-avatar {
  width: 38px;
  height: 38px;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.user-info { font-size: 13px; }
.user-info small { color: var(--text-muted); font-size: 11px; }

/* المحتوى الرئيسي */
.main {
  flex: 1;
  margin-right: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin var(--transition);
}
.sidebar.collapsed ~ .main { margin-right: var(--sidebar-collapsed); }

/* الشريط العلوي */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: white;
  border-bottom: 1px solid var(--border);
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  box-shadow: var(--shadow);
}
.topbar-right, .topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar h1 { font-size: 18px; font-weight: 700; color: var(--text); }

.icon-btn {
  background: var(--border-soft);
  border: none;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  cursor: pointer;
  color: var(--text);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}
.icon-btn:hover { background: var(--primary); color: white; }
.mobile-toggle { display: none; }
.badge {
  position: absolute;
  top: -4px;
  left: -4px;
  background: var(--danger);
  color: white;
  font-size: 10px;
  font-weight: 700;
  border-radius: 10px;
  padding: 2px 6px;
  min-width: 18px;
  text-align: center;
}

.search-box {
  display: flex;
  align-items: center;
  background: var(--border-soft);
  border-radius: 10px;
  padding: 8px 14px;
  width: 320px;
  transition: var(--transition);
}
.search-box:focus-within { background: white; box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.15); }
.search-box i { color: var(--text-muted); margin-left: 8px; }
.search-box input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  font-family: inherit;
  font-size: 14px;
}
.topbar-date {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--border-soft);
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 13px;
  color: var(--text-muted);
}

/* لوحة الإشعارات */
.notif-panel {
  position: fixed;
  top: var(--topbar-h);
  left: 24px;
  width: 360px;
  background: white;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  z-index: 200;
  max-height: 480px;
  display: flex;
  flex-direction: column;
}
.notif-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.notif-header h3 { font-size: 15px; }
.text-btn {
  background: none;
  border: none;
  color: var(--primary);
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
}
.notif-list {
  list-style: none;
  overflow-y: auto;
  flex: 1;
  padding: 8px;
}
.notif-item {
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 4px;
  background: var(--border-soft);
  display: flex;
  gap: 12px;
  cursor: pointer;
}
.notif-item:hover { background: var(--border); }
.notif-item i { color: var(--primary); margin-top: 4px; }
.notif-item .notif-text { flex: 1; font-size: 13px; }
.notif-item .notif-time { font-size: 11px; color: var(--text-muted); }

/* شريط الطفل الثابت */
.child-bar {
  background: linear-gradient(135deg, #ffffff 0%, #f0fdfa 100%);
  border-bottom: 2px solid var(--primary);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  position: sticky;
  top: var(--topbar-h);
  z-index: 40;
  box-shadow: var(--shadow);
}
.child-bar-photo {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  border: 3px solid white;
  box-shadow: var(--shadow);
  overflow: hidden;
  flex-shrink: 0;
}
.child-bar-photo img { width: 100%; height: 100%; object-fit: cover; }
.child-bar-info { flex: 1; min-width: 0; }
.child-bar-name { font-size: 18px; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.child-bar-meta { display: flex; flex-wrap: wrap; gap: 16px; font-size: 13px; }
.meta-item { color: var(--text-muted); }
.meta-item strong { color: var(--text); margin-left: 4px; }
.meta-item.balance {
  background: var(--primary);
  color: white;
  padding: 4px 12px;
  border-radius: 8px;
  font-weight: 600;
}
.meta-item.balance strong { color: white; }
.child-bar-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.tab-btn {
  background: white;
  border: 1.5px solid var(--border);
  padding: 8px 14px;
  border-radius: 10px;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition);
}
.tab-btn:hover { background: var(--border-soft); }
.tab-btn.active { background: var(--primary); color: white; border-color: var(--primary); }

/* محتوى الشاشة */
.screen-content {
  flex: 1;
  padding: 24px;
  min-height: calc(100vh - var(--topbar-h));
}

/* الأزرار */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); box-shadow: var(--shadow); }
.btn-secondary { background: var(--secondary); color: white; }
.btn-secondary:hover { background: #4f46e5; }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #059669; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #dc2626; }
.btn-warning { background: var(--warning); color: white; }
.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--primary);
}
.btn-outline:hover { background: var(--primary); color: white; }
.btn-ghost {
  background: var(--border-soft);
  color: var(--text);
}
.btn-ghost:hover { background: var(--border); }
.btn-block { width: 100%; justify-content: center; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-icon { padding: 7px 10px; }

/* البطاقات */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.card-title { font-size: 16px; font-weight: 700; color: var(--text); display: flex; align-items: center; gap: 8px; }
.card-title i { color: var(--primary); }

/* بطاقات إحصائية */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
  transition: var(--transition);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-card::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 4px;
  height: 100%;
  background: var(--primary);
}
.stat-card.success::before { background: var(--success); }
.stat-card.danger::before { background: var(--danger); }
.stat-card.warning::before { background: var(--warning); }
.stat-card.info::before { background: var(--info); }
.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  margin-bottom: 12px;
}
.stat-card.success .stat-icon { background: var(--success); }
.stat-card.danger .stat-icon { background: var(--danger); }
.stat-card.warning .stat-icon { background: var(--warning); }
.stat-card.info .stat-icon { background: var(--info); }
.stat-value { font-size: 24px; font-weight: 800; color: var(--text); }
.stat-label { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

/* الجداول */
.table-wrap {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.table-toolbar {
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
}
.table-toolbar .search-mini {
  display: flex;
  align-items: center;
  background: var(--border-soft);
  border-radius: 8px;
  padding: 6px 12px;
  width: 260px;
}
.table-toolbar .search-mini input {
  background: transparent;
  border: none;
  outline: none;
  flex: 1;
  font-family: inherit;
  font-size: 13px;
}
.table-toolbar .filters { display: flex; gap: 8px; flex-wrap: wrap; }
.table-scroll { overflow-x: auto; }
table.data {
  width: 100%;
  border-collapse: collapse;
}
table.data th, table.data td {
  padding: 12px 14px;
  text-align: right;
  border-bottom: 1px solid var(--border-soft);
  font-size: 13px;
  white-space: nowrap;
}
table.data th {
  background: var(--border-soft);
  font-weight: 700;
  color: var(--text);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
table.data tbody tr:hover { background: #f8fafc; }
table.data td.actions { white-space: nowrap; }
table.data .action-btn {
  background: transparent;
  border: none;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}
table.data .action-btn:hover { background: var(--primary); color: white; }
table.data .action-btn.danger:hover { background: var(--danger); }

/* النماذج */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}
.form-group { margin-bottom: 14px; }
.form-group label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
}
.form-group label .req { color: var(--danger); }
.form-control {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  background: white;
  transition: var(--transition);
  direction: rtl;
}
.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}
.form-control:read-only { background: var(--border-soft); }
textarea.form-control { min-height: 80px; resize: vertical; }
.form-row { display: flex; gap: 10px; flex-wrap: wrap; }
.form-row > .form-group { flex: 1; min-width: 200px; }
.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.file-drop {
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  background: var(--border-soft);
}
.file-drop:hover { border-color: var(--primary); background: white; }
.file-drop i { font-size: 32px; color: var(--primary); margin-bottom: 8px; }

/* حالة الطفل pills */
.status-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  background: var(--border-soft);
  color: var(--text-muted);
}
.status-pill.active { background: #d1fae5; color: #047857; }
.status-pill.paused { background: #fef3c7; color: #b45309; }
.status-pill.withdrawn { background: #fee2e2; color: #b91c1c; }
.status-pill.completed { background: #dbeafe; color: #1e40af; }
.status-pill.archived { background: #f1f5f9; color: #64748b; }

/* التبويبات */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
  overflow-x: auto;
  white-space: nowrap;
}
.tab-item {
  padding: 10px 18px;
  cursor: pointer;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition);
}
.tab-item:hover { color: var(--primary); }
.tab-item.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-pane { display: none; }
.tab-pane.active { display: block; animation: fade 0.25s ease; }

@keyframes fade {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* النوافذ المنبثقة */
.modal-root {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
}
.modal-window {
  position: relative;
  background: white;
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 720px;
  max-height: 90vh;
  min-height: 0;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: zoom 0.2s ease;
}
@keyframes zoom {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}
.modal-window.lg { max-width: 900px; }
.modal-window.xl { max-width: 1100px; }
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.modal-header h3 { font-size: 16px; }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; min-height: 0; }
.modal-body { scrollbar-width: thin; scrollbar-color: #0f766e #e5e7eb; }
.modal-body::-webkit-scrollbar { width: 10px; }
.modal-body::-webkit-scrollbar-track { background: #e5e7eb; border-radius: 5px; }
.modal-body::-webkit-scrollbar-thumb { background: #0f766e; border-radius: 5px; }
.modal-body::-webkit-scrollbar-thumb:hover { background: #115e59; }

/* Scrollbar واضح للملاحظة الخماسية ومناطق التمرير الداخلية */
#fiveDayPanes { scrollbar-width: thin; scrollbar-color: #0f766e #f1f5f9; }
#fiveDayPanes::-webkit-scrollbar { width: 10px; }
#fiveDayPanes::-webkit-scrollbar-track { background: #f1f5f9; border-radius: 5px; }
#fiveDayPanes::-webkit-scrollbar-thumb { background: #0f766e; border-radius: 5px; }
#fiveDayPanes::-webkit-scrollbar-thumb:hover { background: #115e59; }
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-start;
  gap: 8px;
  flex-shrink: 0;
  background: white;
}

/* رسائل Toast */
.toast-root {
  position: fixed;
  top: 80px;
  left: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: white;
  border-radius: 10px;
  padding: 12px 18px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 500;
  border-right: 4px solid var(--primary);
  animation: slideIn 0.3s ease;
  min-width: 280px;
}
.toast.success { border-right-color: var(--success); }
.toast.error { border-right-color: var(--danger); }
.toast.warning { border-right-color: var(--warning); }
.toast i { font-size: 18px; }
.toast.success i { color: var(--success); }
.toast.error i { color: var(--danger); }
.toast.warning i { color: var(--warning); }
.toast.info i { color: var(--info); }
@keyframes slideIn {
  from { opacity: 0; transform: translateX(-20px); }
  to { opacity: 1; transform: translateX(0); }
}

/* الصور والوسائط */
.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.lg { width: 80px; height: 80px; font-size: 28px; }
.avatar.sm { width: 32px; height: 32px; font-size: 12px; }

.thumb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}
.thumb {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--border-soft);
  display: flex;
  flex-direction: column;
}
.thumb-preview {
  height: 100px;
  background: var(--border-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 32px;
  overflow: hidden;
}
.thumb-preview img { width: 100%; height: 100%; object-fit: cover; }
.thumb-info { padding: 8px; font-size: 12px; }
.thumb-info b { display: block; }
.thumb-actions { display: flex; gap: 4px; padding: 6px 8px; border-top: 1px solid var(--border-soft); }

/* قوائم منسدلة */
.dropdown { position: relative; display: inline-block; }
.dropdown-toggle {
  background: white;
  border: 1.5px solid var(--border);
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.dropdown-toggle::after { content: "▾"; margin-right: 4px; }
.dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  background: white;
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  min-width: 200px;
  padding: 6px;
  z-index: 100;
  display: none;
  border: 1px solid var(--border);
}
.dropdown.open .dropdown-menu { display: block; }
.dropdown-item {
  padding: 8px 12px;
  cursor: pointer;
  border-radius: 6px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.dropdown-item:hover { background: var(--border-soft); }

/* ==== Quick Settings Menu (⚙️) — Phase 37 Display Mode ==== */
#quickSettingsDropdown { position: relative; }
#quickSettingsDropdown .icon-btn.quick-settings-toggle,
#quickSettingsDropdown .icon-btn.dropdown-toggle {
  background: var(--border-soft);
  border: none;
  border-radius: 10px;
  width: 38px;
  height: 38px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text);
  position: relative;
  transition: var(--transition);
}
#quickSettingsDropdown .icon-btn.quick-settings-toggle::after,
#quickSettingsDropdown .icon-btn.dropdown-toggle::after { content: none; }
#quickSettingsDropdown .icon-btn.quick-settings-toggle:hover,
#quickSettingsDropdown .icon-btn.dropdown-toggle:hover {
  background: var(--primary);
  color: white;
}
.quick-settings-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: auto;
  min-width: 300px;
  max-width: 340px;
  background: white;
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.18);
  border: 1px solid var(--border);
  padding: 0;
  z-index: 200;
  display: none;
  overflow: hidden;
  direction: rtl;
}
[dir="rtl"] .quick-settings-menu { left: auto; right: 0; }
#quickSettingsDropdown.open .quick-settings-menu { display: block; animation: qsMenuIn 0.16s ease; }
@keyframes qsMenuIn {
  from { opacity: 0; transform: translateY(-6px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.quick-settings-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  background: linear-gradient(135deg, #0f766e 0%, #14b8a6 100%);
  color: white;
  font-weight: 700;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}
.quick-settings-header i { font-size: 14px; }
.quick-settings-section { padding: 10px; }
.quick-settings-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  margin: 4px 6px 8px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.quick-settings-label i { color: var(--primary); font-size: 13px; }
.quick-settings-options {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 8px;
}
.display-mode-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--border-soft);
  border: 1.5px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  font-family: inherit;
  text-align: right;
  width: 100%;
  color: var(--text);
  transition: var(--transition);
  position: relative;
}
.display-mode-option:hover {
  background: white;
  border-color: var(--primary);
  transform: translateX(-2px);
}
.display-mode-option[aria-checked="true"] {
  background: rgba(15, 118, 110, 0.08);
  border-color: var(--primary);
}
.display-mode-option > i:first-child {
  width: 28px;
  height: 28px;
  background: white;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  font-size: 12px;
  flex-shrink: 0;
  border: 1px solid var(--border);
}
.display-mode-option[aria-checked="true"] > i:first-child {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}
.display-mode-option-text {
  display: flex;
  flex-direction: column;
  flex: 1;
  text-align: right;
  line-height: 1.3;
}
.display-mode-option-text strong {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}
.display-mode-option-text small {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 1px;
}
.display-mode-check {
  color: var(--primary);
  font-size: 14px;
  opacity: 0;
  transition: var(--transition);
  flex-shrink: 0;
}
.display-mode-option[aria-checked="true"] .display-mode-check { opacity: 1; }
.quick-settings-reset {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 8px 10px;
  margin-top: 4px;
  background: transparent;
  border: 1px dashed var(--border);
  border-radius: 10px;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}
.quick-settings-reset:hover {
  background: var(--border-soft);
  color: var(--danger);
  border-color: var(--danger);
}
.quick-settings-reset i { font-size: 11px; }

/* ==== Display Mode — تطبيق CSS Variables على باقي الواجهة ==== */
body.display-mode-normal,
body.display-mode-fit,
body.display-mode-auto {
  font-size: var(--ui-base-font);
  transition: font-size 0.2s ease;
}
/* البطاقات */
.card {
  padding: var(--ui-card-padding);
  margin-bottom: var(--ui-gap);
}
.card-header {
  margin-bottom: calc(var(--ui-gap) * 0.75);
  padding-bottom: calc(var(--ui-gap) * 0.5);
}
.card-title {
  font-size: var(--ui-section-title);
}
/* النماذج */
.form-grid {
  gap: calc(var(--ui-gap) * 0.85);
}
.form-group {
  margin-bottom: calc(var(--ui-gap) * 0.85);
}
.form-group label {
  margin-bottom: calc(var(--ui-gap) * 0.35);
}
.form-control {
  min-height: var(--ui-input-h);
  padding: 6px 12px;
  font-size: var(--ui-base-font);
}
.form-row {
  gap: var(--ui-gap);
}
textarea.form-control {
  min-height: calc(var(--ui-input-h) * 2);
}
/* الجداول */
.table-wrapper,
.dataTables_wrapper {
  font-size: var(--ui-base-font);
}
table.data {
  font-size: var(--ui-base-font);
}
table.data th,
table.data td {
  padding: var(--ui-table-cell-pad) 10px;
}
/* شبكة الإحصائيات */
.stats-grid {
  gap: var(--ui-gap);
  grid-template-columns: repeat(auto-fit, minmax(calc(180px - var(--ui-gap)), 1fr));
}
.stat-card {
  padding: calc(var(--ui-card-padding) * 0.85);
}
.stat-card-value {
  font-size: calc(var(--ui-section-title) + 6px);
}
/* Modals */
.modal-window {
  max-width: min(96vw, 1100px);
}
.modal-header,
.modal-footer {
  padding: calc(var(--ui-gap) * 0.85) calc(var(--ui-card-padding) * 0.85);
}
.modal-body {
  padding: calc(var(--ui-card-padding) * 0.85);
}
/* Sidebar */
.sidebar {
  width: var(--ui-sidebar-w, var(--sidebar-width));
}
.sidebar.collapsed {
  width: calc(var(--ui-sidebar-w, var(--sidebar-width)) * 0.45);
}
.main {
  margin-right: var(--ui-sidebar-w, var(--sidebar-width));
  max-width: calc(100vw - var(--ui-sidebar-w, var(--sidebar-width)));
}
.sidebar.collapsed ~ .main {
  margin-right: calc(var(--ui-sidebar-w, var(--sidebar-width)) * 0.45);
}
/* Sections & Titles */
.section-title {
  font-size: var(--ui-section-title);
}
/* Tabs */
.tabs {
  gap: calc(var(--ui-gap) * 0.4);
}
.tab-item {
  padding: 8px calc(var(--ui-gap) * 0.85);
  font-size: var(--ui-base-font);
}
/* أزرار */
.btn {
  padding: 8px 14px;
  font-size: var(--ui-base-font);
  min-height: var(--ui-input-h);
}

/* معلومات */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}
.empty-state i { font-size: 48px; margin-bottom: 12px; opacity: 0.4; }
.empty-state h4 { font-size: 16px; margin-bottom: 6px; color: var(--text); }
.loading { text-align: center; padding: 24px; color: var(--text-muted); }

/* Progress */
.progress {
  background: var(--border-soft);
  border-radius: 8px;
  height: 8px;
  overflow: hidden;
  margin-top: 4px;
}
.progress-bar {
  height: 100%;
  background: var(--primary);
  border-radius: 8px;
  transition: width 0.4s ease;
}
.progress-bar.success { background: var(--success); }
.progress-bar.danger { background: var(--danger); }
.progress-bar.warning { background: var(--warning); }

/* قارئ تاريخ */
.date-picker-wrap { position: relative; }
.date-picker-wrap input { padding-left: 38px; }
.date-picker-wrap i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

/* حقل التاريخ بصيغة يوم/شهر/سنة */
input.date-ddmm {
  font-variant-numeric: tabular-nums;
  letter-spacing: 1px;
  font-weight: 600;
  background: linear-gradient(180deg, #fff 0%, #fafbfc 100%);
  border: 1.5px solid var(--border);
  transition: border-color 0.15s, box-shadow 0.15s;
}
input.date-ddmm:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(44, 122, 123, 0.1);
  outline: none;
}
input.date-ddmm::placeholder {
  color: #b0b8c1;
  font-weight: 400;
}

/* معاينة اسم الطفل ورقم الملف في نافذة الإضافة */
.child-name-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: linear-gradient(135deg, #f0f9f9 0%, #e6f4f4 100%);
  border: 1px dashed var(--primary);
  border-radius: 10px;
  margin-bottom: 14px;
  font-size: 14px;
}
.child-name-preview .label {
  color: var(--text-muted);
  font-size: 12px;
}
.child-name-preview .value {
  color: var(--primary);
  font-weight: 700;
  font-size: 16px;
}
.child-name-preview .name {
  color: var(--text);
  font-weight: 600;
  font-size: 15px;
}

/* رسالة تأكيد قبل الحذف */
.confirm-message { text-align: center; padding: 20px; }
.confirm-message i {
  font-size: 56px;
  color: var(--warning);
  margin-bottom: 16px;
}
.confirm-message h4 { font-size: 17px; margin-bottom: 8px; }
.confirm-message p { color: var(--text-muted); }

/* Responsive */
@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(100%);
    width: var(--sidebar-width) !important;
  }
  .sidebar.open { transform: translateX(0); }
  .main { margin-right: 0 !important; }
  .mobile-toggle { display: flex !important; }
  .search-box { width: 200px; }
  .child-bar { flex-direction: column; align-items: flex-start; }
  .child-bar-actions { width: 100%; overflow-x: auto; }
}
@media (max-width: 768px) {
  .search-box { display: none; }
  .topbar-date span { display: none; }
  .screen-content { padding: 14px; }
  .form-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-card { padding: 14px; }
  .stat-value { font-size: 20px; }
  .stat-icon { width: 38px; height: 38px; font-size: 18px; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .topbar h1 { font-size: 14px; }
  .modal-window { max-width: 100%; }
}

/* Print */
@media print {
  .sidebar, .topbar, .child-bar, .table-toolbar, .btn { display: none !important; }
  .main { margin: 0 !important; }
  .screen-content { padding: 0 !important; }
  .card { box-shadow: none; border: 1px solid #ccc; }
  /* إخفاء شارات الواجهة عند طباعة صفحات النظام */
  .no-print, .notif-panel, #modalRoot, #toastRoot { display: none !important; }
  /* ضمان عدم انقسام الجداول */
  table { page-break-inside: auto; }
  tr, th, td { page-break-inside: avoid; }
  thead { display: table-header-group; }
  tfoot { display: table-footer-group; }
  /* خلفية بيضاء صافية */
  body { background: #fff !important; }
}

/* معاينة قبل الطباعة (تُستخدم من print-utils.js) */
.print-preview-wrapper { max-width: 850px; margin: 0 auto; }
.print-preview-toolbar { background: #fff; padding: 14px 18px; border-radius: 8px; box-shadow: 0 2px 6px rgba(0,0,0,0.08); margin-bottom: 14px; position: sticky; top: 0; z-index: 10; }
.pp-title { font-size: 1.05em; font-weight: 700; margin-bottom: 10px; color: #0f766e; }
.pp-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.pp-actions .btn { padding: 8px 14px; border-radius: 6px; border: 1px solid #d1d5db; cursor: pointer; font-size: 14px; display: inline-flex; align-items: center; gap: 6px; }
.pp-actions .btn-primary { background: #0f766e; color: #fff; border-color: #0f766e; }
.pp-actions .btn-outline { background: #fff; color: #0f766e; }
.pp-actions .btn-ghost { background: #fff; color: #555; }
.pp-hint { margin-top: 8px; font-size: 12px; color: #6b7280; }
.print-page { background: #fff; width: 210mm; min-height: 297mm; padding: 14mm 12mm; margin: 0 auto; box-shadow: 0 4px 20px rgba(0,0,0,0.1); font-size: 12px; line-height: 1.5; }
@media (max-width: 900px) {
  .print-page { width: 100%; padding: 12px; }
}

/* ============================================
   Multi-Step Form (MSF) - نموذج متعدد الخطوات
   ============================================ */
.msf-form { display: block; }
.msf-wrapper { display: grid; grid-template-columns: 240px 1fr; gap: 0; min-height: 480px; }
@media (max-width: 800px) { .msf-wrapper { grid-template-columns: 1fr; } }

.msf-sidebar {
  background: linear-gradient(180deg, #f0fdfa 0%, #ecfeff 100%);
  border-left: 1px solid #d1d5db;
  padding: 18px 12px;
  display: flex; flex-direction: column; align-items: center;
  border-radius: 0 0 0 8px;
}
.msf-progress-ring { position: relative; width: 80px; height: 80px; margin-bottom: 8px; }
.msf-progress-ring svg { display: block; }
.msf-progress-text {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  font-weight: 800; color: #0f766e; font-size: 1.1em;
}
.msf-progress-label { font-size: 0.85em; color: #047857; margin-bottom: 14px; text-align: center; }

.msf-steps { list-style: none; padding: 0; margin: 0; width: 100%; }
.msf-step {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; margin-bottom: 4px; border-radius: 6px;
  cursor: pointer; transition: all 0.2s;
  font-size: 0.9em; color: #4b5563; position: relative;
}
.msf-step:hover { background: rgba(15, 118, 110, 0.06); }
.msf-step.active { background: #0f766e; color: #fff; font-weight: 700; }
.msf-step.active .msf-step-num { background: #fff; color: #0f766e; }
.msf-step.done .msf-step-num { background: #10b981; color: #fff; }
.msf-step.done .msf-step-check { color: #10b981; margin-right: auto; }
.msf-step.has-error { color: #dc2626; }
.msf-step.has-error .msf-step-warn { color: #dc2626; margin-right: auto; }
.msf-step-num {
  width: 24px; height: 24px; border-radius: 50%; background: #e5e7eb; color: #6b7280;
  display: flex; align-items: center; justify-content: center; font-size: 0.85em; font-weight: 700;
  flex-shrink: 0;
}
.msf-step-icon { font-size: 0.9em; }
.msf-step-label { flex: 1; }

.msf-content {
  padding: 20px 24px;
  background: #fff;
  border-radius: 0 0 8px 0;
  min-height: 480px;
}
.msf-content-head {
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px;
  margin-bottom: 16px; padding-bottom: 12px; border-bottom: 2px solid #f3f4f6;
}
.msf-section-title { margin: 0; color: #0f766e; font-size: 1.15em; display: flex; align-items: center; gap: 8px; }
.msf-section-title i { color: #0f766e; }
.msf-content-meta { color: #6b7280; font-size: 0.85em; }

.msf-subsection { margin-bottom: 18px; }
.msf-subsection-title {
  font-size: 0.95em; color: #374151; margin: 0 0 8px;
  padding-right: 8px; border-right: 3px solid #0f766e;
}

.msf-footer {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 16px; padding-top: 14px; border-top: 1px solid #e5e7eb;
  gap: 10px; flex-wrap: wrap;
}
.msf-nav { display: flex; gap: 8px; }

/* عرض الأخطاء في الحقول */
.is-invalid, .form-control.is-invalid, input.is-invalid, select.is-invalid, textarea.is-invalid {
  border-color: #dc2626 !important;
  background: #fef2f2 !important;
  box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.15) !important;
}

.checkbox-row {
  display: flex; align-items: center; gap: 8px; cursor: pointer;
  font-weight: 500; padding: 4px 0;
}
.checkbox-row input[type="checkbox"] { width: 18px; height: 18px; margin: 0; }

/* التحسين على الموبايل */
@media (max-width: 600px) {
  .msf-sidebar { border-radius: 8px 8px 0 0; }
  .msf-content { border-radius: 0 0 8px 8px; }
  .msf-footer { flex-direction: column-reverse; align-items: stretch; }
  .msf-nav { width: 100%; justify-content: space-between; }
  .msf-nav .btn { flex: 1; justify-content: center; }
}

/* حالات الـ buttons */
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Error Boundary */
.app-error {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  padding: 20px;
  direction: rtl;
}
.app-error.hidden { display: none; }
.app-error-card {
  max-width: 560px;
  width: 100%;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
  overflow: hidden;
  border-top: 4px solid #dc2626;
}
.app-error-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  background: #fef2f2;
  border-bottom: 1px solid #fecaca;
  color: #991b1b;
}
.app-error-head h3 { margin: 0; font-size: 18px; color: #991b1b; flex: 1; }
.app-error-head i.fa-exclamation-triangle { font-size: 22px; color: #dc2626; }
.app-error-close {
  background: transparent; border: 0; color: #991b1b; cursor: pointer;
  font-size: 16px; padding: 4px 8px; border-radius: 6px;
}
.app-error-close:hover { background: #fee2e2; }
.app-error-body { padding: 18px 20px; color: #334155; line-height: 1.6; }
.app-error-body p { margin: 0 0 8px; }
.app-error-meta { font-size: 12px; color: #94a3b8; direction: ltr; text-align: left; }
.app-error-hint { font-size: 13px; color: #64748b; margin-top: 10px; }
.app-error-actions {
  display: flex; gap: 10px; justify-content: flex-end;
  padding: 14px 20px; background: #f8fafc; border-top: 1px solid #e2e8f0;
}
.app-error pre {
  text-align: left; background: #fff; padding: 10px; border-radius: 4px;
  font-size: 0.8em; max-height: 200px; overflow: auto;
  direction: ltr;
}
@media (max-width: 640px) {
  .app-error { padding: 10px; }
  .app-error-card { max-width: 100%; }
}

/* Section header */
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  flex-wrap: wrap;
  gap: 10px;
}
.section-head h2 { font-size: 20px; font-weight: 700; }
.section-head p { color: var(--text-muted); font-size: 13px; }

/* Notes textarea enhanced */
.note-box {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 10px;
  padding: 12px;
  font-size: 13px;
  color: #92400e;
}

/* Form section */
.form-section { margin-bottom: 24px; }
.form-section-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px dashed var(--border);
}

/* تقييمات النجوم */
.rating {
  display: inline-flex;
  gap: 2px;
}
.rating i { color: #fde68a; cursor: pointer; transition: var(--transition); }
.rating i.filled { color: #f59e0b; }

/* اختصارات سريعة */
.quick-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin-top: 12px;
}
.quick-action {
  background: var(--border-soft);
  padding: 12px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  text-decoration: none;
  color: var(--text);
  transition: var(--transition);
}
.quick-action:hover { background: var(--primary); color: white; }
.quick-action i { font-size: 20px; color: var(--primary); }
.quick-action:hover i { color: white; }
.quick-action span { font-size: 13px; font-weight: 600; }

/* Badges */
.badge-soft {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 700;
  background: var(--border-soft);
  color: var(--text);
}
.badge-soft.primary { background: #ccfbf1; color: var(--primary-dark); }
.badge-soft.success { background: #d1fae5; color: #047857; }
.badge-soft.danger { background: #fee2e2; color: #b91c1c; }
.badge-soft.warning { background: #fef3c7; color: #b45309; }
.badge-soft.info { background: #dbeafe; color: #1e40af; }

/* =====================================================================
   Phase 40: Payment Method Badges
   ===================================================================== */
.pm-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #e2e8f0;
  white-space: nowrap;
  line-height: 1.4;
}
.pm-badge i { font-size: 11px; opacity: 0.85; }
.pm-badge.cash { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }
.pm-badge.card { background: #eff6ff; color: #1e40af; border-color: #bfdbfe; }
.pm-badge.bank_transfer { background: #f5f3ff; color: #5b21b6; border-color: #ddd6fe; }
.pm-badge.cheque { background: #fffbeb; color: #b45309; border-color: #fde68a; }
.pm-badge.mixed { background: linear-gradient(135deg, #fef3c7 0%, #ecfdf5 50%, #eff6ff 100%); color: #475569; border-color: #cbd5e1; }
.pm-badge.other { background: #f1f5f9; color: #475569; }

.pm-mini-badge {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 600;
  background: #f8fafc;
  color: #475569;
  border: 1px solid #e2e8f0;
  white-space: nowrap;
}
.pm-mini-badge.cash { background: #d1fae5; color: #047857; }
.pm-mini-badge.card { background: #dbeafe; color: #1e40af; }
.pm-mini-badge.bank_transfer { background: #ede9fe; color: #5b21b6; }
.pm-mini-badge.cheque { background: #fef3c7; color: #b45309; }
