/* أساس مشترك: متغيرات، أزرار، حقول، نوافذ، إشعارات، جداول. (CSP: بلا style مضمَّن؛ كل شيء بأصناف.) */
:root {
  --navy: #0b1220; --navy2: #141c2f; --ink: #0f172a; --dim: #64748b; --line: #e5e9f2; --bg: #f5f7fb; --card: #ffffff;
  --brand: #2f6bff; --brand-strong: #2457e0; --soft: #eaf0ff; --gold: #f5a524; --gold-soft: #fff4dc; --gold-ink: #8a5a00;
  --ok: #0f9d6b; --ok-soft: #e3f6ee; --warn: #d97706; --warn-soft: #fff1de; --bad: #e5304f; --bad-soft: #ffe8ed;
  --r: 14px; --r2: 20px; --rb: 999px; --ease: cubic-bezier(.2, .7, .2, 1);
  --sh1: 0 1px 2px rgba(15, 23, 42, .05), 0 8px 22px -14px rgba(15, 23, 42, .18); --sh2: 0 2px 6px rgba(15, 23, 42, .06), 0 28px 44px -26px rgba(15, 23, 42, .32);
  --font: 'Tajawal', 'Segoe UI', Tahoma, sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); color: var(--ink); background: var(--bg); font-size: 16px; line-height: 1.65; -webkit-font-smoothing: antialiased; overflow-x: hidden; }
body.modal-open { overflow: hidden; }
h1, h2, h3, h4, p { margin: 0; } h1, h2, h3, h4 { line-height: 1.35; letter-spacing: -.005em; }
a { color: inherit; text-decoration: none; } img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
[hidden] { display: none !important; }
.i { width: 20px; height: 20px; flex: none; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 45%, transparent); outline-offset: 2px; border-radius: 6px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--dim); } .ltr { direction: ltr; unicode-bidi: plaintext; } .num { font-variant-numeric: tabular-nums; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; } .row.end { justify-content: flex-end; } .row.between { justify-content: space-between; } .grow { flex: 1; min-width: 0; }

/* أزرار */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 20px; border-radius: var(--rb); font-weight: 700; font-size: 15px; border: 1.5px solid var(--line); background: #fff; color: var(--ink); transition: transform .18s var(--ease), background .18s, border-color .18s, box-shadow .18s; white-space: nowrap; }
.btn:hover:not([disabled]) { border-color: #c5cde0; transform: translateY(-1px); }
.btn.primary { background: var(--brand-strong); border-color: var(--brand-strong); color: #fff; box-shadow: 0 12px 24px -14px var(--brand); }
.btn.primary:hover:not([disabled]) { background: var(--brand); border-color: var(--brand); box-shadow: 0 16px 30px -14px var(--brand); }
.btn.dark { background: var(--navy); border-color: var(--navy); color: #fff; } .btn.dark:hover:not([disabled]) { background: var(--navy2); }
.btn.gold { background: var(--gold); border-color: var(--gold); color: #2b1a00; } .btn.gold:hover:not([disabled]) { filter: brightness(1.05); }
.btn.wa { background: #12a150; border-color: #12a150; color: #fff; } .btn.wa:hover:not([disabled]) { background: #0f8f46; }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; } .btn.ghost { background: transparent; }
.btn.sm { min-height: 36px; padding: 0 14px; font-size: 14px; } .btn.lg { min-height: 52px; padding: 0 28px; font-size: 17px; } .btn.block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; } .btn.loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.loading::after { content: ''; position: absolute; width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid rgba(255, 255, 255, .5); border-top-color: #fff; animation: spin .7s linear infinite; }
.btn:not(.primary):not(.dark):not(.gold):not(.wa):not(.danger).loading::after { border-color: var(--line); border-top-color: var(--brand); }
@keyframes spin { to { transform: rotate(360deg); } }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; display: inline-grid; place-items: center; color: var(--ink); transition: background .15s; } .icon-btn:hover { background: var(--soft); }

/* حقول */
.field { display: grid; gap: 6px; margin-bottom: 16px; }
.field > label, .lbl { font-weight: 700; font-size: 14px; } .field .opt { color: var(--dim); font-weight: 500; }
.input, .field input, .field select, .field textarea, select.input, textarea.input { width: 100%; min-height: 50px; border: 1.5px solid var(--line); border-radius: var(--r); padding: 10px 14px; background: #fff; transition: border-color .15s, box-shadow .15s; }
.field textarea, textarea.input { min-height: 96px; resize: vertical; }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px var(--soft); }
.field.bad input, .field.bad select, .field.bad textarea { border-color: var(--bad); } .field .err { color: var(--bad); font-size: 13px; min-height: 0; } .field .err:empty { display: none; } .field .hint { color: var(--dim); font-size: 13px; }
.input.sm { min-height: 38px; padding: 6px 10px; font-size: 14px; }
.form-err { color: var(--bad); background: var(--bad-soft); border-radius: var(--r); padding: 10px 14px; font-size: 14px; margin-bottom: 12px; } .form-err:empty { display: none; }
.hp { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); opacity: 0; pointer-events: none; }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; } .check input { width: 18px; height: 18px; accent-color: var(--brand-strong); }

/* شارات */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 12px; border-radius: var(--rb); font-size: 13px; font-weight: 700; background: var(--soft); color: var(--brand-strong); white-space: nowrap; }
.chip.ok { background: var(--ok-soft); color: var(--ok); } .chip.warn { background: var(--warn-soft); color: var(--warn); } .chip.bad { background: var(--bad-soft); color: var(--bad); } .chip.gold { background: var(--gold-soft); color: var(--gold-ink); } .chip.gray { background: #eef1f6; color: var(--dim); }
.chip .i { width: 14px; height: 14px; }

/* نافذة منبثقة */
.modal { position: fixed; inset: 0; z-index: 200; background: rgba(8, 13, 26, .6); display: grid; place-items: center; padding: 18px; animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.modal-box { width: min(520px, 100%); max-height: 92vh; overflow: auto; background: #fff; border-radius: var(--r2); box-shadow: var(--sh2); animation: rise .28s var(--ease); }
.modal-box.wide { width: min(860px, 100%); }
@keyframes rise { from { opacity: 0; transform: translateY(18px) scale(.98); } }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #fff; z-index: 1; } .modal-head h3 { font-size: 18px; }
.modal-body { padding: 20px; display: grid; gap: 14px; }

/* إشعارات */
.toasts { position: fixed; inset-inline: 0; bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 300; display: grid; justify-items: center; gap: 8px; pointer-events: none; padding: 0 14px; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 10px; background: var(--navy); color: #fff; padding: 12px 18px; border-radius: var(--rb); box-shadow: var(--sh2); font-weight: 600; font-size: 15px; animation: rise .3s var(--ease); max-width: 92vw; }
.toast.err { background: #8f1d33; } .toast.out { opacity: 0; transform: translateY(8px); transition: .3s; } .toast .i { width: 18px; height: 18px; color: #7ef0c0; } .toast.err .i { color: #ffd0d8; }

/* جداول */
.tbl-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); background: #fff; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.tbl th { text-align: start; padding: 11px 14px; background: #f8f9fc; color: var(--dim); font-weight: 700; font-size: 13px; white-space: nowrap; border-bottom: 1px solid var(--line); position: sticky; top: 0; }
.tbl td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; } .tbl tr:last-child td { border-bottom: 0; } .tbl tbody tr:hover { background: #fafbfe; }
.skel { background: linear-gradient(90deg, #eef1f7 25%, #f7f9fc 37%, #eef1f7 63%); background-size: 400% 100%; animation: sh 1.3s infinite; border-radius: 10px; } @keyframes sh { from { background-position: 100% 0; } to { background-position: 0 0; } }
.empty { text-align: center; color: var(--dim); padding: 46px 16px; display: grid; gap: 10px; justify-items: center; } .empty .i { width: 42px; height: 42px; opacity: .55; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
