/* SCAN Maps — mobile-first UI */
:root {
  --scan-green: #0b7d3e;
  --scan-green-dark: #075c2d;
  --scan-navy: #10243c;
  --scan-bg: #ffffff;
  --scan-text: #142033;
  --scan-muted: #5b6b80;
  --scan-line: #e3e8ef;
  --scan-blue: #1a73e8;
  --radius: 16px;
  --shadow: 0 4px 18px rgba(16, 36, 60, .18);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--scan-text);
  overscroll-behavior: none;
}

#map { position: fixed; inset: 0; z-index: 0; background: #dfe8dd; }

/* ---------- Top bar ---------- */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20;
  padding: calc(10px + env(safe-area-inset-top)) 12px 0;
  pointer-events: none;
}
.searchwrap {
  pointer-events: auto;
  background: var(--scan-bg); border-radius: 28px; box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 8px; padding: 4px 14px;
}
.searchwrap .logo {
  font-weight: 800; color: var(--scan-green); font-size: 14px; white-space: nowrap;
}
.searchwrap input {
  flex: 1; border: 0; outline: none; font-size: 16px; padding: 12px 2px; background: transparent;
  min-width: 0;
}
.searchwrap button {
  border: 0; background: transparent; font-size: 18px; padding: 8px; cursor: pointer; color: var(--scan-muted);
}
.chips {
  pointer-events: auto;
  display: flex; gap: 8px; padding: 10px 2px; overflow-x: auto; scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  background: var(--scan-bg); border: 1px solid var(--scan-line); border-radius: 20px;
  padding: 9px 14px; font-size: 14px; font-weight: 600; white-space: nowrap;
  box-shadow: 0 2px 8px rgba(16,36,60,.10); cursor: pointer; color: var(--scan-text);
}
.chip.primary { background: var(--scan-green); color: #fff; border-color: var(--scan-green); }

/* Search results */
.results {
  pointer-events: auto;
  background: var(--scan-bg); border-radius: var(--radius); box-shadow: var(--shadow);
  margin-top: 6px; max-height: 46vh; overflow-y: auto; display: none;
}
.results.open { display: block; }
.result {
  display: flex; align-items: center; gap: 12px; padding: 13px 14px;
  border-bottom: 1px solid var(--scan-line); cursor: pointer;
}
.result:last-child { border-bottom: 0; }
.result .ricon { font-size: 20px; }
.result .rname { font-weight: 700; font-size: 15px; }
.result .rdetail { color: var(--scan-muted); font-size: 13px; }

/* ---------- Map controls ---------- */
.mapctl {
  position: fixed; right: 12px; z-index: 15; display: flex; flex-direction: column; gap: 10px;
}
.mapctl button {
  width: 46px; height: 46px; border-radius: 50%; border: 0; background: var(--scan-bg);
  box-shadow: var(--shadow); font-size: 20px; cursor: pointer; color: var(--scan-navy);
}

/* ---------- Bottom sheet ---------- */
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
  background: var(--scan-bg); border-radius: 20px 20px 0 0; box-shadow: 0 -6px 24px rgba(16,36,60,.22);
  padding: 10px 18px calc(16px + env(safe-area-inset-bottom));
  transform: translateY(110%); transition: transform .25s ease;
  max-height: 72vh; overflow-y: auto;
}
.sheet.open { transform: translateY(0); }
.grab { width: 44px; height: 5px; border-radius: 3px; background: var(--scan-line); margin: 4px auto 12px; }

.dest-kicker { color: var(--scan-muted); font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.dest-title { font-size: 24px; font-weight: 800; margin: 2px 0 2px; }
.dest-sub { color: var(--scan-muted); font-size: 15px; margin-bottom: 10px; }

.pillrow { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 14px; }
.pill {
  background: #f1f5f0; border-radius: 12px; padding: 8px 12px; font-size: 13px; font-weight: 600;
}
.pill b { color: var(--scan-green-dark); }

.btnrow { display: flex; gap: 10px; }
.btn {
  flex: 1; border: 0; border-radius: 14px; padding: 16px; font-size: 17px; font-weight: 800;
  cursor: pointer; text-align: center;
}
.btn.go { background: var(--scan-green); color: #fff; }
.btn.go:active { background: var(--scan-green-dark); }
.btn.ghost { background: #eef2f7; color: var(--scan-navy); flex: 0 0 auto; padding: 16px 18px; font-size: 15px; }

/* ---------- Navigation mode ---------- */
.navbanner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 30;
  background: var(--scan-navy); color: #fff;
  padding: calc(12px + env(safe-area-inset-top)) 16px 14px;
  display: none;
}
.navbanner.open { display: block; }
.nav-stage { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: #9fd4b4; }
.nav-instruction { font-size: 21px; font-weight: 800; margin-top: 3px; line-height: 1.25; }
.nav-sub { margin-top: 4px; font-size: 14px; color: #c6d2e0; }

.navfoot {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: var(--scan-bg); border-radius: 18px 18px 0 0; box-shadow: 0 -6px 24px rgba(16,36,60,.22);
  padding: 14px 18px calc(14px + env(safe-area-inset-bottom));
  display: none; align-items: center; gap: 14px;
}
.navfoot.open { display: flex; }
.nav-eta { font-size: 22px; font-weight: 800; color: var(--scan-green-dark); }
.nav-dist { font-size: 14px; color: var(--scan-muted); }
.nav-exit {
  margin-left: auto; border: 0; background: #fdecea; color: #b3261e;
  border-radius: 12px; padding: 12px 16px; font-weight: 800; font-size: 15px; cursor: pointer;
}

/* ---------- Arrival overlay ---------- */
.arrive {
  position: fixed; inset: 0; z-index: 40; display: none;
  background: rgba(11,125,62,.96); color: #fff; text-align: center;
  padding: 24px; flex-direction: column; justify-content: center; align-items: center; gap: 10px;
}
.arrive.open { display: flex; }
.arrive .big { font-size: 34px; font-weight: 900; }
.arrive .mid { font-size: 19px; font-weight: 600; opacity: .95; }
.arrive .btn { flex: 0 0 auto; max-width: 320px; width: 100%; background: #fff; color: var(--scan-green-dark); margin-top: 14px; }
.arrive .btn.alt { background: rgba(255,255,255,.16); color: #fff; }

/* ---------- Phase 2: alerts, modal, sheet links ---------- */
.destalert {
  background: #fdecea; border: 1px solid #f5c6c0; color: #7a1d16;
  border-radius: 12px; padding: 12px 14px; font-size: 14px; margin: 8px 0 4px; line-height: 1.4;
}
.destalert b { letter-spacing: .04em; }
.destalert .btn { width: 100%; padding: 12px; font-size: 15px; }
.sheetlinks { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; }
.linkbtn { border: 0; background: transparent; color: var(--scan-muted); font-size: 13px;
  text-decoration: underline; cursor: pointer; padding: 4px 0; }
.modal { position: fixed; inset: 0; background: rgba(16,36,60,.55); display: none;
  align-items: center; justify-content: center; z-index: 70; padding: 18px; }
.modal.open { display: flex; }
.modal .card { background: var(--scan-bg); border-radius: 16px; padding: 20px; max-width: 420px; width: 100%; }
.modal .card h2 { margin: 0 0 12px; font-size: 18px; }
.modal select, .modal textarea { width: 100%; padding: 10px; border: 1px solid var(--scan-line);
  border-radius: 10px; font-size: 15px; font-family: inherit; margin-top: 8px; }
.modal textarea { min-height: 70px; }

/* ---------- Phase 3: alerts bar, booking, field-change overlay ---------- */
.alertbar { pointer-events: auto; margin-top: 6px; }
.alertmsg {
  background: #e8f1fb; border: 1px solid #bcd6f5; color: #123f73;
  border-radius: 12px; padding: 10px 13px; font-size: 13px; font-weight: 600; margin-bottom: 6px;
  box-shadow: 0 2px 8px rgba(16,36,60,.10);
}
.alertmsg.warn { background: #fdecea; border-color: #f5c6c0; color: #7a1d16; }
.modal input { width: 100%; padding: 10px; border: 1px solid var(--scan-line); border-radius: 10px;
  font-size: 15px; font-family: inherit; margin-top: 8px; }
.bookwhen { color: var(--scan-green-dark); font-weight: 700; font-size: 14px; margin: 0 0 4px; }
.bookfine { color: var(--scan-muted); font-size: 12px; margin: 10px 0 0; }
.arrive.warn { background: rgba(179,38,30,.96); }
.arrive.warn .btn { color: #7a1d16; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 96px; left: 50%; transform: translateX(-50%);
  background: var(--scan-navy); color: #fff; padding: 11px 18px; border-radius: 22px;
  font-size: 14px; z-index: 60; box-shadow: var(--shadow); display: none; max-width: 88vw; text-align: center;
}
.toast.open { display: block; }

/* Field marker */
.field-marker {
  background: var(--scan-green); color: #fff; border: 2px solid #fff; border-radius: 10px;
  font-weight: 800; font-size: 12px; padding: 3px 7px; box-shadow: 0 2px 6px rgba(0,0,0,.35);
  white-space: nowrap;
}
.poi-marker {
  background: #fff; color: var(--scan-navy); border: 1px solid var(--scan-line); border-radius: 10px;
  font-weight: 700; font-size: 11px; padding: 2px 6px; box-shadow: 0 2px 6px rgba(0,0,0,.25); white-space: nowrap;
}
.gps-acc { font-size: 11px; color: var(--scan-muted); }
