:root {
  --brand: #4f8f31; --brand-dark: #3a6d22; --bg: #f4f1f3; --card: #fff; --text: #1d1b1c;
  --muted: #6d6569; --line: #e6dfe3; --green: #1e8e3e; --red: #d93025; --amber: #f29900;
  --blue: #1a73e8;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--red); min-height: 1.2em; }
.screen { min-height: 100%; display: flex; flex-direction: column; }

/* login */
#login { justify-content: center; align-items: center; padding: 24px;
  background: linear-gradient(160deg, var(--brand), var(--brand-dark)); }
.login-box { background: #fff; border-radius: 18px; padding: 28px 22px; width: 100%;
  max-width: 360px; text-align: center; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.login-box h1 { margin: 8px 0 0; font-size: 24px; }
.logo { width: 150px; height: auto; }
.login-box input { width: 100%; margin: 8px 0; padding: 14px; font-size: 17px;
  border: 1px solid var(--line); border-radius: 10px; }

/* buttons */
.btn { border: 1px solid var(--line); background: #fff; color: var(--text); border-radius: 12px;
  padding: 12px 14px; font-size: 16px; font-weight: 600; cursor: pointer; }
.btn:active { transform: scale(.98); }
.btn.big { width: 100%; padding: 15px; font-size: 18px; margin-top: 8px; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.success { background: var(--green); border-color: var(--green); color: #fff; }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.blue { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn:disabled { opacity: .5; }
.icon-btn { background: none; border: 0; color: #fff; font-size: 26px; width: 44px; height: 44px; }

/* top bar */
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px;
  justify-content: space-between; background: var(--brand); color: #fff;
  padding: calc(10px + env(safe-area-inset-top)) 12px 10px 16px; }
.topbar .grow { flex: 1; min-width: 0; }
.hello { font-weight: 700; font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sub { font-size: 13px; opacity: .9; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #ffb4b4;
  margin-right: 6px; }
.dot.on { background: #7dff9b; }
.menu { position: fixed; right: 10px; top: 60px; z-index: 20; background: #fff; border-radius: 12px;
  box-shadow: 0 6px 24px rgba(0,0,0,.2); overflow: hidden; }
.menu button { display: block; width: 100%; padding: 14px 20px; border: 0; background: #fff;
  text-align: left; font-size: 16px; }
.menu button + button { border-top: 1px solid var(--line); }
.queue { background: #fff3cd; color: #6b4e00; padding: 8px 16px; font-size: 14px; }

/* tabs */
.tabs { display: flex; background: #fff; border-bottom: 1px solid var(--line); position: sticky;
  top: 64px; z-index: 4; }
.tab { flex: 1; padding: 13px 6px; border: 0; background: none; font-size: 15px; font-weight: 600;
  color: var(--muted); border-bottom: 3px solid transparent; }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); }
.badge { background: var(--line); color: var(--text); border-radius: 10px; padding: 1px 8px;
  font-size: 13px; margin-left: 4px; }
.tab.active .badge { background: var(--brand); color: #fff; }

/* list */
.list { padding: 12px; display: flex; flex-direction: column; gap: 12px; padding-bottom: 40px; }
.card { background: var(--card); border-radius: 14px; padding: 14px; box-shadow: 0 1px 3px rgba(0,0,0,.08);
  border-left: 6px solid var(--amber); }
.card.s-out_for_delivery { border-left-color: #8f8fe8; }
.card.s-delivered { border-left-color: #2fbf2f; opacity: .9; }
.card.s-failed { border-left-color: #ff3b3b; }
.card.s-cancelled { border-left-color: #999; opacity: .7; }
.card .top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.card .name { font-weight: 700; font-size: 17px; }
.card .area { margin: 4px 0; }
.card .desc { color: var(--muted); font-size: 14px; }
.chip { display: inline-block; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 20px;
  background: #fff4c2; color: #6b4e00; white-space: nowrap; }
.chip.s-out_for_delivery { background: #c9c9f7; color: #1f1f6b; }
.chip.s-delivered { background: #5fe35f; color: #0b3d0b; }
.chip.s-failed { background: #ff4d4d; color: #fff; }
.chip.s-cancelled { background: #e4e4e4; color: #444; }
.card .meta { display: flex; gap: 10px; flex-wrap: wrap; font-size: 13px; color: var(--muted); margin-top: 6px; }
.card .quick { display: flex; gap: 8px; margin-top: 10px; }
.card .quick .btn { flex: 1; padding: 10px 6px; font-size: 15px; }
.empty { text-align: center; color: var(--muted); padding: 60px 20px; }
.pending { font-size: 12px; color: #6b4e00; margin-top: 6px; }

/* detail */
.detail-body { padding: 14px; padding-bottom: 150px; display: flex; flex-direction: column; gap: 12px; }
.block { background: #fff; border-radius: 14px; padding: 14px; }
.block h4 { margin: 0 0 6px; font-size: 13px; text-transform: uppercase; color: var(--muted); letter-spacing: .04em; }
.block .big { font-size: 18px; font-weight: 700; }
.row { display: flex; gap: 10px; margin-top: 10px; }
.row .btn { flex: 1; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 15px; }
.kv b { color: var(--muted); font-weight: 600; }
.actions { position: fixed; left: 0; right: 0; bottom: 0; background: #fff; padding: 12px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom)); box-shadow: 0 -2px 12px rgba(0,0,0,.1);
  display: flex; flex-direction: column; gap: 8px; }
.actions .row { margin: 0; }
.pod-img { width: 100%; border-radius: 10px; margin-top: 8px; }

/* sheets */
.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 30; display: flex; align-items: flex-end; }
.sheet { background: #fff; width: 100%; border-radius: 18px 18px 0 0; padding: 18px;
  padding-bottom: calc(18px + env(safe-area-inset-bottom)); max-height: 92vh; overflow: auto; }
.sheet h3 { margin: 0 0 12px; }
.sheet textarea { width: 100%; padding: 12px; font: inherit; border: 1px solid var(--line); border-radius: 10px; margin-top: 10px; }
.reasons { display: flex; flex-wrap: wrap; gap: 8px; }
.reasons button { border: 1px solid var(--line); background: #fff; border-radius: 20px; padding: 9px 14px; font-size: 15px; }
.reasons button.sel { background: var(--brand); color: #fff; border-color: var(--brand); }
.photo-pick { display: block; cursor: pointer; margin-bottom: 12px; }
.pod-preview { border: 2px dashed var(--line); border-radius: 12px; min-height: 140px; display: flex;
  align-items: center; justify-content: center; text-align: center; color: var(--muted); overflow: hidden; }
.pod-preview img { width: 100%; max-height: 260px; object-fit: cover; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #222; color: #fff;
  padding: 12px 18px; border-radius: 10px; z-index: 50; max-width: 90%; text-align: center; }
.gps { margin-left: 4px; }
a.btn { text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }

.toplogo { height: 40px; width: auto; background: #fff; border-radius: 8px; padding: 2px 4px; }
.topbar { justify-content: flex-start; }
.topbar .icon-btn { margin-left: auto; }
/* chat */
.chat { display: flex; flex-direction: column; height: calc(100vh - 118px); }
.chat-msgs { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; background: #efeae2; }
.bubble { max-width: 80%; padding: 8px 11px; border-radius: 12px; box-shadow: 0 1px 1px rgba(0,0,0,.1); white-space: pre-wrap; word-wrap: break-word; }
.bubble.me { align-self: flex-end; background: #d9fdd3; border-bottom-right-radius: 3px; }
.bubble.them { align-self: flex-start; background: #fff; border-bottom-left-radius: 3px; }
.bubble .meta { font-size: 11px; color: #667; margin-top: 3px; text-align: right; }
.chat-bar { display: flex; gap: 8px; padding: 8px; background: #fff; border-top: 1px solid var(--line); }
.chat-bar input { flex: 1; padding: 12px; font-size: 16px; border: 1px solid var(--line); border-radius: 22px; }
.chat-bar .btn { border-radius: 22px; }
.chat .quick { display: flex; gap: 6px; overflow-x: auto; padding: 0 8px 8px; background: #fff; margin: 0; }
.chat .quick button { flex: none; border: 1px solid var(--line); background: #fff; border-radius: 16px; padding: 7px 12px; font-size: 14px; }
.badge.alert { background: #ff9800 !important; color: #fff !important; }
