:root {
  --green: #7CF46E;
  --green-dark: #0E5E21;
  --green-soft: #E8FFE4;
  --ink: #121713;
  --muted: #667067;
  --line: #E5E9E4;
  --surface: #FFFFFF;
  --page: #F3F5F2;
  --danger: #B83B2C;
  --danger-soft: #FFF0ED;
  --shadow: 0 20px 55px rgba(20, 35, 22, 0.12);
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  background: radial-gradient(circle at top, #FFFFFF 0, #F5F7F4 45%, #EEF1ED 100%);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  display: grid;
  place-items: center;
  padding: 20px;
}

button, input, textarea, select { font: inherit; }
button { cursor: pointer; }

.app-shell {
  width: min(100%, 430px);
  min-height: min(900px, calc(100vh - 40px));
  background: var(--surface);
  border: 1px solid rgba(18, 23, 19, 0.08);
  border-radius: 30px;
  overflow: hidden;
  box-shadow: var(--shadow);
  position: relative;
}

.app-header {
  height: 88px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 20px;
  background: var(--green);
  border-bottom: 1px solid rgba(18, 23, 19, 0.08);
}

.brand-mark {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: #101610;
  color: var(--green);
  display: grid;
  place-items: center;
  font-size: 25px;
  font-weight: 900;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.1);
}

.brand-title { font-weight: 850; font-size: 22px; letter-spacing: -0.03em; }
.brand-subtitle { font-size: 12px; opacity: 0.65; margin-top: 2px; }

.screen {
  display: none;
  min-height: calc(min(900px, calc(100vh - 40px)) - 88px);
  animation: fadeIn 180ms ease;
}

.screen.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.map-card {
  height: 565px;
  position: relative;
  overflow: hidden;
  background: #EEF0ED;
}

.map-card svg { width: 100%; height: 100%; display: block; }

.map-status-card {
  position: absolute;
  top: 18px;
  left: 18px;
  right: 18px;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(18,23,19,0.07);
  border-radius: 18px;
  padding: 13px 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 8px 22px rgba(20,35,22,0.10);
}

.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22B84C;
  margin-right: 7px;
}

.ride-panel {
  padding: 20px;
  display: grid;
  gap: 18px;
  background: #fff;
}

h1 {
  margin: 6px 0 8px;
  font-size: clamp(29px, 7.5vw, 39px);
  line-height: 1.05;
  letter-spacing: -0.045em;
}

p { margin: 0; }

.eyebrow {
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #536054;
}

.muted { color: var(--muted); line-height: 1.45; font-size: 15px; }
.centered { text-align: center; max-width: 330px; }

.primary-btn,
.secondary-btn {
  width: 100%;
  border: 0;
  border-radius: 16px;
  min-height: 56px;
  padding: 15px 18px;
  font-weight: 850;
  font-size: 16px;
  transition: transform 120ms ease, filter 120ms ease, background 120ms ease;
}

.primary-btn {
  background: #111811;
  color: #fff;
  box-shadow: 0 10px 20px rgba(17,24,17,0.14);
}
.primary-btn:hover { filter: brightness(1.08); }
.primary-btn:active, .secondary-btn:active { transform: scale(0.985); }

.secondary-btn {
  background: #F0F3EF;
  color: #1B211B;
  border: 1px solid #E1E6E0;
}

.center-screen {
  padding: 72px 26px 34px;
  text-align: center;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
}

.center-screen.active { display: flex; }

.state-icon {
  width: 76px;
  height: 76px;
  border-radius: 24px;
  margin: 24px 0 28px;
  display: grid;
  place-items: center;
}

.spinner {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 6px solid #E5E9E4;
  border-top-color: #111811;
  animation: spin 0.85s linear infinite;
  background: transparent;
}

@keyframes spin { to { transform: rotate(360deg); } }

.warning {
  background: var(--danger-soft);
  color: var(--danger);
  border-radius: 50%;
  font-size: 36px;
  font-weight: 900;
}

.success-mark {
  background: var(--green-soft);
  color: var(--green-dark);
  border-radius: 50%;
  font-size: 36px;
  font-weight: 900;
}

.danger-text { color: var(--danger); }
.success-text { color: var(--green-dark); }

.action-stack {
  width: 100%;
  margin-top: 36px;
  display: grid;
  gap: 10px;
}

.scanner-screen { padding: 28px 20px 24px; }
.scanner-copy { text-align: left; }
.scanner-copy h1 { font-size: 31px; }

.camera-frame {
  height: 430px;
  border-radius: 24px;
  overflow: hidden;
  position: relative;
  margin: 24px 0 16px;
  background: linear-gradient(145deg, #1F2621, #0F1310 70%);
  border: 1px solid #2D352F;
}

#cameraVideo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}

.camera-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 13px;
  color: rgba(255,255,255,0.72);
  font-size: 14px;
}

.camera-icon {
  width: 56px;
  height: 42px;
  border: 3px solid rgba(255,255,255,0.8);
  border-radius: 10px;
  position: relative;
}
.camera-icon::before {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border: 3px solid rgba(255,255,255,0.8);
  border-radius: 50%;
  left: 17px;
  top: 10px;
}
.camera-icon::after {
  content: "";
  position: absolute;
  width: 19px;
  height: 8px;
  border-radius: 4px 4px 0 0;
  background: rgba(255,255,255,0.8);
  left: 6px;
  top: -8px;
}

.scan-box {
  width: 210px;
  height: 210px;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

.scan-box span {
  position: absolute;
  width: 48px;
  height: 48px;
  border-color: var(--green);
  border-style: solid;
}
.scan-box span:nth-child(1) { left: 0; top: 0; border-width: 5px 0 0 5px; border-radius: 12px 0 0 0; }
.scan-box span:nth-child(2) { right: 0; top: 0; border-width: 5px 5px 0 0; border-radius: 0 12px 0 0; }
.scan-box span:nth-child(3) { left: 0; bottom: 0; border-width: 0 0 5px 5px; border-radius: 0 0 0 12px; }
.scan-box span:nth-child(4) { right: 0; bottom: 0; border-width: 0 5px 5px 0; border-radius: 0 0 12px 0; }

.scan-line {
  position: absolute;
  left: 50%;
  top: calc(50% - 92px);
  width: 176px;
  height: 2px;
  background: var(--green);
  box-shadow: 0 0 12px rgba(124,244,110,0.9);
  transform: translateX(-50%);
  animation: scan 2s ease-in-out infinite alternate;
}

@keyframes scan {
  from { transform: translate(-50%, 0); }
  to { transform: translate(-50%, 182px); }
}

.scanner-actions { display: grid; gap: 10px; }
.microcopy { margin-top: 12px; color: #7B847C; font-size: 12px; line-height: 1.4; text-align: center; }
.microcopy.error-text { color: var(--danger); font-weight: 700; font-size: 13px; }

.receipt-card {
  width: 100%;
  margin: 32px 0 16px;
  background: #F5F7F4;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 8px 18px;
}

.receipt-card div {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 15px 0;
  border-bottom: 1px solid var(--line);
  text-align: left;
}
.receipt-card div:last-child { border-bottom: 0; }
.receipt-card span { color: var(--muted); }
.receipt-card strong { text-align: right; }

@media (max-width: 470px) {
  body { padding: 0; background: #fff; }
  .app-shell {
    width: 100%;
    min-height: 100dvh;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }
  .screen { min-height: calc(100dvh - 88px); }
  .map-card { height: calc(100dvh - 325px); min-height: 440px; }
}

#cameraVideo.scan-success {
  filter: brightness(1.12) saturate(1.08);
  outline: 5px solid var(--green);
  outline-offset: -5px;
}

#cameraVideo.scan-error {
  outline: 5px solid var(--danger);
  outline-offset: -5px;
}

.invalid-banner {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 16px;
  z-index: 5;
  display: grid;
  gap: 4px;
  padding: 14px 16px;
  border-radius: 16px;
  background: var(--danger);
  color: #FFFFFF;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  animation: banner-in 0.2s ease-out;
}

.invalid-banner[hidden] { display: none; }
.invalid-banner strong { font-size: 20px; }
.invalid-banner span { font-size: 14px; line-height: 1.35; }

@keyframes banner-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.directions-map { height: 440px; }

.route-casing {
  fill: none;
  stroke: #FFFFFF;
  stroke-width: 12;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.route-line {
  fill: none;
  stroke: #111811;
  stroke-width: 5;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 10 9;
  animation: route-flow 0.9s linear infinite;
}

@keyframes route-flow { to { stroke-dashoffset: -19; } }

.directions-meta { display: block; margin-top: 4px; font-size: 17px; }

.parking-badge {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--green);
  color: #0D150E;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 20px;
}

.action-stack.tight { margin-top: 0; }
