/* ==========================================================
   نظام التصميم المشترك — الزبائن · السواق · الإدارة
   ========================================================== */
:root {
  --bg: #f4f2ec;
  --bg-2: #ebe7de;
  --surface: #ffffff;
  --surface-2: #f9f8f4;
  --ink: #111a28;
  --ink-2: #465063;
  --muted: #8b93a3;
  --line: #e7e2d8;
  --brand: #0d3d45;
  --brand-2: #16606b;
  --brand-soft: #e3efee;
  --on-brand: #ffffff;
  --gold: #c39a43;
  --gold-soft: #f6eedb;
  --ok: #17845a;
  --ok-bg: #e3f3ea;
  --warn: #a8560c;
  --warn-bg: #fbeedd;
  --err: #b42318;
  --err-bg: #fbe9e7;
  --radius: 20px;
  --radius-sm: 13px;
  --shadow-sm: 0 1px 2px rgba(17,26,40,.05);
  --shadow: 0 1px 2px rgba(17,26,40,.04), 0 10px 30px -8px rgba(17,26,40,.12);
  --shadow-lg: 0 24px 60px -12px rgba(17,26,40,.35);
  --ease: cubic-bezier(.2,.8,.2,1);
  --nav-h: 68px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c1014; --bg-2: #12171d; --surface: #151b22; --surface-2: #1a2129;
    --ink: #eef1f4; --ink-2: #b4bcc8; --muted: #7d8794; --line: #252d37;
    --brand: #4fb4b8; --brand-2: #6cc7ca; --brand-soft: #16302f; --on-brand: #06201f;
    --gold: #d9b562; --gold-soft: #2b2416;
    --ok: #4cc58d; --ok-bg: #12291f; --warn: #f0a050; --warn-bg: #2e2112; --err: #f2766a; --err-bg: #2f1714;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 10px 30px -8px rgba(0,0,0,.5);
    --shadow-lg: 0 24px 60px -12px rgba(0,0,0,.7);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0c1014; --bg-2: #12171d; --surface: #151b22; --surface-2: #1a2129;
  --ink: #eef1f4; --ink-2: #b4bcc8; --muted: #7d8794; --line: #252d37;
  --brand: #4fb4b8; --brand-2: #6cc7ca; --brand-soft: #16302f; --on-brand: #06201f;
  --gold: #d9b562; --gold-soft: #2b2416;
  --ok: #4cc58d; --ok-bg: #12291f; --warn: #f0a050; --warn-bg: #2e2112; --err: #f2766a; --err-bg: #2f1714;
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { scroll-behavior: smooth; }
body {
  font-family: 'IBM Plex Sans Arabic', 'Segoe UI', Tahoma, sans-serif;
  background: var(--bg); color: var(--ink);
  font-size: 15px; line-height: 1.6; min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
a { color: var(--brand); text-decoration: none; }
svg.i { width: 1.25em; height: 1.25em; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.hidden { display: none !important; }

/* ---------- تخطيط ---------- */
.wrap { max-width: 720px; margin: 0 auto; padding: 0 16px; }
.page { padding: 18px 0 calc(var(--nav-h) + 40px); }
.view { display: none; animation: rise .45s var(--ease); }
.view.active { display: block; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.stack > * + * { margin-top: 12px; }
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.section-title { display: flex; align-items: center; justify-content: space-between; margin: 26px 2px 12px; }
.section-title h2 { font-size: 17px; font-weight: 700; letter-spacing: -.01em; }
.section-title .link { font-size: 13px; font-weight: 600; color: var(--brand); display: inline-flex; gap: 4px; align-items: center; }

/* ---------- الشريط العلوي ---------- */
.appbar {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.6) blur(16px); -webkit-backdrop-filter: saturate(1.6) blur(16px);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
}
.appbar .wrap { display: flex; align-items: center; gap: 12px; height: 62px; }
.brandmark {
  width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center;
  background: linear-gradient(145deg, var(--brand-2), var(--brand)); color: var(--on-brand);
  box-shadow: 0 6px 16px -6px color-mix(in srgb, var(--brand) 70%, transparent);
}
.brandmark svg.i { width: 20px; height: 20px; }
/* الشعار: الرمز الذهبي على بلاطة بلون الهوية (أزرق مخضر داكن بنقش نقاط خفيف) — نفس المظهر في كل الصفحات */
.brandmark.has-logo {
  background:
    radial-gradient(rgba(255,255,255,.10) 1px, transparent 1.3px) 0 0 / 8px 8px,
    radial-gradient(120% 120% at 100% 0%, rgba(233,201,119,.24), transparent 55%),
    linear-gradient(160deg, #155a64, #0a2f36 78%) !important;
  border: 1px solid rgba(217,181,98,.38) !important;
  padding: 4px; box-shadow: 0 8px 20px -10px rgba(10,47,54,.85);
}
.brandmark.has-logo img { width: 100%; height: 100%; object-fit: contain; display: block; filter: drop-shadow(0 2px 4px rgba(0,0,0,.35)); }
.appbar .brandmark.has-logo, .side .brandmark.has-logo { width: 42px; height: 42px; border-radius: 13px; padding: 3px; }
.auth-card .brandmark.has-logo { width: 116px; height: 116px; border-radius: 30px; padding: 14px; box-shadow: 0 18px 40px -16px rgba(10,47,54,.9), 0 0 0 6px color-mix(in srgb, var(--gold) 10%, transparent); }
.appbar h1 { font-size: 16px; font-weight: 700; line-height: 1.2; }
.appbar small { display: block; font-size: 12px; color: var(--muted); font-weight: 500; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  color: var(--ink-2); background: var(--surface); border: 1px solid var(--line);
  transition: transform .15s var(--ease), background .2s;
}
.icon-btn:active { transform: scale(.94); }

/* ---------- الشريط السفلي ---------- */
.bottomnav {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 30;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.6) blur(18px); -webkit-backdrop-filter: saturate(1.6) blur(18px);
  border-top: 1px solid var(--line);
}
.bottomnav .inner { max-width: 520px; margin: 0 auto; display: flex; gap: 4px; }
.bottomnav button {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 7px 4px; border-radius: 14px; font-size: 11.5px; font-weight: 600; color: var(--muted);
  transition: color .2s, background .25s var(--ease);
}
.bottomnav button svg.i { width: 23px; height: 23px; transition: transform .3s var(--ease); }
.bottomnav button.active { color: var(--brand); background: var(--brand-soft); }
.bottomnav button.active svg.i { transform: translateY(-1px) scale(1.06); }

/* ---------- البطاقات ---------- */
.card {
  background: var(--surface); border-radius: var(--radius); padding: 18px;
  box-shadow: var(--shadow); border: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
}
.card.flat { box-shadow: var(--shadow-sm); }
.card h3 { font-size: 15px; font-weight: 700; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.card h3 svg.i { color: var(--brand); }
.tap { transition: transform .18s var(--ease), box-shadow .25s var(--ease); cursor: pointer; }
.tap:active { transform: scale(.985); }
@media (hover:hover) { .tap:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); } }

/* بطاقة منتج */
.pcard { padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.mono {
  width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center;
  font-weight: 700; font-size: 18px; color: #fff; flex-shrink: 0;
  background: linear-gradient(145deg, hsl(var(--h,180) 45% 42%), hsl(calc(var(--h,180) + 25) 50% 28%));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.25);
}
.mono.lg { width: 64px; height: 64px; border-radius: 18px; font-size: 26px; }
.mono.photo { background: #fff; padding: 3px; border: 1px solid var(--line); box-shadow: none; }
.mono.photo img { width: 100%; height: 100%; object-fit: contain; border-radius: 10px; }
.ph { position: relative; aspect-ratio: 4 / 3; border-radius: 15px; overflow: hidden; display: grid; place-items: center; background: #fff; border: 1px solid color-mix(in srgb, var(--line) 80%, transparent); }
/* الصورة مثبّتة على حدود الإطار تماماً، فتظهر كاملة دائماً مهما كان شكلها (لا قصّ) */
.ph img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; padding: 8px; box-sizing: border-box; transition: transform .5s var(--ease); }
.ph:not(:has(img)) { background: linear-gradient(160deg, var(--surface-2), var(--bg-2)); }
.tap:hover .ph img { transform: scale(1.04); }
.ph.big { aspect-ratio: auto; height: min(360px, 78vw); width: 100%; border-radius: 20px; margin-bottom: 14px; }
.ph.big img { padding: 16px; }
.pcard .name { font-weight: 700; font-size: 14.5px; line-height: 1.45; }
.price { font-weight: 700; color: var(--ink); font-size: 14px; }
.price small { font-weight: 500; color: var(--muted); font-size: 11px; margin-inline-start: 2px; }

/* صفوف القوائم */
.list { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; border: 1px solid color-mix(in srgb, var(--line) 60%, transparent); }
.li { display: flex; align-items: center; gap: 12px; padding: 14px 16px; }
.li + .li { border-top: 1px solid var(--line); }
.li .t { font-weight: 600; font-size: 14.5px; }
.li .s { font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.li-ico { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); flex-shrink: 0; }
.rank { width: 30px; height: 30px; border-radius: 10px; display: grid; place-items: center; font-size: 13px; font-weight: 700; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); flex-shrink: 0; }
.rank.first { background: linear-gradient(145deg, #e3c06d, var(--gold)); color: #2a1f05; border: none; }

/* ---------- الأزرار ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 13px 20px; border-radius: 14px; font-weight: 700; font-size: 15px;
  transition: transform .15s var(--ease), box-shadow .25s, background .2s, opacity .2s;
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; pointer-events: none; }
.btn.block { width: 100%; }
.btn-primary { background: linear-gradient(160deg, var(--brand-2), var(--brand)); color: var(--on-brand); box-shadow: 0 10px 24px -10px color-mix(in srgb, var(--brand) 80%, transparent); }
.btn-gold { background: linear-gradient(160deg, #dcbb6a, var(--gold)); color: #241a04; box-shadow: 0 10px 24px -10px color-mix(in srgb, var(--gold) 90%, transparent); }
.btn-soft { background: var(--brand-soft); color: var(--brand); }
.btn-ghost { background: var(--surface); color: var(--ink); border: 1px solid var(--line); }
.btn-danger { background: var(--err-bg); color: var(--err); }
.btn-sm { padding: 8px 12px; font-size: 13px; border-radius: 11px; }
.btn-lg { padding: 17px 22px; font-size: 16px; border-radius: 17px; }
.pill-btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 11px; font-size: 13px; font-weight: 600; background: var(--brand-soft); color: var(--brand); transition: transform .15s var(--ease); }
.pill-btn:active { transform: scale(.95); }
.pill-btn.danger { background: var(--err-bg); color: var(--err); }
.pill-btn.plain { background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); }

/* ---------- الحقول ---------- */
.field { display: block; }
.field + .field { margin-top: 12px; }
.field > span { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.input, select.input, textarea.input {
  width: 100%; padding: 13px 14px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1.5px solid var(--line); font-size: 15px;
  transition: border-color .2s, box-shadow .2s, background .2s; outline: none; appearance: none;
}
select.input { background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: 18px 55%, 13px 55%; background-size: 5px 5px; background-repeat: no-repeat; padding-left: 34px; }
textarea.input { resize: vertical; min-height: 84px; }
.input:focus { border-color: var(--brand); background: var(--surface); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 14%, transparent); }
.input-group { position: relative; display: flex; align-items: center; }
/* الزر على اليسار دائماً (الصفحة RTL)، فالمسافة يسار الحقل حتى لو كان الحقل LTR كالباركود */
.input-group .input { padding-left: 50px; padding-right: 14px; }
.input-group select.input { background-position: 58px 55%, 53px 55%; padding-left: 74px; }
.input-group .addon { position: absolute; inset-inline-end: 6px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 6px; }

/* البحث الكبير */
.searchbar {
  display: flex; align-items: center; gap: 10px; background: var(--surface); border-radius: 18px;
  padding: 6px 6px 6px 6px; padding-inline-start: 16px; box-shadow: var(--shadow-lg);
  border: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
}
.searchbar svg.i { color: var(--muted); }
.searchbar input { flex: 1; border: none; outline: none; background: none; font-size: 15.5px; padding: 10px 0; min-width: 0; }
.scan-chip { display: inline-flex; align-items: center; gap: 7px; padding: 11px 14px; border-radius: 13px; font-weight: 700; font-size: 14px; background: linear-gradient(160deg, var(--brand-2), var(--brand)); color: var(--on-brand); }

/* ---------- الشارات والرقائق ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.err { background: var(--err-bg); color: var(--err); }
.badge.mute { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.badge.gold { background: var(--gold-soft); color: var(--gold); }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 5px 11px; border-radius: 999px; font-size: 12.5px; font-weight: 600; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); }
.chip-scroll { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 8px; scrollbar-width: none; }
.chip-scroll::-webkit-scrollbar { display: none; }
.chip-scroll button { flex-shrink: 0; padding: 9px 15px; border-radius: 999px; font-size: 13.5px; font-weight: 600; background: var(--surface); color: var(--ink-2); border: 1px solid var(--line); transition: all .25s var(--ease); }
.chip-scroll button.active { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.seg { display: flex; background: var(--surface-2); border: 1px solid var(--line); padding: 4px; border-radius: 14px; gap: 4px; }
.seg button { flex: 1; padding: 9px; border-radius: 10px; font-size: 13.5px; font-weight: 600; color: var(--muted); transition: all .25s var(--ease); }
.seg button.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }

/* ---------- إحصاءات ---------- */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (min-width: 640px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat { background: var(--surface); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); border: 1px solid color-mix(in srgb, var(--line) 60%, transparent); }
.stat .k { font-size: 12.5px; color: var(--muted); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.stat .v { font-size: 26px; font-weight: 700; letter-spacing: -.02em; margin-top: 4px; }
.stat.hero { background: linear-gradient(150deg, var(--brand-2), var(--brand)); color: var(--on-brand); border: none; }
.stat.hero .k { color: color-mix(in srgb, var(--on-brand) 75%, transparent); }

/* ---------- الجداول ---------- */
.table-wrap { overflow-x: auto; margin: 0 -18px; padding: 0 18px; }
table.t { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.t th { text-align: start; font-weight: 600; color: var(--muted); font-size: 12px; padding: 10px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.t td { padding: 11px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.t tr:last-child td { border-bottom: none; }
table.t tfoot td { font-weight: 700; border-top: 1.5px solid var(--line); }
table.t .zero { color: var(--line); }

/* ---------- الحالات الفارغة والتحميل ---------- */
.empty { text-align: center; padding: 42px 20px; color: var(--muted); }
.empty .ico { width: 64px; height: 64px; margin: 0 auto 12px; border-radius: 20px; display: grid; place-items: center; background: var(--surface); box-shadow: var(--shadow); color: var(--brand); }
.empty .ico svg.i { width: 28px; height: 28px; }
.empty b { display: block; color: var(--ink); font-size: 15px; margin-bottom: 4px; }
.skel { background: linear-gradient(90deg, var(--bg-2) 25%, var(--surface-2) 37%, var(--bg-2) 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; border-radius: 12px; }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ---------- اللوحة المنزلقة (Sheet) ---------- */
.sheet-root { position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-end; justify-content: center; pointer-events: none; }
.sheet-root.open { pointer-events: auto; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(8,12,18,.5); opacity: 0; transition: opacity .35s var(--ease); backdrop-filter: blur(2px); }
.sheet-root.open .sheet-backdrop { opacity: 1; }
.sheet {
  position: relative; width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto;
  background: var(--surface); border-radius: 26px 26px 0 0; padding: 10px 20px calc(24px + env(safe-area-inset-bottom));
  transform: translateY(100%); transition: transform .45s var(--ease); box-shadow: var(--shadow-lg);
}
.sheet.wide { max-width: 860px; }
.sheet-root.open .sheet { transform: none; }
.sheet .grab { width: 42px; height: 5px; border-radius: 9px; background: var(--line); margin: 0 auto 14px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 16px; }
.sheet-head h2 { font-size: 18px; font-weight: 700; }
@media (min-width: 700px) {
  .sheet-root { align-items: center; padding: 24px; }
  .sheet { border-radius: 26px; transform: translateY(24px) scale(.97); opacity: 0; transition: transform .4s var(--ease), opacity .3s; }
  .sheet-root.open .sheet { transform: none; opacity: 1; }
  .sheet .grab { display: none; }
}

/* ---------- الإشعارات ---------- */
.toasts { position: fixed; top: 14px; inset-inline: 0; z-index: 90; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
.toast {
  display: flex; align-items: center; gap: 10px; max-width: 460px; padding: 12px 16px; border-radius: 16px;
  background: var(--ink); color: var(--bg); font-size: 14px; font-weight: 600; box-shadow: var(--shadow-lg);
  animation: toastIn .45s var(--ease); pointer-events: auto;
}
.toast.out { animation: toastOut .35s var(--ease) forwards; }
.toast .ti { width: 26px; height: 26px; border-radius: 9px; display: grid; place-items: center; flex-shrink: 0; }
.toast.ok .ti { background: var(--ok); color: #fff; }
.toast.err .ti { background: var(--err); color: #fff; }
.toast.info .ti { background: var(--brand-2); color: #fff; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-16px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-12px) scale(.96); } }

/* ---------- الماسح ---------- */
.scanner { position: fixed; inset: 0; z-index: 80; background: #05080b; color: #fff; display: flex; flex-direction: column; opacity: 0; pointer-events: none; transition: opacity .3s; }
.scanner.open { opacity: 1; pointer-events: auto; }
.scanner-top { display: flex; align-items: center; justify-content: space-between; padding: calc(14px + env(safe-area-inset-top)) 16px 10px; }
.scanner-top h3 { font-size: 16px; font-weight: 700; }
.scanner-top p { font-size: 12.5px; opacity: .65; }
.scanner .icon-btn { background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.12); color: #fff; }
.scanner-view { position: relative; flex: 1; overflow: hidden; }
.scanner-view #reader { position: absolute; inset: 0; border: none !important; }
.scanner-view #reader video { width: 100% !important; height: 100% !important; object-fit: cover; }
.scanner-view #reader img[alt="Info icon"], .scanner-view #reader__dashboard_section_csr span { display: none !important; }
.viewfinder { position: absolute; top: 50%; left: 50%; width: min(70vw, 300px); aspect-ratio: 1; transform: translate(-50%, -55%); border-radius: 26px; box-shadow: 0 0 0 100vmax rgba(5,8,11,.55); pointer-events: none; }
.viewfinder::before { content: ''; position: absolute; inset: 0; border-radius: 26px; padding: 3px; background: conic-gradient(from 0deg, var(--gold), transparent 25%, transparent 50%, var(--gold) 50%, transparent 75%, transparent); -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude; opacity: .9; }
.viewfinder .laser { position: absolute; inset-inline: 14px; height: 2px; top: 14px; border-radius: 2px; background: linear-gradient(90deg, transparent, #e9c977, transparent); box-shadow: 0 0 14px #e9c977; animation: laser 2.2s var(--ease) infinite alternate; }
@keyframes laser { to { top: calc(100% - 16px); } }
.scanner-tools { position: absolute; bottom: 74px; inset-inline: 0; display: flex; justify-content: center; align-items: center; gap: 12px; z-index: 3; }
.sc-tool { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; color: #fff; background: rgba(0,0,0,.5); border: 1px solid rgba(255,255,255,.18); backdrop-filter: blur(8px); }
.sc-tool.on { background: #e9c977; color: #241a04; }
.sc-zoom { display: flex; gap: 4px; padding: 4px; border-radius: 999px; background: rgba(0,0,0,.5); border: 1px solid rgba(255,255,255,.18); backdrop-filter: blur(8px); }
.sc-zoom button { min-width: 42px; height: 40px; border-radius: 999px; color: #fff; font-weight: 700; font-size: 14px; }
.sc-zoom button.on { background: #fff; color: #111; }
.scanner-msg { position: absolute; bottom: 24px; inset-inline: 16px; text-align: center; font-size: 13.5px; background: rgba(0,0,0,.55); padding: 10px 14px; border-radius: 14px; display: none; }
.scanner-msg.show { display: block; }
.scanner-bottom { padding: 16px 16px calc(18px + env(safe-area-inset-bottom)); display: flex; gap: 10px; }
.scanner-bottom .btn { flex: 1; background: rgba(255,255,255,.1); color: #fff; border: 1px solid rgba(255,255,255,.14); }

/* ---------- شاشة الدخول ---------- */
.auth-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background:
  radial-gradient(1200px 600px at 100% -10%, color-mix(in srgb, var(--brand) 22%, transparent), transparent 60%),
  radial-gradient(900px 500px at -10% 110%, color-mix(in srgb, var(--gold) 18%, transparent), transparent 60%), var(--bg); }
.auth-card { width: 100%; max-width: 400px; animation: rise .6s var(--ease); }
.auth-card .brandmark { width: 60px; height: 60px; border-radius: 19px; margin: 0 auto 16px; }
.auth-card .brandmark svg.i { width: 28px; height: 28px; }
.auth-card h1 { text-align: center; font-size: 22px; font-weight: 700; letter-spacing: -.01em; }
.auth-card .sub { text-align: center; color: var(--muted); font-size: 13.5px; margin: 4px 0 22px; }
/* مبدّل نوع الدخول أعلى بطاقة تسجيل الدخول: السائق | الإدارة */
.auth-switch { display: flex; gap: 4px; padding: 4px; margin: -8px 0 22px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); }
.auth-switch a { flex: 1; display: flex; align-items: center; justify-content: center; gap: 7px; padding: 9px; border-radius: 10px; font-size: 13.5px; font-weight: 700; color: var(--muted); transition: background .25s var(--ease), color .25s; }
.auth-switch a svg.i { width: 17px; height: 17px; }
.auth-switch a.active { background: var(--surface); color: var(--brand); box-shadow: var(--shadow-sm); pointer-events: none; }
.auth-switch a:not(.active):hover { color: var(--ink); }
.auth-back { display: flex; justify-content: center; align-items: center; gap: 6px; margin-top: 16px; font-size: 13px; font-weight: 600; color: var(--muted); }
.auth-back:hover { color: var(--brand); }
.auth-err { margin-top: 12px; padding: 10px 12px; border-radius: 12px; background: var(--err-bg); color: var(--err); font-size: 13.5px; font-weight: 600; display: none; }
.auth-err.show { display: block; animation: shake .4s; }
@keyframes shake { 25% { transform: translateX(6px); } 50% { transform: translateX(-6px); } 75% { transform: translateX(3px); } }

/* ---------- QR للطباعة ---------- */
.qr-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.qr-card { border: 1.5px dashed var(--line); border-radius: 18px; padding: 16px 12px; text-align: center; break-inside: avoid; background: #fff; color: #111a28; }
.qr-card img { width: 100%; max-width: 190px; image-rendering: pixelated; display: block; margin: 8px auto; }
.qr-card b { display: block; font-size: 15px; }
.qr-card span { display: block; font-size: 11.5px; color: #6b7280; }
@media print {
  body > *:not(.sheet-root) { display: none !important; }
  .sheet-root { position: static; display: block; }
  .sheet-backdrop, .no-print, .sheet .grab { display: none !important; }
  .sheet { transform: none !important; opacity: 1 !important; max-height: none; box-shadow: none; padding: 0; max-width: none; border-radius: 0; }
  .qr-card { border-color: #bbb; }
}

/* ---------- قراءة صورة الفاتورة ---------- */
.ocr-cta { display: flex; align-items: center; gap: 14px; width: 100%; text-align: start; padding: 14px 16px; border-radius: 18px; margin-bottom: 14px;
  background: linear-gradient(150deg, var(--brand-2), var(--brand)); color: var(--on-brand); box-shadow: 0 12px 26px -12px var(--brand); transition: transform .15s var(--ease); }
.ocr-cta:active { transform: scale(.98); }
.ocr-cta .ci { width: 46px; height: 46px; border-radius: 15px; display: grid; place-items: center; background: rgba(255,255,255,.18); flex-shrink: 0; }
.ocr-cta .ci svg.i { width: 23px; height: 23px; }
.ocr-cta b { display: block; font-size: 15.5px; }
.ocr-cta small { display: block; font-size: 12.5px; opacity: .85; }
.ocr-prog { padding: 14px; border-radius: 16px; background: var(--surface-2); border: 1px solid var(--line); margin-bottom: 14px; animation: rise .3s var(--ease); }
.ocr-prog b { font-size: 14px; }
.ocr-found { padding: 12px 14px; border-radius: 16px; background: var(--ok-bg); color: var(--ok); margin-bottom: 14px; font-size: 13.5px; animation: rise .3s var(--ease); }
.ocr-found.warn { background: var(--warn-bg); color: var(--warn); }
.ocr-found ul { margin: 6px 0 0; padding-inline-start: 18px; color: var(--ink-2); }
.ocr-found li b { color: var(--ink); }

/* ---------- مؤشر الانشغال ---------- */
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid currentColor; border-top-color: transparent; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
body.busy { cursor: progress; }

/* ---------- اللغة ---------- */
.lang-btn { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 12px; border-radius: 999px; font-size: 13px; font-weight: 700;
  color: var(--ink-2); background: var(--surface); border: 1px solid var(--line); transition: transform .15s var(--ease), background .2s; flex-shrink: 0; }
.lang-btn svg.i { width: 17px; height: 17px; }
.lang-btn:active { transform: scale(.94); }
.lang-btn.on-dark { color: #fff; background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.2); }
.lang-list { display: grid; gap: 10px; }
.lang-opt { display: flex; align-items: center; gap: 14px; width: 100%; padding: 14px 16px; border-radius: 16px; background: var(--surface-2); border: 1.5px solid var(--line); text-align: start; transition: border-color .2s, background .2s, transform .15s var(--ease); }
.lang-opt:active { transform: scale(.98); }
.lang-opt b { flex: 1; font-size: 16px; }
.lang-opt .lang-badge { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-weight: 700; font-size: 14px; background: var(--brand-soft); color: var(--brand); flex-shrink: 0; }
.lang-opt.on { border-color: var(--brand); background: var(--brand-soft); }
.lang-opt.on svg.i { color: var(--brand); }

svg.i.flip { transform: scaleX(-1); }
/* حقول ترجمة المنتج في الإدارة */
.tr-box { margin-top: 14px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface-2); }
.tr-box summary { cursor: pointer; padding: 12px 14px; font-weight: 700; font-size: 14px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; list-style: none; }
.tr-box summary::-webkit-details-marker { display: none; }
.tr-box summary svg.i { width: 18px; height: 18px; color: var(--brand); }
.tr-box summary small { font-weight: 500; font-size: 12px; }
.tr-box[open] summary { border-bottom: 1px solid var(--line); }
.tr-box .tr-in { padding: 4px 14px 14px; }
.tr-box .tr-in .field { margin-top: 12px; }

/* ---------- الواجهة الإنكليزية (من اليسار لليمين) ---------- */
html[dir=ltr] svg.i.chev { transform: scaleX(-1); }
html[dir=ltr] svg.i.chev.flip { transform: none; }
html[dir=ltr] select.input { background-position: right 13px top 55%, right 18px top 55%; padding-left: 14px; padding-right: 34px; }
html[dir=ltr] .input-group .input { padding-left: 14px; padding-right: 50px; }
html[dir=ltr] .input-group select.input { background-position: right 53px top 55%, right 58px top 55%; padding-right: 74px; }
