/* =========================
 * نمط "أثـَــر" — ملف CSS محسن
 * ========================= */

/* لوحة ألوان أثر (Sea) والمتغيرات العامة */
:root {
  --sea-25: #f0f9ff;
  --sea-50: #e6f2ff;
  --sea-100: #d7e9ff;
  --sea-200: #b9d7ff;
  --sea-300: #93c5fd;
  --sea-400: #60a5fa;
  --sea-500: #3b82f6;
  --sea-600: #1e40af;
  --sea-700: #1e3a8a;
  --sea-800: #172554;
  --ink: #0f172a;
  --muted: #334155;
  --bg: #ffffff;
  --card: #ffffff;
  --radius: 20px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.12);
  --gold: #c8a84e;
  --glass: rgba(255, 255, 255, 0.12);
  --primary: var(--sea-600);
  --primary-2: var(--sea-500);
  --brand: var(--primary);
  --brand-2: var(--primary-2);
}

/* وضع داكن — قلب الباليت */
.dark {
  --bg: #0b1220;
  --card: #0f172a;
  --ink: #f1f5f9;
  --muted: #cbd5e1;
  --shadow: 0 22px 60px rgba(0, 0, 0, 0.45),
    0 1px 0 rgba(255, 255, 255, 0.03) inset;
  --glass: rgba(255, 255, 255, 0.06);
}

/* قواعد عامة */
* {
  box-sizing: border-box;
}

/* تحسين: دمج خصائص html, body من أماكن متفرقة */
html,
body {
  height: 100%;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: "Cairo", system-ui, Tahoma, Arial;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.9;
  font-size: 17px;
}

/* خلفية الصورة العامة لكل الصفحات */
.global-bg {
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background: url("assets/bg/bg.webp") center/cover no-repeat;
  opacity: 0.25;
}

/* المتدرّج تحت الصورة */
.backdrop {
  position: fixed;
  inset: 0;
  z-index: -3;
  pointer-events: none;
  background: linear-gradient(160deg, #f0f9ff 0%, #e6f2ff 40%, #fdfdfd 100%);
}
.dark .backdrop {
  background: linear-gradient(160deg, #0b1220 0%, #111827 50%, #1e293b 100%);
}

/* الزخرفة فوق الصورة */
.pattern {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.14;
  background: url("assets/img/pattern.svg") repeat 220px 220px fixed;
  will-change: opacity;
  mix-blend-mode: soft-light;
}
.dark .pattern {
  opacity: 0.1;
}

/* ===== الشريط العلوي (Topbar) — النسخة النهائية (Grid) ===== */
/* تحسين: إزالة تعريف .topbar القديم (flex) المكرر */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: grid;
  grid-template-columns: 1fr auto 1fr; /* يسار | وسط | يمين */
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  backdrop-filter: blur(8px);
  background: rgba(255, 255, 255, 0.7);
  border-bottom: 1px solid color-mix(in srgb, var(--primary) 22%, transparent);
  will-change: transform; /* موجودة بالأساس - جيدة للأداء */
}
.dark .topbar {
  background: rgba(17, 24, 39, 0.6);
}

/* يسار: دخول/تسجيل فوق بعض */
.tb-left {
  justify-self: start;
  display: grid;
  gap: 6px;
}

/* الوسط: زر 🌓 وبجانبه مساحة إبداعي */
.tb-center {
  justify-self: center;
  display: inline-flex;
  gap: 10px;
  align-items: center;
}

/* يمين: زر الخطط لوحده */
.tb-right {
  justify-self: end;
  display: inline-flex;
  gap: 10px;
  align-items: center;
}

/* تحسين: إزالة الميديا المكررة لـ topbar */
@media (max-width: 640px) {
  .topbar {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
  }
  .tb-left,
  .tb-right,
  .tb-center {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
  }
  /* تحسين: دمج media query للأزرار هنا */
  .btn {
    padding: 8px 10px;
    font-size: 13px;
  }
}

/* أزرار عامة */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 12px;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid color-mix(in srgb, var(--primary) 25%, transparent);
  background: linear-gradient(180deg, #ffffffd0, #ffffffb5);
  color: #0a2540;
  font-weight: 800;
  transition: 0.3s ease all;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.1);
  white-space: nowrap;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}
.btn:hover {
  transform: translateY(-1px);
}
.btn:active {
  transform: translateY(0) scale(0.98);
}

/* Dark mode button styling */
.dark .btn {
  background: linear-gradient(
    180deg,
    rgba(30, 64, 175, 0.2),
    rgba(30, 64, 175, 0.1)
  );
  color: #93c5fd;
  border-color: color-mix(in srgb, var(--primary) 40%, transparent);
  text-shadow: none;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.3);
}

.dark .btn:hover {
  background: linear-gradient(
    180deg,
    rgba(30, 64, 175, 0.3),
    rgba(30, 64, 175, 0.2)
  );
  color: #bfdbfe;
}

.btn.primary {
  background: var(--primary-2);
  color: #fff;
  border-color: rgba(0, 0, 0, 0.05);
  box-shadow: 0 12px 30px color-mix(in srgb, var(--primary) 35%, transparent);
}
.btn.primary:hover {
  background: var(--primary);
}

.dark .btn.primary {
  background: #3b82f6;
  color: #fff;
  border-color: rgba(59, 130, 246, 0.3);
}

.dark .btn.primary:hover {
  background: #60a5fa;
}

.btn.ghost {
  background: transparent;
}

/* تحسين نص الأزرار في الوضع الداكن ليكون أسود */
.dark .topbar .btn,
.dark .topbar .btn:hover,
.dark .topbar .btn:active,
.dark .topbar .btn.primary,
.dark .topbar .btn.ghost {
  color: #000 !important;
  text-shadow: none;
}

/* ===== الهيدر: الشعار + الوسم ===== */
header {
  position: relative;
  padding: 48px 18px 28px;
  text-align: center;
}
.hero {
  max-width: 1100px;
  margin: 0 auto;
  position: relative;
}

.logo {
  font-family: "Cairo", system-ui, Tahoma, Arial;
  font-weight: 700;
  letter-spacing: 0.5px;
  font-size: clamp(44px, 6.2vw, 84px);
  margin: 0;
  color: var(--primary);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.55);
  display: block;
  text-align: center;
}
.dark .logo {
  color: #93c5fd;
  text-shadow: none;
}

.tag {
  display: block;
  text-align: center;
  margin: 12px auto 0;
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid color-mix(in srgb, var(--primary) 28%, transparent);
  color: #0a2540;
  font-weight: 700;
  max-width: fit-content;
}
.dark .tag {
  background: rgba(17, 24, 39, 0.55);
  color: #e2e8f0;
  border-color: var(--primary);
}
.tag .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold);
  display: inline-block;
  margin-inline-end: 8px;
}

/* ===== المحتوى العام ===== */
main {
  padding: 18px;
}
@media (max-width: 640px) {
  main {
    padding-inline: 12px;
  }
}

/* تحسين: .container هذا يغطي التعريف السابق (980px) */
.container {
  width: min(1100px, 92vw);
  margin-inline: auto;
  padding-inline: 16px;
}

/* بطاقات عامة */
.card {
  background: var(--card);
  border: 1px solid color-mix(in srgb, var(--primary) 22%, transparent);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  overflow: hidden; /* تحسين: دمج من باتش التوافقية */
}
.dark .card {
  border-color: color-mix(in srgb, var(--primary) 32%, transparent);
}

/* عناوين وأوصاف */
.title {
  text-align: center;
  margin: 0 0 10px;
  color: var(--primary);
  font-size: clamp(22px, 3.6vw, 30px);
  font-weight: 800;
}
.lead {
  text-align: center;
  margin: 0;
  color: var(--ink);
  opacity: 0.95;
}

/* شبكة صناديق */
.grid {
  display: grid;
  gap: 18px;
  margin-top: 22px;
  grid-template-columns: 1fr;
}
@media (min-width: 800px) {
  .grid {
    grid-template-columns: 1fr 1fr;
  }
}

.box {
  background: linear-gradient(180deg, #ffffffcc, #ffffffaa);
  border: 1px solid color-mix(in srgb, var(--primary) 22%, transparent);
  border-radius: 16px;
  padding: 22px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.08);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.box.full {
  grid-column: span 2;
}

.dark .box {
  background: linear-gradient(180deg, #111827, #0f172a);
  border-color: color-mix(in srgb, var(--primary) 32%, transparent);
}
.box:hover {
  transform: translateY(-6px);
  box-shadow: 0 26px 60px rgba(0, 0, 0, 0.2);
}
.box h3 {
  margin: 0 0 10px;
  color: var(--primary);
  font-size: 20px;
}
.box p {
  margin: 0;
  color: var(--ink);
  opacity: 0.92;
}
.dark .box p {
  color: var(--ink);
}

/* ===== بطاقات التسعير ===== */
.plans {
  display: grid;
  gap: 16px;
  margin-top: 22px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
.plan {
  background: var(--card);
  border: 1px solid color-mix(in srgb, var(--primary) 22%, transparent);
  border-radius: 16px;
  padding: 22px;
  text-align: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.dark .plan {
  border-color: color-mix(in srgb, var(--primary) 32%, transparent);
}
.plan:hover {
  transform: translateY(-6px);
  box-shadow: 0 22px 50px rgba(0, 0, 0, 0.16);
}
.plan h4 {
  margin: 0 0 8px;
}
.price {
  font-size: 24px;
  color: var(--primary);
  margin: 8px 0 16px;
  font-weight: 800;
}

/* ===== Enhanced Footer Design ===== */
footer {
  text-align: center;
  margin-top: 40px;
  padding: 40px 20px;
  color: var(--muted);
  font-size: 14px;
  background: linear-gradient(
    180deg,
    rgba(30, 64, 175, 0.05) 0%,
    rgba(30, 64, 175, 0.02) 100%
  );
  border-top: 1px solid rgba(30, 64, 175, 0.1);
  transition: all 0.3s ease;
}

footer .foot-line {
  margin: 0 0 12px;
  font-style: italic;
  color: var(--gold);
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: 0.3px;
  font-family: "Amiri", serif;
}

footer .foot-name {
  margin: 8px 0 20px;
  font-weight: 800;
  color: var(--primary);
  font-size: 16px;
  letter-spacing: 0.5px;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
}

footer .foot-links {
  font-size: 13px;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin: 20px 0;
}

footer .foot-links a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
  transition: all 0.2s ease;
  position: relative;
  padding-bottom: 2px;
}

footer .foot-links a:hover {
  color: var(--sea-500);
  text-decoration: underline;
}

footer .foot-links a::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--sea-500);
  transition: width 0.2s ease;
}

footer .foot-links a:hover::after {
  width: 100%;
}

footer .foot-links .sep {
  color: var(--muted);
  opacity: 0.5;
  font-weight: 300;
}

footer .foot-copy {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid rgba(30, 64, 175, 0.1);
  color: var(--muted);
  font-size: 12px;
  opacity: 0.8;
  transition: opacity 0.2s ease;
}

/* Dark mode enhancements */
.dark footer {
  background: linear-gradient(
    180deg,
    rgba(59, 130, 246, 0.08) 0%,
    rgba(30, 64, 175, 0.03) 100%
  );
  border-top-color: rgba(59, 130, 246, 0.15);
}

.dark footer .foot-copy {
  border-top-color: rgba(59, 130, 246, 0.15);
}

.dark footer .foot-line {
  color: #f1f5f9;
}

.dark footer .foot-name {
  color: #60a5fa;
}

.dark footer .foot-links a {
  color: #60a5fa;
}

.dark footer .foot-links a:hover {
  color: #93c5fd;
}

.dark footer .foot-links a::after {
  background: #93c5fd;
}

/* Mobile responsive */
@media (max-width: 640px) {
  footer {
    padding: 30px 16px;
    margin-top: 30px;
  }

  footer .foot-line {
    font-size: 14px;
  }

  footer .foot-name {
    font-size: 15px;
  }

  footer .foot-links {
    flex-direction: column;
    gap: 6px;
  }

  footer .foot-links a {
    display: block;
    padding-bottom: 4px;
  }
}

/* ===== المودالات ===== */
.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.45);
  z-index: 80;
  padding: 20px;
}
.modal.show {
  display: flex;
}
.modal .sheet {
  width: min(520px, 96vw);
  background: var(--card);
  color: var(--ink);
  border: 1px solid color-mix(in srgb, var(--primary) 22%, transparent);
  border-radius: 18px;
  padding: 20px;
  box-shadow: var(--shadow);
  animation: pop 0.16s ease;
}
.dark .modal .sheet {
  border-color: color-mix(in srgb, var(--primary) 32%, transparent);
}

/* تحسين: إزالة @keyframes pop المكررة */
@keyframes pop {
  from {
    transform: scale(0.98);
    opacity: 0.7;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}
.sheet h3 {
  margin: 0 0 10px;
  color: var(--primary);
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 520px) {
  .form-row {
    grid-template-columns: 1fr;
  }
}
/* ✅ Enhanced input styling - modern, accessible, consistent */
label {
  display: block;
  font-weight: 700;
  margin: 10px 0 6px;
  color: var(--ink);
  font-size: 0.95rem;
}

/* تحسين: دمج input, select, textarea */
input,
select,
textarea {
  width: 100%;
  max-width: 100%; /* من باتش التوافقية */
  padding: 12px;
  border: 1px solid var(--sea-600);
  border-radius: 12px;
  background: var(--card);
  color: var(--ink);
  font-family: Cairo, system-ui, Tahoma, Arial;
  font-size: 1rem; /* 16px لمنع تكبير iOS */
  transition: all 0.2s ease;
  outline: none;
}

input:hover,
select:hover,
textarea:hover {
  border-color: var(--sea-500);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.1);
}

input::placeholder,
textarea::placeholder {
  color: var(--muted);
  opacity: 0.8;
}

/* Hide native select arrow and number spinners */
select,
input[type="number"] {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type="number"] {
  appearance: textfield;
}

/* Dark mode */
.dark input,
.dark select,
.dark textarea {
  background: var(--card);
  color: var(--ink);
  border-color: var(--sea-600);
}
.dark input:hover,
.dark select:hover,
.dark textarea:hover {
  border-color: #60a5fa;
}
.dark input:focus,
.dark select:focus,
.dark textarea:focus {
  border-color: #60a5fa;
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.15);
}
.dark input::placeholder,
.dark textarea::placeholder {
  color: var(--muted);
  opacity: 0.8;
}

/* تحسين: دمج flex-wrap من باتش التوافقية */
.actions-row {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 14px;
  flex-wrap: wrap;
}
@media (max-width: 640px) {
  .actions-row {
    justify-content: stretch;
  }
  .actions-row .btn {
    width: 100%;
  }
}

/* شارة صغيرة (عامّة) */
.badge {
  display: inline-block;
  font-weight: 800;
  color: #15803d;
  background: #dcfce7;
  border: 1px solid #86efac;
  border-radius: 999px;
  padding: 4px 10px;
}
.dark .badge {
  color: #a7f3d0;
  background: #052e1a;
  border-color: #064e3b;
}

/* ===== توست محسّن ===== */
.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  display: none;
  opacity: 0;
  transform: translateY(120%) translateX(20px);
  transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
  font-size: 15px;
  line-height: 1.5;
  font-weight: 500;
  letter-spacing: 0.3px;
}

.toast.show {
  display: flex;
  opacity: 1;
  transform: translateY(0) translateX(0);
  pointer-events: auto;
}

/* أنواع التوست المختلفة */
.toast-content {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 12px;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  max-width: 360px;
  word-wrap: break-word;
  position: relative;
}

/* نجاح */
.toast.success .toast-content {
  background: linear-gradient(
    135deg,
    rgba(16, 185, 129, 0.95) 0%,
    rgba(5, 150, 105, 0.9) 100%
  );
  color: #fff;
  border-color: rgba(16, 185, 129, 0.4);
}

/* خطأ */
.toast.error .toast-content {
  background: linear-gradient(
    135deg,
    rgba(239, 68, 68, 0.95) 0%,
    rgba(220, 38, 38, 0.9) 100%
  );
  color: #fff;
  border-color: rgba(239, 68, 68, 0.4);
}

/* تحذير */
.toast.warning .toast-content {
  background: linear-gradient(
    135deg,
    rgba(245, 158, 11, 0.95) 0%,
    rgba(217, 119, 6, 0.9) 100%
  );
  color: #fff;
  border-color: rgba(245, 158, 11, 0.4);
}

/* معلومة */
.toast.info .toast-content {
  background: linear-gradient(
    135deg,
    rgba(59, 130, 246, 0.95) 0%,
    rgba(37, 99, 235, 0.9) 100%
  );
  color: #fff;
  border-color: rgba(59, 130, 246, 0.4);
}

/* icon inside toast */
.toast-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: bold;
  animation: toastIconPop 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* رسالة التوست */
.toast-message {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.toast-title {
  font-weight: 600;
  font-size: 15px;
}

.toast-text {
  font-weight: 400;
  font-size: 13px;
  opacity: 0.95;
}

/* زر الإغلاق */
.toast-close {
  flex-shrink: 0;
  cursor: pointer;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  color: inherit;
  font-size: 14px;
  transition: all 0.2s ease;
  padding: 0;
  opacity: 0.8;
}

.toast-close:hover {
  background: rgba(255, 255, 255, 0.25);
  opacity: 1;
  transform: scale(1.1);
}

.toast-close:active {
  transform: scale(0.95);
}

/* شريط التقدم */
.toast-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  background: rgba(255, 255, 255, 0.4);
  border-radius: 0 0 12px 0;
  animation: toastProgress 4s linear forwards;
}

/* في الوضع الداكن */
.dark .toast-content {
  background: linear-gradient(
    135deg,
    rgba(30, 64, 175, 0.9) 0%,
    rgba(25, 55, 140, 0.85) 100%
  );
  color: #f1f5f9;
  border-color: rgba(59, 130, 246, 0.3);
}

.dark .toast.success .toast-content {
  background: linear-gradient(
    135deg,
    rgba(16, 185, 129, 0.9) 0%,
    rgba(5, 150, 105, 0.85) 100%
  );
}

.dark .toast.error .toast-content {
  background: linear-gradient(
    135deg,
    rgba(239, 68, 68, 0.9) 0%,
    rgba(220, 38, 38, 0.85) 100%
  );
}

.dark .toast.warning .toast-content {
  background: linear-gradient(
    135deg,
    rgba(245, 158, 11, 0.9) 0%,
    rgba(217, 119, 6, 0.85) 100%
  );
}

.dark .toast.info .toast-content {
  background: linear-gradient(
    135deg,
    rgba(59, 130, 246, 0.9) 0%,
    rgba(37, 99, 235, 0.85) 100%
  );
}

/* الرسوميات */
@keyframes toastIconPop {
  0% {
    transform: scale(0) rotate(-45deg);
    opacity: 0;
  }
  70% {
    transform: scale(1.15) rotate(10deg);
  }
  100% {
    transform: scale(1) rotate(0);
    opacity: 1;
  }
}

@keyframes toastProgress {
  0% {
    width: 100%;
  }
  100% {
    width: 0%;
  }
}

/* للشاشات الصغيرة */
@media (max-width: 640px) {
  .toast {
    bottom: 16px;
    right: 12px;
    left: 12px;
  }

  .toast-content {
    max-width: 100%;
    padding: 14px 14px;
  }

  .toast-title {
    font-size: 14px;
  }

  .toast-text {
    font-size: 12px;
  }
}

/* ===== عناصر هوية أعلى الصفحة ===== */
.brand-wrap {
  text-align: center;
  padding: 22px 0 10px;
}
.brand-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
}
.brand-icon svg {
  width: 28px;
  height: 28px;
  transform: translateY(2px);
  fill: var(--primary-2);
}
.brand-name {
  font-family: "Cairo", system-ui, Tahoma, Arial;
  font-weight: 700;
  font-size: 3rem;
  letter-spacing: 0.5px;
  margin: 0;
  color: var(--primary);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.55);
}
@media (max-width: 640px) {
  .brand-name {
    font-size: 2.4rem;
  }
}
.brand-tag {
  color: var(--muted);
  font-weight: 700;
  margin-top: 0.18rem;
}
.dark .brand-tag {
  color: #e2e8f0;
}

/* ===== عناوين ناتج التوليد (إن وجدت) ===== */
#out h2,
#out h3 {
  color: var(--sea-600);
  margin: 0 0 8px;
}
.dark #out h2,
.dark #out h3 {
  color: #93c5fd;
}

/* ===== شارات أعلى الناتج ===== */
#chips .chip {
  display: inline-block;
  padding: 0.28rem 0.65rem;
  border-radius: 999px;
  background: var(--sea-100);
  color: #0c4a6e;
  font-size: 0.82rem;
  border: 1px solid rgba(59, 130, 246, 0.25);
  margin-inline-start: 6px;
}
.dark #chips .chip {
  background: #0f172a;
  color: #e2e8f0;
  border-color: var(--primary);
}

/* ===== Select Dropdown Styling ===== */
.select-wrap {
  position: relative;
}

/* تحسين: دمج .sel مع input, select, textarea كان سيصبح معقداً، لذا إبقاؤه منفصلاً أفضل */
.select-wrap .sel {
  width: 100%;
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--sea-600);
  border-radius: 12px;
  padding: 0.9rem 1rem 0.9rem 2.2rem;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  font-family: Cairo, system-ui, Tahoma, Arial;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s ease;
}
.select-wrap .sel:hover {
  border-color: var(--sea-500);
}
.select-wrap .sel:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.1);
}
.select-wrap .sel option {
  font-family: Cairo, system-ui, Tahoma, Arial;
  color: #0f172a;
  background: #ffffff;
  padding: 8px;
}
.dark .select-wrap .sel {
  background: var(--card);
  color: var(--ink);
  border-color: var(--sea-600);
}
.dark .select-wrap .sel:hover {
  border-color: #60a5fa;
}
.dark .select-wrap .sel:focus {
  border-color: #60a5fa;
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.15);
}
.dark .select-wrap .sel option {
  background: #1e293b;
  color: #f1f5f9;
}

/* Custom dropdown icon */
.select-wrap .sel-icon {
  position: absolute;
  inset-inline-start: 0.7rem;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  pointer-events: none;
  color: var(--sea-500);
  transition: color 0.2s ease;
}
.select-wrap .sel-icon svg {
  width: 16px;
  height: 16px;
  display: block;
  fill: currentColor;
}
.select-wrap .sel:focus ~ .sel-icon,
.select-wrap .sel:hover ~ .sel-icon {
  color: var(--primary);
}
.dark .select-wrap .sel-icon {
  color: #60a5fa;
}
.dark .select-wrap .sel:focus ~ .sel-icon,
.dark .select-wrap .sel:hover ~ .sel-icon {
  color: #93c5fd;
}

/* ===== نص خافت مساعد ===== */
.muted {
  color: var(--muted);
}

/* ===== مرتكز: تكبير الحقول والبطاقات ===== */
.info-card {
  margin-bottom: 24px;
}
.info-card:last-child {
  margin-bottom: 0;
}
.info-card .lead a {
  color: var(--sea-600);
  text-decoration: underline;
  font-weight: 600;
}
.info-card .lead a:hover {
  color: var(--sea-400);
}
.dark .info-card .lead a {
  color: #60a5fa;
  font-weight: 600;
}
.dark .info-card .lead a:hover {
  color: #93c5fd;
}

/* شرائط الطالب */
.strip {
  margin-bottom: 12px;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  overflow: hidden;
}
.strip .head {
  display: grid;
  grid-template-columns: 180px 120px 120px 120px 1fr;
  align-items: center;
  background: color-mix(in oklab, var(--primary) 16%, white);
}
.strip .head > div {
  padding: 8px 10px;
  border-inline-start: 1px solid #cbd5e1;
  font-weight: 800;
  text-align: center;
  color: #0a2540;
}
.dark .strip .head {
  background: color-mix(in oklab, var(--primary) 28%, black);
  color: #c7d2fe;
}
.strip .row {
  display: grid;
  grid-template-columns: 180px 120px 120px 120px 1fr;
}
.strip .row + .row {
  border-top: 1px solid #e2e8f0;
}
.strip .cell {
  padding: 8px 10px;
  border-inline-start: 1px solid #e5e7eb;
  background: var(--card);
}
.strip .cell.right {
  overflow: auto;
}

.meta-title {
  font-weight: 800;
  text-align: right;
}
.meta-box {
  background: #f8fafc;
  border: 1px dashed #94a3b8;
  border-radius: 10px;
  min-height: 38px;
  color: #1e293b;
  font-weight: 500;
}

.weeks {
  display: grid;
  grid-template-columns: repeat(10, minmax(48px, 1fr));
  gap: 0;
}
.week {
  border-inline-start: 1px solid #cbd5e1;
  border-bottom: 1px solid #e2e8f0;
}
.week .wtitle {
  background: #e2e8f0;
  text-align: center;
  font-weight: 800;
  padding: 2px 0;
  color: #0a2540;
}
.dark .week .wtitle {
  background: #1f2937;
  color: #e2e8f0;
}

.criteria {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2px;
  padding: 4px;
}
.crit {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: center;
  padding: 4px 0;
}

.badge-col {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  border: 1px solid rgba(59, 130, 246, 0.25);
  font-size: 0.72rem;
}

/* 5 أيام داخل كل خلية أسبوع */
.d5 {
  display: flex;
  gap: 2px;
}
.d5 .dot,
.d5 .sq {
  width: 10px;
  height: 10px;
  border: 1.6px solid #64748b;
  border-radius: 999px;
}
.d5 .sq {
  border-radius: 3px;
}
.d5 .mk {
  font-weight: 800;
  line-height: 1;
}

/* ====== Athar — Global Responsive Patch ====== */

/* وسائط وصور مرنة */
img,
video,
canvas,
svg,
iframe {
  max-width: 100%;
  height: auto;
  display: block;
}

/* لفّ الاختيارات الطويلة (checkbox/radio) بأناقة */
.field.inline label {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  white-space: normal;
  flex-wrap: wrap;
  line-height: 1.6;
}
.field.inline input[type="checkbox"],
.field.inline input[type="radio"] {
  margin-top: 3px;
  flex: 0 0 auto;
}

/* شبكات جاهزة للاستعمال العام */
.grid-2,
.grid-3 {
  display: grid;
  gap: 16px;
  grid-template-columns: 1fr; /* تحسين: دمج التعريف الافتراضي */
}

@media (min-width: 900px) {
  .grid-2 {
    grid-template-columns: 1fr 1fr;
  }
  .grid-3 {
    grid-template-columns: 1fr 1fr 1fr;
  }
}

/* جداول: تمرير أفقي لطيف */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.table-wrap table {
  width: 100%;
  border-collapse: collapse;
}

/* هوامش آمنة لحافة أجهزة iPhone */
@supports (padding: env(safe-area-inset-bottom)) {
  body {
    padding-bottom: env(safe-area-inset-bottom);
  }
}

/* تحسينات بصرية صغيرة */
h1,
h2,
h3 {
  line-height: 1.25;
}

/* تحسين: إضافة white-space لـ button ليتطابق مع .btn */
button {
  white-space: nowrap;
}

/* ===== (إضافات جديدة للملف الشخصي) ===== */
.badge.active {
  color: #166534;
  background: #dcfce7;
  border: 1px solid #bbf7d0;
}
.badge.trial {
  color: #0c4a6e;
  background: #e0f2fe;
  border: 1px solid #bae6fd;
}
.badge.pending {
  color: #854d0e;
  background: #fef3c7;
  border: 1px solid #fde68a;
}
.badge.inactive {
  color: #991b1b;
  background: #fee2e2;
  border: 1px solid #fecaca;
}
.dark .badge.active {
  color: #a7f3d0;
  background: #052e1a;
  border-color: #064e3b;
}
.dark .badge.trial {
  color: #93c5fd;
  background: #082f49;
  border-color: #0ea5e9;
}
.dark .badge.pending {
  color: #fde68a;
  background: #3d2f08;
  border-color: #a16207;
}
.dark .badge.inactive {
  color: #fecaca;
  background: #450a0a;
  border-color: #7f1d1d;
}

/* Theme picker (تخصيص اللون) */
.theme-picker {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}
.theme-picker button {
  all: unset;
  display: inline-block;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px #e5e7eb;
  cursor: pointer;
}
.theme-picker button[data-reset] {
  background: #111827;
}
.theme-picker button.is-active {
  outline: 3px solid color-mix(in oklab, var(--primary) 65%, white);
  outline-offset: 2px;
}

/* عناصر الملف الشخصي (صورة + اسم قابل للتعديل) */
.profile-header {
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
}
.avatar {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  overflow: hidden;
  position: relative;
  border: 3px solid color-mix(in srgb, var(--primary) 35%, white 65%);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}
.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.avatar .edit {
  position: absolute;
  inset: auto 4px 4px auto;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 6px 16px color-mix(in srgb, var(--primary) 40%, transparent);
}

.name-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.name {
  font-size: clamp(20px, 3.4vw, 26px);
  font-weight: 800;
  color: var(--ink);
}
.name .edit-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid color-mix(in srgb, var(--primary) 25%, transparent);
  background: #fff;
  color: var(--primary);
  cursor: pointer;
}

/* زر الفواتير (قريبًا) */
.bill-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 10px;
  background: repeating-linear-gradient(
    45deg,
    #f1f5f9 0 10px,
    #e2e8f0 10px 20px
  );
  color: #334155;
  border: 1px dashed #94a3b8;
}
.dark .bill-btn {
  background: repeating-linear-gradient(
    45deg,
    #111827 0 10px,
    #0f172a 10px 20px
  );
  color: #94a3b8;
  border-color: #475569;
}
.bill-btn .soon {
  font-weight: 900;
  color: var(--primary);
}
/* ===== Enhanced Responsive Navbar ===== */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
  background: rgba(255, 255, 255, 0.85);
  border-bottom: 1px solid color-mix(in srgb, var(--primary) 20%, transparent);
  box-shadow: 0 2px 20px rgba(0, 0, 0, 0.08);
  transition: all 0.3s ease;
}

.dark .navbar {
  background: rgba(15, 23, 42, 0.9);
  border-bottom-color: color-mix(in srgb, var(--primary) 30%, transparent);
}

.nav-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 70px;
}

/* Brand/Logo */
.nav-brand {
  flex-shrink: 0;
}

.brand-link {
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-text {
  font-family: "Cairo", system-ui, Tahoma, Arial;
  font-weight: 800;
  font-size: 28px;
  color: var(--primary);
  letter-spacing: 0.5px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.dark .brand-text {
  color: #93c5fd;
  text-shadow: none;
}

/* Mobile Toggle Button */
.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  transition: all 0.3s ease;
}

.nav-toggle:hover {
  background: rgba(59, 130, 246, 0.1);
}

.hamburger {
  width: 24px;
  height: 3px;
  background: var(--ink);
  margin: 3px 0;
  transition: all 0.3s ease;
  border-radius: 2px;
}

.nav-toggle.active .hamburger:nth-child(1) {
  transform: rotate(45deg) translate(6px, 6px);
}

.nav-toggle.active .hamburger:nth-child(2) {
  opacity: 0;
}

.nav-toggle.active .hamburger:nth-child(3) {
  transform: rotate(-45deg) translate(6px, -6px);
}

/* Navigation Menu */
.nav-menu {
  display: flex;
  align-items: center;
  gap: 32px;
}

.nav-section {
  display: flex;
  align-items: center;
  gap: 16px;
}

.nav-main {
  gap: 24px;
}

.nav-actions {
  gap: 12px;
}

/* Navigation Links */
.nav-link {
  text-decoration: none;
  color: var(--ink);
  font-weight: 600;
  font-size: 16px;
  padding: 8px 12px;
  border-radius: 8px;
  transition: all 0.3s ease;
  position: relative;
  white-space: nowrap;
}

.nav-link:hover {
  color: var(--primary);
  background: rgba(59, 130, 246, 0.08);
  transform: translateY(-1px);
}

.nav-link.active {
  color: var(--primary);
  background: rgba(59, 130, 246, 0.12);
}

/* Navigation Buttons */
.nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: 10px;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
  font-weight: 700;
  font-size: 14px;
  transition: all 0.3s ease;
  white-space: nowrap;
  font-family: "Cairo", system-ui, Tahoma, Arial;
}

.theme-btn {
  background: rgba(255, 255, 255, 0.8);
  border-color: color-mix(in srgb, var(--primary) 25%, transparent);
  color: var(--ink);
  width: 44px;
  height: 44px;
  padding: 0;
  font-size: 18px;
}

.auth-btn {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.profile-btn {
  background: rgba(255, 255, 255, 0.9);
  color: var(--primary);
  border-color: color-mix(in srgb, var(--primary) 30%, transparent);
}

.logout-btn {
  background: rgba(239, 68, 68, 0.1);
  color: #dc2626;
  border-color: rgba(239, 68, 68, 0.3);
}

.nav-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.auth-btn:hover {
  background: color-mix(in srgb, var(--primary) 90%, black 10%);
  box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
}

.logout-btn:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #b91c1c;
}

/* Dark Mode Styles */
.dark .nav-link {
  color: var(--ink);
}

.dark .nav-link:hover {
  color: #93c5fd;
  background: rgba(147, 197, 253, 0.1);
}

.dark .theme-btn {
  background: rgba(30, 41, 59, 0.8);
  border-color: color-mix(in srgb, var(--primary) 40%, transparent);
}

.dark .profile-btn {
  background: rgba(30, 41, 59, 0.9);
  color: #93c5fd;
  border-color: color-mix(in srgb, var(--primary) 40%, transparent);
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .nav-toggle {
    display: flex;
  }

  .nav-container {
    padding: 0 16px;
    height: 60px;
  }

  .brand-text {
    font-size: 24px;
  }

  .nav-menu {
    position: fixed;
    top: 60px;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid color-mix(in srgb, var(--primary) 20%, transparent);
    flex-direction: column;
    gap: 0;
    padding: 20px;
    transform: translateY(-100%);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  }

  .dark .nav-menu {
    background: rgba(15, 23, 42, 0.95);
    border-bottom-color: color-mix(in srgb, var(--primary) 30%, transparent);
  }

  .nav-menu.active {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
  }

  .nav-section {
    flex-direction: column;
    width: 100%;
    gap: 12px;
  }

  .nav-main {
    border-bottom: 1px solid rgba(59, 130, 246, 0.2);
    padding-bottom: 20px;
    margin-bottom: 20px;
  }

  .nav-link {
    width: 100%;
    text-align: center;
    padding: 12px 16px;
    font-size: 16px;
  }

  .nav-btn {
    width: 100%;
    justify-content: center;
    padding: 12px 16px;
    font-size: 16px;
  }

  .theme-btn {
    width: 100%;
    height: auto;
  }
}

@media (max-width: 480px) {
  .nav-container {
    padding: 0 12px;
  }

  .brand-text {
    font-size: 20px;
  }

  .nav-menu {
    padding: 16px;
  }
}
