:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --bg2: var(--tg-theme-secondary-bg-color, #f2f3f5);
  --text: var(--tg-theme-text-color, #15171a);
  --hint: var(--tg-theme-hint-color, #8a8f98);
  --link: var(--tg-theme-link-color, #2481cc);
  --accent: #ffc400;
  --accent-text: #15171a;
  --ok: #16a34a;
  --danger: #e5383b;
  --card: var(--tg-theme-section-bg-color, var(--bg));
  --border: color-mix(in srgb, var(--text) 10%, transparent);
  --shadow: 0 6px 24px rgba(0, 0, 0, .12);
  --radius: 16px;
}
@media (prefers-color-scheme: dark) {
  :root:not(.tg) {
    --bg: #17191d; --bg2: #0f1013; --text: #eef0f3; --hint: #8c929c; --link: #5aa7ff; --card: #1f2227;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  background: var(--bg2); color: var(--text); overflow: hidden;
}
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--link); text-decoration: none; }
.hidden { display: none !important; }
.muted { color: var(--hint); }
.small { font-size: 13px; }
.row { display: flex; align-items: center; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Layout ---------- */
.app { display: flex; flex-direction: column; height: 100%; }
.screen { flex: 1; min-height: 0; position: relative; display: flex; flex-direction: column; }
.scroll { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 16px 16px 24px; }

#map { position: absolute; inset: 0; z-index: 0; background: #dde3ea; }
.map-wrap { position: relative; flex: 1; min-height: 180px; }

.center-pin {
  position: absolute; left: 50%; top: 50%; z-index: 500; pointer-events: none;
  transform: translate(-50%, -100%); font-size: 40px; line-height: 1;
  filter: drop-shadow(0 4px 4px rgba(0,0,0,.3)); transition: transform .15s;
}
.center-pin.lift { transform: translate(-50%, -125%); }
.center-pin .tip {
  position: absolute; left: 50%; bottom: -4px; width: 8px; height: 4px; margin-left: -4px;
  border-radius: 50%; background: rgba(0,0,0,.35);
}
.map-btn {
  position: absolute; z-index: 500; right: 14px; bottom: 14px; width: 46px; height: 46px; border-radius: 50%;
  border: 0; background: var(--card); box-shadow: var(--shadow); font-size: 20px; cursor: pointer;
}
.map-badge {
  position: absolute; z-index: 500; left: 14px; top: 14px; padding: 7px 12px; border-radius: 20px;
  background: var(--card); box-shadow: var(--shadow); font-size: 13px; font-weight: 600;
}

.sheet {
  position: relative; z-index: 600; background: var(--bg); border-radius: 22px 22px 0 0;
  box-shadow: 0 -8px 30px rgba(0,0,0,.12); padding: 10px 16px 16px; margin-top: -20px;
  max-height: 70%; overflow-y: auto;
}
.sheet::before {
  content: ""; display: block; width: 40px; height: 4px; border-radius: 4px; margin: 0 auto 12px;
  background: var(--border);
}

/* ---------- Tabbar ---------- */
.tabbar {
  display: flex; background: var(--bg); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar button {
  flex: 1; border: 0; background: none; padding: 8px 0 10px; font-size: 12px; color: var(--hint); cursor: pointer;
}
.tabbar button span { display: block; font-size: 22px; line-height: 1.2; }
.tabbar button.active { color: var(--text); font-weight: 600; }

/* ---------- Address fields ---------- */
.addr {
  display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: 12px; background: var(--bg2);
  margin-bottom: 8px; cursor: pointer; min-height: 48px;
}
.addr .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.addr .dot.a { background: var(--ok); }
.addr .dot.b { background: var(--danger); }
.addr input { border: 0; background: none; outline: none; width: 100%; }

/* ---------- Services ---------- */
.services { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 12px; }
.svc {
  border: 2px solid transparent; background: var(--bg2); border-radius: var(--radius); padding: 14px 6px 12px;
  text-align: center; cursor: pointer; transition: transform .1s, border-color .15s;
}
.svc:active { transform: scale(.96); }
.svc .ic { font-size: 34px; line-height: 1.1; }
.svc .nm { font-weight: 600; font-size: 13px; margin-top: 6px; }
.svc .pr { font-size: 12px; color: var(--hint); margin-top: 2px; }
.svc.sel { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, var(--bg)); }

.svc-list .svc-item {
  display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 14px; background: var(--bg2);
  margin-bottom: 8px; cursor: pointer; border: 2px solid transparent;
}
.svc-list .svc-item.sel { border-color: var(--accent); }
.svc-item .ic { font-size: 30px; }

/* ---------- Buttons ---------- */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  border: 0; border-radius: 14px; padding: 15px; font-weight: 700; font-size: 16px; cursor: pointer;
  background: var(--accent); color: var(--accent-text); transition: opacity .15s, transform .1s;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; }
.btn.ghost { background: var(--bg2); color: var(--text); font-weight: 600; }
.btn.danger { background: color-mix(in srgb, var(--danger) 12%, var(--bg)); color: var(--danger); }
.btn.ok { background: var(--ok); color: #fff; }
.btn.sm { padding: 10px; font-size: 14px; border-radius: 12px; }
.btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.btns.three { grid-template-columns: 1fr 1fr 1fr; }

/* ---------- Forms ---------- */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; color: var(--hint); margin: 0 0 6px 4px; }
.input {
  width: 100%; border: 1px solid var(--border); background: var(--bg2); border-radius: 12px; padding: 12px 14px; outline: none;
}
.input:focus { border-color: var(--accent); }
textarea.input { resize: none; min-height: 60px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--border); background: var(--bg2); border-radius: 20px; padding: 8px 12px; cursor: pointer; font-size: 14px;
}
.chip.sel { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
.seg { display: flex; background: var(--bg2); border-radius: 12px; padding: 4px; gap: 4px; }
.seg button { flex: 1; border: 0; background: none; padding: 9px; border-radius: 9px; cursor: pointer; font-weight: 600; }
.seg button.sel { background: var(--bg); box-shadow: 0 1px 4px rgba(0,0,0,.1); }

/* ---------- Cards ---------- */
.card { background: var(--card); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.h1 { font-size: 22px; font-weight: 800; margin: 4px 0 12px; }
.h2 { font-size: 17px; font-weight: 700; margin: 0 0 10px; }
.price { font-size: 26px; font-weight: 800; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.stat { background: var(--card); border-radius: 14px; padding: 12px 8px; text-align: center; }
.stat b { display: block; font-size: 18px; }
.stat span { font-size: 12px; color: var(--hint); }

.avatar {
  width: 56px; height: 56px; border-radius: 50%; background: var(--accent); color: var(--accent-text);
  display: grid; place-items: center; font-size: 24px; font-weight: 800; flex: none; overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }

/* Davlat raqami — O'zbekiston uslubida */
.plate {
  display: inline-flex; align-items: center; border: 2px solid #222; border-radius: 6px; background: #fff; color: #111;
  font-family: "Roboto Mono", ui-monospace, monospace; font-weight: 800; font-size: 17px; letter-spacing: 1px; overflow: hidden;
}
.plate .reg { padding: 2px 6px; border-right: 2px solid #222; }
.plate .num { padding: 2px 8px; }
.plate .flag { padding: 0 5px; font-size: 10px; line-height: 1.1; text-align: center; color: #0a6; }

/* ---------- Searching radar ---------- */
.radar { position: relative; width: 110px; height: 110px; margin: 6px auto 12px; }
.radar::before, .radar::after, .radar span {
  content: ""; position: absolute; inset: 0; border-radius: 50%; border: 3px solid var(--accent);
  animation: ping 2.4s infinite ease-out; opacity: 0;
}
.radar::after { animation-delay: .8s; }
.radar span { animation-delay: 1.6s; }
.radar i { position: absolute; inset: 0; display: grid; place-items: center; font-size: 42px; font-style: normal; }
@keyframes ping { 0% { transform: scale(.3); opacity: 1; } 100% { transform: scale(1.2); opacity: 0; } }

.status-pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 20px; font-size: 13px; font-weight: 700;
  background: color-mix(in srgb, var(--accent) 22%, var(--bg)); color: var(--text);
}
.status-pill.ok { background: color-mix(in srgb, var(--ok) 16%, var(--bg)); color: var(--ok); }
.status-pill.bad { background: color-mix(in srgb, var(--danger) 14%, var(--bg)); color: var(--danger); }

/* ---------- History ---------- */
.hist-item { background: var(--card); border-radius: 14px; padding: 12px 14px; margin-bottom: 8px; cursor: pointer; }
.hist-item .top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.hist-item .details { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border); font-size: 14px; }
.hist-item .details div { margin: 4px 0; }
.timeline { margin: 8px 0 0; padding: 0; list-style: none; font-size: 13px; }
.timeline li { padding-left: 16px; position: relative; margin: 3px 0; color: var(--hint); }
.timeline li::before { content: ""; position: absolute; left: 2px; top: 7px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }

.stars { display: flex; justify-content: center; gap: 8px; font-size: 38px; margin: 10px 0; }
.stars button { border: 0; background: none; cursor: pointer; filter: grayscale(1); opacity: .4; padding: 0; transition: transform .1s; }
.stars button.on { filter: none; opacity: 1; transform: scale(1.1); }

/* ---------- Search results ---------- */
.results { margin-top: 6px; }
.results .res { padding: 10px 6px; border-bottom: 1px solid var(--border); cursor: pointer; }
.results .res:last-child { border-bottom: 0; }

/* ---------- Toast ---------- */
#toast {
  position: fixed; left: 16px; right: 16px; top: 14px; z-index: 9999; padding: 12px 16px; border-radius: 14px;
  background: #1f2329; color: #fff; box-shadow: var(--shadow); transform: translateY(-140%); transition: transform .25s;
  font-weight: 500;
}
#toast.show { transform: translateY(0); }
#toast.err { background: var(--danger); }

/* ---------- Driver app ---------- */
.online-toggle {
  display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; background: var(--bg);
  border-bottom: 1px solid var(--border); gap: 10px;
}
.switch { position: relative; width: 58px; height: 32px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span {
  position: absolute; inset: 0; background: #c4c8ce; border-radius: 32px; transition: .2s; cursor: pointer;
}
.switch span::before {
  content: ""; position: absolute; width: 26px; height: 26px; left: 3px; top: 3px; border-radius: 50%; background: #fff; transition: .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
}
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span::before { transform: translateX(26px); }

.offer {
  background: var(--card); border-radius: 18px; padding: 14px; margin-bottom: 10px; box-shadow: var(--shadow);
  border: 2px solid var(--accent); animation: pop .3s ease-out;
}
@keyframes pop { from { transform: scale(.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.offer .timer { height: 4px; border-radius: 4px; background: var(--bg2); overflow: hidden; margin: 10px 0; }
.offer .timer i { display: block; height: 100%; background: var(--accent); transition: width 1s linear; }

.empty { text-align: center; padding: 30px 10px; color: var(--hint); }
.empty .big { font-size: 48px; }

.leaflet-control-attribution { font-size: 9px !important; }
.car-marker { font-size: 26px; line-height: 1; transition: transform .5s; }
.me-marker {
  width: 18px; height: 18px; border-radius: 50%; background: #2a7fff; border: 3px solid #fff; box-shadow: 0 0 0 6px rgba(42,127,255,.25);
}

/* ---------- Taksometr va katta summa ---------- */
.meter {
  margin-top: 10px; padding: 14px 12px; border-radius: 18px; text-align: center;
  background: var(--bg2); border: 2px solid var(--border);
}
.meter.on { background: #15171a; color: #fff; border-color: var(--accent); }
.meter .lbl { font-size: 13px; text-transform: uppercase; letter-spacing: .6px; opacity: .7; font-weight: 700; }
.meter .big {
  font-size: clamp(38px, 12vw, 56px); font-weight: 900; line-height: 1.1; margin: 4px 0;
  font-variant-numeric: tabular-nums; letter-spacing: -1px;
}
.meter.on .big { color: var(--accent); }
.meter .sub { font-size: 14px; opacity: .85; }
.meter .big.bump { animation: bump .35s ease-out; }
@keyframes bump { 0% { transform: scale(1.12); } 100% { transform: scale(1); } }

.start-btn { margin-top: 12px; padding: 20px; font-size: 24px; font-weight: 900; letter-spacing: 1px; background: var(--ok); color: #fff; }
.start-btn.finish { background: var(--accent); color: var(--accent-text); font-size: 20px; }

.pickup {
  display: flex; align-items: baseline; gap: 8px; justify-content: center; margin: 0 0 10px; padding: 10px;
  border-radius: 12px; background: color-mix(in srgb, var(--accent) 18%, var(--bg)); font-size: 15px;
}
.pickup b { font-size: 26px; font-weight: 900; }
.pickup span { color: var(--hint); font-size: 14px; }

/* ---------- Kontakt va marshrut ---------- */
.link-btn { border: 0; background: none; color: var(--link); cursor: pointer; padding: 2px 6px; font-size: 13px; }
.route-info { font-size: 14px; margin-top: 2px; }
.route-info b { font-size: 16px; }
.info-grid { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; font-size: 14px; }
.info-grid span:nth-child(odd) { color: var(--hint); }
.info-grid span:nth-child(even) { font-weight: 600; text-align: right; }

#map { transition: filter .3s, opacity .3s; }
#map.dim { filter: grayscale(1) blur(3px); opacity: .45; }
