* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
:root {
  --green: #1e9e57;
  --green-d: #12743f;
  --green-soft: #e9f7ef;
  --bg: #f4f6f4;
  --card: #ffffff;
  --ink: #1c2a22;
  --muted: #7d8b83;
  --line: #e6ebe7;
  --amber: #b7791f;
  --amber-soft: #fdf5e3;
  --blue: #1f6fb2;
  --blue-soft: #e8f2fb;
}
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, "Segoe UI", Tahoma, Arial, sans-serif;
  background: var(--bg); color: var(--ink);
  max-width: 480px; margin: 0 auto; min-height: 100vh;
  line-height: 1.5;
}
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.hidden { display: none !important; }
button, input, textarea, select { font-family: inherit; }

/* ======= أزرار ======= */
.btn-primary {
  width: 100%; padding: 14px; font-size: 16px; font-weight: 800; color: #fff;
  background: var(--green); border: none; border-radius: 12px; cursor: pointer;
  box-shadow: 0 4px 12px rgba(30,158,87,.22);
}
.btn-primary:active { background: var(--green-d); }
.btn-ghost {
  padding: 11px 16px; font-size: 14px; font-weight: 700; color: var(--green-d);
  background: #fff; border: 1px solid var(--green); border-radius: 11px; cursor: pointer;
}
.btn-ghost.wide { width: 100%; border-style: dashed; margin-bottom: 10px; }
.btn-link { background: none; border: none; color: var(--muted); font-size: 14px; cursor: pointer; padding: 10px; }
.btn-link.light { color: #fff; }

/* ======= شاشة الكود ======= */
.gate { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background: linear-gradient(180deg, #eef8f2 0%, var(--bg) 55%); }
.gate-card { background: var(--card); border-radius: 22px; padding: 30px 22px 24px; width: 100%; text-align: center; box-shadow: 0 10px 30px rgba(20,60,40,.08); }
.gate-logo { width: 62px; height: 62px; margin: 0 auto 12px; border-radius: 18px; background: var(--green-soft); color: var(--green-d); display: grid; place-items: center; }
.gate-logo svg { width: 30px; height: 30px; }
.gate-card h1 { font-size: 26px; color: var(--green-d); }
.gate-sub { color: var(--muted); font-size: 14px; margin: 2px 0 22px; }
.gate-hint { margin-bottom: 10px; font-size: 15px; font-weight: 600; }
.gate-card input {
  width: 100%; padding: 15px; font-size: 22px; text-align: center; letter-spacing: 6px;
  border: 2px solid var(--line); border-radius: 12px; margin-bottom: 12px; background: #fafcfb;
}
.gate-card input:focus { outline: none; border-color: var(--green); }
.gate-error { color: #c62828; font-size: 13px; margin-bottom: 10px; }
.gate-note { color: var(--muted); font-size: 12px; margin-top: 14px; line-height: 1.6; }

/* ======= الهيدر ======= */
.hdr {
  position: sticky; top: 0; z-index: 12; background: #fff;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-bottom: 1px solid var(--line);
}
.hdr-titles { flex: 1; text-align: center; }
.hdr-titles h1 { font-size: 17px; font-weight: 800; color: var(--ink); }
.hdr-titles p { font-size: 11px; color: var(--muted); }
.hdr-cart, .hdr-fav {
  position: relative; width: 40px; height: 40px; border-radius: 12px; border: none;
  background: var(--green-soft); color: var(--green-d); display: grid; place-items: center; cursor: pointer;
}
.hdr-spacer { width: 40px; }
.badge {
  position: absolute; top: -4px; left: -4px; min-width: 19px; height: 19px; border-radius: 10px;
  background: var(--green); color: #fff; font-size: 11px; font-weight: 800;
  display: grid; place-items: center; padding: 0 5px; border: 2px solid #fff;
}

/* ======= البحث ======= */
.search { display: flex; align-items: center; gap: 8px; margin: 12px; background: #fff; border: 1px solid var(--line); border-radius: 24px; padding: 4px 4px 4px 12px; }
.search input { flex: 1; border: none; background: none; font-size: 15px; padding: 9px 4px; outline: none; color: var(--ink); }
.search input::placeholder { color: #a8b3ac; }
.search-btn { width: 38px; height: 38px; border-radius: 50%; border: none; background: var(--green); color: #fff; display: grid; place-items: center; cursor: pointer; flex: 0 0 auto; }
.search-btn svg { width: 19px; height: 19px; }

/* ======= عناوين ======= */
.sec-title { font-size: 16px; font-weight: 800; color: var(--green-d); margin: 16px 14px 10px; }

/* ======= الفئات ======= */
.cats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; padding: 0 12px; }
.cat { background: #fff; border-radius: 14px; padding: 6px 6px 8px; box-shadow: 0 1px 3px rgba(20,60,40,.06); cursor: pointer; border: none; text-align: center; font-family: inherit; }
.cat:active { transform: scale(.97); }
.cat .thumb { position: relative; width: 100%; aspect-ratio: 1/1; border-radius: 10px; overflow: hidden; display: grid; place-items: center; background: linear-gradient(160deg, #eef8f2, #dff1e7); color: var(--green-d); }
.cat .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cat .thumb svg { width: 32px; height: 32px; stroke-width: 1.5; }
.cat .soon { position: absolute; bottom: 5px; left: 5px; background: rgba(255,255,255,.94); color: var(--green-d); font-size: 9px; font-weight: 800; padding: 1px 6px; border-radius: 7px; }
.cat .lbl { display: block; font-size: 12px; font-weight: 700; margin-top: 6px; color: var(--ink); line-height: 1.35; }
.cat .cnt { display: block; font-size: 10px; color: var(--muted); font-weight: 600; }

/* ======= شريط أفقي للمنتجات ======= */
.hstrip { display: flex; gap: 10px; overflow-x: auto; padding: 0 12px 4px; scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch; }
.hstrip::-webkit-scrollbar { display: none; }
.hcard { flex: 0 0 128px; background: #fff; border-radius: 14px; overflow: hidden; box-shadow: 0 1px 3px rgba(20,60,40,.06); scroll-snap-align: start; cursor: pointer; border: none; padding: 0; font-family: inherit; text-align: right; }
.hcard img { width: 100%; height: 128px; object-fit: cover; display: block; background: #eef2ef; }
.hcard .hc-body { padding: 7px 8px 9px; }
.hcard .hc-name { font-size: 12px; font-weight: 700; }
.hcard .hc-meta { font-size: 10px; color: var(--muted); margin-top: 1px; }
.strip-foot { padding: 8px 14px 0; text-align: center; }

/* ======= عنوان فرعي / رجوع ======= */
.subhdr { display: flex; align-items: center; gap: 8px; padding: 12px 12px 8px; position: sticky; top: 56px; background: var(--bg); z-index: 8; }
.subhdr.plain { padding-top: 16px; }
.subhdr h2 { font-size: 17px; font-weight: 800; color: var(--green-d); }
.back { width: 36px; height: 36px; border-radius: 11px; border: 1px solid var(--line); background: #fff; color: var(--ink); display: grid; place-items: center; cursor: pointer; }
.back svg { width: 18px; height: 18px; }

/* ======= شبكة منتجات ======= */
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 0 12px; }
.p-card { background: #fff; border-radius: 14px; overflow: hidden; box-shadow: 0 1px 3px rgba(20,60,40,.06); position: relative; }
.p-img { width: 100%; aspect-ratio: 3/4; object-fit: cover; display: block; background: #eef2ef; cursor: pointer; }
.p-fav { position: absolute; top: 7px; left: 7px; width: 32px; height: 32px; border-radius: 50%; border: none; background: rgba(255,255,255,.92); color: #98a49d; display: grid; place-items: center; cursor: pointer; }
.p-fav.on { color: #e0245e; }
.p-fav svg { width: 17px; height: 17px; fill: none; }
.p-fav.on svg { fill: currentColor; }
.p-body { padding: 9px 10px 10px; }
.p-name { font-size: 13px; font-weight: 700; }
.p-meta { font-size: 11px; color: var(--muted); margin: 2px 0 8px; }
.p-add { width: 100%; padding: 8px; border: 1px solid var(--green); background: #fff; color: var(--green-d); border-radius: 9px; font-size: 12px; font-weight: 800; cursor: pointer; }
.p-add:active { background: var(--green); color: #fff; }

/* ======= صفحة المنتج ======= */
.det-img { width: 100%; max-height: 62vh; object-fit: contain; background: #fff; display: block; cursor: zoom-in; }
.det-wrap { background: #fff; border-radius: 18px 18px 0 0; margin-top: -14px; position: relative; padding: 18px 16px 150px; }
.det-title { font-size: 19px; font-weight: 800; }
.det-meta { font-size: 13px; color: var(--muted); margin-top: 4px; }
.det-note { background: var(--green-soft); color: var(--green-d); font-size: 12px; border-radius: 10px; padding: 10px 12px; margin-top: 12px; line-height: 1.6; }
.qty-pick { display: flex; align-items: center; justify-content: space-between; background: #f7faf8; border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; margin-top: 16px; }
.qty-pick span { font-size: 14px; font-weight: 700; }
.qty { display: flex; align-items: center; gap: 14px; }
.qty button { width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--line); background: #fff; font-size: 18px; font-weight: 700; color: var(--ink); cursor: pointer; }
.qty b { min-width: 18px; text-align: center; font-size: 15px; }
.det-actions { position: fixed; bottom: 70px; left: 0; right: 0; max-width: 480px; margin: 0 auto; background: #fff; border-top: 1px solid var(--line); padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); display: flex; gap: 10px; z-index: 14; }

/* ======= السلة ======= */
.cart-lines { padding: 0 12px; }
.cart-line { display: flex; gap: 10px; align-items: center; background: #fff; border-radius: 13px; padding: 9px; margin-bottom: 9px; box-shadow: 0 1px 3px rgba(20,60,40,.05); }
.cart-line img { width: 54px; height: 68px; object-fit: cover; border-radius: 9px; background: #eef2ef; }
.cart-line .cl-info { flex: 1; min-width: 0; }
.cart-line .cl-name { font-size: 13px; font-weight: 700; }
.cart-line .cl-meta { font-size: 11px; color: var(--muted); }
.cart-line .cl-del { background: none; border: none; color: #c0392b; font-size: 12px; cursor: pointer; padding: 4px; }
.checkout { background: #fff; border-radius: 14px; padding: 14px; margin: 6px 12px 12px; box-shadow: 0 1px 3px rgba(20,60,40,.05); }
.checkout h3 { font-size: 15px; font-weight: 800; margin-bottom: 10px; color: var(--green-d); }
.checkout label { display: block; font-size: 13px; font-weight: 600; color: var(--ink); margin-bottom: 10px; }
.checkout input, .checkout textarea {
  width: 100%; padding: 11px; font-size: 15px; border: 1px solid var(--line); border-radius: 10px; margin-top: 4px; background: #fbfcfb;
}
.checkout input:focus, .checkout textarea:focus { outline: none; border-color: var(--green); }

/* ======= الطلبات ======= */
.ord { background: #fff; border-radius: 14px; padding: 13px; margin: 0 12px 10px; box-shadow: 0 1px 3px rgba(20,60,40,.05); cursor: pointer; border: none; width: calc(100% - 24px); text-align: right; font-family: inherit; }
.ord-head { display: flex; justify-content: space-between; align-items: center; }
.ord-num { font-size: 14px; font-weight: 800; }
.ord-date { font-size: 11px; color: var(--muted); }
.ord-items { font-size: 12px; color: #4a5a51; margin-top: 6px; line-height: 1.7; }
.ord-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }
.ord-count { font-size: 11px; color: var(--muted); }
.chip { font-size: 11px; font-weight: 800; padding: 3px 9px; border-radius: 20px; background: var(--green-soft); color: var(--green-d); }
.chip.s1 { background: var(--amber-soft); color: var(--amber); }
.chip.s2 { background: var(--blue-soft); color: var(--blue); }
.chip.s3 { background: var(--green-soft); color: var(--green-d); }

/* تتبع الطلب */
.track { display: flex; flex-direction: column; gap: 0; margin: 14px 0 4px; }
.track-step { display: flex; gap: 10px; align-items: flex-start; position: relative; padding-bottom: 18px; }
.track-step:last-child { padding-bottom: 0; }
.track-step .dot { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); background: #fff; flex: 0 0 auto; display: grid; place-items: center; color: transparent; font-size: 12px; }
.track-step .dot svg { width: 12px; height: 12px; stroke-width: 3; }
.track-step:not(:last-child):before { content: ''; position: absolute; top: 22px; right: 10px; width: 2px; height: calc(100% - 22px); background: var(--line); }
.track-step.done .dot { background: var(--green); border-color: var(--green); color: #fff; }
.track-step.done:before { background: var(--green); }
.track-step .t-lbl { font-size: 14px; font-weight: 700; }
.track-step .t-sub { font-size: 11px; color: var(--muted); }

/* ======= المزيد ======= */
.more-head { text-align: center; padding: 24px 16px 18px; }
.more-logo { width: 58px; height: 58px; margin: 0 auto 10px; border-radius: 17px; background: var(--green-soft); color: var(--green-d); display: grid; place-items: center; }
.more-logo svg { width: 28px; height: 28px; }
.more-head h2 { font-size: 19px; font-weight: 800; }
.more-head p { font-size: 12px; color: var(--muted); }
.menu { list-style: none; background: #fff; margin: 0 12px; border-radius: 15px; overflow: hidden; box-shadow: 0 1px 3px rgba(20,60,40,.05); }
.menu li { display: flex; align-items: center; gap: 11px; padding: 13px 14px; border-bottom: 1px solid var(--line); font-size: 14px; font-weight: 600; cursor: pointer; }
.menu li:last-child { border-bottom: none; }
.menu li:active { background: #f7faf8; }
.menu .mi { width: 34px; height: 34px; border-radius: 11px; background: var(--green-soft); color: var(--green-d); display: grid; place-items: center; flex: 0 0 auto; }
.menu .mi svg { width: 18px; height: 18px; }
.menu .chev { margin-inline-start: auto; color: #bcc7c0; width: 18px; height: 18px; }
.about { margin: 12px 14px; font-size: 13px; color: #4a5a51; line-height: 1.8; background: #fff; border-radius: 13px; padding: 13px; }
.more-foot { text-align: center; font-size: 11px; color: var(--muted); padding: 18px 0 100px; }

/* ======= شريط التنقل السفلي ======= */
.bnav {
  position: fixed; bottom: 0; left: 0; right: 0; max-width: 480px; margin: 0 auto;
  background: #fff; border-top: 1px solid var(--line); display: flex;
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); z-index: 15;
}
.bn-item { flex: 1; background: none; border: none; display: flex; flex-direction: column; align-items: center; gap: 1px; color: #93a09a; font-size: 10.5px; font-family: inherit; cursor: pointer; padding: 0; }
.bn-ico { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; transition: transform .16s ease, background .16s ease; }
.bn-ico svg { width: 21px; height: 21px; }
.bn-item.active .bn-ico { background: var(--green); color: #fff; width: 46px; height: 46px; margin-top: -15px; box-shadow: 0 6px 14px rgba(30,158,87,.35); }
.bn-item.active .bn-lbl { color: var(--green-d); font-weight: 800; }
.view { padding-bottom: 96px; }

/* ======= حالات فاضية ======= */
.empty { text-align: center; padding: 40px 26px; color: var(--muted); }
.empty .e-ico { width: 62px; height: 62px; margin: 0 auto 12px; border-radius: 20px; background: var(--green-soft); color: var(--green-d); display: grid; place-items: center; }
.empty .e-ico svg { width: 28px; height: 28px; }
.empty h3 { font-size: 15px; color: var(--ink); margin-bottom: 5px; }
.empty p { font-size: 13px; line-height: 1.7; }

/* ======= عرض الصورة ======= */
.viewer { position: fixed; inset: 0; background: rgba(0,0,0,.94); z-index: 40; display: flex; align-items: center; justify-content: center; }
.viewer img { max-width: 100%; max-height: 100%; object-fit: contain; }
.viewer-x { position: absolute; top: 14px; left: 14px; color: #fff; font-size: 26px; background: none; border: none; cursor: pointer; }

/* ======= لوحة المالك ======= */
.owner-top { background: var(--green-d); color: #fff; display: flex; align-items: center; justify-content: space-between; padding: 16px 14px; }
.owner-top h1 { font-size: 17px; }
.owner-login { padding: 44px 22px; text-align: center; }
.owner-login input { width: 100%; padding: 13px; font-size: 17px; border: 2px solid var(--line); border-radius: 11px; margin: 12px 0; text-align: center; }
.owner-panel { padding: 14px 12px 60px; }
.card { background: #fff; border-radius: 15px; padding: 15px; margin-bottom: 12px; box-shadow: 0 1px 3px rgba(20,60,40,.05); }
.card h2 { font-size: 15px; font-weight: 800; margin-bottom: 8px; color: var(--green-d); }
.big-code { font-size: 38px; font-weight: 800; letter-spacing: 9px; text-align: center; color: var(--green-d); padding: 8px 0 2px; direction: ltr; }
.muted { color: var(--muted); font-size: 12px; margin: 6px 0; line-height: 1.7; }
.used-codes { margin-top: 12px; font-size: 12px; color: var(--muted); line-height: 2; }
.used-codes span { display: inline-block; background: #f2f5f3; border-radius: 7px; padding: 1px 7px; margin: 2px; text-decoration: line-through; }
.owner-input { width: 100%; padding: 11px; font-size: 14px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; background: #fbfcfb; }
.orders-list .order { border: 1px solid var(--line); border-radius: 11px; padding: 10px; margin-bottom: 9px; }
.order-head { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
.order-who { font-weight: 800; margin: 4px 0; font-size: 14px; }
.order-items { font-size: 13px; margin: 4px 0; white-space: pre-line; line-height: 1.7; }
.order select { padding: 7px; border-radius: 8px; border: 1px solid var(--line); font-size: 13px; background: #fff; margin-top: 6px; }
.switch-row { display: flex; align-items: center; gap: 10px; font-size: 13px; line-height: 1.6; }
.switch-row input { width: 20px; height: 20px; flex: 0 0 auto; accent-color: var(--green); }
.cat-editor .ce-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.cat-editor input { flex: 1; padding: 10px; font-size: 14px; border: 1px solid var(--line); border-radius: 9px; background: #fbfcfb; }
.cat-editor .ce-del { width: 36px; height: 36px; border-radius: 9px; border: 1px solid #f2d7d4; background: #fdf3f2; color: #c0392b; cursor: pointer; font-size: 15px; flex: 0 0 auto; }

/* ======= بانر المعاينة ======= */
.demo-banner {
  position: fixed; bottom: 0; left: 0; right: 0; max-width: 480px; margin: 0 auto;
  background: #fff8e1; color: #6d5b16; font-size: 11px; text-align: center; padding: 5px 10px;
  border-top: 1px solid #e8d88a; z-index: 30;
}
body.demo .bnav { padding-bottom: 24px; }
body.demo .det-actions { bottom: 94px; }

/* ======= منتجات المالك ======= */
.prod-list .pl-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.pl-row img { width: 46px; height: 58px; object-fit: cover; border-radius: 8px; background: #eef2ef; flex: 0 0 auto; }
.pl-row .pl-info { flex: 1; min-width: 0; }
.pl-row .pl-name { font-size: 13px; font-weight: 700; }
.pl-row .pl-meta { font-size: 11px; color: var(--muted); }
.pl-row button { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 6px 9px; font-size: 12px; cursor: pointer; }
.pl-row .pl-del { color: #c0392b; border-color: #f2d7d4; }
.prod-form { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line); }
.prod-form h3 { font-size: 14px; margin-bottom: 8px; color: var(--green-d); }
.pf-photo { display: block; border: 2px dashed var(--green); border-radius: 12px; padding: 16px; text-align: center; color: var(--green-d); font-size: 13px; font-weight: 700; margin-bottom: 8px; cursor: pointer; }
.pf-photo input { display: none; }
.pf-prev { display: block; width: 120px; height: 150px; object-fit: cover; border-radius: 10px; margin: 0 auto 8px; }
.sold { position: absolute; top: 8px; right: 8px; background: #c62828; color: #fff; font-size: 10px; font-weight: 800; padding: 2px 8px; border-radius: 8px; }
.p-add[disabled] { opacity: .45; cursor: default; }
.p-price { font-size: 12px; font-weight: 800; color: var(--green-d); margin-bottom: 6px; }
