@font-face { font-family: 'YekanBakh'; font-weight: 400; src: url('../shared/fonts/yb-en-regular.ttf'); font-display: swap; }
@font-face { font-family: 'YekanBakh'; font-weight: 700; src: url('../shared/fonts/yb-en-bold.ttf'); font-display: swap; }

:root {
  --bg: #f3f3f0; --surface: #fff; --ink: #1c1d1d; --ink2: #4a4c4c; --muted: #85878a; --line: #e5e5e0; --line2: #d4d4ce;
  --accent: #0f6b5f; --accent-d: #0b5248; --accent-soft: #e4f1ee; --danger: #c0392b; --warn: #a96a00; --blue: #1d5fa8;
  --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px);
  --bar: 56px;
}
* { box-sizing: border-box; }
html { -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%; overscroll-behavior: none; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: 'YekanBakh', 'Segoe UI', Tahoma, sans-serif; font-size: 15px; -webkit-font-smoothing: antialiased; }
#app { min-height: 100dvh; }
.screen { min-height: 100dvh; display: flex; flex-direction: column; }
button, a, [role=button], .prow, .icard, .chipx { touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
button { font: inherit; color: inherit; cursor: pointer; }
input, select, textarea { font: inherit; font-size: 16px; color: inherit; }
.ltr { direction: ltr; unicode-bidi: plaintext; text-align: right; }
.grow { flex: 1; }
.mut, .hint { color: var(--muted); }
small { font-size: 11.5px; color: var(--muted); }
svg.i { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---- top bar ---- */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px; padding: calc(var(--sat) + 8px) 14px 8px; background: rgba(255,255,255,.94); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); min-height: calc(var(--bar) + var(--sat)); }
.top .logo { height: 26px; }
.top h2 { margin: 0; font-size: 17px; }
.icon-btn { width: 44px; height: 44px; border: 0; background: transparent; border-radius: 12px; display: flex; align-items: center; justify-content: center; color: var(--ink2); flex: none; }
.icon-btn:active { background: rgba(0,0,0,.07); }
.top .sync { margin-inline-start: auto; }
.top.compact .sync { margin-inline-start: 0; }
.sync { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 5px 10px; border-radius: 99px; background: #eaf5f1; color: var(--accent-d); white-space: nowrap; }
.sync i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.sync.off { background: #efefec; color: var(--ink2); }
.sync.pend { background: #fdf1dc; color: var(--warn); }
.sync.busy i { animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .25; } }

/* ---- home ---- */
.home { padding: 14px 14px calc(24px + var(--sab)); display: grid; gap: 12px; align-content: start; }
.cta { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; padding: 20px; border: 0; border-radius: 18px; background: var(--accent); color: #fff; font-size: 19px; font-weight: 700; box-shadow: 0 8px 22px rgba(15,107,95,.28); transition: transform .12s, background .12s; }
.cta:active { transform: scale(.98); background: var(--accent-d); }
.cta svg.i { width: 26px; height: 26px; stroke-width: 2.4; }
.sec { margin-top: 8px; font-weight: 700; display: flex; gap: 8px; align-items: center; }
.icard { width: 100%; text-align: right; border: 1px solid var(--line); background: var(--surface); border-radius: 16px; padding: 14px; display: grid; gap: 6px; margin-bottom: 10px; transition: transform .1s, background .1s; }
.icard:active { transform: scale(.985); background: #f9f9f6; }
.icard .r1 { display: flex; justify-content: space-between; align-items: center; }
.icard .r1 b { font-size: 16px; direction: ltr; }
.icard .r2 { font-weight: 700; }
.icard .r3 { display: flex; justify-content: space-between; color: var(--ink2); font-size: 13px; align-items: baseline; gap: 8px; }
.icard .r3 b { color: var(--accent-d); font-size: 15px; }
.chip { display: inline-flex; padding: 3px 10px; border-radius: 99px; font-size: 12px; font-weight: 700; background: #efefec; color: var(--ink2); }
.chip.amber { background: #fdf1dc; color: var(--warn); } .chip.green { background: #e4f1ee; color: var(--accent-d); } .chip.blue { background: #e6eff9; color: var(--blue); } .chip.gray { background: #efefec; color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 50px 20px; line-height: 1.9; }
.empty svg.i { width: 44px; height: 44px; opacity: .4; margin-bottom: 8px; }
.empty.small { padding: 30px; }

/* ---- builder ---- */
.searchbox { flex: 1; position: relative; }
.searchbox svg.i { position: absolute; inset-inline-start: 12px; top: 50%; transform: translateY(-50%); width: 20px; color: var(--muted); }
.searchbox input { width: 100%; height: 44px; border: 1px solid var(--line2); border-radius: 12px; padding: 0 12px; padding-inline-start: 40px; background: #fff; outline: none; }
.searchbox input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(15,107,95,.16); }
.stick { position: sticky; top: calc(var(--bar) + var(--sat)); z-index: 15; background: var(--bg); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 8px 14px 10px; background: var(--bg); scrollbar-width: none; overscroll-behavior-x: contain; }
.chips::-webkit-scrollbar { display: none; }
.chipx { flex: none; max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border: 1px solid var(--line2); background: #fff; border-radius: 99px; padding: 9px 14px; font-size: 14px; }
.chipx.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.chipx.on small { color: #bbb; }
.plist { padding: 4px 12px calc(96px + var(--sab)); display: grid; gap: 8px; align-content: start; }
.prow { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 10px; min-height: 76px; transition: transform .1s, border-color .12s, background .12s; }
.prow:active { transform: scale(.985); }
.prow.in { border-color: #b9d6d1; background: #f6fbfa; }
.prow.pop { animation: pop .22s ease-out; }
@keyframes pop { 40% { transform: scale(1.02); } }
.pimg { width: 56px; height: 56px; border-radius: 10px; background: #f3f3ef; display: flex; align-items: center; justify-content: center; overflow: hidden; flex: none; color: #b5b5ae; font-weight: 700; font-size: 20px; }
.pimg img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.pinfo { flex: 1; min-width: 0; }
.pname { font-weight: 700; line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pcode { color: var(--muted); font-size: 12px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pprice { color: var(--accent-d); font-weight: 700; margin-top: 3px; }
.pctl { flex: none; }
.add { width: 44px; height: 44px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-d); display: flex; align-items: center; justify-content: center; }
.add svg.i { stroke-width: 2.6; }
.stp { display: flex; align-items: center; gap: 2px; background: #fff; border: 1px solid var(--line2); border-radius: 99px; padding: 3px; }
.stp button { width: 38px; height: 38px; border: 0; border-radius: 50%; background: var(--accent); color: #fff; font-size: 22px; line-height: 1; display: flex; align-items: center; justify-content: center; }
.stp button[data-d="-1"] { background: #efefec; color: var(--ink); }
.stp b { min-width: 30px; text-align: center; font-size: 16px; }
.stp.v { flex-direction: column; border-radius: 22px; }
.plist.grid { grid-template-columns: 1fr 1fr; gap: 10px; }
.plist.grid .prow { flex-direction: column; align-items: stretch; padding: 0; overflow: hidden; gap: 0; }
.plist.grid .pimg { width: 100%; height: 130px; border-radius: 0; }
.plist.grid .pinfo { padding: 10px 10px 4px; }
.plist.grid .pctl { padding: 4px 10px 10px; display: flex; justify-content: center; }
.plist.grid .add { width: 100%; border-radius: 12px; height: 40px; }
.sentinel { height: 1px; }
.cartbar { position: fixed; inset-inline: 0; bottom: 0; z-index: 30; padding: 10px 12px calc(10px + var(--sab)); background: linear-gradient(to top, var(--bg) 70%, transparent); }
.cartbtn { width: 100%; height: 58px; display: flex; align-items: center; gap: 12px; padding: 0 14px; border: 0; border-radius: 16px; background: var(--ink); color: #fff; font-weight: 700; font-size: 16px; box-shadow: 0 8px 24px rgba(0,0,0,.25); }
.cartbtn:disabled { background: #cfcfc9; box-shadow: none; }
.cartbtn .cb-n { min-width: 30px; height: 30px; border-radius: 50%; background: var(--accent); display: flex; align-items: center; justify-content: center; font-size: 14px; }
.cartbtn:disabled .cb-n { background: #b5b5ae; }
.cartbtn .cb-t { flex: 1; text-align: right; }
.cartbtn b small { color: #cfd; }

/* ---- review ---- */
.review { padding: 12px 12px calc(110px + var(--sab)); display: grid; gap: 12px; align-content: start; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 14px; display: grid; gap: 8px; }
.card label, label { font-size: 12.5px; color: var(--muted); }
input:not([type=checkbox]) { width: 100%; height: 48px; border: 1px solid var(--line2); border-radius: 12px; padding: 0 12px; background: #fff; outline: none; }
input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(15,107,95,.16); }
.items { display: grid; gap: 8px; }
.ritem { display: flex; gap: 10px; align-items: center; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 10px; }
.ritem-img { width: 52px; height: 52px; border-radius: 10px; background: #f3f3ef; overflow: hidden; flex: none; }
.ritem-img img { width: 100%; height: 100%; object-fit: contain; }
.ritem-t { flex: 1; min-width: 0; }
.rrow { display: flex; align-items: center; gap: 8px; margin-top: 6px; flex-wrap: wrap; }
.rrow .unit { color: var(--ink2); font-size: 13px; }
.rrow .lt { margin-inline-start: auto; color: var(--accent-d); font-size: 16px; }
.disc { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; }
.disc input { width: 56px; height: 34px; padding: 0 6px; text-align: center; border-radius: 9px; }
.totals { background: var(--ink); color: #fff; border-radius: 16px; padding: 16px; }
.totals div { display: flex; justify-content: space-between; align-items: center; font-size: 15px; }
.totals b { font-size: 20px; }
.totals small { color: #cfd; }
.actbar { position: fixed; inset-inline: 0; bottom: 0; z-index: 30; display: flex; gap: 10px; padding: 10px 12px calc(10px + var(--sab)); background: rgba(255,255,255,.96); backdrop-filter: blur(10px); border-top: 1px solid var(--line); }
.btn { height: 52px; padding: 0 18px; border-radius: 14px; border: 1px solid var(--line2); background: #fff; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: 8px; transition: transform .1s, background .1s; }
.btn:active { transform: scale(.97); background: #f0f0ec; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:active { background: var(--accent-d); }
.btn.danger { color: var(--danger); background: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.big { width: 100%; height: 56px; font-size: 16px; }
.btn:disabled { opacity: .5; }
.seg { display: inline-flex; background: #e9e9e4; border-radius: 10px; padding: 3px; }
.seg button { border: 0; background: transparent; padding: 7px 14px; border-radius: 8px; font-size: 13.5px; }
.seg button.on { background: #fff; font-weight: 700; box-shadow: 0 1px 3px rgba(0,0,0,.12); }

/* ---- invoice view ---- */
.invview { padding: 12px 12px calc(100px + var(--sab)); display: grid; gap: 12px; align-content: start; }
.banner { padding: 11px 14px; border-radius: 12px; font-size: 13.5px; line-height: 1.7; }
.banner.amber { background: #fdf1dc; color: #7a5200; } .banner.green { background: #e4f1ee; color: var(--accent-d); } .banner.blue { background: #e6eff9; color: var(--blue); }
.pages { display: grid; gap: 10px; }
.pg { width: 100%; display: block; border-radius: 10px; border: 1px solid var(--line); background: #fff; box-shadow: 0 4px 14px rgba(0,0,0,.08); }
.skeleton { text-align: center; color: var(--muted); padding: 60px 10px; background: #fff; border-radius: 12px; border: 1px dashed var(--line2); }
.skeleton.err { color: var(--danger); }
.zoom { position: fixed; inset: 0; z-index: 90; background: #111; display: flex; flex-direction: column; }
.zoom .icon-btn { position: absolute; top: calc(var(--sat) + 8px); inset-inline-start: 8px; z-index: 2; background: rgba(255,255,255,.18); color: #fff; }
.zscroll { flex: 1; overflow: auto; touch-action: pan-x pan-y pinch-zoom; -webkit-overflow-scrolling: touch; display: flex; align-items: center; }
.zscroll img { width: 230vw; max-width: none; height: auto; }

/* ---- settings / pair ---- */
.settings { padding: 14px 14px calc(30px + var(--sab)); display: grid; gap: 12px; align-content: start; }
.kv > div { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.kv > div:last-child { border-bottom: 0; }
.kv span { color: var(--muted); }
.errrow { color: var(--danger); }
.hint.c { text-align: center; font-size: 12.5px; }
.pair { padding: calc(var(--sat) + 40px) 22px calc(30px + var(--sab)); display: grid; gap: 10px; align-content: start; max-width: 480px; margin: 0 auto; width: 100%; }
.pair .plogo { width: 150px; margin: 0 auto 8px; }
.pair h1 { margin: 0; font-size: 22px; text-align: center; }
.pair p { margin: 0 0 8px; color: var(--ink2); line-height: 1.9; text-align: center; }
.pair input.big { font-size: 26px; letter-spacing: 8px; text-align: center; height: 60px; font-weight: 700; }
.err { color: var(--danger); text-align: center; min-height: 22px; }

/* ---- sheet + toast ---- */
.sheet-ovl { position: fixed; inset: 0; z-index: 100; background: rgba(0,0,0,.4); display: flex; align-items: flex-end; animation: fade .15s; }
.sheet-ovl.out { opacity: 0; transition: opacity .16s; }
.sheet { width: 100%; background: #fff; border-radius: 22px 22px 0 0; padding: 10px 18px calc(18px + var(--sab)); animation: up .2s ease-out; }
.sheet .grab { width: 40px; height: 4px; background: #d6d6d0; border-radius: 4px; margin: 0 auto 14px; }
.sheet h3 { margin: 0 0 6px; } .sheet p { margin: 0 0 16px; color: var(--ink2); line-height: 1.8; }
.sheet-act { display: grid; gap: 8px; }
@keyframes up { from { transform: translateY(100%); } }
@keyframes fade { from { opacity: 0; } }
#toast { position: fixed; inset-inline: 16px; bottom: calc(90px + var(--sab)); z-index: 120; background: var(--ink); color: #fff; padding: 13px 16px; border-radius: 14px; text-align: center; opacity: 0; transform: translateY(10px); pointer-events: none; transition: opacity .18s, transform .18s; }
#toast.show { opacity: 1; transform: none; }
#toast.err { background: var(--danger); }

@media (hover: hover) and (pointer: fine) {
  .prow:hover { border-color: var(--line2); }
  .btn:hover { background: #f6f6f2; }
  .btn.primary:hover { background: var(--accent-d); }
  .icard:hover { background: #fafaf7; }
}
@media (min-width: 700px) { .plist.list, .home, .review, .invview, .settings { max-width: 640px; margin-inline: auto; width: 100%; } .plist.grid { grid-template-columns: repeat(3, 1fr); max-width: 760px; margin-inline: auto; } }

/* showroom code */
.srbar { padding: 8px 12px 0; }
.srin { display: flex; align-items: center; gap: 10px; background: #fff; border: 2px solid var(--accent); border-radius: 14px; padding: 4px 6px 4px 14px; }
.srin span { font-weight: 700; color: var(--accent-d); white-space: nowrap; }
.srin input { border: 0; height: 46px; font-size: 24px; font-weight: 700; text-align: center; letter-spacing: 4px; box-shadow: none !important; background: transparent; }
.srmiss { margin: 8px 12px 0; padding: 10px 14px; background: #fdf1dc; color: #7a5200; border-radius: 12px; font-size: 13.5px; }
.srcard { margin: 8px 12px 0; background: #fff; border: 1px solid #b9d6d1; border-radius: 16px; padding: 10px; display: grid; gap: 10px; max-height: 46vh; overflow: auto; overscroll-behavior: contain; }
.srh { display: flex; gap: 10px; align-items: center; }
.srthumb { width: 54px; height: 54px; border-radius: 10px; background: #f3f3ef; overflow: hidden; flex: none; }
.srthumb img { width: 100%; height: 100%; object-fit: contain; }
.srt { min-width: 0; } .srt b { display: block; line-height: 1.5; } .srt small { display: block; }
.srv { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.srbtn { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 62px; justify-content: center; border: 1px solid var(--line2); background: #fff; border-radius: 14px; padding: 8px; transition: transform .1s, background .1s; }
.srbtn b { font-size: 16px; } .srbtn span { color: var(--accent-d); font-weight: 700; font-size: 14px; }
.srbtn:active { transform: scale(.96); background: var(--accent-soft); }
.srbtn.in { border-color: var(--accent); background: #f1f9f7; }
.srbtn i { position: absolute; top: 6px; inset-inline-start: 6px; min-width: 22px; height: 22px; border-radius: 11px; background: var(--accent); color: #fff; font-style: normal; font-size: 12px; display: flex; align-items: center; justify-content: center; padding: 0 5px; }
.searchbox input { padding-inline-start: 42px !important; }

textarea { width: 100%; border: 1px solid var(--line2); border-radius: 12px; padding: 10px 12px; font: inherit; font-size: 16px; line-height: 1.9; background: #fff; outline: none; resize: vertical; min-height: 84px; }
textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(15,107,95,.16); }
.qn { display: flex; flex-wrap: wrap; gap: 6px; }
.qn button { border: 1px solid var(--line2); background: #fff; border-radius: 99px; padding: 8px 12px; font-size: 13px; color: var(--ink2); max-width: 100%; }
.qn button:active { background: var(--accent-soft); }

/* ---- send-to-customer sheet ---- */
.sheet.send { max-height: 92vh; overflow-y: auto; display: grid; gap: 10px; }
.sheet.send h3 { margin: 0; }
.sheet.send .lbl { font-size: 13px; color: var(--ink2); margin-top: 4px; }
.sheet.send input { width: 100%; }
.msgrs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.mchip { position: relative; display: flex; align-items: center; gap: 8px; justify-content: center; padding: 14px 10px; border: 2px solid var(--line2); border-radius: 14px; background: #fff; font-size: 16px; color: var(--ink2); touch-action: manipulation; }
.mchip i { width: 12px; height: 12px; border-radius: 50%; background: var(--c); opacity: .35; }
.mchip.on { border-color: var(--c); color: var(--ink); background: color-mix(in srgb, var(--c) 9%, #fff); font-weight: 700; }
.mchip.on i { opacity: 1; }
.mchip .ok { display: none; color: var(--c); }
.mchip.sent .ok { display: inline; }
.sstat { font-size: 13px; color: var(--ink2); display: flex; align-items: center; gap: 8px; min-height: 22px; }
.sstat.bad { color: var(--danger, #b3261e); }
.sstat .okc { color: #1a8a5a; }
.spin { width: 14px; height: 14px; border: 2px solid var(--line2); border-top-color: var(--accent); border-radius: 50%; animation: sp .8s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }
.sec-act { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.sheet.send .hint.c { text-align: center; margin: 0; min-height: 0; }
