:root {
  --accent: #4f46e5;
  --accent-dark: #4338ca;
  --accent-light: #eef2ff;
  --cta: #ffc82c;
  --cta-dark: #f5b400;
  --cta-ink: #1f1400;
  --green: #16a34a;
  --red: #dc2626;
  --amber: #d97706;
  --ink: #111827;
  --ink-soft: #6b7280;
  --line: #e5e7eb;
  --bg: #eef3fb;
  --card: rgba(255, 255, 255, 0.92);
  --shadow: 0 8px 30px rgba(17, 24, 39, 0.12);
  --radius: 16px;
  font-size: 16px;
}

* { box-sizing: border-box; }
button { font-family: inherit; -webkit-appearance: none; appearance: none; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

#map {
  position: fixed;
  inset: 0;
  background: #dfe3e8;
}

/* ---------- Top bar ---------- */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card);
  backdrop-filter: blur(10px);
  padding: 10px 16px;
  border-radius: 999px;
  box-shadow: var(--shadow);
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--ink);
}
.brand .dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

.icon-btn {
  background: var(--card);
  backdrop-filter: blur(10px);
  border: none;
  box-shadow: var(--shadow);
  border-radius: 999px;
  padding: 10px 16px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  color: var(--ink);
}
.icon-btn:hover { background: #fff; }

/* ---------- Cards / panels ---------- */
.panel {
  background: var(--card);
  backdrop-filter: blur(10px);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.center-wrap {
  min-height: 100%;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 90px 16px 40px;
  position: relative;
  z-index: 10;
}

.stack { max-width: 480px; width: 100%; display: flex; flex-direction: column; gap: 14px; }

h1.title { font-size: 1.4rem; margin: 0 0 4px; }
p.subtitle { margin: 0 0 6px; color: var(--ink-soft); font-size: 0.92rem; line-height: 1.5; }

label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

input[type="text"], input[type="search"] {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  font-size: 1rem;
  background: #fff;
  color: var(--ink);
}
input[type="text"]:focus, input[type="search"]:focus {
  outline: none;
  border-color: var(--accent);
}

.field { margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 10px;
  padding: 13px 18px;
  font-size: 0.98rem;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
  transition: transform 0.05s ease, background 0.15s ease;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary { background: var(--cta); color: var(--cta-ink); }
.btn-primary:hover:not(:disabled) { background: var(--cta-dark); }

.btn-secondary { background: var(--accent); color: #fff; }
.btn-secondary:hover:not(:disabled) { background: var(--accent-dark); }

.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }

.btn-ghost { background: #fff; color: var(--ink); border: 1.5px solid var(--line); }
.btn-ghost:hover { background: #f9fafb; }

.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }

.hint {
  font-size: 0.82rem;
  color: var(--ink-soft);
  background: var(--accent-light);
  border-radius: 10px;
  padding: 10px 12px;
  line-height: 1.5;
}

.step-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--accent-light);
  color: var(--accent-dark);
}

.map-pick-hint {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 15;
}

/* ---------- Status badges ---------- */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 999px;
}
.status-live { background: #dcfce7; color: var(--green); }
.status-pending { background: #fef3c7; color: var(--amber); }
.status-completed { background: #e5e7eb; color: var(--ink-soft); }

.pulse {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: currentColor;
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.5); }
  70%  { box-shadow: 0 0 0 8px rgba(22, 163, 74, 0); }
  100% { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0); }
}

/* ---------- Bottom sheet (viewer / tracker) ---------- */
.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 20;
  padding: 14px;
}
.sheet-inner {
  max-width: 560px;
  margin: 0 auto;
}

.trip-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.trip-header h2 {
  margin: 0;
  font-size: 1.05rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}
.stat {
  background: #f9fafb;
  border-radius: 10px;
  padding: 10px 8px;
  text-align: center;
}
.stat .value { font-size: 1.05rem; font-weight: 700; }
.stat .label { font-size: 0.7rem; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.03em; margin-top: 2px; }

.share-box {
  display: flex;
  gap: 8px;
  align-items: center;
  background: #f9fafb;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  margin-bottom: 10px;
}
.share-box input {
  border: none;
  background: transparent;
  flex: 1;
  font-size: 0.85rem;
  color: var(--ink-soft);
  min-width: 0;
}
.share-box input:focus { outline: none; }
.share-box button {
  border: none;
  background: var(--accent);
  color: #fff;
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
}

.share-label { font-size: 0.75rem; font-weight: 700; color: var(--ink-soft); margin: 10px 0 4px; text-transform: uppercase; letter-spacing: 0.03em; }
.share-label:first-child { margin-top: 0; }

.footer-note {
  text-align: center;
  font-size: 0.78rem;
  color: var(--ink-soft);
  margin-top: 10px;
}

.error-banner {
  background: #fef2f2;
  color: var(--red);
  border: 1.5px solid #fecaca;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.85rem;
  display: none;
}
.error-banner.show { display: block; }

/* ---------- Map markers ---------- */
.marker-pin {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  box-shadow: 0 3px 8px rgba(0,0,0,0.35);
  border: 2px solid #fff;
}
.marker-pin span {
  transform: rotate(45deg);
  font-size: 14px;
  font-weight: 800;
  color: #fff;
}
.marker-pin.start { background: var(--green); }
.marker-pin.end { background: var(--red); }

.live-marker {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid #fff;
  box-shadow: 0 0 0 6px rgba(79, 70, 229, 0.25), 0 2px 6px rgba(0,0,0,0.3);
  position: relative;
}
.live-marker::after {
  content: "";
  position: absolute;
  inset: -10px;
  border-radius: 50%;
  border: 2px solid rgba(79, 70, 229, 0.4);
  animation: livepulse 1.8s ease-out infinite;
}
@keyframes livepulse {
  0% { transform: scale(0.6); opacity: 0.9; }
  100% { transform: scale(1.9); opacity: 0; }
}

/* ---------- Address fields (pickup / drop) ---------- */
.address-field {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  background: #fff;
  border-radius: 14px;
  padding: 14px 16px;
  border: 1.5px solid var(--line);
  margin-bottom: 12px;
  transition: border-color 0.15s ease;
}
.address-field:focus-within { border-color: var(--ink); }
.address-field .af-icon { flex-shrink: 0; display: flex; color: var(--ink); }
/* Scoped with the [type="text"] attribute selector so this always outranks
   (and fully neutralizes) the generic input[type="text"] rule above,
   regardless of stylesheet order — keeps this address pill from ever
   growing its own border/background/padding again. */
.address-field input[type="text"] {
  border: none;
  outline: none;
  flex: 1;
  min-width: 0;
  width: auto;
  padding: 0;
  border-radius: 0;
  font-size: 1rem;
  background: transparent;
  color: var(--ink);
}
.address-field input::placeholder { color: #9aa1ad; }
.address-field .af-clear,
.address-field .af-locate {
  border: none;
  background: none;
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
}
.address-field .af-clear {
  color: var(--ink-soft);
  font-size: 1.1rem;
  padding: 2px 4px;
  display: none;
}
.address-field.has-value .af-clear { display: block; }
.address-field .af-locate {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-light);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, color 0.15s ease;
}
.address-field .af-locate:hover { background: #e0e2fc; }
.address-field .af-locate.active { background: #dcfce7; color: var(--green); }
.address-field .af-locate.loading { animation: locateSpin 1s linear infinite; }
@keyframes locateSpin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.address-suggestions {
  position: absolute;
  left: 0; right: 0;
  top: calc(100% + 6px);
  background: #fff;
  border-radius: 12px;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  max-height: 240px;
  overflow-y: auto;
  z-index: 40;
  display: none;
}
.address-suggestions.show { display: block; }
.address-suggestions .sugg-item {
  padding: 11px 14px;
  font-size: 0.86rem;
  cursor: pointer;
  border-bottom: 1px solid var(--line);
  line-height: 1.35;
}
.address-suggestions .sugg-item:last-child { border-bottom: none; }
.address-suggestions .sugg-item:hover,
.address-suggestions .sugg-item.active { background: var(--accent-light); }
.address-suggestions .sugg-empty {
  padding: 12px 14px;
  font-size: 0.82rem;
  color: var(--ink-soft);
}

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.45);
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-overlay.hidden { display: none; }
.modal-box {
  background: #fff;
  border-radius: 18px;
  max-width: 480px;
  width: 100%;
  padding: 22px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
  max-height: 90vh;
  overflow-y: auto;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.modal-header h3 { margin: 0; font-size: 1.1rem; }
.modal-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  color: var(--ink-soft);
  padding: 4px;
}
.modal-close:hover { color: var(--ink); }

@media (max-width: 480px) {
  .stat-row { gap: 6px; }
  .stat { padding: 8px 4px; }
  .stat .value { font-size: 0.92rem; }
}
