:root {
  --brand: #0f766e; --brand-dark: #115e59; --brand-soft: #e6f6f4;
  --ink: #1f2933; --muted: #6b7280; --line: #e5e7eb; --bg: #f6f5f3; --card: #fff;
  --good: #15803d; --good-soft: #dcfce7; --warn: #b45309; --warn-soft: #fef3c7; --bad: #b91c1c; --bad-soft: #fee2e2;
  --info: #1d4ed8; --info-soft: #dbeafe;
  --radius: 14px; --nav-h: 62px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); -webkit-tap-highlight-color: transparent; }
body { padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px)); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand-dark); }
[hidden] { display: none !important; }

/* top bar */
.topbar { position: sticky; top: 0; z-index: 20; background: var(--brand); color: #fff;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px; display: flex; align-items: center; gap: 10px; }
.topbar .back { background: none; border: 0; color: #fff; font-size: 24px; padding: 0 6px 0 0; cursor: pointer; }
.logo { font-weight: 800; font-size: 21px; letter-spacing: -.3px; }
.logo small { font-weight: 500; font-size: 12px; opacity: .85; margin-left: 6px; }
.topbar .title { font-weight: 700; font-size: 17px; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

main { max-width: 760px; margin: 0 auto; padding: 14px 14px 24px; }

/* bottom nav */
.nav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; background: #fff; border-top: 1px solid var(--line);
  display: flex; justify-content: space-around; height: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px); }
.nav a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  text-decoration: none; color: var(--muted); font-size: 11.5px; position: relative; }
.nav a .ic { font-size: 21px; line-height: 1; }
.nav a.on { color: var(--brand); font-weight: 700; }
.nav a.sell .ic { background: var(--brand); color: #fff; width: 46px; height: 46px; border-radius: 50%;
  display: grid; place-items: center; margin-top: -22px; box-shadow: 0 4px 12px rgba(15, 118, 110, .4); font-size: 26px; }
.badge { position: absolute; top: 6px; right: calc(50% - 22px); background: var(--bad); color: #fff; border-radius: 9px;
  font-size: 10.5px; min-width: 17px; height: 17px; display: grid; place-items: center; padding: 0 4px; font-weight: 700; }

/* generic */
.card { background: var(--card); border-radius: var(--radius); box-shadow: 0 1px 3px rgba(0,0,0,.06); padding: 14px; margin-bottom: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
h2 { font-size: 18px; margin: 4px 0 10px; }
h3 { font-size: 15px; margin: 0 0 8px; }
.btn { border: 0; border-radius: 10px; padding: 11px 16px; font-weight: 700; cursor: pointer; background: var(--brand); color: #fff; }
.btn:disabled { opacity: .55; }
.btn.ghost { background: var(--brand-soft); color: var(--brand-dark); }
.btn.line { background: #fff; border: 1.5px solid var(--line); color: var(--ink); }
.btn.danger { background: var(--bad-soft); color: var(--bad); }
.btn.ok { background: var(--good); }
.btn.block { width: 100%; }
.btn.sm { padding: 7px 11px; font-size: 13px; border-radius: 8px; }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: #f1f5f9; color: #334155; }
.pill.good { background: var(--good-soft); color: var(--good); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.info { background: var(--info-soft); color: var(--info); }
.pill.brand { background: var(--brand-soft); color: var(--brand-dark); }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.empty .big { font-size: 42px; }

/* forms */
label.f { display: block; margin-bottom: 12px; font-size: 13px; font-weight: 600; color: #374151; }
label.f input, label.f select, label.f textarea { display: block; width: 100%; margin-top: 5px; padding: 11px 12px; border-radius: 10px;
  border: 1.5px solid var(--line); background: #fff; font-weight: 400; font-size: 15px; }
label.f textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand) !important; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1.5px solid var(--line); background: #fff; border-radius: 999px; padding: 7px 13px; font-size: 13.5px;
  cursor: pointer; white-space: nowrap; }
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.error { background: var(--bad-soft); color: var(--bad); padding: 10px 12px; border-radius: 10px; font-size: 14px; margin-bottom: 12px; }

/* search */
.search { display: flex; gap: 8px; margin-bottom: 10px; }
.search input { flex: 1; padding: 12px 14px; border-radius: 12px; border: 1.5px solid var(--line); font-size: 15px; background: #fff; }
.filters { display: flex; gap: 8px; margin: 8px 0 12px; overflow-x: auto; scrollbar-width: none; }
.filters select { flex: none; padding: 8px 10px; border-radius: 10px; border: 1.5px solid var(--line); background: #fff; font-size: 13.5px; max-width: 170px; }

/* listing grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.lcard { background: #fff; border-radius: var(--radius); overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,.07);
  text-decoration: none; color: inherit; display: flex; flex-direction: column; position: relative; }
.lcard .img { aspect-ratio: 4/3; background: #eee center/cover no-repeat; position: relative; }
.lcard .body { padding: 9px 11px 11px; }
.lcard .price { font-weight: 800; font-size: 16.5px; }
.lcard .t { font-size: 13.5px; margin: 2px 0 4px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.lcard .loc { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lcard .tags { position: absolute; left: 8px; top: 8px; display: flex; gap: 4px; flex-wrap: wrap; }
.heart { position: absolute; right: 8px; top: 8px; width: 34px; height: 34px; border-radius: 50%; border: 0; background: rgba(255,255,255,.92);
  font-size: 17px; cursor: pointer; display: grid; place-items: center; }

/* detail */
.gallery { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; border-radius: var(--radius); background: #ddd; margin: -2px 0 12px; }
.gallery img { flex: none; width: 100%; aspect-ratio: 4/3; object-fit: cover; scroll-snap-align: start; }
.dprice { font-size: 26px; font-weight: 800; }
.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.fact { background: var(--bg); border-radius: 10px; padding: 8px; text-align: center; }
.fact b { display: block; font-size: 14.5px; }
.fact span { font-size: 11.5px; color: var(--muted); }
.meter { height: 10px; border-radius: 6px; background: linear-gradient(90deg, #22c55e 0%, #eab308 50%, #ef4444 100%); position: relative; margin: 14px 0 6px; }
.meter i { position: absolute; top: -5px; width: 4px; height: 20px; background: var(--ink); border-radius: 2px; transform: translateX(-2px); }
.amen { display: flex; flex-wrap: wrap; gap: 6px; }
.seller { display: flex; gap: 12px; align-items: center; }
.avatar { width: 46px; height: 46px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-dark); display: grid; place-items: center;
  font-weight: 800; font-size: 18px; flex: none; }
.actionbar { position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px)); background: #fff; border-top: 1px solid var(--line);
  padding: 10px 14px; display: flex; gap: 10px; z-index: 25; }
.actionbar .btn { flex: 1; }
.has-actionbar { padding-bottom: 80px; }
.hist { display: flex; align-items: flex-end; gap: 4px; height: 60px; margin-top: 8px; }
.hist div { flex: 1; background: var(--brand-soft); border-top: 3px solid var(--brand); border-radius: 4px 4px 0 0; min-height: 6px; }

/* photo picker */
.photos { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 6px; }
.photos .ph { aspect-ratio: 1; border-radius: 10px; background: #eee center/cover; position: relative; }
.photos .ph button { position: absolute; top: 3px; right: 3px; border: 0; background: rgba(0,0,0,.6); color: #fff; border-radius: 50%; width: 22px; height: 22px; font-size: 12px; cursor: pointer; }
.photos .add { aspect-ratio: 1; border-radius: 10px; border: 2px dashed #cbd5e1; display: grid; place-items: center; color: var(--muted);
  font-size: 12px; text-align: center; cursor: pointer; background: #fff; }
.photos .add input { display: none; }

/* deals */
.dlist a { display: flex; gap: 12px; text-decoration: none; color: inherit; padding: 12px; background: #fff; border-radius: var(--radius); margin-bottom: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06); align-items: center; }
.dlist .thumb { width: 62px; height: 62px; border-radius: 10px; background: #eee center/cover; flex: none; }
.dlist .unread { background: var(--brand); color: #fff; border-radius: 999px; font-size: 11px; font-weight: 700; padding: 2px 7px; }
.steps { display: flex; gap: 0; margin: 4px 0 2px; }
.steps div { flex: 1; text-align: center; font-size: 10.5px; color: var(--muted); position: relative; padding-top: 18px; }
.steps div::before { content: ""; position: absolute; top: 4px; left: 50%; width: 11px; height: 11px; border-radius: 50%; background: #d1d5db; transform: translateX(-50%); z-index: 1; }
.steps div::after { content: ""; position: absolute; top: 9px; left: -50%; width: 100%; height: 2px; background: #d1d5db; }
.steps div:first-child::after { display: none; }
.steps div.done { color: var(--good); font-weight: 600; }
.steps div.done::before, .steps div.done::after { background: var(--good); }
.chat { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.msg { max-width: 82%; padding: 9px 12px; border-radius: 14px; font-size: 14.5px; line-height: 1.35; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.msg.me { align-self: flex-end; background: var(--brand-soft); }
.msg .tm { font-size: 10.5px; color: var(--muted); margin-top: 3px; text-align: right; }
.msg.offer { border: 2px solid var(--brand); font-weight: 700; }
.msg.event { align-self: center; background: #eef2ff; color: #3730a3; font-size: 12.5px; text-align: center; max-width: 92%; box-shadow: none; }
.composer { position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px)); background: #fff; border-top: 1px solid var(--line);
  padding: 8px 12px; display: flex; gap: 8px; z-index: 25; }
.composer input { flex: 1; padding: 11px 14px; border-radius: 22px; border: 1.5px solid var(--line); }
.composer .btn { border-radius: 22px; }

/* sheet */
.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: #fff; width: 100%; max-width: 560px; border-radius: 18px 18px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom, 0px));
  max-height: 88vh; overflow-y: auto; }
.toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + 80px); transform: translateX(-50%); background: #111827; color: #fff; padding: 10px 16px;
  border-radius: 10px; font-size: 14px; z-index: 60; max-width: 90vw; text-align: center; }

/* login */
.auth { max-width: 420px; margin: 0 auto; }
.hero { text-align: center; padding: 26px 0 12px; }
.hero .mark { width: 74px; height: 74px; border-radius: 22px; background: var(--brand); color: #fff; display: grid; place-items: center; margin: 0 auto 12px;
  font-size: 36px; font-weight: 900; box-shadow: 0 8px 22px rgba(15, 118, 110, .35); }
.hero h1 { margin: 0; font-size: 28px; }
.demo-logins { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tabs2 { display: flex; background: #eee; border-radius: 12px; padding: 4px; margin-bottom: 14px; }
.tabs2 button { flex: 1; border: 0; background: none; padding: 9px; border-radius: 9px; font-weight: 600; cursor: pointer; }
.tabs2 button.on { background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.1); }

@media (min-width: 700px) {
  .grid { grid-template-columns: repeat(3, 1fr); }
}

/* ---------- BillPe additions ---------- */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.stat { background: #fff; border-radius: var(--radius); padding: 12px 14px; box-shadow: 0 1px 3px rgba(0,0,0,.06); text-decoration: none; color: inherit; display: block; }
.stat b { display: block; font-size: 20px; margin-top: 2px; }
.stat span { font-size: 12px; color: var(--muted); }
.stat.alert b { color: var(--bad); }
.bars { display: flex; gap: 6px; align-items: flex-end; height: 90px; margin-top: 10px; }
.bars div { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; font-size: 10.5px; color: var(--muted); gap: 4px; }
.bars i { display: block; width: 100%; background: var(--brand); border-radius: 5px 5px 0 0; min-height: 3px; }
.list a, .list .li { display: flex; gap: 12px; align-items: center; padding: 12px 14px; background: #fff; border-radius: var(--radius); margin-bottom: 8px;
  text-decoration: none; color: inherit; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.amt { font-weight: 800; text-align: right; white-space: nowrap; }
.ico { width: 42px; height: 42px; border-radius: 12px; background: var(--brand-soft); color: var(--brand-dark); display: grid; place-items: center; font-size: 20px; flex: none; }

/* invoice */
.invoice { background: #fff; border-radius: var(--radius); box-shadow: 0 1px 4px rgba(0,0,0,.08); padding: 16px; font-size: 13.5px; margin-bottom: 12px; }
.inv-head { text-align: center; border-bottom: 2px solid var(--ink); padding-bottom: 10px; margin-bottom: 10px; }
.inv-head h2 { margin: 0; font-size: 20px; }
.inv-type { display: inline-block; margin-top: 6px; font-weight: 800; letter-spacing: 1px; font-size: 12px; border: 1.5px solid var(--ink); padding: 2px 10px; border-radius: 4px; }
.inv-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; margin-bottom: 10px; }
.inv-meta div span { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.tbl-wrap { overflow-x: auto; margin: 0 -4px; }
table.inv { width: 100%; border-collapse: collapse; min-width: 330px; }
table.inv th, table.inv td { font-size: 12.5px; }
table.inv th, table.inv td { padding: 7px 5px; border-bottom: 1px solid var(--line); text-align: right; vertical-align: top; }
table.inv th { font-size: 11px; color: var(--muted); text-transform: uppercase; font-weight: 600; }
table.inv th:first-child, table.inv td:first-child { text-align: left; }
table.inv td .sub { font-size: 11px; color: var(--muted); }
.totals { margin-left: auto; max-width: 280px; margin-top: 8px; }
.totals div { display: flex; justify-content: space-between; padding: 3px 0; }
.totals .grand { font-size: 18px; font-weight: 800; border-top: 2px solid var(--ink); margin-top: 4px; padding-top: 6px; }
.words { font-style: italic; font-size: 12.5px; margin-top: 8px; color: #374151; }
.verify { display: flex; gap: 10px; align-items: center; background: var(--brand-soft); border-radius: 10px; padding: 10px; margin-top: 12px; }
.code { font-family: ui-monospace, Consolas, monospace; font-weight: 800; letter-spacing: 2px; font-size: 16px; }

/* guarantee card */
.gcard { border-radius: 16px; padding: 16px; color: #fff; margin-bottom: 12px; position: relative; overflow: hidden;
  background: linear-gradient(135deg, #0f766e, #134e4a); box-shadow: 0 6px 16px rgba(15, 118, 110, .3); }
.gcard.guarantee { background: linear-gradient(135deg, #7c3aed, #4c1d95); box-shadow: 0 6px 16px rgba(124, 58, 237, .3); }
.gcard.expiring { background: linear-gradient(135deg, #d97706, #92400e); }
.gcard.expired { background: linear-gradient(135deg, #6b7280, #374151); box-shadow: none; }
.gcard::after { content: ""; position: absolute; right: -40px; top: -40px; width: 140px; height: 140px; border-radius: 50%; background: rgba(255,255,255,.08); }
.gcard .lbl { font-size: 10.5px; text-transform: uppercase; letter-spacing: 1px; opacity: .8; }
.gcard .item { font-size: 17px; font-weight: 800; margin: 4px 0 10px; }
.gcard .grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; font-size: 12.5px; }
.gcard .grid3 b { display: block; font-size: 13.5px; }
.gcard .left { position: absolute; right: 16px; top: 14px; text-align: right; z-index: 1; }
.gcard .left b { font-size: 26px; display: block; line-height: 1; }
.gcard .cardno { font-family: ui-monospace, Consolas, monospace; letter-spacing: 1.5px; font-size: 12.5px; margin-top: 10px; opacity: .9; }
.gcard .btn { background: rgba(255,255,255,.18); color: #fff; }
.item-row { border: 1.5px solid var(--line); border-radius: 12px; padding: 10px; margin-bottom: 10px; position: relative; }
.item-row .x { position: absolute; top: 6px; right: 8px; border: 0; background: none; font-size: 18px; color: var(--muted); cursor: pointer; }
.item-row label.f { margin-bottom: 8px; }
.three { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.seg { display: flex; background: #eee; border-radius: 10px; padding: 3px; }
.seg button { flex: 1; border: 0; background: none; padding: 9px 6px; border-radius: 8px; font-weight: 600; cursor: pointer; font-size: 13.5px; }
.seg button.on { background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.12); color: var(--brand-dark); }
.seg button:disabled { opacity: .4; }
.summary-bar { position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px)); background: #fff; border-top: 1px solid var(--line);
  padding: 10px 14px; display: flex; gap: 12px; align-items: center; z-index: 25; }
.shopid { font-family: ui-monospace, Consolas, monospace; font-size: 30px; font-weight: 900; letter-spacing: 3px; color: var(--brand-dark); }
@media print {
  .topbar, .nav, .no-print, .summary-bar { display: none !important; }
  body { padding: 0; background: #fff; } .invoice { box-shadow: none; }
}
