/* سوق قبة — التطبيق المصغر. الألوان رموز تتبدل في الوضع الداكن حسب تيليجرام. */
:root {
  --bg: #F7F3EA; --card: #FFFFFF; --ink: #1B1F1D; --muted: #5E625F; --line: #E6E0D2; --soft: #F1EEE6;
  --brand: #146C43; --brand-ink: #FFFFFF; --brand-soft: #E7F2EC; --brand-deep: #0E4F31;
  --gold: #E8B23A; --warn-bg: #FFF1CC; --warn-ink: #7A4F00; --off-bg: #EEEBE4; --off-ink: #4A4D4B;
  --shadow: 0 10px 24px rgba(20, 108, 67, .25);
  --safe-b: env(safe-area-inset-bottom, 0px);
}
html.dark {
  --bg: #121614; --card: #1C2220; --ink: #ECEFED; --muted: #A3ABA7; --line: #2C3431; --soft: #232A27;
  --brand: #2FA36B; --brand-ink: #FFFFFF; --brand-soft: #173A29; --brand-deep: #8FD9B1;
  --warn-bg: #3A2F12; --warn-ink: #F3CE7A; --off-bg: #2A2F2D; --off-ink: #C3C9C6;
  --shadow: 0 10px 24px rgba(0, 0, 0, .4);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font-family: 'IBM Plex Sans Arabic', system-ui, sans-serif; font-size: 15px; line-height: 1.5; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img { display: block; }
.hide-scroll { scrollbar-width: none; } .hide-scroll::-webkit-scrollbar { display: none; }
.press { transition: transform .12s ease; } .press:active { transform: scale(.97); }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.splash { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; }
.brand { font-family: 'Reem Kufi', serif; font-weight: 700; font-size: 30px; color: var(--brand); }
.spin { width: 26px; height: 26px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--brand); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.screen { padding-bottom: calc(110px + var(--safe-b)); min-height: 100vh; animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* الرئيسية */
.hero { background: var(--brand); color: #FFFFFF; padding: 20px 18px 18px; border-radius: 0 0 28px 28px; display: flex; flex-direction: column; gap: 14px; }
.hero-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.hero-hi { font-size: 14px; color: #D8EFE3; }
.hero .brand { color: #FFFFFF; font-size: 26px; line-height: 1.2; }
.chip-addr { display: flex; align-items: center; gap: 6px; max-width: 48%; background: rgba(255,255,255,.14); color: #FFFFFF; border: 1px solid rgba(255,255,255,.25); border-radius: 999px; padding: 7px 12px; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search { display: flex; align-items: center; gap: 10px; background: var(--card); color: var(--muted); border-radius: 16px; padding: 11px 14px; }
.search input { border: 0; outline: none; background: transparent; flex: 1; color: var(--ink); min-width: 0; }
.wrap { padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.notice { border-radius: 18px; padding: 14px 16px; background: var(--warn-bg); color: var(--warn-ink); font-weight: 600; }
.card-btn { display: flex; align-items: center; gap: 12px; width: 100%; text-align: right; background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: 18px; padding: 13px 14px; }
.card-btn .ico { width: 42px; height: 42px; border-radius: 13px; background: var(--brand-soft); color: var(--brand); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.card-btn .txt { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.card-btn b { font-size: 15px; }
.card-btn small { color: var(--muted); font-size: 13px; }
.card-btn .go { color: var(--brand); font-weight: 700; font-size: 13px; }
.active-card { background: var(--ink); color: var(--bg); border: 0; }
html.dark .active-card { background: var(--brand-soft); color: var(--ink); }
.active-card .ico { background: var(--gold); color: #1B1F1D; }
.active-card small { color: inherit; opacity: .75; }
.active-card .go { color: var(--gold); }
.chips { display: flex; gap: 8px; overflow-x: auto; margin: 0 -16px; padding: 0 16px; }
.chip { flex-shrink: 0; border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 999px; padding: 8px 15px; font-size: 14px; }
.chip.on { background: var(--ink); color: var(--bg); border-color: var(--ink); font-weight: 700; }
.h2 { margin: 6px 0 0; font-size: 18px; font-weight: 700; display: flex; justify-content: space-between; align-items: baseline; }
.h2 small { font-size: 13px; color: var(--muted); font-weight: 400; }
.store { display: flex; gap: 13px; align-items: center; width: 100%; text-align: right; background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: 20px; padding: 11px; }
.logo { width: 64px; height: 64px; border-radius: 18px; flex-shrink: 0; background: var(--brand); color: #FFFFFF; display: flex; align-items: center; justify-content: center; font-family: 'Reem Kufi', serif; font-size: 26px; font-weight: 700; overflow: hidden; }
.logo img { width: 100%; height: 100%; object-fit: cover; }
.store.closed .logo { opacity: .55; }
.store .info { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 0; }
.store .name { font-size: 16px; font-weight: 700; }
.store .meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.badge { font-size: 12px; font-weight: 600; border-radius: 999px; padding: 2px 10px; }
.badge.open { background: var(--brand-soft); color: var(--brand-deep); }
.badge.closing { background: var(--warn-bg); color: var(--warn-ink); }
.badge.closed, .badge.paused { background: var(--off-bg); color: var(--off-ink); }
.empty { text-align: center; color: var(--muted); padding: 36px 12px; }

/* المحل */
.cover { position: relative; color: #FFFFFF; padding: 16px 16px 20px; border-radius: 0 0 28px 28px; background: var(--brand); overflow: hidden; min-height: 170px; display: flex; flex-direction: column; justify-content: flex-end; }
.cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cover::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,0,0,.05), rgba(0,0,0,.6)); }
.cover > * { position: relative; z-index: 1; }
.cover h1 { margin: 0; font-family: 'Reem Kufi', serif; font-size: 28px; line-height: 1.25; }
.cover .row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: 13px; margin-top: 6px; }
.cover .badge { background: #FFFFFF; color: var(--brand-deep); }
.cover .badge.closing { background: var(--warn-bg); color: var(--warn-ink); }
.cover .badge.closed, .cover .badge.paused { background: #FFFFFF; color: #4A4D4B; }
.sec-title { margin: 16px 16px 10px; font-size: 16px; font-weight: 700; display: flex; align-items: center; gap: 6px; }
.pop { display: flex; gap: 8px; overflow-x: auto; padding: 0 16px 4px; }
.pop .p { width: 112px; flex-shrink: 0; }
.tabs { position: sticky; top: 0; z-index: 5; background: var(--bg); display: flex; gap: 8px; overflow-x: auto; padding: 10px 16px; border-bottom: 1px solid var(--line); margin-top: 6px; }
/* المنتجات: ثلاثة في الصف، صورة صغيرة، السعر ثم زر الإضافة بعرض البطاقة */
.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; padding: 12px 16px 0; }
.p { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 6px; display: flex; flex-direction: column; gap: 4px; text-align: right; color: var(--ink); }
.thumb { position: relative; aspect-ratio: 1 / 1; border: 0; padding: 0; border-radius: 12px; background: var(--soft); overflow: hidden; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 11px; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb .tag { position: absolute; top: 5px; left: 5px; background: var(--card); color: var(--ink); font-size: 10px; font-weight: 700; border-radius: 999px; padding: 1px 6px; }
.p .pname { font-size: 12.5px; font-weight: 600; line-height: 1.35; min-height: 34px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; padding: 0 2px; }
.price { font-weight: 700; font-size: 13px; white-space: nowrap; padding: 0 2px; }
.p .add { width: 100%; height: 32px; border: 0; border-radius: 10px; background: var(--brand-soft); color: var(--brand); display: flex; align-items: center; justify-content: center; }
.p .step { justify-content: space-between; border-radius: 10px; padding: 1px; }
.p .step button { width: 30px; height: 30px; }
.step { display: flex; align-items: center; gap: 2px; background: var(--brand); border-radius: 12px; padding: 3px; color: var(--brand-ink); }
.step button { width: 30px; height: 30px; border: 0; border-radius: 9px; background: transparent; color: inherit; display: flex; align-items: center; justify-content: center; }
.step b { min-width: 18px; text-align: center; }
.step.outline { background: transparent; border: 1px solid var(--line); color: var(--brand); }
.step.outline b { color: var(--ink); }

/* شريط سفلي */
.bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; padding: 12px 16px calc(14px + var(--safe-b)); background: linear-gradient(rgba(0,0,0,0), var(--bg) 35%); }
.bar button { width: 100%; height: 56px; border: 0; border-radius: 18px; background: var(--brand); color: var(--brand-ink); display: flex; align-items: center; justify-content: space-between; padding: 0 18px; font-size: 16px; font-weight: 700; box-shadow: var(--shadow); }
.bar button.center { justify-content: center; }
.bar button:disabled { opacity: .55; box-shadow: none; }
.bar .count { background: var(--brand-ink); color: var(--brand); border-radius: 10px; min-width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center; margin-left: 10px; }

/* السلة */
.head { padding: 16px 16px 4px; display: flex; align-items: center; gap: 12px; }
.head h1 { margin: 0; font-size: 21px; }
.head small { color: var(--muted); }
.box { background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 4px 14px; }
.line { display: flex; align-items: center; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.line:last-child { border-bottom: 0; }
.line .mini { width: 44px; height: 44px; border-radius: 12px; background: var(--soft); overflow: hidden; flex-shrink: 0; }
.line .mini img { width: 100%; height: 100%; object-fit: cover; }
.line .t { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.line .t small { color: var(--muted); font-size: 12px; }
.line .amt { min-width: 62px; text-align: left; font-weight: 700; font-size: 14px; white-space: nowrap; }
.label { font-weight: 700; margin-bottom: 8px; display: block; }
.map { height: 210px; border-radius: 20px; overflow: hidden; border: 1px solid var(--line); position: relative; background: var(--soft); }
.map .pin { position: absolute; left: 50%; top: 50%; z-index: 500; width: 34px; height: 34px; margin: -34px 0 0 -17px; pointer-events: none; }
.map-actions { display: flex; gap: 8px; margin-top: 8px; }
.ghost { flex: 1; height: 44px; border-radius: 14px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font-weight: 600; display: flex; align-items: center; justify-content: center; gap: 6px; }
.field { width: 100%; border: 1px solid var(--line); border-radius: 14px; padding: 12px; background: var(--card); color: var(--ink); resize: none; }
.choices { display: flex; gap: 8px; }
.choice { flex: 1; border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 16px; padding: 12px; font-weight: 700; }
.choice.on { border: 2px solid var(--brand); background: var(--brand-soft); color: var(--brand-deep); }
.sum { background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.sum .r { display: flex; justify-content: space-between; }
.sum .r span:first-child { color: var(--muted); }
.sum .total { font-size: 17px; font-weight: 700; border-top: 1px solid var(--line); padding-top: 8px; }
.sum .total span:first-child { color: var(--ink); }
.eta-line { display: flex; align-items: center; gap: 6px; color: var(--brand); font-size: 13px; font-weight: 600; }
.err { color: #B42318; font-weight: 600; }
html.dark .err { color: #FDA29B; }

/* التتبع */
.track-top { background: var(--brand); color: #FFFFFF; padding: 22px 18px 26px; border-radius: 0 0 28px 28px; display: flex; flex-direction: column; gap: 6px; }
.track-top small { color: #D8EFE3; }
.track-top h1 { margin: 0; font-size: 24px; line-height: 1.3; }
.eta-pill { align-self: flex-start; background: rgba(255,255,255,.16); border-radius: 14px; padding: 7px 12px; font-weight: 700; margin-top: 4px; }
.bars { display: flex; gap: 6px; }
.bars span { flex: 1; height: 6px; border-radius: 9px; background: var(--line); }
.bars span.on { background: var(--brand); }
.steps { list-style: none; margin: 0; padding: 0; }
.steps li { display: flex; gap: 12px; }
.steps .dotcol { display: flex; flex-direction: column; align-items: center; }
.steps .dot { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line); background: var(--bg); flex-shrink: 0; }
.steps .done .dot { background: var(--brand); border-color: var(--brand); }
.steps .now .dot { border: 5px solid var(--brand); background: var(--card); }
.steps .stem { width: 2px; height: 26px; background: var(--line); }
.steps .done .stem { background: var(--brand); }
.steps .t { padding-bottom: 12px; display: flex; flex-direction: column; }
.steps .t small { color: var(--muted); font-size: 12px; }
.steps .later .t span { color: var(--muted); }
.steps .now .t span { font-weight: 700; }
.danger { height: 46px; border-radius: 14px; border: 1px solid #F1C7C2; background: transparent; color: #B42318; font-weight: 700; }
html.dark .danger { border-color: #5A2A26; color: #FDA29B; }
.live { animation: pulse 1.8s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(20,108,67,.45); } 70% { box-shadow: 0 0 0 12px rgba(20,108,67,0); } 100% { box-shadow: 0 0 0 0 rgba(20,108,67,0); } }

/* نافذة المنتج */
.veil { position: fixed; inset: 0; z-index: 40; background: rgba(15,18,17,.48); border: 0; animation: fadeIn .2s ease; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; background: var(--card); border-radius: 26px 26px 0 0; padding: 10px 18px calc(18px + var(--safe-b)); display: flex; flex-direction: column; gap: 14px; max-height: 88vh; overflow-y: auto; animation: up .26s cubic-bezier(.2,.8,.2,1); }
@keyframes up { from { transform: translateY(100%); } to { transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.grab { align-self: center; width: 44px; height: 5px; border-radius: 9px; background: var(--line); }
.sheet .thumb { aspect-ratio: 16 / 10; border-radius: 20px; }
.sheet h2 { margin: 0; font-size: 20px; }
.sheet .desc { color: var(--muted); margin: 0; }
.sizes { display: flex; gap: 8px; flex-wrap: wrap; }
.size { min-width: 96px; border-radius: 14px; padding: 9px 14px; border: 1px solid var(--line); background: var(--card); color: var(--ink); display: flex; flex-direction: column; align-items: center; font-weight: 700; }
.size small { font-weight: 400; font-size: 12px; color: var(--muted); }
.size.on { border: 2px solid var(--brand); background: var(--brand-soft); color: var(--brand-deep); }
.sheet-foot { display: flex; gap: 12px; align-items: center; }
.sheet-foot .primary { flex: 1; height: 54px; border: 0; border-radius: 16px; background: var(--brand); color: var(--brand-ink); font-size: 16px; font-weight: 700; }
.sheet-foot .step { background: var(--soft); color: var(--brand); padding: 4px; border-radius: 16px; }
.sheet-foot .step button { width: 40px; height: 40px; }
.sheet-foot .step b { min-width: 26px; font-size: 18px; color: var(--ink); }

#toast { position: fixed; top: 12px; left: 50%; transform: translateX(-50%) translateY(-120%); z-index: 60; background: var(--ink); color: var(--bg); border-radius: 14px; padding: 11px 16px; font-size: 14px; max-width: calc(100% - 32px); text-align: center; transition: transform .25s ease; pointer-events: none; }
#toast.show { transform: translateX(-50%) translateY(0); }
.leaflet-container { font-family: inherit; }

/* صفحة المحل: البحث و«اكتب طلبك» والأقسام */
.store-tools { padding: 14px 16px 0; display: flex; flex-direction: column; gap: 10px; }
.search.boxed { border: 1px solid var(--line); }
.search input[type=search]::-webkit-search-cancel-button { display: none; }
.write-btn { display: flex; align-items: center; gap: 12px; width: 100%; text-align: right; border: 0; border-radius: 18px; padding: 12px 14px; background: var(--brand); color: var(--brand-ink); box-shadow: var(--shadow); }
.write-btn .ico { width: 40px; height: 40px; border-radius: 12px; background: rgba(255,255,255,.16); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.write-btn .txt { display: flex; flex-direction: column; }
.write-btn small { opacity: .85; font-size: 13px; }
.secs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; padding: 0 16px; }
.sec { display: flex; flex-direction: column; align-items: center; gap: 4px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 8px 6px 10px; color: var(--ink); }
.sec-img { width: 100%; aspect-ratio: 1 / 1; border-radius: 12px; background: var(--brand-soft); color: var(--brand); overflow: hidden; display: flex; align-items: center; justify-content: center; font-size: 26px; font-weight: 700; }
.sec-img img { width: 100%; height: 100%; object-fit: cover; }
.sec-name { font-size: 13px; font-weight: 700; text-align: center; line-height: 1.3; }
.sec small { color: var(--muted); font-size: 11px; }
.more { display: flex; justify-content: center; padding: 22px 0; }
.spin.sm { width: 18px; height: 18px; border-width: 2px; }

/* اكتب طلبك: مراجعة البنود */
.wl { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.wl.check { border-color: var(--gold); box-shadow: inset 0 0 0 1px var(--gold); }
.wl.off { opacity: .5; }
.wl.off .t span { text-decoration: line-through; }
.wl-top { display: flex; align-items: center; gap: 10px; }
.wl .mini { width: 44px; height: 44px; border-radius: 12px; background: var(--soft); overflow: hidden; flex-shrink: 0; }
.wl .mini img { width: 100%; height: 100%; object-fit: cover; }
.wl .t { display: flex; flex-direction: column; flex: 1; min-width: 0; font-weight: 600; }
.wl .t small { color: var(--muted); font-size: 12px; font-weight: 400; }
.wl.check .t small { color: var(--warn-ink); }
.wl .x { width: 32px; height: 32px; border-radius: 10px; border: 1px solid var(--line); background: transparent; color: var(--muted); font-size: 20px; line-height: 1; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.opts { display: flex; gap: 6px; overflow-x: auto; }
.opts .chip { padding: 6px 12px; font-size: 13px; }
.wl-foot { display: flex; align-items: center; justify-content: space-between; }
.wl-foot .amt { font-weight: 700; white-space: nowrap; }
.miss { background: var(--off-bg); color: var(--off-ink); border-radius: 18px; padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; }
.miss-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.link { border: 0; background: transparent; color: var(--brand); font-weight: 700; padding: 4px 0; }

/* ملاحظة المنتج وتفضيل الناقص */
.note-btn { align-self: flex-start; border: 0; background: transparent; color: var(--brand); font-size: 12px; font-weight: 600; padding: 2px 0 0; text-align: right; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hint { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.sheet .field { min-height: 90px; }

/* المنتج الناقص في التتبع */
.missing-card { background: var(--warn-bg); color: var(--warn-ink); border-radius: 18px; padding: 12px 14px; display: grid; grid-template-columns: 48px 1fr; gap: 10px 12px; align-items: center; }
.missing-card .mini { width: 48px; height: 48px; border-radius: 12px; background: var(--card); overflow: hidden; }
.missing-card .mini img { width: 100%; height: 100%; object-fit: cover; }
.missing-card .txt { display: flex; flex-direction: column; }
.missing-card .txt small { font-size: 13px; opacity: .85; }
.missing-card .row2 { grid-column: 1 / -1; display: flex; gap: 8px; }
.primary-sm { flex: 1; height: 44px; border: 0; border-radius: 14px; background: var(--brand); color: var(--brand-ink); font-weight: 700; }
.sub-list { display: flex; flex-direction: column; gap: 8px; }
.sub-row { display: flex; align-items: center; gap: 10px; width: 100%; text-align: right; background: var(--bg); border: 1px solid var(--line); border-radius: 16px; padding: 8px 10px; color: var(--ink); }
.sub-row .mini { width: 48px; height: 48px; border-radius: 12px; background: var(--soft); overflow: hidden; flex-shrink: 0; }
.sub-row .mini img { width: 100%; height: 100%; object-fit: cover; }
.sub-row .t { display: flex; flex-direction: column; flex: 1; min-width: 0; font-weight: 600; }
.sub-row .t small { color: var(--muted); font-weight: 400; }
.sub-row .go { color: var(--brand); font-weight: 700; }
