/* واجهات بوابة واتساب — مبنية على هوية سمارت برو (assets/brand/smartpro-ui.css)
   كل الألوان والخطوط من متغيرات الهوية. ممنوع إضافة لون خارجها. */

:root, [data-theme="dark"] {
  /* أسماء قديمة تستخدمها الصفحات، مربوطة بأدوار الهوية */
  --brand: var(--primary);
  --brand-ink: var(--on-primary);
  --brand-soft: var(--success-bg);
  --ok: var(--success-fg);  --ok-soft: var(--success-bg);
  --warn: var(--warning-fg); --warn-soft: var(--warning-bg);
  --bad: var(--danger-fg);  --bad-soft: var(--danger-bg);
  --info: var(--info-fg);   --info-soft: var(--info-bg);
  --shadow: var(--shadow-2);
  --radius: var(--sp-r-lg);
}

/* الأرقام والحروف اللاتينية تطلع بخط Poppins تلقائياً داخل النص العربي، والعربي بخط Tajawal */
@font-face { font-family: 'SP Latin'; font-weight: 400; font-display: swap; src: url('brand/fonts/Poppins-Regular.ttf') format('truetype'); unicode-range: U+0021-007E, U+00A0-00FF, U+2010-2027; }
@font-face { font-family: 'SP Latin'; font-weight: 500; font-display: swap; src: url('brand/fonts/Poppins-Medium.ttf') format('truetype'); unicode-range: U+0021-007E, U+00A0-00FF, U+2010-2027; }
@font-face { font-family: 'SP Latin'; font-weight: 600; font-display: swap; src: url('brand/fonts/Poppins-SemiBold.ttf') format('truetype'); unicode-range: U+0021-007E, U+00A0-00FF, U+2010-2027; }
@font-face { font-family: 'SP Latin'; font-weight: 700 900; font-display: swap; src: url('brand/fonts/Poppins-Bold.ttf') format('truetype'); unicode-range: U+0021-007E, U+00A0-00FF, U+2010-2027; }
:root { --sp-font-ar: 'SP Latin', 'Tajawal', 'Almarai', 'Cairo', system-ui, sans-serif; }

html, body { margin: 0; }
body { min-height: 100vh; }
code, .mono { font-family: var(--sp-font-en); font-size: .9em; direction: ltr; unicode-bidi: isolate; }
[hidden] { display: none !important; }
svg.i { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.ltr { direction: ltr; unicode-bidi: isolate; font-family: var(--sp-font-en); }
input, textarea, select, button { font-family: inherit; }
.teal { color: var(--sp-teal); }
h1 .sp-underline, .page-head .sp-underline { margin-top: var(--sp-2); }

/* ---------- الهيكل: قائمة جانبية كحلية على اليمين ---------- */
.app { display: grid; grid-template-columns: var(--sp-sidebar-w) 1fr; min-height: 100vh; }
.side {
  background: var(--sidebar-bg); color: var(--sp-white);
  padding: var(--sp-6) var(--sp-4); display: flex; flex-direction: column; gap: 2px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
[data-theme="dark"] .side { border-inline-start: 1px solid var(--border); }
.logo { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-1) var(--sp-3) var(--sp-6); text-decoration: none; }
.side .logo { border-bottom: 1px solid rgba(255,255,255,.12); margin-bottom: var(--sp-4); }
.logo img.sp-logo { width: 168px; height: auto; display: block; }
.logo .sp-product { color: var(--sp-mist); }
.logo.on-light .sp-product { color: var(--heading); border-inline-start-color: var(--border-strong); }
.logo:hover { text-decoration: none; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  position: relative; display: flex; align-items: center; gap: var(--sp-3); min-height: 44px; padding: 0 var(--sp-3);
  border-radius: var(--sp-r); color: rgba(255,255,255,.82); font-weight: 500; text-decoration: none;
  transition: background .15s var(--sp-ease), color .15s var(--sp-ease);
}
.nav a svg { color: rgba(215,232,223,.7); }
.nav a:hover { background: rgba(255,255,255,.07); color: var(--sp-white); text-decoration: none; }
.nav a.active { background: rgba(22,167,101,.16); color: var(--sp-white); font-weight: 700; }
.nav a.active svg { color: var(--sp-teal); }
.nav a.active::before { content: ""; position: absolute; inset-inline-start: -16px; top: 10px; bottom: 10px; width: 4px; border-start-end-radius: 4px; border-end-end-radius: 4px; background: var(--sp-teal); }
.side-foot { margin-top: auto; display: grid; gap: var(--sp-3); padding: var(--sp-4) var(--sp-1) 0; border-top: 1px solid rgba(255,255,255,.12); }
.who { font-size: var(--sp-fs-sm); color: rgba(215,232,223,.7); padding: 0 var(--sp-2); }
.who b { color: var(--sp-white); display: block; font-size: 14px; }
.side .icon-btn { border-color: rgba(255,255,255,.18); color: rgba(215,232,223,.85); }
.side .icon-btn:hover { background: rgba(255,255,255,.08); color: var(--sp-white); }

.main { padding: var(--sp-8) clamp(16px, 3vw, 40px) var(--sp-12); max-width: 1240px; width: 100%; min-width: 0; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: var(--sp-4); flex-wrap: wrap; margin-bottom: var(--sp-6); }
.page-head h1 { margin: 0; font-size: var(--sp-fs-h1); font-weight: 800; color: var(--heading); }
.page-head h1::after { content: ""; display: block; width: 44px; height: 3px; border-radius: 3px; background: var(--sp-teal); margin-top: var(--sp-2); }
.page-head p { margin: var(--sp-2) 0 0; color: var(--text-2); }
.mobile-top { display: none; }

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .side { position: sticky; z-index: 30; height: auto; flex-direction: row; align-items: center; padding: var(--sp-2) var(--sp-3); overflow-x: auto; gap: 2px; }
  .side .logo { padding: 0 var(--sp-1) 0 var(--sp-2); border: 0; margin: 0; }
  .side .logo img.sp-logo { content: url('brand/mersal/mersal-symbol.svg'); width: 38px; }
  .side .logo .sp-product, .side-foot .who { display: none; }
  .nav { flex-direction: row; gap: 2px; }
  .nav a { white-space: nowrap; padding: 0 var(--sp-3); min-height: 40px; }
  .nav a span { display: none; }
  .nav a.active::before { display: none; }
  .side-foot { margin: 0; margin-inline-start: auto; border: 0; padding: 0; display: flex; }
  .side-foot .row { flex-wrap: nowrap; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-3); }
  .tile { padding: var(--sp-4); }
  .tile .value { font-size: 24px; }
  .main { padding: var(--sp-5) var(--sp-4) var(--sp-10); }
}

/* ---------- البطاقات والشبكات ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--sp-r-lg); box-shadow: var(--shadow-2); padding: var(--sp-6); }
.card h2 { margin: 0 0 4px; font-size: var(--sp-fs-h3); font-weight: 700; color: var(--heading); }
.card .sub { color: var(--text-2); margin: 0 0 var(--sp-4); font-size: 14px; }
.grid { display: grid; gap: var(--sp-4); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.stack { display: grid; gap: var(--sp-4); }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.muted { color: var(--text-2); }
.small { font-size: var(--sp-fs-sm); }
p { margin: 0 0 .6em; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: var(--sp-4); }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--sp-r-lg); padding: var(--sp-5); box-shadow: var(--shadow-2); display: flex; flex-direction: column; gap: var(--sp-2); }
.tile .label { color: var(--text-2); font-size: var(--sp-fs-sm); font-weight: 500; display: flex; align-items: center; gap: var(--sp-2); }
.tile .label svg { width: 36px; height: 36px; padding: 8px; border-radius: 10px; background: var(--success-bg); color: var(--icon); box-sizing: border-box; }
.tile .value { font-family: var(--sp-font-en); font-size: var(--sp-fs-kpi); font-weight: 600; color: var(--heading); line-height: 1.1; font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; text-align: end; align-self: flex-start; }
.tile .hint { font-size: var(--sp-fs-xs); color: var(--text-3); }
.meter { height: 8px; background: var(--info-bg); border-radius: var(--sp-r-pill); overflow: hidden; margin-top: var(--sp-2); }
.meter > i { display: block; height: 100%; background: var(--sp-gradient-mark); border-radius: inherit; }
.meter.warn > i { background: var(--sp-amber); }

/* ---------- الأزرار والحقول ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2); min-height: var(--sp-control-h);
  border: 1px solid transparent; border-radius: var(--sp-r); padding: 0 var(--sp-5);
  font: inherit; font-weight: 700; font-size: var(--sp-fs-body); cursor: pointer; text-decoration: none; white-space: nowrap;
  background: var(--primary); color: var(--on-primary); transition: background .15s var(--sp-ease), border-color .15s, color .15s, transform .1s;
}
.btn:hover { background: var(--primary-hover); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn.accent { background: var(--accent); color: var(--on-accent); }
.btn.accent:hover { background: var(--accent-hover); }
.btn.ghost { background: var(--surface); color: var(--heading); border-color: var(--border-strong); }
.btn.ghost:hover { background: var(--surface-2); border-color: var(--heading); }
.btn.danger { background: var(--sp-danger); color: var(--sp-white); }
.btn.danger:hover { filter: brightness(.92); }
.btn.danger-ghost { background: transparent; color: var(--danger-fg); border-color: var(--border-strong); }
.btn.danger-ghost:hover { background: var(--danger-bg); }
.btn.sm { min-height: 36px; padding: 0 var(--sp-3); font-size: var(--sp-fs-sm); }
.btn.block { width: 100%; }
.btn.lg { min-height: 52px; font-size: 16px; padding: 0 var(--sp-6); }
.icon-btn { background: transparent; border: 1px solid var(--border-strong); color: var(--text-2); border-radius: var(--sp-r); width: 38px; height: 38px; display: inline-grid; place-items: center; cursor: pointer; }
.icon-btn:hover { background: var(--info-bg); color: var(--heading); }

label.field { display: grid; gap: 6px; font-size: var(--sp-fs-sm); font-weight: 700; color: var(--text); }
label.field .help { font-weight: 400; color: var(--text-3); font-size: var(--sp-fs-xs); }
input, textarea, select {
  font: inherit; font-size: var(--sp-fs-body); font-weight: 400; color: var(--text); background: var(--surface-2); border: 1px solid var(--border-strong);
  border-radius: var(--sp-r); padding: 0 var(--sp-4); min-height: var(--sp-control-h); width: 100%; outline: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
textarea { padding: var(--sp-3) var(--sp-4); resize: vertical; min-height: 110px; line-height: 1.6; }
input::placeholder, textarea::placeholder { color: var(--text-3); }
input:hover, textarea:hover, select:hover { border-color: var(--sp-teal); }
input:focus, textarea:focus, select:focus { border-color: var(--sp-teal); background: var(--surface); box-shadow: 0 0 0 4px rgba(22,167,101,.18); }
input[dir="ltr"], textarea[dir="ltr"], input[type="email"], input[type="tel"] { text-align: left; font-family: var(--sp-font-en); }
input[type="file"] { padding: var(--sp-2); }
input[type="checkbox"], input[type="radio"] { width: 18px; height: 18px; min-height: 0; accent-color: var(--sp-teal); padding: 0; }
.check { display: flex; align-items: center; gap: var(--sp-2); font-size: 14px; font-weight: 500; cursor: pointer; }
.check input { width: 18px; }
.form-grid { display: grid; gap: var(--sp-4); grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

/* ---------- الحالات: متصل تيل، ينتظر كهرماني، فشل أحمر ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: var(--sp-r-pill); font-size: var(--sp-fs-xs); font-weight: 700; white-space: nowrap; background: var(--info-bg); color: var(--info-fg); }
.pill::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.pill.ok { background: var(--success-bg); color: var(--success-fg); }
.pill.ok::before { background: var(--sp-teal); box-shadow: 0 0 0 3px rgba(22,167,101,.22); }
.pill.warn { background: var(--warning-bg); color: var(--warning-fg); }
.pill.warn::before { background: var(--sp-amber); }
.pill.bad { background: var(--danger-bg); color: var(--danger-fg); }
.pill.info { background: var(--info-bg); color: var(--info-fg); }
.pill.neutral { background: var(--surface-2); color: var(--text-2); }
.pill.pulse::before { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }

.ticks { display: inline-flex; align-items: center; gap: 6px; font-size: var(--sp-fs-sm); font-weight: 500; white-space: nowrap; }
.ticks svg { width: 18px; height: 18px; }
.ticks.sent, .ticks.queued { color: var(--text-2); }
.ticks.delivered { color: var(--icon); }
.ticks.read { color: var(--success-fg); font-weight: 700; }
.ticks.read svg { color: var(--sp-teal); }
.ticks.failed { color: var(--danger-fg); }

/* ---------- الجداول ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--sp-r-lg); background: var(--surface); box-shadow: var(--shadow-2); }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }
th { text-align: start; font-weight: 700; color: var(--text-2); font-size: var(--sp-fs-sm); background: var(--surface-2); padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: var(--info-bg); }
.empty { text-align: center; color: var(--text-3); padding: var(--sp-10) var(--sp-3); }
.cell-main { font-weight: 700; color: var(--heading); }
.cell-sub { font-size: var(--sp-fs-xs); color: var(--text-3); }
.truncate { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.seg { display: inline-flex; padding: 4px; gap: 4px; border-radius: var(--sp-r); background: var(--surface-2); border: 1px solid var(--border); flex-wrap: wrap; }
.seg button { border: 0; background: none; font: inherit; font-size: var(--sp-fs-sm); font-weight: 500; color: var(--text-2); padding: 6px 14px; border-radius: var(--sp-r-sm); cursor: pointer; }
.seg button:hover { color: var(--heading); }
.seg button.on { background: var(--surface); color: var(--heading); font-weight: 700; box-shadow: var(--shadow-1); }
[data-theme="dark"] .seg button.on { background: var(--sp-deep-navy); }

/* ---------- الربط (QR) ---------- */
.link-card { display: grid; grid-template-columns: 1fr auto; gap: var(--sp-8); align-items: center; }
@media (max-width: 760px) { .link-card { grid-template-columns: 1fr; justify-items: center; } .link-card > :last-child { order: -1; } }
.qr-frame { width: 268px; aspect-ratio: 1; height: auto; border-radius: var(--sp-r-lg); border: 1px solid var(--border-strong); background: var(--sp-white); display: grid; place-items: center; padding: 14px; position: relative; margin-inline: auto; }
.qr-frame::before, .qr-frame::after { content: ""; position: absolute; width: 28px; height: 28px; border: 3px solid var(--sp-teal); }
.qr-frame::before { top: -6px; right: -6px; border-left: 0; border-bottom: 0; border-radius: 0 12px 0 0; }
.qr-frame::after { bottom: -6px; left: -6px; border-right: 0; border-top: 0; border-radius: 0 0 0 12px; }
.qr-frame[style*="border:0"]::before, .qr-frame[style*="border:0"]::after { display: none; }
.qr-frame[style*="border:0"] { background: transparent; }
.qr-frame img { width: 100%; height: 100%; image-rendering: pixelated; }
.spinner { width: 38px; height: 38px; border: 3px solid var(--info-bg); border-top-color: var(--sp-teal); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.steps { margin: var(--sp-3) 0 0; padding: 0; list-style: none; counter-reset: s; display: grid; gap: var(--sp-4); }
.steps li { counter-increment: s; display: flex; gap: var(--sp-3); align-items: flex-start; }
.steps li::before { content: counter(s); flex: none; width: 28px; height: 28px; border-radius: 50%; background: var(--success-bg); color: var(--success-fg); font-family: var(--sp-font-en); font-size: var(--sp-fs-sm); font-weight: 600; display: grid; place-items: center; }
.pair-code { font-family: var(--sp-font-en); font-size: 34px; font-weight: 700; letter-spacing: 4px; direction: ltr; text-align: center; color: var(--heading); background: var(--surface-2); border: 1px dashed var(--border-strong); border-radius: var(--sp-r-lg); padding: 18px; }
.phone-badge { display: flex; align-items: center; gap: var(--sp-4); }
.avatar { width: 52px; height: 52px; border-radius: 14px; background: var(--success-bg); color: var(--icon); display: grid; place-items: center; flex: none; }
.avatar svg { width: 26px; height: 26px; }
.big-num { font-family: var(--sp-font-en); font-size: 20px; font-weight: 600; color: var(--heading); direction: ltr; unicode-bidi: isolate; }

/* ---------- الإرسال ---------- */
.drop { border: 1.5px dashed var(--border-strong); border-radius: var(--sp-r); padding: 22px; text-align: center; color: var(--text-2); cursor: pointer; transition: border .15s, background .15s; }
.drop:hover, .drop.over { border-color: var(--sp-teal); background: var(--success-bg); }
.drop b { color: var(--heading); }
.file-chip { display: inline-flex; align-items: center; gap: var(--sp-2); background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--sp-r); padding: var(--sp-2) var(--sp-3); font-size: 14px; }
.file-chip svg { color: var(--icon); }

/* ---------- الكود ---------- */
pre.code { margin: 0; padding: 48px 16px 16px !important; background: var(--sp-midnight); color: var(--sp-mist); border-radius: var(--sp-r); overflow-x: auto; font-family: var(--sp-font-en); font-size: 13px; line-height: 1.6; direction: ltr; text-align: left; }
[data-theme="dark"] pre.code { background: rgba(3,24,17,.55); border: 1px solid var(--border); }
.copy-row { display: flex; align-items: center; gap: var(--sp-2); background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--sp-r); padding: 6px 6px 6px 12px; }
.copy-row code { flex: 1; overflow-x: auto; white-space: nowrap; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 10px var(--sp-4); align-items: center; }
@media (max-width: 560px) { .kv { grid-template-columns: 1fr; gap: 4px; } }
.kv dt { color: var(--text-2); font-size: 14px; }
.kv dd { margin: 0; min-width: 0; }

/* ---------- النوافذ والتنبيهات ---------- */
dialog { border: 1px solid var(--border); border-radius: var(--sp-r-xl); padding: 0; width: min(520px, calc(100vw - 32px)); background: var(--surface); color: var(--text); box-shadow: var(--shadow-3); }
[data-theme="dark"] dialog { background: var(--sp-deep-navy); }
dialog::backdrop { background: var(--overlay); backdrop-filter: blur(2px); }
dialog .d-head { padding: var(--sp-6) var(--sp-6) 0; display: flex; justify-content: space-between; align-items: center; }
dialog .d-head h3 { margin: 0; font-size: var(--sp-fs-h2); color: var(--heading); }
dialog .d-body { padding: var(--sp-4) var(--sp-6); display: grid; gap: var(--sp-4); }
dialog .d-foot { padding: 0 var(--sp-6) var(--sp-6); display: flex; gap: var(--sp-3); justify-content: flex-end; }
.notice { border-radius: var(--sp-r); padding: var(--sp-3) var(--sp-4); font-size: 14px; display: flex; gap: var(--sp-3); align-items: flex-start; background: var(--info-bg); color: var(--text); border-inline-start: 4px solid var(--info-fg); }
.notice svg { margin-top: 2px; color: var(--info-fg); }
.notice.warn { background: var(--warning-bg); border-color: var(--sp-amber); }
.notice.warn svg { color: var(--sp-amber); }
.notice.bad { background: var(--danger-bg); border-color: var(--danger-fg); }
.notice.bad svg { color: var(--danger-fg); }
.notice.ok { background: var(--success-bg); border-color: var(--sp-teal); }
.notice.ok svg { color: var(--icon); }
.notice b, .notice strong { color: var(--heading); }

#toasts { position: fixed; bottom: 20px; inset-inline-start: 20px; display: grid; gap: var(--sp-2); z-index: 200; }
.toast { display: flex; align-items: center; gap: var(--sp-3); background: var(--sp-midnight); color: var(--sp-white); padding: var(--sp-3) var(--sp-4); border-radius: var(--sp-r); font-size: 14px; font-weight: 500; box-shadow: var(--shadow-3); animation: up .2s ease-out; max-width: 380px; }
.toast::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--sp-teal); flex: none; }
.toast.bad::before { background: var(--sp-danger); }
[data-theme="dark"] .toast { background: var(--sp-deep-navy); border: 1px solid var(--border-strong); }
@keyframes up { from { transform: translateY(8px); opacity: 0; } }

/* ---------- صفحة الدخول (هوية سمارت برو) ---------- */
.auth { display: grid; grid-template-columns: minmax(380px, 1fr) 1.1fr; min-height: 100vh; background: var(--surface); }
[data-theme="dark"] .auth { background: var(--bg); }
.auth-form { display: flex; flex-direction: column; justify-content: center; padding: var(--sp-12) clamp(24px, 6vw, 96px); gap: var(--sp-6); }
.auth-form > img { width: 180px; height: auto; }
.auth-form form { display: flex; flex-direction: column; gap: var(--sp-5); max-width: 400px; width: 100%; }
.auth-form h1 { font-size: var(--sp-fs-display); font-weight: 800; }
.auth-hero { background: var(--sp-gradient); color: var(--sp-white); padding: var(--sp-12); display: flex; flex-direction: column; justify-content: space-between; gap: var(--sp-8); position: relative; overflow: hidden; isolation: isolate; }
.auth-hero > img { width: 200px; height: auto; }
.auth-hero h2 { font-size: var(--sp-fs-display); font-weight: 800; color: var(--sp-white); line-height: 1.35; }
.auth-hero .lead { color: var(--sp-mist); margin-top: var(--sp-4); max-width: 460px; }
.auth-badges { display: flex; flex-wrap: wrap; gap: 10px; margin-top: var(--sp-6); }
.auth-badges span.b { display: inline-flex; align-items: center; gap: var(--sp-2); height: 32px; padding: 0 14px; border-radius: var(--sp-r-pill); background: rgba(255,255,255,.1); color: var(--sp-white); font-size: var(--sp-fs-sm); font-weight: 700; }
.auth-badges svg { width: 16px; height: 16px; color: var(--sp-teal); }
.sp-contact .sp-contact__item svg { width: 17px; height: 17px; color: var(--sp-teal); }
@media (max-width: 960px) {
  .auth { grid-template-columns: 1fr; }
  .auth-hero { order: -1; padding: var(--sp-8) var(--sp-5); gap: var(--sp-5); }
  .auth-hero h2 { font-size: 24px; }
  .auth-hero > img { width: 160px; }
  .auth-form { padding: var(--sp-8) var(--sp-5); }
}
.pw-wrap { position: relative; display: block; }
.pw-wrap input { padding-left: 44px; }
.pw-wrap button { position: absolute; inset-inline-end: 6px; top: 50%; transform: translateY(-50%); border: 0; background: transparent; color: var(--text-3); cursor: pointer; padding: 6px; display: grid; }
.pw-wrap button:hover { color: var(--icon); }
.err { color: var(--danger-fg); font-size: var(--sp-fs-sm); font-weight: 500; min-height: 0; margin: 0; }
.err:empty { display: none; }

.chart { width: 100%; height: 140px; }
.chart text { font-family: var(--sp-font-en); }
.legend-dot { display: inline-block; width: 9px; height: 9px; border-radius: 3px; vertical-align: 0; margin-inline-end: 4px; }
.section-title { font-size: var(--sp-fs-sm); font-weight: 700; color: var(--text-3); margin: var(--sp-2) 0 -4px; }

/* ---------- الصفحة الرئيسية العامة ---------- */
.site-nav { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); max-width: 1160px; margin: 0 auto; padding: var(--sp-4) var(--sp-5); }
.site-nav .logo { padding: 0; }
.site-nav .logo img.sp-logo { width: 160px; }
.site-nav .links { display: flex; gap: var(--sp-5); align-items: center; }
.site-nav .links a:not(.btn) { color: var(--text-2); font-weight: 500; }
.site-nav .links a:not(.btn):hover { color: var(--heading); }
@media (max-width: 760px) { .site-nav .links a:not(.btn) { display: none; } .site-nav .logo .sp-product { display: none; } }
.hero-band { background: var(--sp-gradient); color: var(--sp-white); position: relative; overflow: hidden; isolation: isolate; }
.hero-band .site-nav .links a:not(.btn) { color: rgba(255,255,255,.82); }
.hero-band .site-nav .links a:not(.btn):hover { color: var(--sp-white); }
.hero-band .site-nav .logo .sp-product { color: var(--sp-mist); }
.hero { max-width: 1160px; margin: 0 auto; padding: var(--sp-10) var(--sp-5) var(--sp-12); display: grid; grid-template-columns: 1.1fr 1fr; gap: var(--sp-10); align-items: center; }
.hero h1 { font-size: clamp(30px, 4.2vw, 44px); line-height: 1.3; margin: 0 0 var(--sp-4); color: var(--sp-white); font-weight: 800; }
.hero h1::after { content: ""; display: block; width: 44px; height: 3px; border-radius: 3px; background: var(--sp-teal); margin-top: var(--sp-4); }
.hero p.lead { font-size: 17px; color: var(--sp-mist); margin: 0 0 var(--sp-6); max-width: 520px; }
.hero .cta { display: flex; gap: var(--sp-3); flex-wrap: wrap; }
.hero .btn.ghost { background: transparent; color: var(--sp-white); border-color: rgba(255,255,255,.35); }
.hero .btn.ghost:hover { background: rgba(255,255,255,.08); border-color: var(--sp-white); }
.hero .auth-badges { margin-top: var(--sp-8); }
@media (max-width: 860px) { .hero { grid-template-columns: 1fr; padding-top: var(--sp-4); } }
.mock { background: var(--surface); border: 1px solid var(--border); border-radius: var(--sp-r-xl); box-shadow: var(--shadow-3); padding: var(--sp-4); color: var(--text); }
.mock-head { display: flex; align-items: center; gap: var(--sp-3); padding: 2px 4px var(--sp-3); border-bottom: 1px solid var(--border); margin-bottom: var(--sp-3); }
.mock-head .avatar { width: 38px; height: 38px; border-radius: 10px; }
.mock-head .avatar svg { width: 20px; height: 20px; }
.chat { background: var(--bg); border-radius: var(--sp-r); padding: var(--sp-4); display: grid; gap: 10px; }
.bubble { background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 14px 14px 4px 14px; padding: 10px 12px; max-width: 88%; justify-self: start; font-size: 14px; box-shadow: var(--shadow-1); }
.bubble .file { display: flex; align-items: center; gap: 10px; background: var(--info-bg); border-radius: var(--sp-r-sm); padding: 8px 10px; margin-bottom: 6px; }
.bubble .file b { color: var(--sp-white); background: var(--primary); font-family: var(--sp-font-en); font-size: 11px; border-radius: 4px; padding: 1px 5px; }
[data-theme="dark"] .bubble .file b { color: var(--sp-midnight); }
.bubble .meta { display: flex; justify-content: flex-end; align-items: center; gap: 4px; font-family: var(--sp-font-en); font-size: 11px; color: var(--text-3); margin-top: 4px; direction: ltr; }
.bubble .meta svg { width: 15px; height: 15px; color: var(--sp-teal); }
.section { max-width: 1160px; margin: 0 auto; padding: var(--sp-12) var(--sp-5); }
.section h2.title { font-size: var(--sp-fs-h1); font-weight: 800; margin: 0 0 var(--sp-2); text-align: center; }
.section h2.title::after { content: ""; display: block; width: 44px; height: 3px; border-radius: 3px; background: var(--sp-teal); margin: var(--sp-3) auto 0; }
.section p.subtitle { text-align: center; color: var(--text-2); margin: var(--sp-3) auto var(--sp-8); max-width: 620px; }
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: var(--sp-4); }
.feature .ic { width: 44px; height: 44px; border-radius: 12px; background: var(--success-bg); color: var(--icon); display: grid; place-items: center; margin-bottom: var(--sp-3); }
.feature .ic svg { width: 22px; height: 22px; }
.feature h3 { margin: 0 0 6px; }
.feature p { margin: 0; color: var(--text-2); font-size: 14.5px; }
.steps-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: var(--sp-5); counter-reset: st; padding-top: var(--sp-4); }
.steps-row .card { position: relative; padding-top: var(--sp-8); }
.steps-row .card::before { counter-increment: st; content: counter(st); position: absolute; top: -18px; inset-inline-start: var(--sp-6); width: 36px; height: 36px; border-radius: 50%; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; font-family: var(--sp-font-en); font-weight: 700; }
.pricing { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: var(--sp-5); align-items: stretch; }
.price-card { display: flex; flex-direction: column; gap: var(--sp-4); position: relative; }
.price-card h3 { font-weight: 800; }
.price-card.featured { border: 2px solid var(--sp-teal); box-shadow: 0 0 0 6px rgba(22,167,101,.10), var(--shadow-2); }
.price-card .price { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; font-size: 22px; font-weight: 800; color: var(--heading); }
.price-card .price .num { font-size: 40px; font-weight: 700; line-height: 1; }
.price-card .price small { font-size: 14px; color: var(--text-2); font-weight: 500; }
.price-card ul { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--sp-3); color: var(--text); font-size: 14.5px; flex: 1; align-content: start; }
.price-card li { display: flex; gap: var(--sp-2); align-items: flex-start; }
.price-card li svg { color: var(--icon); margin-top: 2px; }
.price-card .btn { margin-top: auto; }
.price-card .tag { position: absolute; top: -13px; inset-inline-start: var(--sp-6); height: 26px; padding: 0 12px; border-radius: var(--sp-r-pill); background: var(--sp-teal); color: var(--sp-midnight); font-size: var(--sp-fs-xs); font-weight: 700; display: inline-flex; align-items: center; }
.faq details { background: var(--surface); border: 1px solid var(--border); border-radius: var(--sp-r); padding: 14px 18px; margin-bottom: 10px; }
.faq details[open] { border-color: var(--border-strong); }
.faq summary { cursor: pointer; font-weight: 700; color: var(--heading); }
.faq p { color: var(--text-2); margin: 10px 0 0; }
.site-footer { background: var(--sp-gradient); color: var(--sp-mist); margin-top: var(--sp-6); }
.site-footer .inner { max-width: 1160px; margin: 0 auto; padding: var(--sp-8) var(--sp-5); display: grid; gap: var(--sp-5); }
.site-footer .top { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-4); flex-wrap: wrap; }
.site-footer .top img { width: 120px; height: auto; }
.site-footer .sp-contact { margin: 0; }
.site-footer .bottom { display: flex; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; font-size: var(--sp-fs-sm); color: rgba(215,232,223,.7); }
.site-footer a { color: var(--sp-mist); }
.site-footer a:hover { color: var(--sp-white); }
.legal { max-width: 860px; margin: 0 auto; padding: var(--sp-6) var(--sp-5) var(--sp-12); }
.legal h1 { margin-bottom: var(--sp-6); }
.legal h1::after { content: ""; display: block; width: 44px; height: 3px; border-radius: 3px; background: var(--sp-teal); margin-top: var(--sp-2); }
.legal .card { white-space: pre-wrap; line-height: 1.9; }
.on-light-bar { background: var(--surface); border-bottom: 1px solid var(--border); }
.site-nav .logo.on-light img.sp-logo { width: 160px; }
[data-theme="dark"] .logo.on-light img.sp-logo { content: url('brand/mersal/mersal-logo-inverse.svg'); }
[data-theme="dark"] .logo.on-light .sp-product { color: var(--sp-mist); border-inline-start-color: rgba(255,255,255,.22); }

/* ---------- الحركات (خفيفة، وتتوقف مع «تقليل الحركة» في الجهاز) ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
@keyframes grow { from { transform: scaleY(0); } }
@keyframes ring { 0% { box-shadow: 0 0 0 0 rgba(22,167,101,.55); } 70%, 100% { box-shadow: 0 0 0 7px rgba(22,167,101,0); } }
[data-section]:not([hidden]) .page-head,
[data-section]:not([hidden]) .stack > *,
[data-section]:not([hidden]) > .grid > *,
[data-section]:not([hidden]) > .table-wrap,
.auth-form > *, .auth-hero > *, .hero > *, .hero-dev .inner > * { animation: rise .5s var(--sp-ease) both; }
.stack > :nth-child(2), .grid > :nth-child(2), .auth-form > :nth-child(2), .hero > :nth-child(2), .hero-dev .inner > :nth-child(2) { animation-delay: .07s; }
.stack > :nth-child(3), .grid > :nth-child(3), .auth-form > :nth-child(3) { animation-delay: .14s; }
.stack > :nth-child(4), .auth-form > :nth-child(4) { animation-delay: .21s; }
.tile, .card.feature, .price-card, .steps-row .card { transition: transform .2s var(--sp-ease), box-shadow .2s var(--sp-ease); }
.tile:hover, .card.feature:hover, .price-card:hover, .steps-row .card:hover { transform: translateY(-3px); box-shadow: var(--shadow-3); }
.chart.anim rect { transform-box: fill-box; transform-origin: bottom; animation: grow .7s var(--sp-ease) both; }
.pill.ok::before { animation: ring 2s ease-out infinite; }
.btn { position: relative; overflow: hidden; }
.reveal { opacity: 0; transform: translateY(16px); transition: opacity .6s var(--sp-ease), transform .6s var(--sp-ease); }
.reveal.in { opacity: 1; transform: none; }
.chat .bubble { animation: rise .45s var(--sp-ease) both; }
.chat .bubble:nth-child(1) { animation-delay: .5s; }
.chat .bubble:nth-child(2) { animation-delay: 1.2s; }
.chat .bubble:nth-child(3) { animation-delay: 1.9s; }
@media (prefers-reduced-motion: reduce) { .reveal { opacity: 1; transform: none; } }

/* ---------- عناصر لوحات التحكم ---------- */
.avatar-sm { width: 34px; height: 34px; border-radius: 10px; flex: none; display: inline-grid; place-items: center; background: var(--info-bg); color: var(--info-fg); font-weight: 800; font-size: 15px; }
.name-cell { display: flex; align-items: center; gap: var(--sp-3); }
.tile { position: relative; overflow: hidden; }
.tile .spark { position: absolute; inset-inline-end: 14px; bottom: 14px; width: 110px; height: 32px; opacity: .9; }
.spark .line { fill: none; stroke: var(--sp-teal); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.spark .area { fill: var(--success-bg); stroke: none; }
.delta { font-size: var(--sp-fs-xs); font-weight: 700; border-radius: var(--sp-r-pill); padding: 1px 8px; display: inline-flex; gap: 4px; align-items: center; width: max-content; }
.delta.up { background: var(--success-bg); color: var(--success-fg); }
.delta.down { background: var(--warning-bg); color: var(--warning-fg); }

.ring-wrap { display: grid; grid-template-columns: 150px 1fr; gap: var(--sp-5); align-items: center; }
.ring { width: 150px; height: 150px; }
.ring circle { transition: stroke-dasharray .8s var(--sp-ease); }
.ring-box { position: relative; width: 150px; height: 150px; }
.ring-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; pointer-events: none; }
.ring-center b { font-size: 26px; color: var(--heading); line-height: 1.1; }
.ring-center span { font-size: var(--sp-fs-xs); color: var(--text-3); }
.ring-legend { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sp-2); }
.ring-legend li { display: flex; align-items: center; gap: var(--sp-2); font-size: 14px; color: var(--text-2); }
.ring-legend i { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.ring-legend b { margin-inline-start: auto; color: var(--heading); font-weight: 600; }
@media (max-width: 560px) { .ring-wrap { grid-template-columns: 1fr; justify-items: center; } .ring-legend { width: 100%; } }

@keyframes shimmer { to { background-position: -200% 0; } }
.skeleton span { display: block; height: 12px; border-radius: 6px; background: linear-gradient(90deg, var(--surface-2) 25%, var(--info-bg) 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; }
.skeleton span:nth-child(1) { width: 40%; }
.skeleton span:nth-child(2) { width: 30%; height: 28px; margin: 10px 0; }
.skeleton span:nth-child(3) { width: 60%; }

/* شريط علوي: بحث سريع */
.topbar { display: flex; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-5); }
.search-trigger { display: inline-flex; align-items: center; gap: var(--sp-2); min-width: 260px; height: 40px; padding: 0 var(--sp-3); border-radius: var(--sp-r); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-3); font: inherit; font-size: 14px; cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.search-trigger:hover { border-color: var(--sp-teal); box-shadow: 0 0 0 4px rgba(22,167,101,.12); }
.search-trigger kbd, .cmdk kbd { margin-inline-start: auto; font-family: var(--sp-font-en); font-size: 11px; border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 6px; padding: 0 6px; color: var(--text-3); background: var(--surface-2); }
@media (max-width: 860px) { .search-trigger { min-width: 0; flex: 1; } .search-trigger kbd { display: none; } }

dialog.cmdk-dialog { width: min(600px, calc(100vw - 24px)); margin-top: 12vh; animation: rise .18s var(--sp-ease); }
.cmdk-input { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border); }
.cmdk-input svg { color: var(--icon); }
.cmdk-input input { border: 0; background: none; box-shadow: none !important; min-height: 44px; padding: 0; font-size: 16px; }
.cmdk-list { max-height: 52vh; overflow-y: auto; padding: var(--sp-2); }
.cmdk-group { font-size: var(--sp-fs-xs); font-weight: 700; color: var(--text-3); padding: var(--sp-3) var(--sp-3) var(--sp-1); }
.cmdk-item { display: flex; align-items: center; gap: var(--sp-3); width: 100%; border: 0; background: none; font: inherit; color: var(--text); padding: 10px var(--sp-3); border-radius: var(--sp-r-sm); cursor: pointer; text-align: start; }
.cmdk-item svg { color: var(--icon); }
.cmdk-item small { margin-inline-start: auto; color: var(--text-3); font-size: var(--sp-fs-xs); }
.cmdk-item.on, .cmdk-item:hover { background: var(--success-bg); }
.cmdk-item.on { box-shadow: inset 3px 0 0 var(--sp-teal); }
.cmdk-empty { padding: var(--sp-8); text-align: center; color: var(--text-3); }

/* ---------- العروض (صفحة الدخول والبوابة) ---------- */
.promo-slider { position: relative; margin-top: var(--sp-6); max-width: 520px; }
.promo-card { background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.14); border-radius: var(--sp-r-lg); padding: var(--sp-5); backdrop-filter: blur(6px); display: none; animation: rise .45s var(--sp-ease) both; }
.promo-card.on { display: block; }
.promo-card .chip { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: var(--sp-r-pill); background: var(--sp-teal); color: var(--sp-midnight); font-size: var(--sp-fs-xs); font-weight: 800; }
.promo-card .chip.news { background: rgba(255,255,255,.16); color: var(--sp-white); }
.promo-card h3 { color: var(--sp-white); font-size: 20px; margin: var(--sp-3) 0 var(--sp-1); }
.promo-card p { color: var(--sp-mist); margin: 0; }
.promo-card .btn { margin-top: var(--sp-4); }
.promo-dots { display: flex; gap: 6px; margin-top: var(--sp-3); }
.promo-dots button { width: 8px; height: 8px; border-radius: 99px; border: 0; padding: 0; background: rgba(255,255,255,.3); cursor: pointer; transition: width .25s var(--sp-ease), background .25s; }
.promo-dots button.on { width: 22px; background: var(--sp-teal); }
.promo-banner { position: relative; overflow: hidden; isolation: isolate; display: flex; align-items: center; gap: var(--sp-5); flex-wrap: wrap; background: var(--sp-gradient); color: var(--sp-white); border: 0; }
.promo-banner::after { content: ""; position: absolute; inset-inline-end: -80px; top: -80px; width: 240px; height: 240px; border-radius: 50%; background: radial-gradient(closest-side, rgba(22,167,101,.35), transparent); z-index: -1; }
.promo-banner h2 { color: var(--sp-white); }
.promo-banner p { color: var(--sp-mist); margin: 4px 0 0; }
.promo-banner .grow { flex: 1; min-width: 220px; }
.promo-banner .ic { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; background: rgba(22,167,101,.2); color: var(--sp-teal); flex: none; }
.promo-banner .ic svg { width: 24px; height: 24px; }
.upgrade-plans { display: flex; gap: var(--sp-2); flex-wrap: wrap; }

/* ===== الإرسال الجماعي ===== (ألوان فقاعة المعاينة تقليد لشكل واتساب نفسه، عشان العميل يشوف رسالته كما بتوصل) */
.step-no { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--sp-gradient-mark); color: #fff; font-size: 13px; font-weight: 700; margin-inline-end: 8px; vertical-align: 2px; }
.sum-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--sp-2); }
.sum-grid > div { border: 1px solid var(--border); border-radius: var(--sp-r); padding: 10px 12px; background: var(--surface-2); }
.sum-grid b { display: block; font-size: 22px; color: var(--heading); line-height: 1.2; }
.sum-grid span { font-size: 12.5px; color: var(--text-2); }
.sum-grid .ok b { color: var(--ok); }
.sum-grid .bad b { color: var(--danger-fg); }
.sum-grid .warn b { color: var(--warn); }
@media (max-width: 560px) { .sum-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.wa-preview { background: #e9e2d8; border-radius: var(--sp-r); padding: 18px 14px; min-height: 120px; }
[data-theme="dark"] .wa-preview { background: #0b141a; }
.wa-bubble { background: #d9fdd3; color: #111b21; border-radius: 10px 0 10px 10px; padding: 8px 10px 18px; max-width: 88%; margin-inline-start: auto; white-space: pre-wrap; font-size: 14.5px; line-height: 1.6; position: relative; box-shadow: 0 1px .5px rgba(0,0,0,.13); }
[data-theme="dark"] .wa-bubble { background: #005c4b; color: #e9edef; }
.wa-bubble .optout { color: #667781; font-size: 13px; }
[data-theme="dark"] .wa-bubble .optout { color: #aebac1; }
.wa-bubble .wa-time { position: absolute; inset-inline-end: 8px; bottom: 3px; font-size: 11px; color: #667781; }
.wa-bubble .wa-media { display: flex; align-items: center; gap: 8px; background: rgba(0,0,0,.06); border-radius: 8px; padding: 8px 10px; margin-bottom: 6px; font-size: 13px; }
.wa-bubble .wa-media img { max-width: 100%; border-radius: 8px; display: block; }
.rules { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.rules li { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; color: var(--text-2); }
.rules li svg { flex: none; color: var(--sp-teal); margin-top: 2px; }
.rules b { color: var(--heading); }
.camp-progress { height: 10px; background: var(--info-bg); border-radius: var(--sp-r-pill); overflow: hidden; display: flex; }
.camp-progress i { display: block; height: 100%; }
.camp-progress .s { background: var(--sp-gradient-mark); }
.camp-progress .f { background: var(--sp-danger); }
.camp-progress .k { background: var(--border-strong); }

/* ===== الحركة: خفيفة، تشتغل في المتصفح بس، وتنطفي مع «تقليل الحركة» ===== */
.aurora { position: absolute; inset: 0; z-index: -1; pointer-events: none; overflow: hidden; }
.aurora i { position: absolute; width: 46vmax; height: 46vmax; border-radius: 50%; filter: blur(80px); opacity: .14; will-change: transform; }
.aurora i:nth-child(1) { background: #16A765; top: -22vmax; inset-inline-start: -12vmax;  }
.aurora i:nth-child(2) { background: #6FE7BE; bottom: -26vmax; inset-inline-end: -14vmax; opacity: .06;  }
.aurora i:nth-child(3) { background: #126B45; top: 30%; left: 40%; width: 30vmax; height: 30vmax; opacity: .18;  }
@keyframes drift1 { to { transform: translate(14vmax, 10vmax) scale(1.15); } }
@keyframes drift2 { to { transform: translate(-12vmax, -8vmax) scale(.9); } }
@keyframes drift3 { to { transform: translate(-10vmax, 6vmax) scale(1.2); } }
/* توهج يلحق الماوس */
.glow-follow::before { content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none; background: radial-gradient(520px circle at var(--gx, 70%) var(--gy, 30%), rgba(111,231,190,.07), transparent 60%); transition: background .2s; }
/* خطوط السرعة من الشعار */
.speed-lines { position: absolute; inset: 0; z-index: -1; pointer-events: none; }
.speed-lines span { position: absolute; height: 6px; border-radius: 6px; background: rgba(111,231,190,.16); animation: zoom 6s linear infinite; right: -20%; }
.speed-lines span:nth-child(1) { top: 22%; width: 90px; animation-delay: 0s; }
.speed-lines span:nth-child(2) { top: 58%; width: 140px; animation-delay: 2.1s; opacity: .6; }
.speed-lines span:nth-child(3) { top: 80%; width: 60px; animation-delay: 4s; }
@keyframes zoom { from { transform: translateX(0); opacity: 0; } 10% { opacity: 1; } 90% { opacity: 1; } to { transform: translateX(-140vw); opacity: 0; } }

/* العنوان يطلع كلمة كلمة */
.words .w { display: inline-block; opacity: 0; transform: translateY(.5em); filter: blur(6px); animation: word .7s var(--sp-ease) forwards; }
@keyframes word { to { opacity: 1; transform: none; filter: none; } }

/* شريط التنقل يصير زجاجي مع النزول */
.site-nav.sticky { position: sticky; top: 0; z-index: 30; transition: background .3s, box-shadow .3s, backdrop-filter .3s; }
.site-nav.sticky.scrolled { background: rgba(10,42,33,.85); backdrop-filter: blur(14px) saturate(1.4); box-shadow: 0 8px 30px rgba(3,24,17,.25); }

/* بطاقات بإضاءة تلحق الماوس وترتفع */
.spot { position: relative; overflow: hidden; transition: transform .35s var(--sp-ease), box-shadow .35s var(--sp-ease), border-color .35s; }
.spot::after { content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .3s; background: radial-gradient(300px circle at var(--mx, 50%) var(--my, 50%), rgba(22,167,101,.12), transparent 65%); }
.spot:hover { transform: translateY(-4px); box-shadow: var(--shadow-3); border-color: rgba(22,167,101,.35); }
.spot:hover::after { opacity: 1; }
.feature.spot:hover .ic { animation: pop .5s var(--sp-ease); }
@keyframes pop { 40% { transform: scale(1.14) rotate(-6deg); } }

/* لمعة على الأزرار المهمة */
.btn.accent, .btn.shine { position: relative; overflow: hidden; }
.btn.accent::after, .btn.shine::after { content: ""; position: absolute; top: 0; bottom: 0; width: 40%; left: -60%; background: linear-gradient(100deg, transparent, rgba(255,255,255,.45), transparent); transform: skewX(-20deg); transition: left .7s var(--sp-ease); pointer-events: none; }
.btn.accent:hover::after, .btn.shine:hover::after { left: 120%; }

/* رحلة الفاتورة في المعاينة */
.mock { position: relative; transform-style: preserve-3d; transition: transform .25s ease-out; }
.mock .typing { justify-self: start; display: inline-flex; gap: 4px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px 14px 4px 14px; }
.mock .typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); animation: dot 1s infinite; }
.mock .typing i:nth-child(2) { animation-delay: .15s; } .mock .typing i:nth-child(3) { animation-delay: .3s; }
@keyframes dot { 30% { transform: translateY(-4px); opacity: .5; } }
.chat .bubble.live { animation: rise .45s var(--sp-ease) both; }
.jticks { display: inline-flex; color: var(--text-3); transition: color .4s; }
.jticks svg { width: 17px; height: 17px; }
.jticks .t2 { margin-inline-start: -10px; opacity: 0; transition: opacity .3s; }
.jticks[data-s="delivered"] .t2, .jticks[data-s="read"] .t2 { opacity: 1; }
.jticks[data-s="read"] { color: #16A765; }
.state-chip { position: absolute; z-index: 2; display: inline-flex; align-items: center; gap: 6px; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 999px; padding: 7px 12px; font-size: 13px; font-weight: 700; box-shadow: var(--shadow-3); }
.state-chip svg { width: 16px; height: 16px; color: #16A765; }
.state-chip.a { top: -16px; inset-inline-start: -22px; }
.state-chip.b { bottom: 26px; inset-inline-end: -26px; animation-delay: -2.5s; }
@keyframes float { 50% { transform: translateY(-9px); } }
@media (max-width: 860px) { .state-chip.a { inset-inline-start: 6px; } .state-chip.b { inset-inline-end: 6px; } }

/* الخطوات: أرقام وخط يرتسم مع النزول */
.steps-row { position: relative; }
.steps-row .card { position: relative; padding-top: var(--sp-8); }
.step-num { position: absolute; top: -18px; inset-inline-start: var(--sp-5); width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: var(--sp-gradient-mark); color: #fff; font-family: var(--sp-font-en); font-weight: 700; box-shadow: 0 6px 16px rgba(22,167,101,.35); }
.steps-line { position: absolute; top: 0; inset-inline: 8%; height: 2px; background: var(--border); border-radius: 2px; overflow: hidden; }
.steps-line::after { content: ""; position: absolute; inset: 0; background: var(--sp-gradient-mark); transform: scaleX(0); transform-origin: right; transition: transform 1.4s var(--sp-ease); }
.steps-row.in .steps-line::after { transform: scaleX(1); }
@media (max-width: 760px) { .steps-line { display: none; } }

@media (prefers-reduced-motion: reduce) {
  .aurora i, .speed-lines span, .state-chip, .mock .typing i { animation: none !important; }
  .words .w { animation: none; opacity: 1; transform: none; filter: none; }
  .spot:hover { transform: none; }
  .steps-line::after { transition: none; }
}
.auth-form > * { animation: rise .6s var(--sp-ease) both; }
.auth-form > *:nth-child(2) { animation-delay: .08s; } .auth-form > *:nth-child(3) { animation-delay: .16s; }
@media (prefers-reduced-motion: reduce) { .auth-form > * { animation: none; } }
.doc .signup { margin-top: var(--sp-5); position: relative; }
.hp { position: absolute; top: 0; inset-inline-start: 0; width: 1px; height: 1px; opacity: 0; pointer-events: none; overflow: hidden; border: 0; padding: 0; }

/* ===== 2.8: سجل الرسائل الذكي، الردود، القوالب ===== */
.filters { display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center; margin-bottom: var(--sp-4); }
.filters input, .filters select { height: 40px; min-width: 0; }
.filters select { width: auto; flex: 0 0 auto; min-width: 130px; }
.filters .grow { flex: 1 1 220px; }
.filters input[type="date"] { width: 150px; }
@media (max-width: 640px) { .filters input[type="date"] { width: calc(50% - 4px); } }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--surface-2); }
/* لوحة جانبية */
dialog.sheet { margin: 0; margin-inline-start: auto; height: 100vh; max-height: 100vh; width: min(460px, 100vw); border-radius: 0; border-block: 0; border-inline-end: 0; animation: sheet-in .28s var(--sp-ease); }
@keyframes sheet-in { from { transform: translateX(-40px); opacity: 0; } }
[dir="rtl"] dialog.sheet { margin-inline-start: 0; margin-inline-end: auto; }
.timeline { list-style: none; padding: 0; margin: 0; position: relative; }
.timeline li { position: relative; padding: 0 30px 18px 0; }
.timeline li::before { content: ""; position: absolute; right: 9px; top: 20px; bottom: 0; width: 2px; background: var(--border); }
.timeline li:last-child::before { display: none; }
.timeline .dot { position: absolute; right: 0; top: 2px; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); border: 2px solid var(--border-strong); }
.timeline li.done .dot { background: var(--sp-teal); border-color: var(--sp-teal); color: #fff; }
.timeline li.bad .dot { background: var(--danger-fg); border-color: var(--danger-fg); color: #fff; }
.timeline .dot svg { width: 12px; height: 12px; }
.timeline b { display: block; color: var(--heading); font-size: 14px; }
.timeline span { font-size: 12.5px; color: var(--text-2); }
.msg-box { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--sp-r); padding: 12px 14px; white-space: pre-wrap; font-size: 14px; }
/* شارة العدد في القائمة */
.nav a .count { margin-inline-start: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--sp-teal); color: #fff; font-size: 11.5px; font-weight: 700; display: inline-grid; place-items: center; }
/* الردود */
.inbox { display: grid; grid-template-columns: 320px 1fr; gap: var(--sp-4); align-items: start; }
@media (max-width: 860px) { .inbox { grid-template-columns: 1fr; } }
.thread-list { padding: 6px; max-height: 70vh; overflow: auto; }
.thread-item { display: flex; gap: 10px; align-items: flex-start; padding: 10px; border-radius: var(--sp-r); cursor: pointer; border: 1px solid transparent; }
.thread-item:hover { background: var(--surface-2); }
.thread-item.on { background: var(--success-bg); border-color: rgba(46,154,107,.25); }
.thread-item .t { flex: 1; min-width: 0; }
.thread-item .t .cell-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread-item .count { min-width: 20px; height: 20px; border-radius: 999px; background: var(--sp-teal); color: #fff; font-size: 11.5px; font-weight: 700; display: grid; place-items: center; padding: 0 6px; }
.convo { display: grid; gap: 8px; padding: var(--sp-4); background: var(--bg); border-radius: var(--sp-r); max-height: 56vh; overflow: auto; }
.convo .b { max-width: 80%; padding: 8px 12px; border-radius: 12px; font-size: 14px; white-space: pre-wrap; box-shadow: var(--shadow-1); }
.convo .b.in { justify-self: end; background: var(--surface); border: 1px solid var(--border); border-radius: 12px 12px 12px 4px; }
.convo .b.out { justify-self: start; background: #d9fdd3; color: #111b21; border-radius: 12px 12px 4px 12px; }
[data-theme="dark"] .convo .b.out { background: #005c4b; color: #e9edef; }
.convo .b small { display: block; font-size: 11px; opacity: .65; margin-top: 3px; direction: ltr; text-align: end; }
.invoice-chip { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--sp-r); background: var(--surface-2); margin-bottom: var(--sp-3); font-size: 13.5px; }
.invoice-chip svg { color: var(--icon); flex: none; }
/* القوالب */
.tpl-bar { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.tpl-bar select { height: 34px; font-size: 13px; padding-block: 0; max-width: 220px; }
/* التقرير الشهري */
.report-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: var(--sp-2); margin: var(--sp-3) 0; }
.report-grid > div { border: 1px solid var(--border); border-radius: var(--sp-r); padding: 10px 12px; background: var(--surface-2); }
.report-grid b { display: block; font-size: 22px; color: var(--heading); }
.report-grid span { font-size: 12.5px; color: var(--text-2); }

/* ===== التفاعلات: هادئة وتوضح الاستجابة (مستوحاة من فئات Code and Chill، مكتوبة من الصفر) ===== */
/* مؤشر القائمة المتحرك */
.nav.has-ind { position: relative; }
.nav-ind { position: absolute; inset-inline: 0; top: 0; border-radius: var(--sp-r); background: rgba(46,154,107,.18); box-shadow: inset 0 0 0 1px rgba(127,211,176,.14); transition: transform .35s var(--sp-ease), height .35s var(--sp-ease), opacity .2s; pointer-events: none; z-index: 0; }
.nav-ind::before { content: ""; position: absolute; inset-inline-start: -16px; top: 10px; bottom: 10px; width: 4px; border-start-end-radius: 4px; border-end-end-radius: 4px; background: var(--sp-teal); }
.nav.has-ind a { position: relative; z-index: 1; }
.nav.has-ind a.active { background: transparent; }
.nav.has-ind a.active::before { display: none; }
.nav a svg { transition: transform .25s var(--sp-ease); }
.nav a:hover svg { transform: translateX(-2px); }
@media (max-width: 900px) { .nav-ind { display: none; } .nav.has-ind a.active { background: rgba(22,167,101,.16); } }

/* حالات الأزرار */
.btn { transition: background .2s, box-shadow .2s, transform .12s, color .2s; }
.btn:active:not(:disabled) { transform: scale(.97); }
.btn.is-busy { opacity: 1 !important; cursor: progress; }
.btn.is-done { background: var(--sp-teal) !important; color: #fff !important; }
.btn.is-done svg { animation: pop .35s var(--sp-ease); }
.btn.is-error { animation: shake .4s; }
.btn-spin { width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid currentColor; border-inline-end-color: transparent; animation: spin .7s linear infinite; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.icon-btn.copied, .btn.copied { color: var(--sp-teal) !important; border-color: var(--sp-teal) !important; }
.icon-btn { transition: background .2s, color .2s, border-color .2s, transform .12s; }
.icon-btn:active { transform: scale(.92); }

/* الحقول */
input, select, textarea { transition: border-color .2s, box-shadow .2s, background .2s; }
input:focus, select:focus, textarea:focus { box-shadow: 0 0 0 4px var(--focus); }
input.touched:invalid, textarea.touched:invalid, select.touched:invalid { border-color: var(--danger-fg); box-shadow: 0 0 0 4px var(--danger-bg); }
.shake { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-5px); } 40%, 80% { transform: translateX(5px); } }

/* مفتاح تشغيل بدل مربع الاختيار (للإعدادات) */
.switch { position: relative; padding-inline-start: 0; }
.switch input { appearance: none; -webkit-appearance: none; width: 42px !important; height: 24px; border-radius: 999px; background: var(--border-strong); position: relative; cursor: pointer; flex: none; margin: 0; border: 0; transition: background .25s; }
.switch input::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: inset-inline-start .25s var(--sp-ease), width .2s; }
.switch input:active::after { width: 22px; }
.switch input:checked { background: var(--sp-teal); }
.switch input:checked::after { inset-inline-start: 21px; }
.switch input:checked:active::after { inset-inline-start: 17px; }
.switch input:focus-visible { box-shadow: 0 0 0 4px var(--focus); }

/* الصفحات تدخل بنعومة لما تنتقل بينها */
.main > section:not([hidden]) { animation: sec-in .35s var(--sp-ease); }
@keyframes sec-in { from { opacity: 0; transform: translateY(8px); } }

/* التنبيهات */
#toasts { inset-inline-start: 20px; bottom: 20px; }
.toast { position: relative; overflow: hidden; padding-inline-end: 18px; animation: toast-in .3s var(--sp-ease); }
.toast::before { display: none; }
.toast .t-ic { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: rgba(127,211,176,.18); color: #7FD3B0; flex: none; }
.toast.bad .t-ic { background: rgba(208,68,55,.2); color: #ff9b91; }
.toast .t-ic svg { width: 14px; height: 14px; }
.toast .t-bar { position: absolute; bottom: 0; inset-inline-start: 0; height: 3px; width: 100%; background: var(--sp-teal); transform-origin: left; animation: t-bar 3.8s linear forwards; }
[dir="rtl"] .toast .t-bar { transform-origin: right; }
.toast.bad .t-bar { background: var(--sp-danger); }
.toast.hold .t-bar { animation-play-state: paused; }
.toast.out { animation: toast-out .25s ease-in forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px) scale(.96); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px); } }
@keyframes t-bar { to { transform: scaleX(0); } }

/* البطاقات والمؤشرات: عمق خفيف ولمسة لون */
.tile { position: relative; overflow: hidden; transition: transform .3s var(--sp-ease), box-shadow .3s var(--sp-ease), border-color .3s; }
.tile::after { content: ""; position: absolute; inset-inline: 0; top: 0; height: 3px; background: var(--sp-gradient-mark); opacity: 0; transition: opacity .3s; }
.tile:hover { transform: translateY(-3px); box-shadow: var(--shadow-3); border-color: rgba(46,154,107,.3); }
.tile:hover::after { opacity: 1; }
.tile .label svg { background: linear-gradient(135deg, rgba(46,154,107,.18), rgba(111,231,190,.12)); transition: transform .3s var(--sp-ease); }
.tile:hover .label svg { transform: rotate(-6deg) scale(1.06); }
.card { transition: box-shadow .3s var(--sp-ease), border-color .3s; }
tbody tr { transition: background .15s; }
tbody tr:hover td { background: var(--surface-2); }

/* خلفية اللوحة: نقاط خفيفة جداً تعطي عمق بدون إزعاج */
.app .main { background-image: radial-gradient(rgba(46,154,107,.07) 1px, transparent 1px); background-size: 22px 22px; }
[data-theme="dark"] .app .main { background-image: radial-gradient(rgba(127,211,176,.05) 1px, transparent 1px); }

@media (prefers-reduced-motion: reduce) {
  .nav-ind, .btn, .tile, .toast, .main > section:not([hidden]) { transition: none !important; animation: none !important; }
  .toast .t-bar, .btn-spin { animation-duration: 0s; }
  .btn-spin { animation: spin 1.5s linear infinite; }
  .tile:hover { transform: none; }
  .shake, .btn.is-error { animation: none; }
}

/* ===== الترحيب ورحلة البداية في لوحة العميل ===== */
.welcome { position: relative; overflow: hidden; border-radius: var(--sp-r-xl); background: var(--sp-gradient); color: #fff; padding: var(--sp-6); box-shadow: var(--shadow-2); isolation: isolate; }
.welcome::before { content: ""; position: absolute; width: 340px; height: 340px; border-radius: 50%; background: radial-gradient(closest-side, rgba(111,231,190,.22), transparent); top: -160px; inset-inline-end: -80px; z-index: -1; }
.welcome::after { content: ""; position: absolute; inset: 0; background: url('brand/mersal/mersal-symbol.svg') no-repeat; background-size: 160px; background-position: left -30px bottom -40px; opacity: .07; z-index: -1; }
.w-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--sp-4); flex-wrap: wrap; }
.w-greet { margin: 0; color: #7FD3B0; font-weight: 700; font-size: 14px; }
.welcome h1 { color: #fff; margin: 2px 0 4px; font-size: clamp(22px, 3vw, 28px); }
.w-sub { margin: 0; color: rgba(215,232,223,.8); font-size: 14px; }
.w-status { display: flex; align-items: center; gap: 10px; background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.12); border-radius: 14px; padding: 10px 14px; }
.w-status b { display: block; font-size: 14px; }
.w-status span:not(.orb) { font-size: 12.5px; color: rgba(215,232,223,.75); direction: ltr; unicode-bidi: isolate; }
.orb { width: 12px; height: 12px; border-radius: 50%; background: #F5A623; box-shadow: 0 0 0 4px rgba(245,166,35,.18); flex: none; }
.w-status.on .orb { background: #6FE7BE; box-shadow: 0 0 0 4px rgba(111,231,190,.18); animation: orb 2.4s ease-out infinite; }
@keyframes orb { 0% { box-shadow: 0 0 0 0 rgba(111,231,190,.5); } 70%, 100% { box-shadow: 0 0 0 10px rgba(111,231,190,0); } }
.journey { margin-top: var(--sp-5); }
.j-bar { height: 4px; border-radius: 4px; background: rgba(255,255,255,.12); overflow: hidden; }
.j-bar i { display: block; height: 100%; background: linear-gradient(90deg, #6FE7BE, #2E9A6B); border-radius: inherit; transition: width .8s var(--sp-ease); }
.journey ol { list-style: none; padding: 0; margin: 12px 0 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.journey a { display: flex; align-items: center; gap: 8px; color: rgba(215,232,223,.75); font-size: 13.5px; text-decoration: none; padding: 8px 10px; border-radius: 10px; transition: background .2s; }
.journey a:hover { background: rgba(255,255,255,.06); }
.j-dot { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; border: 1.5px solid rgba(255,255,255,.25); flex: none; }
.j-dot svg { width: 15px; height: 15px; }
.journey li.ok a { color: #fff; }
.journey li.ok .j-dot { background: #2E9A6B; border-color: #2E9A6B; }
.journey li.now a { color: #fff; font-weight: 700; background: rgba(255,255,255,.08); }
.journey li.now .j-dot { border-color: #6FE7BE; color: #6FE7BE; }
.w-ready { margin: var(--sp-4) 0 0; display: flex; align-items: center; gap: 8px; color: #7FD3B0; font-weight: 700; font-size: 14px; }
.w-ready svg { width: 18px; height: 18px; }
@media (max-width: 640px) { .journey ol { grid-template-columns: 1fr; } .welcome { padding: var(--sp-5); } }
/* اختصارات */
.quick { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--sp-3); }
@media (max-width: 860px) { .quick { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.q-card { display: flex; flex-direction: column; gap: 4px; padding: var(--sp-4); border-radius: var(--sp-r-lg); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-1); color: var(--text); text-decoration: none; transition: transform .25s var(--sp-ease), box-shadow .25s, border-color .25s; }
.q-card:hover { text-decoration: none; transform: translateY(-3px); box-shadow: var(--shadow-3); border-color: rgba(46,154,107,.35); }
.q-card b { color: var(--heading); font-size: 15px; }
.q-card > span:last-child { font-size: 12.5px; color: var(--text-2); }
.q-ic { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: linear-gradient(135deg, rgba(46,154,107,.18), rgba(111,231,190,.1)); color: var(--icon); margin-bottom: 6px; transition: transform .3s var(--sp-ease); }
.q-ic svg { width: 20px; height: 20px; }
.q-card:hover .q-ic { transform: translateY(-2px) rotate(-6deg); }
@media (prefers-reduced-motion: reduce) { .w-status.on .orb, .q-card, .q-ic, .j-bar i { animation: none; transition: none; } .q-card:hover { transform: none; } }
.btn.is-done, .btn.is-busy { opacity: 1 !important; }
@media (max-width: 640px) {
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-3); }
  .tile { padding: var(--sp-4); }
  .tile .value { font-size: 24px; }
}
