:root {
  --bg: #f2f6fc;
  --card: #ffffff;
  --card-2: #edf2fa;
  --line: #d9e2f0;
  --text: #17233c;
  --muted: #5c6c8c;
  --accent: #12b76a;
  --accent-dark: #0e9660;
  --warn: #c47f00;
  --danger: #e5484d;
  --radius: 16px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: linear-gradient(180deg, #e7f0fd 0%, #f4f8fe 260px, var(--bg) 100%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: 84px;
}

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 8px;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  background: rgba(255, 255, 255, .85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; letter-spacing: .2px; }
.city-chip {
  display: flex; align-items: center; gap: 6px;
  background: var(--card); color: var(--text);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 7px 13px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.city-chip:active { background: var(--card-2); }

/* ---------- layout ---------- */
#app { padding: 16px; max-width: 520px; margin: 0 auto; }
.screen { display: none; }
/* Visibility never depends on the animation: transform only, no opacity. */
.screen.active { display: block; animation: riseIn .25s ease; }
@keyframes riseIn {
  from { transform: translateY(8px); }
  to { transform: none; }
}
.screen-title { font-size: 22px; margin: 6px 2px 14px; }
.sub-title { font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: .8px; margin: 20px 4px 8px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: 0 2px 12px rgba(23, 35, 60, .06);
  transition: box-shadow .2s;
}
.hidden { display: none !important; }

/* ---------- forms ---------- */
.field { display: block; margin-bottom: 12px; }
.field span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; font-weight: 600; }
.field.inline { flex: 1; }
input, select {
  width: 100%;
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  padding: 12px;
  font-size: 16px;
  outline: none;
  transition: border-color .15s;
}
input:focus, select:focus { border-color: var(--accent); }

.segmented { display: flex; gap: 6px; margin: 4px 0 14px; }
.seg {
  flex: 1; padding: 9px 0;
  background: var(--card-2); color: var(--muted);
  border: 1px solid var(--line); border-radius: 10px;
  font-size: 14px; font-weight: 600; cursor: pointer;
}
.seg.active { background: var(--accent); color: #ffffff; border-color: var(--accent); }

/* ---------- buttons ---------- */
.btn {
  width: 100%; padding: 13px; border-radius: 12px;
  border: none; font-size: 15px; font-weight: 700; cursor: pointer;
}
.btn.primary {
  background: linear-gradient(135deg, #17c47f, #0e9660);
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(18, 183, 106, .28);
}
.btn.primary:active { filter: brightness(.94); }
.btn:active { transform: scale(.98); }
.btn.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); margin-top: 8px; }
.btn.tiny { width: auto; padding: 7px 12px; font-size: 12px; background: var(--card-2); color: var(--text); border: 1px solid var(--line); }
.btn:disabled { opacity: .45; cursor: default; }
.btn-row { display: flex; gap: 8px; }
.btn-row .btn { margin-top: 8px; }
.btn-row .ghost { margin-top: 8px; }

/* ---------- quotes ---------- */
.quote-row { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 4px; }
.quote-main { display: flex; align-items: baseline; gap: 6px; }
.quote-amount { font-size: 30px; font-weight: 800; color: var(--accent); }
.quote-usdc { font-size: 13px; color: var(--muted); font-weight: 700; }
.quote-local { font-size: 13px; color: var(--muted); }
.quote-meta { font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.route-canvas {
  width: 100%; height: 110px;
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  margin: 10px 0;
}
.fineprint { font-size: 12px; color: var(--muted); line-height: 1.5; margin-top: 8px; }
.fineprint.center { text-align: center; margin-top: 4px; }

/* ---------- trip ---------- */
.trip-status { font-size: 16px; font-weight: 700; margin-bottom: 10px; }
.driver-box { display: flex; align-items: center; gap: 12px; background: var(--card-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 6px; }
.avatar {
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--accent); color: #ffffff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 17px; flex-shrink: 0;
}
.driver-info { flex: 1; min-width: 0; }
.driver-name { font-weight: 700; font-size: 15px; }
.driver-sub { font-size: 12.5px; color: var(--muted); }
.driver-sub.verified-line { color: var(--accent-dark); font-weight: 600; }
.driver-rating { font-size: 13px; color: var(--warn); font-weight: 700; white-space: nowrap; }

/* ---------- driver mode ---------- */
.toggle-row { display: flex; align-items: center; justify-content: space-between; }
.toggle-title { font-weight: 700; font-size: 16px; }
.toggle-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.switch {
  width: 52px; height: 30px; border-radius: 999px;
  background: var(--card-2); border: 1px solid var(--line);
  position: relative; cursor: pointer; transition: background .2s;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--muted); transition: transform .2s, background .2s;
}
.switch.on { background: var(--accent); border-color: var(--accent); }
.switch.on::after { transform: translateX(22px); background: #ffffff; }
.earn-row { display: flex; gap: 24px; margin-top: 16px; }
.earn-label { font-size: 12px; color: var(--muted); }
.earn-value { font-size: 20px; font-weight: 800; color: var(--accent); margin-top: 2px; }
.earn-value#sessionJobs { color: var(--text); }

.req-head { font-size: 13px; font-weight: 700; color: var(--warn); margin-bottom: 10px; text-transform: uppercase; letter-spacing: .5px; }
.req-route { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.req-route > div { display: flex; align-items: center; gap: 10px; font-size: 14.5px; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.dot-a { background: var(--accent); }
.dot-b { background: var(--danger); }
.countdown { text-align: center; font-size: 12px; color: var(--muted); margin-top: 10px; height: 14px; }

/* ---------- wallet ---------- */
.wallet-card { text-align: center; }
.balance-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .8px; }
.balance { font-size: 40px; font-weight: 800; margin: 6px 0 2px; }
.balance-unit { font-size: 15px; color: var(--muted); font-weight: 700; margin-left: 6px; }
.balance-local { font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.network-row { display: flex; gap: 10px; text-align: left; margin-bottom: 12px; }
.addr-row { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.addr {
  flex: 1; font-size: 12px; color: var(--accent);
  background: var(--card-2); border: 1px solid var(--line);
  border-radius: 8px; padding: 9px 10px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.wallet-card .btn-row { flex-direction: column; }
.wallet-card .fineprint { text-align: left; }

.list { display: flex; flex-direction: column; gap: 8px; }
.list-item {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.li-main { min-width: 0; }
.li-title { font-size: 14px; font-weight: 700; }
.li-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.li-amount { font-size: 14px; font-weight: 800; white-space: nowrap; }
.li-amount.pos { color: var(--accent); }
.li-amount.neg { color: var(--danger); }
.li-amount.hold { color: var(--warn); }
.empty { font-size: 13px; color: var(--muted); padding: 8px 2px; }

/* ---------- modal ---------- */
.modal {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(23, 35, 60, .45); backdrop-filter: blur(4px);
  display: flex; align-items: flex-end; justify-content: center;
}
.modal-card {
  width: 100%; max-width: 520px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 20px 20px 0 0; padding: 20px 16px 24px;
}
.modal-card h3 { font-size: 18px; margin-bottom: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 14px; }
.chip {
  background: var(--card-2); border: 1px solid var(--line);
  color: var(--text); border-radius: 999px;
  padding: 7px 13px; font-size: 13px; cursor: pointer;
}
.chip:active { border-color: var(--accent); }

/* ---------- bottom nav ---------- */
.bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  display: flex; justify-content: space-around;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding: 8px 4px calc(8px + env(safe-area-inset-bottom));
}
.navbtn {
  background: none; border: none; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: 11px; font-weight: 600; cursor: pointer; padding: 4px 12px;
}
.navbtn.active { color: var(--accent); }

/* ---------- toast ---------- */
.toast {
  position: fixed; bottom: 104px; left: 50%; transform: translateX(-50%);
  background: var(--card-2); border: 1px solid var(--line);
  color: var(--text); font-size: 13.5px; font-weight: 600;
  border-radius: 999px; padding: 10px 18px; z-index: 60;
  box-shadow: 0 8px 24px rgba(23, 35, 60, .18);
  max-width: 90%; text-align: center;
}


/* ---------- top actions & update notes ---------- */
.top-actions { display: flex; align-items: center; gap: 8px; }
.ver { color: var(--muted); font-weight: 600; font-size: 11px; }
.notes-list { margin-top: 12px; max-height: 46vh; overflow-y: auto; }
.note-item { margin-bottom: 14px; }
.note-ver { font-weight: 800; color: var(--accent); font-size: 14px; }
.note-item ul { margin: 6px 0 0 18px; font-size: 13px; color: var(--muted); line-height: 1.6; }


/* ---------- account & KYC ---------- */
.avatar-mini {
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--muted); color: #ffffff;
  font-size: 11px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.city-chip.verified { border-color: var(--accent); }
.city-chip.verified .avatar-mini { background: var(--accent); }
.bottomnav.locked { opacity: .35; pointer-events: none; }
.file-label {
  display: block; text-align: center;
  padding: 14px; margin-bottom: 12px;
  border: 1px dashed var(--line); border-radius: 12px;
  color: var(--muted); font-size: 14px; font-weight: 600; cursor: pointer;
}
.file-label:active { border-color: var(--accent); color: var(--text); }
.kyc-preview {
  width: 100%; max-height: 180px; object-fit: cover;
  border-radius: 12px; border: 1px solid var(--line);
  margin-bottom: 12px;
}
.check {
  display: flex; align-items: flex-start; gap: 8px;
  font-size: 13px; color: var(--muted);
  line-height: 1.5; margin-bottom: 12px; cursor: pointer;
}
.check input {
  width: auto; padding: 0; margin-top: 2px;
  background: none; border: none;
  accent-color: var(--accent);
  flex-shrink: 0;
}
.status-pill {
  display: inline-block; padding: 5px 12px;
  border-radius: 999px; font-size: 12px; font-weight: 700;
}
.status-pill.pending { background: rgba(246,196,83,.15); color: var(--warn); }
.status-pill.approved { background: rgba(61,220,151,.15); color: var(--accent); }
.kv { margin: 12px 0; display: flex; flex-direction: column; gap: 7px; }
.kv > div { display: flex; justify-content: space-between; gap: 10px; font-size: 13.5px; }
.kv-k { color: var(--muted); }
.kv-v { font-weight: 600; text-align: right; overflow-wrap: anywhere; }


/* ---------- country compliance ---------- */
.banner {
  background: #fff4dd;
  border: 1px solid #ecd39c;
  color: #8a5800;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.45;
  margin-bottom: 10px;
}
.banner.danger { background: #fdeaea; border-color: #f2b9bb; color: #a11d24; }
.list-item .btn.tiny { flex-shrink: 0; }


/* ---------- interaction polish ---------- */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

@media (hover: hover) {
  .btn.primary:hover { filter: brightness(1.05); }
  .btn.ghost:hover { border-color: var(--muted); color: var(--text); }
  .seg:not(.active):hover { color: var(--text); }
  .chip:hover, .city-chip:hover { border-color: var(--accent); }
  .card:hover { box-shadow: 0 6px 20px rgba(23, 35, 60, .09); }
  .navbtn:hover { color: var(--text); }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---------- responsive layout ---------- */

@media (min-width: 768px) {
  #app { max-width: 760px; padding: 24px; }
  .screen-title { font-size: 26px; margin: 10px 2px 18px; }
  .card { padding: 20px; }
  .topbar { padding-left: 28px; padding-right: 28px; }
  .route-canvas { height: 150px; }
  .btn { padding: 14px; font-size: 16px; }

  .modal { align-items: center; }
  .modal-card { max-width: 560px; border-radius: 20px; padding: 24px; }

  .bottomnav {
    left: 50%; right: auto; transform: translateX(-50%);
    bottom: calc(16px + env(safe-area-inset-bottom));
    max-width: 560px;
    border-radius: 999px;
    border: 1px solid var(--line);
    box-shadow: 0 10px 30px rgba(23, 35, 60, .16);
    padding: 6px 12px;
  }
  body { padding-bottom: 104px; }
  .toast { bottom: 118px; }
}

@media (min-width: 1024px) {
  #app { max-width: 960px; }
  #screen-ride.active, #screen-delivery.active {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    align-items: start;
  }
  #screen-ride.active .card, #screen-delivery.active .card { margin-bottom: 0; }
  #screen-ride.active .screen-title, #screen-delivery.active .screen-title { grid-column: 1 / -1; }
}

@media (max-width: 350px) {
  #app { padding: 12px; }
  .screen-title { font-size: 20px; }
  .quote-amount { font-size: 25px; }
  .city-chip { padding: 6px 9px; font-size: 12px; gap: 4px; }
  .navbtn { padding: 4px 8px; font-size: 10px; }
  .earn-row { gap: 16px; }
  .balance { font-size: 34px; }
}


/* ---------- ride hero ---------- */
.hero {
  position: relative;
  border-radius: 18px;
  overflow: hidden;
  margin-bottom: 14px;
  min-height: 180px;
  display: flex; align-items: flex-end;
  padding: 18px;
  background:
    linear-gradient(180deg, rgba(13, 27, 48, .08) 0%, rgba(13, 27, 48, .66) 100%),
    url("images/hero.jpg");
  background-size: cover;
  background-position: center 28%;
  box-shadow: 0 2px 12px rgba(23, 35, 60, .12);
  transition: box-shadow .2s;
}
.hero-text h1 {
  color: #ffffff;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -.2px;
  text-shadow: 0 1px 8px rgba(0, 0, 0, .35);
}
.hero-text p {
  color: rgba(255, 255, 255, .92);
  font-size: 13.5px;
  font-weight: 600;
  text-shadow: 0 1px 6px rgba(0, 0, 0, .4);
  margin-top: 3px;
}

@media (min-width: 768px) {
  .hero { min-height: 230px; }
  .hero-text h1 { font-size: 28px; }
  .hero-text p { font-size: 15px; }
}
@media (min-width: 1024px) {
  #screen-ride.active .hero { grid-column: 1 / -1; }
  .hero { min-height: 260px; }
}


/* ---------- guest browsing banner ---------- */
.guest-banner { cursor: pointer; }
.guest-banner:active { filter: brightness(.97); }


/* ---------- platform revenue ---------- */
.platform-rev {
  font-size: 26px;
  font-weight: 800;
  color: var(--accent);
  margin: 6px 0 14px;
}
.platform-rev .balance-unit { font-size: 13px; }


/* ---------- discreet owner toggle ---------- */
.owner-toggle {
  display: block;
  margin: 18px auto 0;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 14px;
}
.owner-toggle:active { opacity: .6; }
