:root {
  --bg: #0b1324;
  --card: #121c31;
  --card-2: #18243d;
  --line: #24314b;
  --text: #eef3fb;
  --muted: #93a2bd;
  --accent: #22d3a6;
  --accent-2: #0ea5e9;
  --danger: #ff6b6b;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --radius: 20px;
  --sheet-h: 58vh;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans HK", "PingFang HK", "Microsoft JhengHei", sans-serif;
  overscroll-behavior: none;
}

#map {
  position: fixed; inset: 0;
  background: radial-gradient(circle at 50% 30%, #16233a, #0a1220 70%);
  z-index: 0;
}

.leaflet-container { background: #0a1220; font-family: inherit; }
.leaflet-tile { filter: invert(1) hue-rotate(180deg) brightness(0.92) contrast(0.95) saturate(0.7); }
.leaflet-control-attribution {
  background: rgba(0,0,0,.45) !important; color: #8ea0bd !important; font-size: 9px !important;
}
.leaflet-control-attribution a { color: #9fb3d1 !important; }
.leaflet-control-zoom { display: none; }

.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 500;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 12px) 16px 12px;
  background: linear-gradient(180deg, rgba(11,19,36,.95), rgba(11,19,36,0));
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }

.brand { display: flex; align-items: center; gap: 10px; }
.brand .logo { display: grid; place-items: center; width: 26px; height: 26px; }
.brand strong { display: block; font-size: 17px; letter-spacing: .5px; }
.brand small { color: var(--muted); font-size: 11px; }

.top-actions { display: flex; gap: 8px; }

.icon-btn {
  width: 40px; height: 40px; border-radius: 14px;
  display: grid; place-items: center;
  background: rgba(24,36,61,.9); border: 1px solid var(--line);
  color: var(--text); font-size: 17px; cursor: pointer; text-decoration: none;
  backdrop-filter: blur(12px);
}
.icon-btn:active { transform: scale(.94); }

.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 600;
  background: var(--card);
  border-radius: 26px 26px 0 0;
  box-shadow: var(--shadow);
  padding: 8px 18px calc(env(safe-area-inset-bottom) + 20px);
  max-height: 78vh; overflow-y: auto;
  border-top: 1px solid rgba(255,255,255,.06);
}

.grabber { padding: 6px 0 10px; display: grid; place-items: center; cursor: pointer; }
.grabber span { width: 44px; height: 4px; border-radius: 99px; background: #33425e; }

.headline { font-size: 22px; margin: 2px 0 16px; font-weight: 700; letter-spacing: -.3px; }

.route { display: flex; gap: 12px; }
.route-line { display: flex; flex-direction: column; align-items: center; padding-top: 16px; width: 12px; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; display: inline-block; }
.dot.pickup { background: var(--accent); box-shadow: 0 0 0 4px rgba(34,211,166,.16); }
.dot.stop { background: #f4d35e; box-shadow: 0 0 0 4px rgba(244,211,94,.16); border-radius: 3px; }
.stop-tag { margin-left: 6px; font-style: normal; font-size: 10px; padding: 1px 6px;
  border-radius: 99px; color: #f4d35e; background: rgba(244,211,94,.12);
  border: 1px solid rgba(244,211,94,.34); }
.dot.drop { background: var(--danger); box-shadow: 0 0 0 4px rgba(255,107,107,.16); border-radius: 3px; }
.bar { flex: 1; width: 2px; background: repeating-linear-gradient(180deg, #33425e 0 4px, transparent 4px 8px); margin: 6px 0; }

.route-inputs { flex: 1; display: grid; gap: 10px; }

.field {
  display: flex; align-items: center; gap: 10px;
  background: var(--card-2); border: 1px solid var(--line);
  border-radius: 14px; padding: 12px 14px;
}
.field span { font-size: 11px; color: var(--muted); width: 34px; flex: 0 0 auto; }
.field input {
  flex: 1; background: none; border: none; outline: none;
  color: var(--text); font-size: 16px; min-width: 0;
}
.field input::placeholder { color: #5f7196; }
.field:focus-within { border-color: var(--accent); }

.suggest {
  position: absolute; left: 18px; right: 18px; z-index: 700;
  background: #16223a; border: 1px solid var(--line);
  border-radius: 14px; overflow: hidden; box-shadow: var(--shadow);
  margin-top: -150px;
}
.suggest button {
  display: flex; width: 100%; gap: 10px; align-items: center;
  padding: 12px 14px; background: none; border: 0; color: var(--text);
  font-size: 14px; text-align: left; cursor: pointer; border-bottom: 1px solid #1e2b45;
}
.suggest button:last-child { border-bottom: 0; }
.suggest button:active { background: #1d2c48; }
.suggest .sub { color: var(--muted); font-size: 11px; margin-left: auto; }

.vehicles { display: grid; gap: 10px; margin: 16px 0 8px; }
.vehicle {
  display: flex; align-items: center; gap: 12px;
  background: var(--card-2); border: 2px solid transparent;
  border-radius: 16px; padding: 12px 14px; cursor: pointer;
  transition: border-color .15s, transform .1s;
}
.vehicle:active { transform: scale(.99); }
.vehicle.sel { border-color: var(--accent); background: #14283a; }
.vehicle .emoji { font-size: 22px; width: 30px; text-align: center; }
.vehicle .v-main { flex: 1; }
.vehicle .v-main strong { display: block; font-size: 14px; }
.vehicle .v-main small { color: var(--muted); font-size: 11px; }
.vehicle .v-price { text-align: right; }
.vehicle .v-price strong { font-size: 16px; }
.vehicle .v-price small { display: block; color: var(--muted); font-size: 10px; }

.empty-hint p { color: var(--muted); font-size: 13px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  background: var(--card-2); border: 1px solid var(--line); color: var(--text);
  border-radius: 99px; padding: 9px 14px; font-size: 13px; cursor: pointer;
}
.chip:active { background: #223252; }

.primary {
  width: 100%; border: 0; border-radius: 16px; padding: 16px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #06251f; font-size: 16px; font-weight: 800; cursor: pointer;
  margin-top: 12px; letter-spacing: .3px;
}
.primary:active { transform: scale(.985); }
.primary:disabled { opacity: .5; }

.ghost {
  background: var(--card-2); border: 1px solid var(--line); color: var(--text);
  border-radius: 16px; padding: 14px 18px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.ghost.danger { color: var(--danger); }

.fineprint { text-align: center; color: #5f7196; font-size: 11px; margin: 12px 0 0; }

/* ---- 投訴師傅 ---- */
.complain { margin-top: 18px; }
.complain-open {
  width: 100%; padding: 13px; border-radius: 14px; cursor: pointer;
  background: rgba(255,107,107,.08); border: 1px solid rgba(255,107,107,.32);
  color: #ff8f8f; font-size: 14px; font-weight: 650; font-family: inherit;
}
.complain-open:active { background: rgba(255,107,107,.14); }
.complain-form {
  padding: 16px; border-radius: 16px; background: var(--card-2);
  border: 1px solid var(--line); margin-top: 10px;
}
.complain-title { margin: 0 0 4px; font-size: 16px; font-weight: 750; }
.complain-sub { margin: 0 0 12px; font-size: 12px; color: var(--muted); }
.complain-lbl { display: block; margin-bottom: 7px; font-size: 13px; color: var(--muted); font-weight: 600; }
.complain-form textarea {
  width: 100%; padding: 12px 13px; font-size: 16px; line-height: 1.5;
  color: var(--text); background: #0e1728; border: 1.5px solid var(--line);
  border-radius: 12px; outline: none; resize: vertical; font-family: inherit;
}
.complain-form textarea:focus { border-color: var(--accent-2); }
.complain-chips { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 13px; }
.complain-chips button {
  padding: 8px 13px; font-size: 12.5px; font-family: inherit; cursor: pointer;
  color: #c3d0e4; background: #0e1728; border: 1.5px solid var(--line);
  border-radius: 999px; transition: .15s;
}
.complain-chips button:active { background: #1b2740; }
.complain-chips button.on {
  color: #ffb4b4; background: rgba(255,107,107,.14);
  border-color: rgba(255,107,107,.55); font-weight: 650;
}
.complain-err {
  margin: 10px 0 0; font-size: 12.5px; color: var(--danger); font-weight: 600;
}
.complain-actions { display: flex; gap: 9px; margin-top: 14px; }
.complain-actions .ghost { flex: 1; }
.danger-solid {
  flex: 1; padding: 14px 18px; border: 0; border-radius: 15px; cursor: pointer;
  background: linear-gradient(135deg, #ff6b6b, #e04848); color: #fff;
  font-size: 14.5px; font-weight: 750; font-family: inherit;
}
.danger-solid:disabled { opacity: .55; }
.complain-done {
  padding: 16px; border-radius: 16px; background: rgba(34,211,166,.09);
  border: 1px solid rgba(34,211,166,.32); color: var(--accent);
  font-size: 13.5px; font-weight: 650; line-height: 1.6;
}
.hidden { display: none !important; }

/* ---- ride panel ---- */
.ride-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.status { font-size: 19px; font-weight: 700; }
.eta { color: var(--accent); font-size: 13px; margin-top: 3px; }
.fare { font-size: 24px; font-weight: 800; letter-spacing: -.5px; }

.progress { display: flex; gap: 6px; margin: 16px 0; }
.step {
  flex: 1; text-align: center; font-size: 10px; color: #5f7196;
  padding-top: 8px; border-top: 3px solid #24314b;
}
.step.on { color: var(--accent); border-top-color: var(--accent); }

.driver-card {
  display: flex; align-items: center; gap: 12px;
  background: var(--card-2); border: 1px solid var(--line);
  border-radius: 16px; padding: 12px 14px; margin-bottom: 12px;
}
.avatar {
  width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center; font-size: 20px;
  background: #20304d;
}
.driver-info { flex: 1; }
.driver-info strong { display: block; font-size: 15px; }
.driver-info small { color: var(--muted); font-size: 12px; }
.plate {
  font-family: ui-monospace, Menlo, monospace; font-size: 13px; font-weight: 700;
  background: #f4d35e; color: #1a1500; padding: 6px 10px; border-radius: 8px; letter-spacing: 1px;
}

.searching { text-align: center; padding: 14px 0 18px; }
.searching p { color: var(--muted); font-size: 13px; margin: 12px 0 0; }
.pulse { display: flex; justify-content: center; gap: 6px; }
.pulse span {
  width: 9px; height: 9px; border-radius: 50%; background: var(--accent);
  animation: bounce 1.2s infinite ease-in-out;
}
.pulse span:nth-child(2) { animation-delay: .15s; }
.pulse span:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 80%, 100% { transform: scale(.6); opacity: .4; } 40% { transform: scale(1); opacity: 1; } }

.route-summary { background: var(--card-2); border-radius: 16px; padding: 14px; display: grid; gap: 10px; }
.rs-row { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.rs-meta { color: var(--muted); font-size: 11px; padding-left: 20px; }

.ride-actions { display: flex; gap: 10px; margin-top: 14px; }
.ride-actions .ghost { flex: 1; }
.ride-actions .primary { flex: 1; margin: 0; }

.stars { display: flex; justify-content: center; gap: 6px; margin: 16px 0 8px; }
.stars button {
  background: none; border: 0; font-size: 34px; color: #33425e; cursor: pointer;
  transition: color .15s, transform .1s; padding: 0 2px;
}
.stars button.on { color: #f4d35e; transform: scale(1.08); }
.muted { color: var(--muted); font-size: 13px; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--sheet-h) + 24px); transform: translateX(-50%);
  background: #1e2b45; color: var(--text); padding: 10px 18px; border-radius: 99px;
  font-size: 13px; z-index: 900; box-shadow: var(--shadow); border: 1px solid var(--line);
  max-width: 86vw; text-align: center;
}

/* ---- 地圖標記 ---- */
.mk {
  width: 18px; height: 18px; border-radius: 50%;
  border: 3px solid #fff; box-shadow: 0 2px 10px rgba(0,0,0,.5);
}
.mk-pickup { background: #22d3a6; }
.mk-drop { background: #ff6b6b; border-radius: 5px; }
.mk-car {
  width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center; font-size: 15px;
  background: #12203a; border: 2px solid #2f4a70;
  box-shadow: 0 3px 10px rgba(0,0,0,.55);
}

/* ---- 師傅台 ---- */
.driver-body { background: var(--bg); min-height: 100%; }
.driver-wrap {
  padding: calc(env(safe-area-inset-top) + 76px) 16px calc(env(safe-area-inset-bottom) + 40px);
  max-width: 560px; margin: 0 auto;
}
.drv-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px;
}
.switch-row { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.switch-row > span:first-child { flex: 1; font-size: 15px; font-weight: 600; }
.pill {
  font-size: 11px; font-weight: 700; padding: 5px 10px; border-radius: 99px;
}
.pill.on { background: rgba(34,211,166,.16); color: var(--accent); }
.pill.off { background: rgba(255,107,107,.14); color: var(--danger); }
.switch {
  appearance: none; width: 52px; height: 30px; border-radius: 99px;
  background: #2a3a58; position: relative; cursor: pointer; transition: background .2s; flex: 0 0 auto;
}
.switch::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px;
  border-radius: 50%; background: #fff; transition: transform .2s;
}
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(22px); }
.drv-meta { color: var(--muted); font-size: 12px; margin-top: 10px; }

.sec-title { font-size: 14px; color: var(--muted); margin: 24px 0 10px; font-weight: 600; letter-spacing: .4px; }
.job-list { display: grid; gap: 12px; }
.job {
  background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 14px;
  display: grid; gap: 10px;
}
.job.active { border-color: rgba(34,211,166,.5); background: #12251f; }
.job-head { display: flex; align-items: center; justify-content: space-between; }
.job-head strong { font-size: 19px; }
.job-tag {
  font-size: 11px; color: var(--muted); background: var(--card-2);
  padding: 4px 9px; border-radius: 99px; border: 1px solid var(--line);
}
.job-route { display: grid; gap: 8px; }
.job-meta { color: var(--muted); font-size: 12px; }
/* 撞時間警示：唔止靠接單時彈錯，卡片面就要見到 */
.clash {
  margin-top: 10px; padding: 9px 11px; border-radius: 10px;
  background: rgba(255,176,32,.1); border: 1px solid rgba(255,176,32,.4);
  color: #ffb020; font-size: 12px; line-height: 1.45;
}
.job .primary[disabled] { opacity: .45; cursor: not-allowed; }
.job .primary { margin: 2px 0 0; padding: 13px; }
.job .ghost { padding: 11px; }

@media (min-width: 720px) {
  .sheet {
    left: auto; right: 24px; bottom: 24px; width: 400px;
    border-radius: 24px; max-height: 82vh;
    border: 1px solid var(--line);
  }
  .grabber { display: none; }
  .topbar { padding: 18px 24px; }
}

/* 司機端：人數／支付／乘客要求 */
.x-row{display:flex;flex-wrap:wrap;gap:7px}
.x-pax,.x-pay{font-size:11.5px;padding:4px 10px;border-radius:99px;
  background:rgba(14,165,233,.12);border:1px solid rgba(14,165,233,.35);color:#7dd3fc}
.x-pay{background:rgba(34,211,166,.12);border-color:rgba(34,211,166,.35);color:#22d3a6}
.x-note{background:rgba(255,184,107,.09);border:1px solid rgba(255,184,107,.32);
  border-radius:12px;padding:9px 11px;display:grid;gap:3px}
.x-note b{font-size:11.5px;color:#ffb86b;font-weight:650}
.x-note span{font-size:13px;color:#e8eff9;line-height:1.45;white-space:pre-wrap;word-break:break-word}
.reply{display:flex;gap:8px;margin-top:2px}
.reply input{flex:1;min-width:0;padding:11px 13px;border-radius:12px;border:1px solid var(--line);
  background:#0d1626;color:var(--text);font:inherit;font-size:13.5px}
.reply input:focus{outline:none;border-color:var(--accent2)}
.reply .ghost{flex:0 0 auto;margin:0;padding:11px 16px}

/* ---- 搶單確認方格 ---- */
.modal-back {
  position: fixed; inset: 0; z-index: 800;
  display: flex; align-items: center; justify-content: center; padding: 18px;
  background: rgba(6, 11, 21, .72); backdrop-filter: blur(3px);
}
.modal-back.hidden { display: none; }

.modal-card {
  width: 100%; max-width: 380px; max-height: 86vh; overflow-y: auto;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 18px; padding: 18px 18px 16px;
  box-shadow: var(--shadow); animation: pop .16s ease-out;
}
@keyframes pop {
  from { transform: scale(.94); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.modal-head h3 { margin: 0; font-size: 17px; font-weight: 750; }
.modal-x {
  width: 30px; height: 30px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--card-2); color: var(--muted); font-size: 14px;
  cursor: pointer; line-height: 1; font-family: inherit;
}

.modal-lbl { margin: 0 0 7px; font-size: 11.5px; font-weight: 700; color: var(--muted);
  letter-spacing: .3px; text-transform: uppercase; }

.pay-big {
  padding: 14px 16px; border-radius: 13px; font-size: 17px; font-weight: 750;
  color: #f4d35e; background: rgba(244, 211, 94, .1);
  border: 1.5px solid rgba(244, 211, 94, .42); text-align: center;
  line-height: 1.35; word-break: break-word;
}
.pay-big.cash { color: var(--accent); background: rgba(34, 211, 166, .1);
  border-color: rgba(34, 211, 166, .4); }

.modal-note { margin: 9px 0 0; font-size: 12.5px; line-height: 1.55; color: var(--muted); text-align: center; }
.modal-note b { color: #ffd66b; }

.modal-route { margin-top: 15px; display: flex; flex-direction: column; gap: 6px; }
.modal-route .rs-row { font-size: 13.5px; }
.modal-route .stop-tag { margin-left: 6px; font-style: normal; font-size: 10px; padding: 1px 6px;
  border-radius: 99px; color: #f4d35e; background: rgba(244, 211, 94, .12);
  border: 1px solid rgba(244, 211, 94, .34); }

.modal-meta { margin-top: 11px; display: flex; flex-wrap: wrap; gap: 6px 12px;
  font-size: 12.5px; color: var(--muted); }

.modal-notes { margin-top: 11px; padding: 10px 12px; border-radius: 10px;
  background: rgba(125, 211, 252, .08); border: 1px solid rgba(125, 211, 252, .22);
  font-size: 12.5px; color: #bae6fd; line-height: 1.5; }

.modal-cd { margin: 14px 0 0; font-size: 12px; color: var(--muted); text-align: center; }
.modal-cd b { color: var(--accent); font-variant-numeric: tabular-nums; }
.modal-cd.expired b { color: var(--danger); }

.modal-actions { display: flex; gap: 10px; margin-top: 15px; }
.modal-actions button { flex: 1; padding: 13px 10px; border-radius: 12px; font-size: 14px;
  font-weight: 700; font-family: inherit; cursor: pointer; border: 1px solid var(--line); }
.modal-actions .ghost { background: var(--card-2); color: var(--muted); }
.modal-actions .primary { background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #06251c; border: none; }
/* 搶輸：字眼轉「已被搶」，成個方格灰落嚟，一秒幾後自動收 */
.modal-card.lost { border-color: rgba(232, 90, 90, .45); }
.modal-actions .primary.lost {
  background: rgba(232, 90, 90, .16);
  color: #ff9b9b;
  border: 1px solid rgba(232, 90, 90, .5);
  cursor: not-allowed;
  opacity: 1;
}
.modal-cd.expired b { color: var(--danger); }
#amIdle { margin-top: 4px; font-size: 11.5px; color: #ffb86b; }

.modal-actions button[disabled] { opacity: .55; cursor: default; }

/* ---- 分數 ---- */
.pts {
  margin-left: auto; font-size: 11px; font-weight: 700; color: #f4d35e;
  background: rgba(244, 211, 94, .12); border: 1px solid rgba(244, 211, 94, .32);
  padding: 2px 8px; border-radius: 99px; white-space: nowrap;
}
.deduct-row { display: flex; align-items: center; gap: 7px; margin: 2px 0 9px; flex-wrap: wrap; }
.deduct {
  font-size: 11.5px; font-weight: 800; padding: 3px 9px; border-radius: 8px;
  font-variant-numeric: tabular-nums;
}
.deduct.free { color: var(--accent); background: rgba(34, 211, 166, .12);
  border: 1px solid rgba(34, 211, 166, .3); }
.deduct.paid { color: #ffb4a2; background: rgba(255, 107, 107, .12);
  border: 1px solid rgba(255, 107, 107, .34); }
.kind-tag { font-size: 10.5px; color: var(--muted); border: 1px solid var(--line);
  padding: 2px 7px; border-radius: 99px; }
.bal-hint { margin-left: auto; font-size: 11px; color: var(--muted); }

.modal-deduct {
  margin-top: 12px; padding: 11px 13px; border-radius: 11px;
  display: flex; align-items: center; gap: 9px; flex-wrap: wrap;
  background: var(--card-2); border: 1px solid var(--line);
}
.modal-deduct span { font-size: 12.5px; color: var(--muted); }
.modal-deduct b { font-size: 17px; font-variant-numeric: tabular-nums; }
.modal-deduct em { font-size: 11.5px; color: var(--muted); font-style: normal; margin-left: auto; }
.modal-deduct.free b { color: var(--accent); }
.modal-deduct.paid b { color: #ff8f7d; }
.modal-deduct.paid { border-color: rgba(255, 107, 107, .3); background: rgba(255, 107, 107, .06); }
