:root {
  --navy: #123a6b;
  --navy-2: #1d4f8c;
  --sun: #f2b632;
  --sun-soft: #fff4d6;
  --coral: #e8664f;
  --mint: #2f9e74;
  --mint-soft: #e3f5ec;
  --red: #c8412f;
  --red-soft: #fdecea;
  --amber-soft: #fff4dc;
  --ink: #1d2433;
  --muted: #667085;
  --line: #e6e1d6;
  --bg: #f7f3ea;
  --card: #ffffff;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(18, 58, 107, .06), 0 6px 20px rgba(18, 58, 107, .07);
  --tap: 48px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-bottom: 110px; }
body {
  margin: 0; font-family: "Tajawal", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
  font-size: 17px; line-height: 1.65; color: var(--ink); background: var(--bg);
  -webkit-font-smoothing: antialiased; min-height: 100vh;
}
img, svg { max-width: 100%; display: block; }
a { color: var(--navy-2); }
h1, h2, h3 { line-height: 1.3; margin: 0 0 .5em; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; }
p { margin: 0 0 .75em; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.center { text-align: center; }
.strong { font-weight: 700; }
.hidden { display: none !important; }
bdi[dir=ltr] { unicode-bidi: isolate; }
:focus-visible { outline: 3px solid var(--sun); outline-offset: 2px; border-radius: 6px; }

.wrap { max-width: 640px; margin: 0 auto; padding: 0 16px; }
.wrap-wide { max-width: 1180px; margin: 0 auto; padding: 0 16px; }

/* شريط علوي */
.topbar { background: var(--navy); color: #fff; position: sticky; top: 0; z-index: 20; }
.topbar .wrap, .topbar .wrap-wide { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; }
.brand-mark { width: 38px; height: 38px; border-radius: 12px; background: var(--sun); display: grid; place-items: center; color: var(--navy); font-weight: 800; font-size: 1.1rem; flex: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text b { font-size: 1.02rem; }
.brand-text small { font-size: .75rem; opacity: .8; }
.topbar .btn-ghost { color: #fff; border-color: rgba(255, 255, 255, .35); }

/* بطاقات وأزرار */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 16px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: var(--tap);
  padding: 10px 20px; border-radius: 12px; border: 1.5px solid transparent; font: inherit; font-weight: 700;
  cursor: pointer; text-decoration: none; transition: transform .08s, background .15s, opacity .15s; user-select: none;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--navy-2); }
.btn-sun { background: var(--sun); color: var(--navy); }
.btn-mint { background: var(--mint); color: #fff; }
.btn-danger { background: #fff; color: var(--red); border-color: #f2c4bd; }
.btn-ghost { background: transparent; color: var(--navy); border-color: var(--line); }
.btn-sm { min-height: 38px; padding: 6px 14px; font-size: .92rem; border-radius: 10px; }
.btn-block { width: 100%; }
.btn-xl { min-height: 58px; font-size: 1.15rem; border-radius: 14px; }
.btn.loading { position: relative; color: transparent !important; }
.btn.loading::after { content: ""; position: absolute; width: 20px; height: 20px; border: 2.5px solid rgba(255,255,255,.5); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
.btn-ghost.loading::after, .btn-danger.loading::after { border-color: rgba(18,58,107,.25); border-top-color: var(--navy); }
@keyframes spin { to { transform: rotate(360deg); } }
.link { background: none; border: 0; padding: 4px 0; color: var(--navy-2); font: inherit; font-weight: 700; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row > .grow { flex: 1; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }

/* حقول */
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-weight: 700; margin-bottom: 6px; font-size: .95rem; }
.field small.hint { display: block; color: var(--muted); font-size: .82rem; margin-top: 4px; }
input, select, textarea {
  width: 100%; min-height: var(--tap); padding: 10px 14px; font: inherit; color: var(--ink);
  border: 1.5px solid var(--line); border-radius: 12px; background: #fff; transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--navy-2); box-shadow: 0 0 0 3px rgba(29, 79, 140, .15); }
.field.invalid input, .field.invalid select, .field.invalid textarea { border-color: var(--red); background: var(--red-soft); }
.field .err { color: var(--red); font-size: .84rem; margin-top: 4px; display: block; min-height: 0; }
.form-error { color: var(--red); font-weight: 700; min-height: 1.4em; margin: 6px 0 10px; }
.form-error:empty { min-height: 0; margin: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
@media (max-width: 480px) { .grid-2 { grid-template-columns: 1fr; } }
.check { display: flex; gap: 12px; align-items: flex-start; padding: 14px; border: 1.5px solid var(--line); border-radius: 12px; cursor: pointer; background: #fff; }
.check input { width: 24px; height: 24px; min-height: 0; flex: none; margin-top: 2px; accent-color: var(--navy); }
.check.invalid { border-color: var(--red); background: var(--red-soft); }
.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 700; }
.switch input { width: 22px; height: 22px; min-height: 0; accent-color: var(--navy); }

/* إدخال الرمز */
.auth { max-width: 440px; margin: 24px auto; }
.otp { display: flex; gap: 8px; justify-content: center; margin: 18px 0 6px; }
.otp input { width: 48px; height: 58px; padding: 0; text-align: center; font-size: 1.5rem; font-weight: 800; border-radius: 12px; }

/* حالات */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 12px; border-radius: 99px; font-size: .84rem; font-weight: 700; white-space: nowrap; }
.st-pending { background: #e8eef8; color: var(--navy-2); }
.st-approved { background: var(--mint-soft); color: #1f7a57; }
.st-wait { background: var(--amber-soft); color: #9a6400; }
.st-declined { background: var(--red-soft); color: var(--red); }
.st-withdrawn { background: #eef0f3; color: #5b6472; }
.notice { padding: 14px 16px; border-radius: 12px; margin-bottom: 14px; font-weight: 500; }
.notice-info { background: #e8eef8; color: var(--navy); }
.notice-warn { background: var(--amber-soft); color: #7a5000; }
.notice-ok { background: var(--mint-soft); color: #1b6b4c; }
.notice-err { background: var(--red-soft); color: var(--red); }

/* إشعارات */
#toasts { position: fixed; bottom: 16px; left: 16px; right: 16px; display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 100; pointer-events: none; }
.toast { background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; box-shadow: var(--shadow); max-width: 460px; transition: opacity .4s, transform .4s; font-weight: 500; }
.toast-ok { background: #1f7a57; }
.toast-err { background: var(--red); }
.toast.out { opacity: 0; transform: translateY(8px); }

/* نافذة حوار */
dialog { border: 0; border-radius: 18px; padding: 0; width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 32px); box-shadow: 0 20px 60px rgba(0,0,0,.25); color: var(--ink); }
dialog::backdrop { background: rgba(16, 24, 40, .5); }
dialog .dlg-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #fff; z-index: 1; }
dialog .dlg-head h3 { margin: 0; }
dialog .dlg-body { padding: 20px; }
dialog .dlg-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-start; position: sticky; bottom: 0; background: #fff; }
.x { background: none; border: 0; font-size: 1.6rem; line-height: 1; cursor: pointer; color: var(--muted); width: 40px; height: 40px; border-radius: 10px; }
.x:hover { background: #f2f2f2; }

.skeleton { background: linear-gradient(90deg, #eee8dc 25%, #f6f2ea 50%, #eee8dc 75%); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: 12px; }
@keyframes sk { to { background-position: -200% 0; } }
.empty { text-align: center; padding: 28px 12px; color: var(--muted); }
footer.foot { text-align: center; color: var(--muted); font-size: .82rem; padding: 24px 16px 40px; }
