:root{
  --bg:#f5f2ec; --card:#fff; --ink:#1c2420; --muted:#6a746e; --line:#e4dfd5;
  --green:#0f6b4f; --green-d:#0a4f3a; --gold:#d4a017; --gold-d:#b5860d; --danger:#c0392b;
}
*{box-sizing:border-box}
[hidden]{display:none!important}
html{-webkit-text-size-adjust:100%}
body{margin:0; background:var(--bg); color:var(--ink); font-family:"Poppins",system-ui,-apple-system,"Segoe UI",Roboto,Arial,sans-serif; line-height:1.5}
button{font:inherit; color:inherit}
.ur{font-family:"Noto Nastaliq Urdu","Noto Naskh Arabic",serif; font-size:.9em; color:var(--muted); font-weight:400}
.warn{margin:12px 16px; padding:10px 14px; background:#fff3cd; border-radius:10px}

.top{padding:20px 16px 4px; max-width:1100px; margin:0 auto}
.brand{display:flex; align-items:center; gap:10px}
.hex{width:34px; height:34px; flex:none}
h1{margin:0; font-size:1.55rem; font-weight:700; letter-spacing:-.01em}
.sub{margin:2px 0 0; color:var(--muted); font-size:.92rem}

.layout{max-width:1100px; margin:0 auto; padding:12px 16px 28px; display:grid; gap:16px; grid-template-columns:1fr}
.layout>*{min-width:0}
.card{min-width:0; background:var(--card); border:1px solid var(--line); border-radius:18px; padding:16px}

/* preview */
.stage{background:conic-gradient(#f1eee7 25%,#fbfaf7 0 50%,#f1eee7 0 75%,#fbfaf7 0) 0 0/20px 20px; border:1px solid var(--line); border-radius:14px; overflow:hidden; aspect-ratio:1/1}
#cv{display:block; width:100%; height:100%; object-fit:contain}
.actions{display:flex; flex-wrap:wrap; gap:10px; margin-top:14px}
.btn{appearance:none; border:0; cursor:pointer; font-weight:600; font-size:.95rem; padding:12px 18px; border-radius:12px; flex:1 1 150px; color:#fff; transition:transform .06s,background .15s}
.btn:active{transform:scale(.98)}
.btn.primary{background:var(--green)} .btn.primary:hover{background:var(--green-d)}
.btn.gold{background:var(--gold)} .btn.gold:hover{background:var(--gold-d)}
.btn.ghost{background:#fff; color:var(--ink); border:1.5px solid var(--line)} .btn.ghost:hover{border-color:#bdb6a4}
.btn.small{flex:0 0 auto; padding:8px 18px}
.btn:disabled{opacity:.55; cursor:default}
.hint{margin:10px 2px 0; font-size:.82rem; color:var(--muted)}
.link{background:none; border:0; padding:4px; color:var(--green); text-decoration:underline; cursor:pointer; font-size:.85rem}

/* controls */
.step{padding:4px 0 16px; border-bottom:1px dashed var(--line); margin-bottom:14px}
.step:last-child{border-bottom:0; margin-bottom:0; padding-bottom:4px}
.lab{display:flex; align-items:center; flex-wrap:wrap; gap:8px; font-weight:600; font-size:.98rem; margin-bottom:10px}
.num{display:inline-grid; place-items:center; width:24px; height:24px; border-radius:50%; background:var(--green); color:#fff; font-size:.8rem}
.count{margin-left:auto; font-size:.78rem; color:var(--muted); font-weight:400}
.sub2{font-size:.82rem; color:var(--muted); margin:-4px 0 8px}
.mini{font-size:.78rem; color:var(--muted)}

input[type=text]{width:100%; min-width:0; font:inherit; font-size:1rem; padding:12px 14px; border:1.5px solid var(--line); border-radius:12px; background:#fff; color:var(--ink); outline:none}
input[type=text]:focus{border-color:var(--green); box-shadow:0 0 0 3px rgba(15,107,79,.15)}
.trow{display:flex; gap:8px; align-items:center; margin-bottom:8px}
.fbtn{flex:none; height:46px; min-width:64px; padding:0 10px; border:1.5px solid var(--line); background:#fff; border-radius:12px; cursor:pointer; font-size:1.05rem; max-width:128px; overflow:hidden; white-space:nowrap; text-overflow:ellipsis}
.fbtn:hover{border-color:#bdb6a4}

/* colour swatch buttons: rainbow ring = "tap to open the colour wheel" */
.sw{flex:none; width:38px; height:38px; padding:3px; border:0; border-radius:50%; cursor:pointer; background:conic-gradient(#f43f5e,#f59e0b,#eab308,#22c55e,#06b6d4,#3b82f6,#a855f7,#f43f5e)}
.sw i{display:block; width:100%; height:100%; border-radius:50%; background:var(--c,#000); border:2.5px solid #fff; box-shadow:inset 0 0 0 1px rgba(0,0,0,.12)}
.swrow{display:flex; flex-wrap:wrap; gap:10px; margin-bottom:12px}
.swrow .none{font-size:.85rem; color:var(--muted)}

.chips{display:flex; gap:8px; overflow-x:auto; padding-bottom:6px; scrollbar-width:thin}
.chips.wrap{flex-wrap:wrap; overflow:visible}
.chip{flex:0 0 auto; border:1.5px solid var(--line); background:#fff; border-radius:999px; padding:7px 13px; font-size:.86rem; cursor:pointer; white-space:nowrap}
.chip small{font-family:"Noto Nastaliq Urdu",serif; color:var(--muted); margin-left:4px; font-size:.95em}
.chip.on{background:var(--green); border-color:var(--green); color:#fff}
.chip.on small{color:#d6efe5}
.chips.small .chip{padding:5px 11px; font-size:.8rem}

.grid{display:grid; grid-template-columns:repeat(auto-fill,minmax(92px,1fr)); gap:10px; max-height:430px; overflow-y:auto; padding:2px; margin:0 -2px}
.tile{aspect-ratio:1; border:1.5px solid var(--line); border-radius:14px; background:#fff; padding:8px; cursor:pointer; display:grid; place-items:center; transition:border-color .15s}
.tile:hover{border-color:#bfb8a8}
.tile.on{border-color:var(--green); box-shadow:0 0 0 3px rgba(15,107,79,.18)}
.tile svg{width:100%; height:100%; display:block}
.tools{margin-top:12px}

.row{display:flex; flex-wrap:wrap; gap:12px; align-items:center; margin-bottom:12px}
.color{display:flex; align-items:center; gap:10px; font-size:.88rem}
.check{display:flex; align-items:center; gap:7px; font-size:.88rem; color:var(--ink)}
.check input{width:18px; height:18px; accent-color:var(--green)}
.seg{display:inline-flex; border:1.5px solid var(--line); border-radius:12px; overflow:hidden; max-width:100%}
.seg.wide{display:flex; flex-wrap:wrap; margin-bottom:12px}
.seg button{border:0; background:#fff; font-size:.85rem; padding:9px 14px; cursor:pointer; flex:1 1 auto}
.seg button.on{background:var(--ink); color:#fff}
.range{display:flex; align-items:center; gap:12px; font-size:.88rem; margin-top:8px}
.range span{width:92px; flex:none}
.range input{flex:1; accent-color:var(--green)}

.foot{max-width:1100px; margin:0 auto; padding:0 16px 28px; color:var(--muted); font-size:.8rem}

/* colour picker */
.pk{position:fixed; z-index:60; width:268px; background:#fff; border:1px solid var(--line); border-radius:16px; padding:12px; box-shadow:0 14px 40px rgba(20,30,25,.22)}
.pk.sheet{left:0; right:0; bottom:0; top:auto; width:auto; border-radius:20px 20px 0 0; padding:14px 16px 18px; max-height:86vh; overflow:auto}
.pk-head,.pop-head,.sheet-head{display:flex; align-items:center; justify-content:space-between; gap:8px; margin-bottom:8px; font-size:.92rem}
.pk-x{background:none; border:0; font-size:1.6rem; line-height:1; cursor:pointer; color:var(--muted); padding:0 4px}
.pk-sv{position:relative; height:150px; border-radius:10px; touch-action:none; cursor:crosshair}
.pk-svh{position:absolute; width:18px; height:18px; margin:-9px 0 0 -9px; border-radius:50%; border:3px solid #fff; box-shadow:0 0 0 1.5px rgba(0,0,0,.5); pointer-events:none}
.pk-hue{position:relative; height:16px; border-radius:8px; margin:12px 0; touch-action:none; background:linear-gradient(to right,#f00,#ff0,#0f0,#0ff,#00f,#f0f,#f00)}
.pk-hueh{position:absolute; top:-3px; width:22px; height:22px; margin-left:-11px; border-radius:50%; border:3px solid #fff; box-shadow:0 0 0 1.5px rgba(0,0,0,.5); pointer-events:none}
.pk-row{display:flex; gap:8px; align-items:center}
.pk-cur{width:38px; height:38px; border-radius:10px; border:1px solid var(--line); flex:none}
.pk-hex{flex:1; min-width:0; font:inherit; font-size:.95rem; text-transform:uppercase; padding:8px 10px; border:1.5px solid var(--line); border-radius:10px}
.pk-eye{display:block; width:100%; margin-top:8px; border:1.5px solid var(--line); background:#fff; border-radius:10px; padding:7px 10px; font-size:.8rem; cursor:pointer}
.pk-lab{font-size:.75rem; color:var(--muted); margin:12px 0 6px; text-transform:uppercase; letter-spacing:.04em}
.pk-grid,.pk-rec{display:flex; flex-wrap:wrap; gap:6px}
.pk-grid{display:grid; grid-template-columns:repeat(8,1fr)}
.pk-s{width:100%; aspect-ratio:1; min-width:22px; border-radius:7px; border:1px solid rgba(0,0,0,.14); padding:0; cursor:pointer}
.pk-rec .pk-s{width:26px; height:26px; aspect-ratio:auto}
.pk-none{font-size:.78rem; color:var(--muted)}
.pk-done{display:none; width:100%; margin-top:14px; padding:12px; border:0; border-radius:12px; background:var(--green); color:#fff; font-weight:600}
.pk.sheet .pk-done{display:block}

/* font popup */
.pop{position:fixed; z-index:60; width:360px; max-width:calc(100vw - 16px); max-height:min(70vh,560px); display:flex; flex-direction:column; background:#fff; border:1px solid var(--line); border-radius:16px; padding:12px; box-shadow:0 14px 40px rgba(20,30,25,.22)}
.pop.sheet{left:0!important; right:0; bottom:0; top:auto!important; width:auto; max-width:none; max-height:80vh; border-radius:20px 20px 0 0}
.flist{overflow-y:auto; margin-top:8px; border-top:1px solid var(--line)}
.frow{display:flex; align-items:center; justify-content:space-between; gap:10px; width:100%; text-align:left; background:none; border:0; border-bottom:1px solid #f0ece3; padding:9px 6px; cursor:pointer}
.frow:hover{background:#faf8f3}
.frow.on{background:#eaf5f0}
.frow .s{font-size:1.45rem; line-height:1.35; color:var(--ink); overflow:hidden; text-overflow:ellipsis; white-space:nowrap}
.frow .n{font-size:.72rem; color:var(--muted); flex:none}
.frow.rtl .s{direction:rtl}

/* modals */
.modal{position:fixed; inset:0; z-index:70; background:rgba(20,28,24,.55); display:flex; align-items:center; justify-content:center; padding:12px}
.sheet{position:relative; background:#fff; border-radius:20px; padding:18px; width:100%; max-height:94vh; overflow:auto}
.editsheet{max-width:720px}
.paysheet{max-width:520px}
.paysheet .pk-x{position:absolute; right:12px; top:8px}
.paysheet h2{margin:0 24px 6px 0; font-size:1.2rem}
.lead{margin:0 0 12px; color:var(--muted); font-size:.92rem}
.steps{margin:0; padding-left:20px; display:grid; gap:14px; font-size:.92rem}
.accts{display:grid; gap:6px; margin-top:6px}
.acct{display:flex; justify-content:space-between; align-items:center; gap:8px; background:#f6f3ec; border-radius:10px; padding:8px 12px}
.acct b{font-size:1rem; letter-spacing:.02em}
.acct small{display:block; color:var(--muted)}
.acct button{border:1.5px solid var(--line); background:#fff; border-radius:8px; padding:5px 10px; font-size:.78rem; cursor:pointer}
.steps .btn{margin-top:8px; width:100%}
.steps .trow{margin-top:8px}
.steps li{min-width:0}
.steps .trow{display:flex; gap:8px; align-items:stretch}
.steps .trow input{flex:1 1 0; min-width:0; width:auto}
.steps .trow .btn{flex:0 0 auto; width:auto; margin-top:0; padding:12px 20px}
.paysheet{overflow-x:hidden}
.msg{min-height:1.4em; margin:10px 0 0; font-size:.88rem; color:var(--danger)}
.msg.ok{color:var(--green)}
.editstage{background:conic-gradient(#f1eee7 25%,#fbfaf7 0 50%,#f1eee7 0 75%,#fbfaf7 0) 0 0/20px 20px; border:1px solid var(--line); border-radius:14px; margin:10px 0; touch-action:pan-y}
.editstage svg{display:block; width:100%; max-height:58vh; margin:0 auto}
.editstage.erase{touch-action:none; cursor:crosshair}
.editstage .ep{cursor:pointer; transition:opacity .12s}
.editstage .ep:hover{opacity:.7}
.editstage .ep.off{opacity:.13}
.editstage .lasso{fill:rgba(192,57,43,.2); stroke:#c0392b; stroke-dasharray:6 5; vector-effect:non-scaling-stroke; stroke-width:2}
.editstage .cutline{fill:none; stroke:#c0392b; stroke-dasharray:6 5; vector-effect:non-scaling-stroke; stroke-width:1.5; pointer-events:none}

@media (min-width:900px){
  .layout{grid-template-columns:1.05fr 1fr; align-items:start}
  .controls{order:1}
  .preview{order:2; position:sticky; top:16px}
  h1{font-size:1.85rem}
}
@media (max-width:639px){
  .sheet{border-radius:20px 20px 0 0; align-self:flex-end}
  .modal{padding:0; align-items:flex-end}
  .editsheet{max-height:96vh}
}

/* business search + family chips */
.nsearch{position:relative;margin-bottom:10px}
.nsearch input{width:100%;min-width:0;font:inherit;font-size:.98rem;padding:11px 14px;border:1.5px solid var(--line);border-radius:12px;background:#fff;color:var(--ink);outline:none}
.nsearch input:focus{border-color:var(--green);box-shadow:0 0 0 3px rgba(15,107,79,.15)}
.nres{position:absolute;left:0;right:0;top:calc(100% + 4px);z-index:30;background:#fff;border:1.5px solid var(--line);border-radius:12px;box-shadow:0 12px 30px rgba(0,0,0,.15);max-height:290px;overflow:auto}
.nres button{display:flex;gap:8px;justify-content:space-between;align-items:center;width:100%;text-align:left;border:0;background:none;padding:10px 14px;font:inherit;font-size:.92rem;cursor:pointer;color:var(--ink);border-bottom:1px solid #f1eee7}
.nres button:last-child{border-bottom:0}
.nres button:hover,.nres button.hl{background:#eef7f2}
.nres small{color:var(--muted);font-size:.78rem;flex:0 0 auto}
.nres .none{padding:12px 14px;color:var(--muted);font-size:.9rem}
.chips.small{margin-top:8px}
.chips.small:empty{display:none}
.chips.small .chip{font-size:.8rem;padding:5px 11px}
