/* لوحة المتجر: للجوال أولاً، من اليمين لليسار، فاتح مع وضع داكن يتبع الجهاز. */
@font-face { font-family: 'Plex Arabic'; font-weight: 400; font-display: swap; src: url('../fonts/ibm-plex-sans-arabic-arabic-400-normal.woff2') format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFF; }
@font-face { font-family: 'Plex Arabic'; font-weight: 600; font-display: swap; src: url('../fonts/ibm-plex-sans-arabic-arabic-600-normal.woff2') format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFF; }
@font-face { font-family: 'Plex Arabic'; font-weight: 400; font-display: swap; src: url('../fonts/ibm-plex-sans-arabic-latin-400-normal.woff2') format('woff2'); unicode-range: U+0000-00FF; }
@font-face { font-family: 'Plex Arabic'; font-weight: 600; font-display: swap; src: url('../fonts/ibm-plex-sans-arabic-latin-600-normal.woff2') format('woff2'); unicode-range: U+0000-00FF; }

:root {
  color-scheme: light dark;
  --bg: #faf7f5; --surface: #ffffff; --ink: #231c26; --muted: #6a606d; --line: #e7dfe2;
  --primary: #7a2e4d; --primary-ink: #ffffff; --soft: #f5e9ee; --soft-ink: #6a2743;
  --ok: #1b6e45; --ok-soft: #e3f3ea; --warn: #8a5200; --warn-soft: #fbefd9; --danger: #b3261e;
  --radius: 14px; --nav-h: 64px; --head-h: 56px;
  --shadow: 0 1px 2px rgb(35 28 38 / .06), 0 4px 14px rgb(35 28 38 / .05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17131a; --surface: #211b25; --ink: #f1eaf0; --muted: #aba0af; --line: #372e3c;
    --primary: #e58fae; --primary-ink: #2b0f1c; --soft: #35212c; --soft-ink: #f3c2d3;
    --ok: #7fd3a6; --ok-soft: #173326; --warn: #f0c070; --warn-soft: #3a2c12; --danger: #ffb4ab;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 16px/1.7 'Plex Arabic', 'Segoe UI', Tahoma, sans-serif; -webkit-tap-highlight-color: transparent; overscroll-behavior-y: none; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 1.15rem; font-weight: 600; }
h2 { font-size: 1.05rem; font-weight: 600; }
h3 { font-size: .95rem; font-weight: 600; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary); }
svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.ltr { direction: ltr; unicode-bidi: isolate; text-align: start; }
.boot { padding: 40vh 16px 0; text-align: center; color: var(--muted); }

/* ───── الهيكل ───── */
.shell { min-height: 100dvh; display: flex; flex-direction: column; }
.head { position: sticky; top: 0; z-index: 5; height: calc(var(--head-h) + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 8px 0; display: flex; align-items: center; gap: 4px; background: var(--bg); border-bottom: 1px solid var(--line); }
.head h1 { flex: 1; padding-inline: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.head .store { padding-inline-end: 8px; max-width: 45%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.iconbtn { width: 44px; height: 44px; display: grid; place-items: center; border: 0; border-radius: 50%; background: none; cursor: pointer; }
.iconbtn:hover { background: var(--soft); }
.main { flex: 1; width: 100%; max-width: 720px; margin: 0 auto; padding: 16px 16px calc(var(--nav-h) + 24px + env(safe-area-inset-bottom)); display: grid; gap: 16px; align-content: start; }
.banner { padding: 8px 16px; font-size: .875rem; text-align: center; background: var(--warn-soft); color: var(--warn); }

.nav { position: fixed; inset: auto 0 0 0; z-index: 6; height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); display: grid; grid-template-columns: repeat(5, 1fr); background: var(--surface); border-top: 1px solid var(--line); }
.nav a { display: grid; justify-items: center; align-content: center; gap: 2px; font-size: .72rem; color: var(--muted); text-decoration: none; min-width: 0; }
.nav a[aria-current] { color: var(--primary); font-weight: 600; }
.nav a.add span.plus { width: 46px; height: 46px; display: grid; place-items: center; border-radius: 50%; background: var(--primary); color: var(--primary-ink); margin-top: -18px; box-shadow: var(--shadow); }
.nav a.add { color: var(--ink); }

@media (min-width: 860px) {
  .shell { padding-inline-start: 104px; }
  .nav { inset: 0 0 0 auto; width: 104px; height: auto; grid-template-columns: 1fr; grid-auto-rows: 84px; align-content: start; padding: 16px 0; border-top: 0; border-inline-end: 1px solid var(--line); }
  .nav a.add span.plus { margin-top: 0; }
  .nav a { font-size: .8rem; }
  .main { padding-bottom: 32px; }
}

/* ───── العناصر ───── */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); display: grid; gap: 12px; }
.row { display: flex; align-items: center; gap: 12px; }
.row > .grow { flex: 1; min-width: 0; }
.stack { display: grid; gap: 4px; }
.wrap { overflow-wrap: anywhere; }

.btn { min-height: 48px; padding: 0 20px; border: 1px solid transparent; border-radius: 12px; background: var(--primary); color: var(--primary-ink); font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; }
.btn.block { width: 100%; }
.btn.ghost { background: none; color: var(--primary); border-color: var(--line); }
.btn.danger { background: none; color: var(--danger); border-color: var(--line); }
.btn.sm { min-height: 40px; padding: 0 14px; font-size: .9rem; }
.btn:disabled { opacity: .55; cursor: default; }

.field { display: grid; gap: 6px; }
.field > label, .field > .label { font-weight: 600; font-size: .92rem; }
.field .hint { font-size: .82rem; color: var(--muted); }
.input, select.input, textarea.input { width: 100%; min-height: 48px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
textarea.input { min-height: 104px; resize: vertical; line-height: 1.8; }
.input:focus { outline: 2px solid var(--primary); outline-offset: 0; border-color: var(--primary); }
.check { display: flex; gap: 12px; align-items: flex-start; padding: 4px 0; cursor: pointer; }
.check input { width: 22px; height: 22px; margin-top: 3px; accent-color: var(--primary); flex: none; }
.form { display: grid; gap: 16px; }
.error { color: var(--danger); font-size: .9rem; }
.note { padding: 12px 14px; border-radius: 12px; background: var(--soft); color: var(--soft-ink); font-size: .92rem; }

.badge { display: inline-block; padding: 1px 10px; border-radius: 99px; font-size: .78rem; font-weight: 600; background: var(--soft); color: var(--soft-ink); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }

.menu { padding: 4px 0; gap: 0; }
.menu a { display: flex; align-items: center; gap: 14px; min-height: 60px; padding: 8px 16px; color: inherit; text-decoration: none; border-bottom: 1px solid var(--line); }
.menu a:last-child { border-bottom: 0; }
.menu a .chev { margin-inline-start: auto; color: var(--muted); width: 20px; height: 20px; }
.menu a > svg:first-child { color: var(--primary); }

.empty { text-align: center; justify-items: center; padding: 32px 20px; }
.empty .art { width: 64px; height: 64px; display: grid; place-items: center; border-radius: 50%; background: var(--soft); color: var(--soft-ink); }
.empty .art svg { width: 30px; height: 30px; }
.empty ul { margin: 0; padding: 0; list-style: none; text-align: start; display: grid; gap: 6px; color: var(--muted); font-size: .92rem; }
.empty li::before { content: '•'; color: var(--primary); margin-inline-end: 8px; }

.tabs { display: grid; grid-template-columns: 1fr 1fr; padding: 4px; border-radius: 12px; background: var(--soft); gap: 4px; }
.tabs button { min-height: 44px; border: 0; border-radius: 9px; background: none; font-weight: 600; color: var(--soft-ink); cursor: pointer; }
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

.auth { min-height: 100dvh; display: grid; align-content: center; gap: 20px; max-width: 420px; margin: 0 auto; padding: 24px 16px; }
.auth .brand { display: grid; justify-items: center; gap: 8px; text-align: center; }
.auth .brand img { width: 72px; height: 72px; border-radius: 18px; }
.auth .brand h1 { font-size: 1.4rem; }

.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.steps li { display: flex; gap: 12px; align-items: baseline; }
.steps .n { flex: none; width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; font-size: .8rem; font-weight: 600; background: var(--soft); color: var(--soft-ink); }
.steps li.done .n { background: var(--ok-soft); color: var(--ok); }

#toast { position: fixed; inset: auto 16px calc(var(--nav-h) + 16px + env(safe-area-inset-bottom)) 16px; z-index: 20; max-width: 480px; margin: 0 auto; padding: 12px 16px; border-radius: 12px; background: var(--ink); color: var(--bg); text-align: center; box-shadow: var(--shadow); }
#toast.bad { background: var(--danger); color: #fff; }
@media (prefers-color-scheme: dark) { #toast.bad { color: #2b0f0c; } }
@media (prefers-reduced-motion: no-preference) { #toast:not([hidden]) { animation: rise .2s ease-out; } @keyframes rise { from { transform: translateY(8px); opacity: 0; } } }

/* ───── المنتجات والمخزون ───── */
.toolbar { display: flex; gap: 8px; align-items: center; }
.toolbar .input { flex: 1; min-width: 0; }
.plist { display: grid; gap: 10px; }
.prow { display: flex; gap: 12px; align-items: center; padding: 10px; color: inherit; text-decoration: none; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.prow.off { opacity: .6; }
.thumb { width: 64px; height: 80px; flex: none; border-radius: 10px; background: var(--soft); color: var(--soft-ink); display: grid; place-items: center; overflow: hidden; }
.thumb img, .photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo { width: 100%; max-width: 280px; aspect-ratio: 4 / 5; margin: 0 auto; border-radius: var(--radius); background: var(--soft); color: var(--soft-ink); display: grid; place-items: center; overflow: hidden; }
.photo svg { width: 48px; height: 48px; }
.price { font-weight: 600; white-space: nowrap; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.vgroup { display: grid; gap: 8px; }
.vgroup + .vgroup { padding-top: 12px; border-top: 1px solid var(--line); }
.vrow { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.vrow .size { min-width: 48px; font-weight: 600; }
.vrow .qty { margin-inline-start: auto; }
.panel { display: grid; gap: 12px; padding: 12px; border-radius: 12px; background: var(--bg); border: 1px solid var(--line); }
.moves { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.moves li { display: flex; gap: 10px; align-items: baseline; font-size: .92rem; }
.moves .delta { min-width: 40px; font-weight: 600; direction: ltr; text-align: end; }
.moves .delta.up { color: var(--ok); }
.moves .delta.down { color: var(--danger); }
.filebtn { position: relative; overflow: hidden; }
.filebtn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.code { direction: ltr; unicode-bidi: isolate; text-align: right; }

/* ───── الطلبيات ───── */
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; min-height: 40px; padding: 0 14px; border: 1px solid var(--line); border-radius: 99px; background: var(--surface); cursor: pointer; white-space: nowrap; }
.chip[aria-pressed="true"] { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); font-weight: 600; }
.chip:disabled { opacity: .45; cursor: default; }
.orow { display: grid; gap: 4px; padding: 12px 14px; color: inherit; text-decoration: none; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.orow .top { display: flex; align-items: center; gap: 8px; }
.orow .num { font-weight: 600; direction: ltr; }
.orow .top .badge { margin-inline-start: auto; }
.badge.st-new { background: var(--soft); color: var(--soft-ink); }
.badge.st-preparing, .badge.st-with_courier { background: var(--warn-soft); color: var(--warn); }
.badge.st-ready, .badge.st-delivered, .badge.st-closed { background: var(--ok-soft); color: var(--ok); }
.badge.st-cancelled { background: var(--line); color: var(--muted); }
.item { display: flex; gap: 12px; align-items: center; }
.item + .item { padding-top: 12px; border-top: 1px solid var(--line); }
.item .thumb { width: 56px; height: 70px; }
.item .pricein { width: 92px; min-height: 44px; padding: 6px 10px; }
.sum { display: grid; gap: 6px; }
.sum div { display: flex; justify-content: space-between; gap: 12px; }
.sum .total { font-weight: 600; font-size: 1.1rem; padding-top: 8px; border-top: 1px solid var(--line); }
.policy { padding: 12px 14px; border-radius: 12px; background: var(--warn-soft); color: var(--warn); font-size: .92rem; font-weight: 600; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; overflow-wrap: anywhere; }
dl.kv { margin: 0; }
.pick { display: grid; gap: 8px; max-height: 60vh; overflow-y: auto; }
.pick .phead { display: flex; gap: 10px; align-items: center; width: 100%; padding: 8px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); text-align: start; cursor: pointer; }
.pick .phead .thumb { width: 44px; height: 55px; }
.pick .vars { display: flex; flex-wrap: wrap; gap: 8px; padding: 4px 4px 8px; }
.hist { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; font-size: .92rem; }
.sheet { position: fixed; inset: 0; z-index: 30; background: var(--bg); overflow-y: auto; display: grid; align-content: start; gap: 12px; padding: 12px 12px calc(24px + env(safe-area-inset-bottom)); }
.sheet img { width: 100%; max-width: 540px; margin: 0 auto; display: block; border: 1px solid var(--line); border-radius: 12px; }
.sheet .bar { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; position: sticky; top: 0; padding: 8px 0; background: var(--bg); }
@media print {
  body > :not(.sheet) { display: none !important; }
  .sheet { position: static; padding: 0; background: #fff; }
  .sheet .bar { display: none; }
  .sheet img { max-width: 100%; border: 0; border-radius: 0; }
}

/* ───── الدليفري ───── */
.stat3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; }
.stat3 div { padding: 10px 4px; border-radius: 12px; background: var(--bg); border: 1px solid var(--line); display: grid; gap: 2px; }
.stat3 strong { font-size: 1.15rem; }
.stat3 span { font-size: .8rem; color: var(--muted); }

/* ───── نتائج التوصيل والمرتجعات ───── */
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.seg button { min-height: 44px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); cursor: pointer; font-weight: 600; }
.seg button[aria-pressed="true"].yes { background: var(--ok-soft); color: var(--ok); border-color: var(--ok); }
.seg button[aria-pressed="true"].no { background: var(--warn-soft); color: var(--warn); border-color: var(--warn); }
.ritem { display: grid; gap: 8px; }
.ritem + .ritem { padding-top: 12px; border-top: 1px solid var(--line); }
.badge.late { background: var(--danger); color: #fff; }
@media (prefers-color-scheme: dark) { .badge.late { color: #2b0f0c; } }
.acts { display: flex; flex-wrap: wrap; gap: 8px; }

/* عناصر الصفحة لا تتجاوز عرض الشاشة حتى لو كان محتواها أعرض (شريط الفلاتر يتمرّر داخله) */
.main > * { min-width: 0; }

/* ───── المالية ───── */
.pay { display: grid; gap: 8px; }
.pay + .pay { padding-top: 12px; border-top: 1px solid var(--line); }
.badge.bad { background: var(--danger); color: #fff; }
@media (prefers-color-scheme: dark) { .badge.bad { color: #2b0f0c; } }
.todo { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: .92rem; }
.todo li::before { content: '○'; margin-inline-end: 8px; color: var(--warn); }
.todo li.ok::before { content: '✓'; color: var(--ok); }

/* ───── التقييمات ───── */
.starline { color: #d18a00; letter-spacing: 1px; white-space: nowrap; }
.starline .off { color: var(--line); }
@media (prefers-color-scheme: dark) { .starline { color: #f0c070; } }
