:root {
  --bg: #f6f4ee;
  --card: #ffffff;
  --ink: #1d2320;
  --muted: #5f6b65;
  --line: #e2ded3;
  --brand: #1f7a4d;
  --brand-ink: #ffffff;
  --brand-soft: #e3f1e9;
  --warn: #b45309;
  --warn-soft: #fdf1e2;
  --bad: #b42318;
  --bad-soft: #fde8e6;
  --good: #1f7a4d;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(29, 35, 32, .08);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: 'Mukta', system-ui, sans-serif;
  font-size: 16px; line-height: 1.45;
  background: var(--bg); color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
.splash { display: grid; place-items: center; height: 100vh; font-size: 22px; font-weight: 700; color: var(--brand); }

/* layout */
#app { display: flex; flex-direction: column; min-height: 100vh; max-width: 640px; margin: 0 auto; background: var(--bg); }
.topbar {
  position: sticky; top: 0; z-index: 900;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  background: var(--brand); color: var(--brand-ink);
}
.topbar h1 { font-size: 19px; margin: 0; flex: 1; font-weight: 700; }
.topbar .sub { font-size: 13px; opacity: .85; display: block; font-weight: 400; }
.topbar button { background: rgba(255,255,255,.16); border: 0; color: #fff; border-radius: 10px; padding: 6px 10px; }
main { flex: 1; padding: 16px; padding-bottom: 96px; }
main.flush { padding: 0; padding-bottom: 72px; }
.tabs {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 640px; z-index: 900;
  display: flex; background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs button {
  flex: 1; border: 0; background: none; padding: 10px 4px 8px; font-size: 13px; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.tabs button .ic { font-size: 20px; line-height: 1; }
.tabs button.on { color: var(--brand); font-weight: 700; }
.tabs .badge { background: var(--bad); color: #fff; border-radius: 99px; font-size: 11px; padding: 0 6px; margin-left: 2px; }

/* cards, forms */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; margin-bottom: 12px; }
.card h3 { margin: 0 0 6px; font-size: 17px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); font-size: 14px; }
.small { font-size: 13px; }
.stack > * + * { margin-top: 10px; }
label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 4px; }
input, select, textarea {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 0; border-color: transparent; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; border-radius: 12px; padding: 12px 16px; font-weight: 700; cursor: pointer;
  background: var(--brand); color: var(--brand-ink); text-decoration: none;
}
.btn.block { width: 100%; }
.btn.ghost { background: var(--brand-soft); color: var(--brand); }
.btn.danger { background: var(--bad-soft); color: var(--bad); }
.btn.small { padding: 7px 12px; font-size: 14px; border-radius: 10px; }
.btn:disabled { opacity: .5; }
.link { background: none; border: 0; color: var(--brand); font-weight: 700; padding: 0; cursor: pointer; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: 13px; font-weight: 600; background: var(--brand-soft); color: var(--brand); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.grey { background: #eceae4; color: var(--muted); }
.seg { display: flex; background: #eceae4; border-radius: 12px; padding: 4px; gap: 4px; }
.seg button { flex: 1; border: 0; border-radius: 9px; padding: 8px; background: none; font-weight: 600; color: var(--muted); }
.seg button.on { background: #fff; color: var(--ink); box-shadow: var(--shadow); }
.empty { text-align: center; color: var(--muted); padding: 32px 12px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 12px 0; }

/* auth */
.auth { padding: 24px 16px 40px; }
.brand-hero { text-align: center; margin: 12px 0 20px; }
.brand-hero .logo { font-size: 44px; }
.brand-hero h2 { margin: 4px 0 0; font-size: 28px; color: var(--brand); }

/* map screen */
.map-wrap { position: relative; height: calc(100vh - 56px - 64px); }
#bigmap { position: absolute; inset: 0; }
.map-tools { position: absolute; top: 10px; left: 10px; right: 10px; z-index: 800; }
.searchbox { display: flex; gap: 8px; background: #fff; border-radius: 12px; box-shadow: var(--shadow); padding: 4px 4px 4px 12px; align-items: center; }
.searchbox input { border: 0; padding: 8px 0; }
.searchbox input:focus { outline: none; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 8px 0 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 0; background: #fff; border-radius: 99px; padding: 6px 12px; box-shadow: var(--shadow); font-size: 14px; white-space: nowrap; }
.chip.on { background: var(--brand); color: #fff; }
.result-count { position: absolute; left: 10px; bottom: 12px; z-index: 800; background: #fff; border-radius: 99px; padding: 4px 12px; box-shadow: var(--shadow); font-size: 13px; }
.cart-fab { position: absolute; right: 12px; bottom: 12px; z-index: 800; box-shadow: 0 4px 14px rgba(0,0,0,.2); }
.shop-pin {
  background: #fff; border: 2px solid var(--brand); border-radius: 50% 50% 50% 4px; transform: rotate(-45deg);
  width: 38px; height: 38px; display: grid; place-items: center; box-shadow: 0 2px 6px rgba(0,0,0,.25);
}
.shop-pin span { transform: rotate(45deg); font-size: 19px; }
.shop-pin.closed { border-color: #9aa39e; filter: grayscale(1); opacity: .75; }
.pin-label { background: #fff; border-radius: 6px; padding: 0 6px; font-size: 12px; font-weight: 600; white-space: nowrap; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.boy-pin { font-size: 28px; filter: drop-shadow(0 2px 2px rgba(0,0,0,.35)); }
.home-pin { font-size: 26px; filter: drop-shadow(0 2px 2px rgba(0,0,0,.35)); }
.minimap { height: 220px; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); }
.trackmap { height: 260px; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); }

/* bottom sheet */
#sheet-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 1000; }
#sheet {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 0; z-index: 1001;
  width: 100%; max-width: 640px; max-height: 88vh; overflow-y: auto;
  background: var(--bg); border-radius: 18px 18px 0 0; padding: 8px 16px 24px;
  padding-bottom: max(24px, env(safe-area-inset-bottom));
}
#sheet .grab { width: 44px; height: 5px; border-radius: 99px; background: #cfcabd; margin: 4px auto 12px; }
.prod { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.prod:last-child { border-bottom: 0; }
.qty { display: flex; align-items: center; gap: 6px; }
.qty button { width: 34px; height: 34px; border-radius: 10px; border: 0; background: var(--brand-soft); color: var(--brand); font-size: 20px; font-weight: 700; }
.qty b { min-width: 22px; text-align: center; }
.price { font-weight: 700; }

/* orders */
.order-item { cursor: pointer; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { position: relative; padding: 0 0 12px 22px; font-size: 14px; }
.timeline li::before { content: ''; position: absolute; left: 5px; top: 7px; width: 9px; height: 9px; border-radius: 50%; background: var(--brand); }
.timeline li::after { content: ''; position: absolute; left: 9px; top: 18px; bottom: 0; width: 1px; background: var(--line); }
.timeline li:last-child::after { display: none; }
.otp-box { text-align: center; background: var(--brand-soft); border-radius: var(--radius); padding: 16px; }
.otp-box .otp { font-size: 40px; letter-spacing: 12px; font-weight: 700; color: var(--brand); }
.qr-box { display: grid; place-items: center; padding: 12px; background: #fff; border-radius: 12px; border: 1px solid var(--line); }
.qr-box img, .qr-box canvas { width: 220px !important; height: 220px !important; }
.proof-img { width: 100%; border-radius: 12px; border: 1px solid var(--line); }
.live-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--bad); margin-right: 6px; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .25; } }

.stars { display: flex; gap: 2px; margin: 4px 0 6px; }
.stars button { border: 0; background: none; font-size: 30px; line-height: 1; color: #d6d1c4; padding: 0 2px; cursor: pointer; }
.stars button.on { color: #f0a92b; }

/* admin report */
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.kpi { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 10px; }
.kpi .k { font-size: 13px; color: var(--muted); }
.kpi .v { font-size: 20px; font-weight: 700; line-height: 1.2; }
.kpi .s { font-size: 12px; color: var(--muted); }
.kpi.on { outline: 2px solid var(--brand); }
.bars { display: flex; align-items: flex-end; gap: 2px; height: 120px; padding-top: 8px; border-bottom: 1px solid var(--line); }
.bars div { flex: 1; background: var(--brand); border-radius: 3px 3px 0 0; min-height: 1px; opacity: .85; }
.bars div.today { background: #f0a92b; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; padding: 4px 4px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 6px 4px; border-bottom: 1px solid var(--line); }
.tbl td.r, .tbl th.r { text-align: right; }
.person { display: flex; align-items: center; gap: 10px; }
.person.off { opacity: .6; }

#toast {
  position: fixed; left: 50%; top: 72px; transform: translateX(-50%); z-index: 2000; text-align: center;
  background: #1d2320; color: #fff; padding: 10px 16px; border-radius: 12px; max-width: 90vw; font-size: 15px;
  box-shadow: 0 6px 20px rgba(0,0,0,.25);
}
#toast.err { background: var(--bad); }

/* signup role cards */
.role-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.role-card { border: 1px solid var(--line); background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px 10px; display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer; text-align: center; }
.role-card .ic { font-size: 34px; }
.role-card b { font-size: 17px; }
.stock { font-size: 12px; color: var(--muted); }
.stock.low { color: var(--warn); font-weight: 600; }
