:root {
  --bg: #f6f3ef;
  --surface: #ffffff;
  --surface2: #faf7f3;
  --line: #ece4da;
  --line2: #ddd2c5;
  --text: #1f1712;
  --muted: #7a6c61;
  --brand: #e1341b;
  --brand-dark: #b9250f;
  --brand-soft: #fdebe6;
  --accent: #ffb51f;
  --accent-soft: #fff4dc;
  --dark: #1b110c;
  --ok: #18915a;
  --ok-soft: #e3f5ec;
  --warn: #b7700b;
  --warn-soft: #fff3dd;
  --info: #2468c9;
  --info-soft: #e5effc;
  --radius: 16px;
  --shadow-sm: 0 1px 2px rgba(40, 20, 10, 0.06), 0 1px 3px rgba(40, 20, 10, 0.06);
  --shadow: 0 6px 24px rgba(40, 20, 10, 0.1);
  --shadow-lg: 0 18px 50px rgba(40, 20, 10, 0.22);
  --font: 'Poppins', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; }
a { color: var(--brand); }
h1, h2, h3 { line-height: 1.25; margin: 0; font-weight: 700; }
img { max-width: 100%; }
.ur { font-family: 'Noto Nastaliq Urdu', serif; direction: rtl; line-height: 1.9; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.wrap { max-width: 1200px; margin: 0 auto; padding: 0 16px; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrapr { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.hidden { display: none !important; }

.i { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }
.i.sm { width: 16px; height: 16px; }
.i.lg { width: 24px; height: 24px; }

.btn {
  appearance: none; border: 1px solid var(--line2); background: var(--surface); color: var(--text);
  border-radius: 12px; padding: 10px 16px; font: inherit; font-weight: 600; font-size: 14px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, transform 0.05s, box-shadow 0.15s;
}
.btn:hover { border-color: var(--muted); }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: 0 4px 14px rgba(225, 52, 27, 0.28); }
.btn.primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.danger { background: var(--surface); border-color: #f1c3ba; color: var(--brand-dark); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: rgba(0, 0, 0, 0.05); }
.btn.soft { background: var(--brand-soft); border-color: transparent; color: var(--brand-dark); }
.btn.wa { background: #25d366; border-color: #25d366; color: #fff; }
.btn.sm { padding: 6px 12px; font-size: 13px; border-radius: 10px; gap: 6px; }
.btn.block { width: 100%; padding: 14px; font-size: 16px; }
.btn.icon { padding: 9px; border-radius: 12px; }

label { display: block; font-size: 13px; font-weight: 500; color: var(--muted); margin: 14px 0 6px; }
input, textarea, select {
  width: 100%; background: var(--surface); border: 1.5px solid var(--line2); color: var(--text);
  border-radius: 12px; padding: 12px 14px; font: inherit; font-size: 16px; transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px rgba(225, 52, 27, 0.12); }
input::placeholder, textarea::placeholder { color: #b3a598; }
textarea { resize: vertical; min-height: 70px; }
input[type='checkbox'] { width: auto; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow-sm); }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--surface2); border: 1px solid var(--line); white-space: nowrap; }
.st-placed { background: var(--brand-soft); color: var(--brand-dark); border-color: #f7c9bf; }
.st-accepted { background: #fff8d6; color: #8a6a00; border-color: #f2e19a; }
.st-preparing { background: var(--warn-soft); color: var(--warn); border-color: #f3d9a6; }
.st-ready { background: #e3f4fb; color: #0d6a8c; border-color: #b6e0ef; }
.st-picked { background: var(--info-soft); color: var(--info); border-color: #bcd3f3; }
.st-delivered { background: var(--ok-soft); color: var(--ok); border-color: #b4e2c9; }
.st-cancelled { background: #f0eeec; color: #77706a; border-color: #dcd8d4; }

dialog {
  border: 0; background: var(--surface); color: var(--text); border-radius: 22px 22px 0 0; padding: 0;
  width: 100%; max-width: 560px; max-height: 94vh; margin: auto auto 0; box-shadow: var(--shadow-lg);
  overflow-y: auto; overscroll-behavior: contain;
}
dialog[open] { animation: up 0.22s ease-out; }
@keyframes up { from { transform: translateY(30px); opacity: 0; } }
@media (min-width: 640px) { dialog { border-radius: 22px; margin: auto; } }
dialog::backdrop { background: rgba(20, 10, 5, 0.55); backdrop-filter: blur(2px); }
.sheet-head { position: sticky; top: 0; background: var(--surface); padding: 14px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 8px; z-index: 2; }
.sheet-head h2 { font-size: 18px; flex: 1; }
.sheet-body { padding: 4px 18px 18px; }
.sheet-foot { position: sticky; bottom: 0; background: var(--surface); padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); z-index: 2; }
.x { background: var(--surface2); border: 1px solid var(--line); color: var(--text); border-radius: 50%; width: 36px; height: 36px; display: grid; place-items: center; cursor: pointer; padding: 0; flex: none; }
.x:hover { background: var(--line); }

#toast {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translate(-50%, 10px);
  background: var(--dark); color: #fff; padding: 12px 18px; border-radius: 14px; font-weight: 500; font-size: 14px; z-index: 1000;
  max-width: calc(100% - 32px); box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.err { background: #8c1d0e; }

.qty { display: inline-flex; align-items: center; background: var(--surface2); border: 1px solid var(--line2); border-radius: 12px; overflow: hidden; }
.qty button { background: transparent; color: var(--brand); border: 0; width: 36px; height: 36px; cursor: pointer; display: grid; place-items: center; }
.qty button:hover { background: var(--brand-soft); }
.qty span { min-width: 28px; text-align: center; font-weight: 700; }

.map { height: 260px; border-radius: 14px; border: 1px solid var(--line2); overflow: hidden; background: #eee; }
.leaflet-container { font: inherit; }

.tabs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: none; display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 99px; border: 1px solid var(--line2); background: var(--surface); color: var(--muted); font: inherit; font-weight: 600; font-size: 14px; cursor: pointer; }
.tab:hover { color: var(--text); }
.tab.on { background: var(--dark); color: #fff; border-color: var(--dark); }
.badge { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 99px; background: var(--brand); color: #fff; font-size: 11px; font-weight: 700; line-height: 20px; text-align: center; }
.tab.on .badge { background: var(--accent); color: var(--dark); }

.empty { text-align: center; padding: 48px 16px; color: var(--muted); }
.empty .i { width: 44px; height: 44px; stroke-width: 1.5; color: var(--line2); margin-bottom: 8px; }
.spinner { width: 22px; height: 22px; border: 3px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin 0.8s linear infinite; display: inline-block; vertical-align: middle; }
.btn .spinner { width: 18px; height: 18px; border-color: rgba(255, 255, 255, 0.4); border-top-color: #fff; }
@keyframes spin { to { transform: rotate(360deg); } }

.note { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 14px; font-size: 14px; margin-top: 12px; background: var(--accent-soft); border: 1px solid #f6dfa6; color: #6b4a00; }
.note.bad { background: var(--brand-soft); border-color: #f7c9bf; color: var(--brand-dark); font-weight: 500; }
.note .i { margin-top: 1px; }

/* staff apps (admin & rider) */
.topbar { position: sticky; top: 0; z-index: 50; background: var(--dark); color: #fff; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15); }
.topbar .wrap { display: flex; align-items: center; gap: 10px; padding-top: 10px; padding-bottom: 10px; }
.topbar img { width: 38px; height: 38px; border-radius: 10px; }
.topbar .title { font-weight: 700; font-size: 16px; }
.topbar .muted { color: #c9b6a6; }
.topbar .btn { background: rgba(255, 255, 255, 0.08); border-color: rgba(255, 255, 255, 0.14); color: #fff; }
.topbar .tab { background: transparent; border-color: rgba(255, 255, 255, 0.16); color: #d8c8bb; }
.topbar .tab.on { background: #fff; color: var(--dark); border-color: #fff; }
.login { max-width: 400px; margin: 8vh auto 0; padding: 28px 22px; background: var(--surface); border-radius: 22px; box-shadow: var(--shadow); }
@media (max-width: 440px) { .login { margin: 6vh 16px 0; } }
.login img { width: 84px; height: 84px; border-radius: 20px; display: block; margin: 0 auto 14px; box-shadow: var(--shadow); }
.login h1 { text-align: center; font-size: 22px; }
.order { display: grid; gap: 10px; }
.order .head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.order .num { font-size: 18px; font-weight: 700; }
.order .items { margin: 0; padding: 10px 12px; list-style: none; background: var(--surface2); border-radius: 12px; display: grid; gap: 4px; font-size: 14px; }
.order .total { font-weight: 700; font-size: 18px; color: var(--brand); }
.order.new { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(225, 52, 27, 0.15), var(--shadow); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 14px; }
.kv b { color: var(--muted); font-weight: 500; }
.list { display: grid; gap: 12px; padding: 16px 0 100px; }
@media (min-width: 900px) { .list.cols { grid-template-columns: 1fr 1fr; align-items: start; } }
@media (min-width: 1250px) { .list.cols { grid-template-columns: 1fr 1fr 1fr; } }
.contact { display: inline-flex; align-items: center; gap: 4px; }
