:root {
  --g: #1f6b3a; --g2: #2f8a4e; --gl: #e6f2e9; --bg: #f6f3ea; --card: #fff; --ink: #1d2a22; --mut: #6b776f; --line: #e5e1d6;
  --red: #c0392b; --amber: #d68910; --blue: #2471a3; --purple: #7d3c98; --wa: #25d366;
  --r: 14px; --sh: 0 1px 2px rgba(0,0,0,.05), 0 4px 14px rgba(31,107,58,.06);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Naskh Arabic", "Geeza Pro", Tahoma, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 16px; -webkit-tap-highlight-color: transparent; }
[dir=rtl] body { font-size: 17px; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0 0 .4em; line-height: 1.3; }
h2 { font-size: 1.35rem; } h3 { font-size: 1.05rem; }
small { font-size: .78em; }
.muted { color: var(--mut); } .red { color: var(--red) !important; } .green { color: var(--g2); } .center { text-align: center; }
.loading { font-size: 3rem; text-align: center; padding: 30vh 0; }

/* layout */
#app { min-height: 100vh; }
#side { display: none; }
#body { padding-bottom: 84px; }
#top { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 16px; background: var(--g); color: #fff; }
#top:empty { display: none; }
.shopname { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who { font-size: .8rem; opacity: .9; white-space: nowrap; display: flex; align-items: center; gap: 6px; }
.net { width: 8px; height: 8px; border-radius: 50%; background: #f1948a; display: inline-block; } .net.on { background: #82e0aa; }
#main { padding: 14px; max-width: 1200px; margin: 0 auto; }
#bottom { position: fixed; bottom: 0; left: 0; right: 0; z-index: 6; display: flex; background: #fff; border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
#bottom:empty { display: none; }
#bottom a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 2px 9px; font-size: .72rem; color: var(--mut); }
#bottom a i { font-style: normal; font-size: 1.35rem; filter: grayscale(1); opacity: .7; }
#bottom a.on { color: var(--g); font-weight: 700; } #bottom a.on i { filter: none; opacity: 1; }
body.bare #body { padding-bottom: 0; }

@media (min-width: 900px) {
  #app { display: grid; grid-template-columns: 220px 1fr; }
  body.bare #app { display: block; }
  #side { display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh; background: var(--g); color: #e8f3ea; padding: 14px 10px; overflow-y: auto; }
  #side:empty { display: none; }
  #side .brand { font-size: 1.15rem; padding: 6px 10px 16px; color: #fff; }
  #side a { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 10px; }
  #side a i { font-style: normal; width: 22px; text-align: center; }
  #side a:hover { background: rgba(255,255,255,.08); }
  #side a.on { background: #fff; color: var(--g); font-weight: 700; }
  #side .lock { margin-top: auto; opacity: .85; }
  #bottom { display: none !important; }
  #body { padding-bottom: 0; }
  #top { background: transparent; color: var(--ink); border-bottom: 1px solid var(--line); position: static; }
  #main { padding: 22px 26px; }
}

/* basics */
.card { background: var(--card); border-radius: var(--r); padding: 14px; box-shadow: var(--sh); margin-bottom: 14px; }
.card.soft { background: var(--gl); box-shadow: none; }
.card-h { display: flex; justify-content: space-between; align-items: baseline; }
.card-h a { color: var(--g); font-size: .85rem; font-weight: 600; }
.row { display: flex; align-items: flex-end; } .row.wrap { flex-wrap: wrap; } .gap { gap: 10px; } .grow { flex: 1; min-width: 0; }
.grid2 { display: grid; gap: 14px; } .grid2 > .card { margin: 0; }
@media (min-width: 760px) { .grid2 { grid-template-columns: 1fr 1fr; } .grid2 .wide { grid-column: 1 / -1; } }
.pagehead { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.pagehead h2 { margin: 0; }
.pagehead .row { flex-wrap: wrap; }
@media (max-width: 560px) { .pagehead .row { width: 100%; } .pagehead .row .btn { flex: 1; } }
#main { overflow-x: clip; }
.brow > * { min-width: 0; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 8px 16px; border-radius: 12px; border: 1.5px solid var(--line); background: #fff; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--g); border-color: var(--g); color: #fff; }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.danger.ghost { background: #fff; color: var(--red); border-color: #f2c4be; }
.btn.ghost { background: transparent; }
.btn.wa { background: var(--wa); border-color: var(--wa); color: #073b1c; }
.btn.big { min-height: 54px; font-size: 1.08rem; width: 100%; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.linkbtn { background: none; border: 0; color: var(--mut); text-decoration: underline; cursor: pointer; padding: 8px; }

.f { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; flex: 1; min-width: 0; }
.f > span { font-size: .82rem; color: var(--mut); font-weight: 600; }
input, select { width: 100%; min-height: 46px; padding: 8px 12px; border: 1.5px solid var(--line); border-radius: 11px; background: #fff; outline: none; }
input:focus, select:focus { border-color: var(--g2); box-shadow: 0 0 0 3px rgba(47,138,78,.15); }
.check { display: flex; align-items: center; gap: 8px; margin: 6px 0 12px; cursor: pointer; white-space: nowrap; }
.check input { width: 20px; min-height: 20px; height: 20px; accent-color: var(--g); }
.hint { font-size: .82rem; color: var(--mut); margin: -2px 0 12px; } .hint.err { color: var(--red); font-weight: 600; }
.search { margin-bottom: 10px; background: #fff url() no-repeat; }

.seg { display: flex; background: #ebe7dc; border-radius: 12px; padding: 4px; gap: 4px; margin-bottom: 12px; }
.seg button { flex: 1; border: 0; background: transparent; padding: 9px 6px; border-radius: 9px; cursor: pointer; font-weight: 600; color: var(--mut); line-height: 1.25; }
.seg button small { display: block; font-weight: 400; }
.seg button.on { background: #fff; color: var(--g); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.seg.mode button.on { background: var(--g); color: #fff; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 10px; scrollbar-width: none; }
.chips button { border: 1.5px solid var(--line); background: #fff; border-radius: 999px; padding: 7px 14px; white-space: nowrap; cursor: pointer; font-weight: 600; }
.chips button.on { background: var(--g); border-color: var(--g); color: #fff; }

.li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 11px 4px; border-bottom: 1px solid var(--line); width: 100%; background: none; border-left: 0; border-right: 0; border-top: 0; text-align: start; }
.li:last-child { border-bottom: 0; }
.li.link { cursor: pointer; } .li.link:hover { background: #faf8f2; }
.li.big { padding: 15px 6px; }
.li small { display: inline; }
.li .amt { text-align: end; white-space: nowrap; font-weight: 700; } .li .amt small { display: block; font-weight: 600; }
.li.cancelled { opacity: .5; text-decoration: line-through; }
.empty { text-align: center; color: var(--mut); padding: 26px 10px; } .empty.big { font-size: 1.2rem; padding: 60px 10px; } .empty .btn { margin-top: 10px; }
.alert { display: block; padding: 12px 14px; border-radius: 12px; margin-bottom: 12px; font-weight: 600; }
.alert.warn { background: #fdf2dc; color: #8a5a00; border: 1px solid #f5d899; }

/* home */
.hello { margin: 4px 0 14px; } .hello h1 { font-size: 1.4rem; margin: 0; }
.quick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
@media (min-width: 760px) { .quick { grid-template-columns: repeat(4, 1fr); } }
.qbtn { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 16px 14px; border-radius: 16px; color: #fff; border: 0; cursor: pointer; text-align: start; min-height: 108px; box-shadow: var(--sh); }
.qbtn i { font-style: normal; font-size: 1.8rem; margin-bottom: 4px; } .qbtn span { font-weight: 800; font-size: 1.08rem; } .qbtn small { opacity: .85; }
.qbtn.green { background: linear-gradient(135deg, #1f6b3a, #2f8a4e); } .qbtn.blue { background: linear-gradient(135deg, #1b4f72, #2471a3); }
.qbtn.amber { background: linear-gradient(135deg, #b9770e, #d68910); } .qbtn.purple { background: linear-gradient(135deg, #6c3483, #8e44ad); }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
@media (min-width: 760px) { .stats { grid-template-columns: repeat(4, 1fr); } .stats.three { grid-template-columns: repeat(3, 1fr); } }
.stat { background: #fff; border-radius: var(--r); padding: 12px 14px; box-shadow: var(--sh); display: flex; flex-direction: column; gap: 2px; border-inline-start: 4px solid var(--g2); }
.stat span { font-size: .8rem; color: var(--mut); font-weight: 600; } .stat b { font-size: 1.25rem; } .stat small { color: var(--mut); }
.stat.warn { border-color: var(--amber); } .stat.good { border-color: var(--g); }

/* bill */
.billgrid { display: grid; gap: 14px; }
@media (min-width: 900px) { .billgrid { grid-template-columns: 1fr 380px; align-items: start; } .col-cart { position: sticky; top: 16px; } }
.ptiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.ptile { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: start; background: #fff; border: 1.5px solid var(--line); border-radius: 14px; padding: 12px 12px 10px; cursor: pointer; border-top: 5px solid var(--g2); min-height: 118px; }
.ptile:hover { border-color: var(--g2); } .ptile:active { transform: scale(.97); }
.ptile.c-pest { border-top-color: var(--purple); } .ptile.c-seed { border-top-color: var(--amber); }
.ptile b { font-size: 1rem; line-height: 1.2; } .ptile small { color: var(--mut); }
.ptile .prate { margin-top: auto; font-weight: 800; color: var(--g); } .ptile .prate i { font-style: normal; font-weight: 500; font-size: .75em; color: var(--mut); }
.ptile .pstock { font-size: .75rem; color: var(--mut); } .ptile .pstock.low { color: var(--red); font-weight: 700; }
.ptile.out { opacity: .55; }
.custbtn { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; border-radius: 12px; border: 1.5px dashed var(--g2); background: var(--gl); cursor: pointer; text-align: start; margin-bottom: 8px; }
.cb-ic { font-size: 1.3rem; } .cb-t { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.cb-t small { color: var(--mut); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .custbtn i { font-style: normal; font-size: 1.5rem; color: var(--g); }
.cart { max-height: 46vh; overflow-y: auto; }
.citem { display: flex; justify-content: space-between; gap: 10px; width: 100%; padding: 10px 4px; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: start; cursor: pointer; }
.citem small { display: block; color: var(--mut); }
.cartfoot { display: flex; gap: 12px; align-items: center; padding-top: 12px; }
.cartfoot > div { display: flex; flex-direction: column; } .cartfoot > div b { font-size: 1.4rem; white-space: nowrap; }
.cartfoot .btn.big { width: auto; flex: 1; }
@media (max-width: 899px) {
  .col-cart { position: sticky; bottom: 70px; z-index: 4; box-shadow: 0 -4px 20px rgba(0,0,0,.08); }
  .col-cart { padding: 10px 12px; margin-bottom: 0; }
  .col-cart .cart { max-height: 22vh; }
  .col-cart .cart .empty { display: none; }
  .col-cart .cartfoot { padding-top: 6px; }
  .col-cart .linkbtn { display: none; }
  [dir=rtl] .cb-t small { direction: rtl; }
}

/* sheet */
#sheet-wrap { position: fixed; inset: 0; z-index: 50; }
#sheet-bg { position: absolute; inset: 0; background: rgba(20,30,24,.45); opacity: 0; transition: opacity .18s; }
#sheet { position: absolute; left: 0; right: 0; bottom: 0; max-height: 92vh; overflow-y: auto; background: #fff; border-radius: 20px 20px 0 0; padding: 20px 16px calc(18px + env(safe-area-inset-bottom)); transform: translateY(100%); transition: transform .2s ease-out; }
#sheet-wrap.open #sheet-bg { opacity: 1; } #sheet-wrap.open #sheet { transform: none; }
@media (min-width: 700px) {
  #sheet { left: 50%; right: auto; bottom: auto; top: 50%; width: 520px; border-radius: 20px; transform: translate(-50%, -45%); opacity: 0; transition: .18s; }
  #sheet-wrap.open #sheet { transform: translate(-50%, -50%); opacity: 1; }
  #sheet.small { width: 400px; }
}
.sheet-x { position: absolute; top: 12px; inset-inline-end: 12px; width: 36px; height: 36px; border-radius: 50%; border: 0; background: #f0ede4; cursor: pointer; }
#sheet h3 { padding-inline-end: 40px; }
.qhead { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; } .qhead h3 { margin: 0; }
.pcat { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; font-size: 1.5rem; background: var(--gl); flex: none; }
.pcat.c-pest { background: #f3e5f5; } .pcat.c-seed { background: #fdf2dc; }
.qtyrow { display: flex; gap: 8px; } .qtyrow input { text-align: center; font-size: 1.5rem; font-weight: 800; }
.step { width: 56px; flex: none; border-radius: 11px; border: 1.5px solid var(--line); background: #f6f3ea; font-size: 1.6rem; cursor: pointer; }
.amountline, .sumline { display: flex; justify-content: space-between; align-items: center; padding: 10px 2px; font-weight: 600; }
.amountline b, .sumline.big b { font-size: 1.5rem; color: var(--g); }
.sumline { border-bottom: 1px dashed var(--line); }
.plist { max-height: 40vh; overflow-y: auto; margin-bottom: 10px; }
.walkin { margin-bottom: 14px; } .walkin > b { display: block; margin-bottom: 8px; }
#sheet h4 { margin: 8px 0; color: var(--mut); }

/* tables */
.table { padding: 6px 14px; } .table h3 { padding-top: 8px; }
.tr { display: grid; grid-template-columns: 2fr 1.2fr 1fr; gap: 10px; align-items: center; padding: 11px 2px; border: 0; border-bottom: 1px solid var(--line); width: 100%; background: none; text-align: start; }
button.tr, a.tr { cursor: pointer; } button.tr:hover, a.tr:hover { background: #faf8f2; }
.tr small { display: block; color: var(--mut); } .tr:last-child { border-bottom: 0; }
.tr.th { font-size: .78rem; color: var(--mut); font-weight: 700; text-transform: uppercase; }
.ledger .tr { grid-template-columns: 1fr 1.8fr 1fr 1fr 1fr; font-size: .92rem; }
@media (max-width: 560px) { .ledger .tr { grid-template-columns: 1.1fr 1.6fr .9fr .9fr 1fr; font-size: .8rem; gap: 6px; } }

/* party */
.balbox { border-radius: 16px; padding: 18px; text-align: center; background: var(--gl); margin-bottom: 12px; }
.balbox span { display: block; color: var(--mut); font-weight: 600; } .balbox b { font-size: 2rem; }
.balbox.due { background: #fdecea; } .balbox.due b { color: var(--red); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }

/* rate board — like the chalk board outside the shop */
.board { background: #22392b; background-image: radial-gradient(rgba(255,255,255,.05) 1px, transparent 1px); background-size: 14px 14px; border: 10px solid #8b5e34; border-radius: 14px; padding: 16px; color: #f4f1e4; box-shadow: inset 0 0 30px rgba(0,0,0,.4), var(--sh); }
.board-h { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 6px; border-bottom: 2px dashed rgba(255,255,255,.25); padding-bottom: 10px; margin-bottom: 6px; }
.board-h b { font-size: 1.2rem; color: #ffe27a; }
.board-cat { margin: 14px 0 4px; font-weight: 800; color: #ffe27a; letter-spacing: .03em; }
.brow { display: grid; grid-template-columns: minmax(0,1fr) auto 110px 92px 34px; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px dashed rgba(255,255,255,.12); }
.brow.changed { background: rgba(255,226,122,.08); }
.bname { font-weight: 700; } .bname small { display: block; color: rgba(244,241,228,.6); font-weight: 400; }
.bch { font-size: .75rem; font-weight: 700; } .bch.up { color: #f1948a; } .bch.down { color: #82e0aa; }
.bin { display: flex; flex-direction: column; } .bin small { font-size: .65rem; color: rgba(244,241,228,.6); }
.bin input { min-height: 40px; background: rgba(0,0,0,.25); border-color: rgba(255,255,255,.2); color: #ffe27a; font-weight: 800; font-size: 1.05rem; text-align: center; padding: 4px; }
.bval { color: #ffe27a; font-weight: 800; font-size: 1.1rem; text-align: end; } .bval small { color: rgba(244,241,228,.6); font-weight: 400; } .bval.sm { font-size: .9rem; }
.bhist { background: none; border: 0; cursor: pointer; font-size: 1rem; opacity: .6; }
@media (max-width: 560px) { .brow { grid-template-columns: minmax(0,1fr) 84px 66px 24px; gap: 6px; } .bch { display: none; } .board { padding: 12px 10px; border-width: 7px; } }

/* reports */
.rp-range { align-items: flex-end; margin-bottom: 8px; } .rp-range .chips { flex: 1 1 100%; }
@media (min-width: 900px) { .rp-range .chips { flex: 1; } .rp-range .f { flex: 0 0 170px; } }
.bars { display: flex; align-items: flex-end; gap: 4px; height: 140px; padding-top: 10px; }
.bar { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; }
.bar i { display: block; width: 100%; max-width: 30px; background: linear-gradient(var(--g2), var(--g)); border-radius: 5px 5px 2px 2px; }
.bar small { color: var(--mut); font-size: .65rem; }

/* setup / login */
.setup { max-width: 440px; margin: 6vh auto; padding: 26px 22px; text-align: center; }
.setup .f { text-align: start; } .setup h1 { color: var(--g); } .setup .btn { margin-top: 6px; width: 100%; }
.logo { font-size: 3.2rem; }
.lang { max-width: 240px; margin: 10px auto 16px; }
.people { display: grid; gap: 10px; }
.person { padding: 16px; border-radius: 14px; border: 1.5px solid var(--line); background: #fff; cursor: pointer; display: flex; justify-content: space-between; align-items: center; }
.person:hover { border-color: var(--g2); }
.pindots { display: flex; justify-content: center; gap: 12px; margin: 14px 0; }
.pindots i { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--g); } .pindots i.on { background: var(--g); }
.pinpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; max-width: 280px; margin: 0 auto 10px; direction: ltr; }
.pinpad button { height: 62px; border-radius: 16px; border: 1.5px solid var(--line); background: #fff; font-size: 1.5rem; font-weight: 700; cursor: pointer; }
.pinpad button:active { background: var(--gl); }

/* bill paper */
.billone { max-width: 520px; margin: 0 auto; }
.paper { background: #fff; border-radius: 6px; box-shadow: var(--sh); padding: 18px; margin-bottom: 10px; position: relative; }
.paper::after { content: ""; position: absolute; left: 0; right: 0; bottom: -8px; height: 8px; background: radial-gradient(circle at 6px 0, transparent 6px, #fff 6px) 0 0 / 12px 8px repeat-x; }
.receipt { font-size: .92rem; }
.r-head { text-align: center; } .r-head b { font-size: 1.25rem; display: block; }
.r-title { text-align: center; margin: 8px 0; padding: 4px; border-top: 1px dashed #999; border-bottom: 1px dashed #999; font-weight: 800; letter-spacing: .05em; }
.r-meta { display: flex; justify-content: space-between; gap: 8px; margin: 3px 0; }
.r-items { width: 100%; border-collapse: collapse; margin: 10px 0; }
.r-items th { text-align: start; font-size: .75rem; border-bottom: 1px solid #333; padding: 4px 2px; }
.r-items td { padding: 6px 2px; border-bottom: 1px dotted #bbb; vertical-align: top; }
.r-items td small { display: block; color: #666; }
.r-items th:not(:first-child), .r-items td:not(:first-child) { text-align: end; white-space: nowrap; }
.r-tot > div { display: flex; justify-content: space-between; padding: 3px 0; }
.r-tot .big { font-size: 1.15rem; font-weight: 800; border-top: 1px solid #333; border-bottom: 1px solid #333; padding: 6px 0; margin: 4px 0; }
.r-tot .khata { font-weight: 700; border-top: 1px dashed #999; margin-top: 4px; padding-top: 6px; }
.r-note { margin-top: 8px; font-style: italic; } .r-foot { text-align: center; margin-top: 12px; color: #555; }
.r-cancel { text-align: center; font-size: 1.6rem; font-weight: 900; color: var(--red); border: 3px solid var(--red); margin: 10px 0; transform: rotate(-4deg); }

/* toast */
#toast { position: fixed; left: 50%; bottom: 96px; transform: translate(-50%, 20px); background: #1d2a22; color: #fff; padding: 12px 18px; border-radius: 12px; opacity: 0; pointer-events: none; transition: .2s; z-index: 60; max-width: 90vw; text-align: center; font-weight: 600; }
#toast.show { opacity: 1; transform: translate(-50%, 0); } #toast.err { background: var(--red); }
#print-area { display: none; }

/* print */
@media print {
  body > *:not(#print-area) { display: none !important; }
  #print-area { display: block !important; color: #000; }
  body { background: #fff; }
  body[data-print="58"] #print-area { width: 54mm; font-size: 10px; }
  body[data-print="80"] #print-area { width: 76mm; font-size: 11px; }
  body[data-print="A4"] #print-area .receipt { font-size: 13px; }
  .receipt { font-size: inherit; }
  .r-items th, .r-items td { padding: 2px 1px; }
}
