/* ============ وثّق — أساسيات التصميم المشتركة ============ */
@font-face {
  font-family: 'Cairo'; font-style: normal; font-weight: 200 1000; font-display: swap;
  src: url(/vendor/fonts/cairo/cairo-arabic-wght-normal.woff2) format('woff2');
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0898-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC, U+102E0-102FB, U+10E60-10E7E, U+1EE00-1EEFF;
}
@font-face {
  font-family: 'Cairo'; font-style: normal; font-weight: 200 1000; font-display: swap;
  src: url(/vendor/fonts/cairo/cairo-latin-wght-normal.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --bg: #f3f5fb;
  --surface: #ffffff;
  --ink: #0d1330;
  --ink-2: #4a5275;
  --ink-3: #8089a8;
  --line: #e3e7f3;
  --brand: #6c5ce7;
  --brand-2: #00b8f5;
  --brand-soft: #eeebff;
  --mint: #10b981;
  --mint-soft: #e3f8f0;
  --gold: #f5b942;
  --gold-soft: #fff4dc;
  --danger: #ef4444;
  --danger-soft: #fee9e9;
  --navy: #0a1030;
  --navy-2: #111a45;
  --grad: linear-gradient(135deg, #6c5ce7 0%, #3b82f6 55%, #00c2ff 100%);
  --radius: 18px;
  --shadow: 0 12px 34px rgba(20, 30, 90, .09), 0 2px 8px rgba(20, 30, 90, .05);
  --shadow-lg: 0 30px 80px rgba(20, 30, 90, .18);
  --ease: cubic-bezier(.2, .8, .2, 1);
  --font: 'Cairo', 'Segoe UI', Tahoma, system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; font-family: var(--font); color: var(--ink); background: var(--bg);
  line-height: 1.7; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
h1, h2, h3, h4, p { margin: 0; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img, svg, canvas { display: block; max-width: 100%; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid rgba(108, 92, 231, .45); outline-offset: 2px; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ico { width: 1.25em; height: 1.25em; flex: none; }

/* ---------- الأزرار ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  padding: 12px 22px; border-radius: 14px; border: 0; font-weight: 700; font-size: 1rem;
  transition: transform .2s var(--ease), box-shadow .2s var(--ease), background .2s, opacity .2s;
  user-select: none; white-space: nowrap; line-height: 1.4;
}
.btn:active { transform: scale(.97); }
.btn[disabled], .btn.is-busy { opacity: .55; pointer-events: none; }
.btn-primary { background: var(--grad); color: #fff; box-shadow: 0 10px 26px rgba(80, 90, 240, .38); }
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 16px 34px rgba(80, 90, 240, .5); }
.btn-dark { background: var(--navy); color: #fff; }
.btn-dark:hover { background: var(--navy-2); }
.btn-soft { background: var(--brand-soft); color: var(--brand); }
.btn-soft:hover { background: #e3defe; }
.btn-ghost { background: transparent; color: var(--ink); border: 1.5px solid var(--line); }
.btn-ghost:hover { border-color: var(--brand); color: var(--brand); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-danger:hover { background: #fcd9d9; }
.btn-ok { background: var(--mint); color: #fff; box-shadow: 0 10px 24px rgba(16, 185, 129, .35); }
.btn-sm { padding: 8px 14px; font-size: .9rem; border-radius: 11px; }
.btn-lg { padding: 16px 32px; font-size: 1.12rem; border-radius: 16px; }
.btn-block { width: 100%; }

/* ---------- النماذج ---------- */
.field { display: grid; gap: 7px; }
.field > label, .lbl { font-weight: 700; font-size: .93rem; color: var(--ink); }
.hint { font-size: .83rem; color: var(--ink-3); }
.input {
  width: 100%; padding: 12px 14px; background: #fff; border: 1.5px solid var(--line);
  border-radius: 12px; transition: border-color .2s, box-shadow .2s; min-height: 46px;
}
.input::placeholder { color: #a3abc6; }
.input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px rgba(108, 92, 231, .14); }
.input[dir=ltr] { text-align: left; }
.input-wrap { position: relative; }
.input-wrap .input { padding-inline: 46px; }
.input-wrap .eye {
  position: absolute; inset-inline-end: 6px; top: 50%; transform: translateY(-50%);
  width: 36px; height: 36px; display: grid; place-items: center; border: 0; background: none; color: var(--ink-3); border-radius: 10px;
}
.input-wrap .eye:hover { color: var(--brand); background: var(--brand-soft); }

.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 10px 0; }
.switch-row .t { display: grid; gap: 1px; }
.switch-row .t b { font-weight: 700; font-size: .95rem; }
.switch-row .t span { font-size: .82rem; color: var(--ink-3); line-height: 1.5; }
.switch { position: relative; width: 48px; height: 28px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 2; }
.switch i { position: absolute; inset: 0; background: #cdd3e8; border-radius: 99px; transition: background .25s; }
.switch i::after {
  content: ''; position: absolute; top: 3px; inset-inline-start: 3px; width: 22px; height: 22px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .25); transition: transform .25s var(--ease);
}
.switch input:checked + i { background: var(--grad); }
.switch input:checked + i::after { transform: translateX(-20px); }
html[dir=ltr] .switch input:checked + i::after { transform: translateX(20px); }
.switch input:focus-visible + i { outline: 3px solid rgba(108, 92, 231, .45); outline-offset: 2px; }

/* ---------- بطاقات وشارات ---------- */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; border: 1px solid rgba(227, 231, 243, .7); }
.card-title { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.05rem; margin-bottom: 14px; }
.card-title .ico { color: var(--brand); }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 99px; font-size: .82rem; font-weight: 700; background: var(--brand-soft); color: var(--brand); }
.chip.ok { background: var(--mint-soft); color: #067a56; }
.chip.warn { background: var(--gold-soft); color: #a46b00; }
.chip.dark { background: var(--navy); color: #fff; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.chip.live .dot { animation: pulse 1.6s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 currentColor; } 70% { box-shadow: 0 0 0 7px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }

.progress { height: 9px; background: #e6e9f6; border-radius: 99px; overflow: hidden; }
.progress > i { display: block; height: 100%; width: 0; background: var(--grad); border-radius: 99px; transition: width .7s var(--ease); }
.progress.ok > i { background: linear-gradient(90deg, #10b981, #34d399); }

/* ---------- نافذة منبثقة ---------- */
.modal-back {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 16px;
  background: rgba(10, 16, 48, .55); backdrop-filter: blur(6px); animation: fadeIn .2s;
}
.modal {
  background: #fff; border-radius: 24px; width: min(560px, 100%); max-height: calc(100dvh - 32px); overflow: auto;
  box-shadow: var(--shadow-lg); animation: popIn .35s var(--ease); padding: 24px;
}
.modal h3 { font-size: 1.25rem; font-weight: 800; margin-bottom: 6px; }
.modal .sub { color: var(--ink-2); margin-bottom: 18px; font-size: .95rem; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-start; margin-top: 20px; flex-wrap: wrap; }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes popIn { from { opacity: 0; transform: translateY(24px) scale(.97); } }
@media (max-width: 640px) {
  .modal-back { align-items: end; padding: 0; }
  .modal { border-radius: 24px 24px 0 0; width: 100%; max-height: 92dvh; animation: sheetIn .35s var(--ease); }
  @keyframes sheetIn { from { transform: translateY(100%); } }
}

/* ---------- تنبيهات ---------- */
.toasts { position: fixed; inset-inline: 0; bottom: 22px; z-index: 200; display: grid; gap: 8px; justify-items: center; pointer-events: none; padding: 0 14px; }
.toast {
  display: flex; align-items: center; gap: 10px; background: var(--navy); color: #fff; padding: 12px 18px; border-radius: 14px;
  font-weight: 600; box-shadow: var(--shadow-lg); animation: toastIn .35s var(--ease); max-width: 480px; pointer-events: auto;
}
.toast.err { background: #b91c1c; }
.toast.ok { background: #047857; }
.toast.out { opacity: 0; transform: translateY(10px); transition: .3s; }
@keyframes toastIn { from { opacity: 0; transform: translateY(16px) scale(.96); } }

.spin { width: 20px; height: 20px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, .35); border-top-color: #fff; animation: spin .8s linear infinite; }
.spin.dark { border-color: rgba(108, 92, 231, .2); border-top-color: var(--brand); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- صفحة الخطأ / التحميل ---------- */
.center-page { min-height: 100dvh; display: grid; place-items: center; padding: 24px; background: radial-gradient(900px 500px at 80% -10%, #e2dcff 0%, transparent 60%), var(--bg); }
.notfound { text-align: center; display: grid; gap: 14px; justify-items: center; }
.nf-code { font-size: 7rem; font-weight: 900; line-height: 1; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.notfound p { color: var(--ink-2); }

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

/* شارات الأمان */
.sec-badges { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0 4px; }
.sec-badges span { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .78rem; font-weight: 700; letter-spacing: .02em; padding: 6px 12px; border-radius: 99px; border: 1px solid rgba(120, 110, 255, .35); background: rgba(120, 110, 255, .08); color: var(--brand, #6c5ce7); direction: ltr; }
