/* تسعير — نظام التصميم (عربي RTL، ألوان ترابية دافئة) */
:root {
  --bg: #faf8f5;
  --card: #fffdf9;
  --ink: #26221c;
  --muted: #7b7365;
  --line: #e5e0d8;
  --line2: #d8d1c4;
  --brand: #1a6b4c;        /* أخضر عميق */
  --brand-dark: #14563e;
  --brand-soft: #e7f0eb;
  --gold: #c8956b;         /* ذهبي دافئ */
  --price: #a3541c;        /* سعر على البطاقة */
  --price-soft: #f7ead9;
  --danger: #b3261e;
  --ok: #2e7d32;
  --warn: #9a6b00;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(80, 66, 30, 0.07);
  --body: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, sans-serif;
  --head: "Changa", "IBM Plex Sans Arabic", sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  line-height: 1.7;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; width: 100%; }
.container { max-width: 980px; margin: 0 auto; padding-inline: 16px; }
a { color: var(--brand); }
h1, h2, h3 { font-family: var(--head); line-height: 1.35; }
h2 { font-size: 21px; margin: 0 0 8px; }
h3 { font-size: 17px; margin: 0 0 6px; }
.mt0 { margin-top: 0; }
.mt8 { margin-top: 8px; }
.mb0 { margin-bottom: 0; }
.mb8 { margin-bottom: 8px; }
.p8 { padding: 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.grow { flex: 1; }
.hide { display: none !important; }

/* ---------- الشريط العلوي ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(255, 253, 249, 0.94);
  backdrop-filter: blur(8px);
  border-bottom: 1.5px solid var(--line);
}
.topbar-in { display: flex; align-items: center; gap: 10px; padding: 10px 16px; max-width: 980px; margin: 0 auto; }
.brand {
  font-family: var(--head); font-weight: 700; font-size: 22px;
  color: var(--brand-dark); text-decoration: none;
  display: flex; align-items: center; gap: 8px;
}
.brand svg { width: 21px; height: 21px; }
.who { font-weight: 600; font-size: 14px; color: var(--ink); }
.badge {
  font-size: 12px; padding: 3px 10px; border-radius: 99px;
  border: 1.5px solid var(--line2); background: #fff; white-space: nowrap;
}
.badge.ok { color: var(--ok); border-color: #bcd9bf; }
.badge.warn { color: var(--warn); border-color: #e6d5a8; }
.badge.off { color: var(--muted); }
.tabs { display: flex; gap: 6px; overflow-x: auto; padding: 6px 16px 0; max-width: 980px; margin: 0 auto; }
.tab {
  padding: 7px 14px; border-radius: 10px 10px 0 0; white-space: nowrap;
  color: var(--muted); text-decoration: none; font-weight: 600; font-size: 14px;
  border: 1.5px solid transparent; border-bottom: none;
}
.tab.on { background: var(--card); border-color: var(--line); color: var(--brand-dark); }

/* ---------- مكوّنات ---------- */
.card {
  background: var(--card); border: 1.5px solid var(--line);
  border-radius: var(--radius); padding: 16px; margin: 14px 0; box-shadow: var(--shadow);
}
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.gap8 { gap: 8px; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: 10px; border: 1.5px solid var(--line2);
  background: #fff; color: var(--ink); font-family: inherit; font-size: 14.5px;
  font-weight: 600; cursor: pointer; text-decoration: none; line-height: 1.4;
}
.btn:hover { border-color: var(--brand); color: var(--brand-dark); }
.btn.primary { background: var(--brand); border-color: var(--brand-dark); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); color: #fff; }
.btn.danger { color: var(--danger); border-color: #e3b8b5; }
.btn.danger:hover { border-color: var(--danger); background: #fdf3f2; }
.btn.warn { color: var(--warn); border-color: #e6d5a8; }
.btn.sm { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn.block { width: 100%; margin-top: 8px; }
.btn:disabled { opacity: 0.5; cursor: default; }
.iconbtn {
  border: 1.5px solid var(--line2); background: #fff; border-radius: 9px;
  width: 36px; height: 36px; font-size: 15px; cursor: pointer; flex: none;
}
.iconbtn:hover { border-color: var(--brand); }
.iconbtn.danger:hover { border-color: var(--danger); }
.input {
  width: 100%; padding: 10px 12px; border: 1.5px solid var(--line2);
  border-radius: 10px; background: #fff; font: inherit; color: var(--ink);
}
.input:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
.input.price { font-size: 18px; font-weight: 600; }
.lbl { display: block; font-weight: 600; font-size: 14px; margin: 12px 0 5px; }
.f { margin-top: 10px; }
.hint { color: var(--muted); font-size: 13px; margin-top: 6px; min-height: 1.2em; }
.warnnote {
  background: #fdf6e3; border: 1.5px solid #e6d5a8; color: var(--warn);
  border-radius: 10px; padding: 8px 12px; font-size: 13.5px; margin: 8px 0;
}
.ratechip {
  font-size: 12.5px; padding: 4px 10px; border-radius: 99px;
  background: var(--brand-soft); color: var(--brand-dark); border: 1px solid #cfe0d7;
}
.ratechip.warn { background: #fdf6e3; color: var(--warn); border-color: #e6d5a8; }
.chk { display: flex; align-items: center; gap: 6px; cursor: pointer; font-size: 14px; }
.qrbox { margin-top: 10px; text-align: center; }
.qrbox svg { border: 1.5px solid var(--line); border-radius: 10px; background: #fff; padding: 6px; }
.kv { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }

/* ---------- الواجهة الرئيسية ---------- */
.hero { text-align: center; padding: 40px 8px 12px; }
.hero h1 {
  font-size: 46px; margin: 6px 0 2px; color: var(--brand-dark); font-weight: 700;
}
.hero .sub { font-size: 17px; color: var(--muted); max-width: 640px; margin: 0 auto; }
.tagline {
  display: inline-block; font-size: 12.5px; color: var(--brand-dark);
  background: var(--brand-soft); border: 1px solid #cfe0d7;
  padding: 3px 12px; border-radius: 99px;
}
.mock {
  display: inline-block; background: #fff; border: 1.5px solid var(--line2);
  border-radius: 10px; padding: 10px 14px; margin-top: 18px; text-align: center;
  box-shadow: var(--shadow);
}
.mock .mname { font-family: var(--head); font-weight: 600; font-size: 14px; }
.mock .bars {
  height: 26px; margin: 6px auto; width: 150px;
  background: repeating-linear-gradient(90deg,
    var(--ink) 0 2px, transparent 2px 4px, var(--ink) 4px 7px, transparent 7px 9px,
    var(--ink) 9px 10px, transparent 10px 14px, var(--ink) 14px 18px, transparent 18px 19px);
}
.mock .mprice { font-family: var(--head); font-weight: 700; color: var(--price); font-size: 18px; }
.steps { padding-inline-start: 20px; margin: 8px 0 0; }
.steps li { margin-bottom: 8px; }

/* ---------- قائمة الأصناف ---------- */
.prow {
  display: flex; gap: 10px; align-items: center; padding: 10px;
  border: 1.5px solid var(--line); border-radius: var(--radius);
  margin: 8px 0; background: #fff;
}
.prow img, .noimg {
  width: 52px; height: 52px; border-radius: 10px; object-fit: cover;
  border: 1px solid var(--line2); flex: none;
}
.noimg { display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 11px; background: var(--bg); }
.noimg.sm { width: 36px; height: 36px; border-radius: 8px; }
.noimg.big { width: 180px; height: 180px; font-size: 13px; }
.pinfo { min-width: 0; flex: 1; }
.pname { font-weight: 600; overflow-wrap: anywhere; }
.pcode { font-size: 11.5px; color: var(--muted); letter-spacing: 1px; }
.pprice { text-align: left; flex: none; }
.syp { font-family: var(--head); font-weight: 700; color: var(--price); font-size: 17px; white-space: nowrap; }
.baseusd { color: var(--muted); font-size: 12.5px; }
.pprice.sm { font-family: var(--head); font-weight: 700; color: var(--price); font-size: 13.5px; }
.pacts { display: flex; gap: 6px; flex: none; }
.imgpick img { width: 74px; height: 74px; object-fit: cover; border-radius: 10px; border: 1.5px solid var(--line2); }
.filein { font-size: 13px; }
.curtoggle { display: flex; gap: 0; border: 1.5px solid var(--line2); border-radius: 10px; overflow: hidden; width: fit-content; }
.cur {
  padding: 8px 16px; border: none; background: #fff; font-family: inherit;
  font-size: 14px; font-weight: 600; color: var(--muted); cursor: pointer;
}
.cur.on { background: var(--brand); color: #fff; }
.chkrow {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  border: 1.5px solid var(--line); border-radius: 10px; margin: 6px 0; background: #fff;
  cursor: pointer;
}
.chkrow img { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; border: 1px solid var(--line2); }
.chkrow .noimg { width: 40px; height: 40px; }
.chkrow .pname { flex: 1; font-size: 14.5px; font-weight: 500; }

/* ---------- بطاقة منتج عامة ---------- */
.pcard { text-align: center; max-width: 460px; margin-inline: auto; }
.pcard .pimgwrap { display: flex; justify-content: center; }
.pcard img { max-width: 100%; max-height: 260px; border-radius: var(--radius); border: 1.5px solid var(--line2); }
.bigprice { font-family: var(--head); font-weight: 700; font-size: 30px; color: var(--price); margin-top: 6px; }
.bigprice small { font-size: 16px; color: var(--ink); }
.shopname { margin-top: 8px; font-weight: 600; }

/* ---------- الماسح ---------- */
.scanner { margin-top: 12px; }
#scanner video { width: 100% !important; max-width: 420px; border-radius: var(--radius); }
.cam { width: 100%; max-width: 420px; border-radius: var(--radius); background: #000; }

/* ---------- مودال وتوست ---------- */
#modalBack {
  position: fixed; inset: 0; background: rgba(38, 34, 28, 0.45);
  display: flex; align-items: center; justify-content: center; z-index: 60; padding: 14px;
}
#modal {
  background: var(--card); border-radius: 16px; max-width: 440px; width: 100%;
  padding: 18px; max-height: 90vh; overflow: auto; box-shadow: 0 12px 40px rgba(0,0,0,0.2);
}
#toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 20px; border-radius: 12px;
  z-index: 99; opacity: 0; transition: opacity 0.25s; font-size: 14px;
  max-width: 90vw; text-align: center; pointer-events: none;
}
#toast.on { opacity: 1; }

/* ---------- الفوتر ---------- */
.foot {
  border-top: 1.5px solid var(--line); margin-top: 30px; padding: 18px 0 26px;
  text-align: center; color: var(--muted); font-size: 13px; background: var(--card);
}
.foot .credit { font-weight: 700; color: var(--brand-dark); margin-top: 4px; font-size: 14px; }

/* ---------- الطباعة A4 ---------- */
#printRoot { display: none; }
#printRoot.on {
  display: block; position: fixed; inset: 0; background: #46433b;
  overflow: auto; z-index: 80; padding: 18px 8px 96px;
}
.printbar {
  position: fixed; bottom: 0; inset-inline: 0; background: var(--card);
  border-top: 1.5px solid var(--line); padding: 10px 16px;
  display: flex; gap: 10px; align-items: center; z-index: 81; flex-wrap: wrap;
}
.sheet {
  width: 210mm; height: 296mm; background: #fff; margin: 0 auto 16px; padding: 4mm;
  display: grid; grid-template-columns: repeat(4, 1fr); grid-template-rows: repeat(5, 1fr);
  position: relative; box-shadow: 0 5px 26px rgba(0, 0, 0, 0.4);
  overflow: hidden; print-color-adjust: exact; -webkit-print-color-adjust: exact;
}
.lblc {
  border: 1px dashed #cfc8b6; margin: 0.7mm; padding: 1.6mm 1.4mm;
  display: flex; flex-direction: column; align-items: center; justify-content: space-between;
  overflow: hidden; text-align: center;
}
.lname {
  font-family: var(--head); font-weight: 600; font-size: 12pt; line-height: 1.25;
  max-height: 2.6em; overflow: hidden; width: 100%;
}
.lmid { display: flex; align-items: center; gap: 1.5mm; width: 100%; justify-content: center; }
.limg { width: 16mm; height: 16mm; object-fit: cover; border: 0.4mm solid #ddd; border-radius: 1.6mm; flex: none; }
.limg.none { display: flex; align-items: center; justify-content: center; font-size: 6pt; color: #999; background: #faf8f5; }
.lbc { flex: 1; min-width: 0; max-width: 24mm; display: flex; flex-direction: column; align-items: center; }
.qrslot { width: 100%; }
.qrslot svg { width: 100%; height: auto; display: block; }
.lcode { font-family: ui-monospace, Menlo, monospace; font-size: 8pt; color: #333; letter-spacing: 1px; }
.lprice { font-family: var(--head); font-weight: 700; font-size: 16pt; color: var(--price); line-height: 1.15; white-space: nowrap; }
.lprice small { font-size: 9.5pt; color: var(--ink); font-weight: 600; }
.lprice .usd { color: var(--muted); font-weight: 500; font-size: 9pt; margin-inline-start: 2px; }
.pcredit { position: absolute; bottom: 1.2mm; inset-inline: 0; text-align: center; font-size: 5.5pt; color: #c2bba9; }

@page { size: A4; margin: 0; }
@media print {
  html, body { background: #fff; }
  body > *:not(#printRoot) { display: none !important; }
  #printRoot, #printRoot.on {
    display: block !important; position: static; background: #fff;
    padding: 0; overflow: visible;
  }
  .printbar { display: none !important; }
  .sheet { box-shadow: none; margin: 0; page-break-after: always; }
  .sheet:last-child { page-break-after: auto; }
}

/* ---------- موبايل ---------- */
@media (max-width: 640px) {
  .hero h1 { font-size: 36px; }
  .who { display: none; }
  .prow { flex-wrap: wrap; }
  .pprice { margin-inline-start: auto; }
  .brand { font-size: 19px; }
}
