/* єМобільність: стилі застосунку. Кольори беруться лише зі змінних з tokens.css. */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 1rem/1.4 system-ui, -apple-system, "SF Pro Text", Roboto, "Segoe UI", "Noto Sans", "Helvetica Neue", sans-serif;
  -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; overflow: hidden; overscroll-behavior: none;
}
button { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--primary); }
h1 { font-size: 1.25rem; line-height: 1.3; font-weight: 600; margin: 4px 0 12px; }
h2 { font-size: 1rem; margin: 0; }
p { margin: 0 0 8px; }
ul { margin: 0; padding: 0; list-style: none; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.sm { font-size: .875rem; }
.lg { font-size: 1.125rem; }
.strong { font-weight: 600; }
.danger-t { color: var(--danger); }
.pos-t { color: var(--success); }
.grow { flex: 1; min-width: 0; }
.right { text-align: right; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.ic { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- каркас ---------- */
#app { display: flex; flex-direction: column; height: var(--vh, 100dvh); padding-top: calc(var(--tg-safe-area-inset-top, 0px) + var(--tg-content-safe-area-inset-top, 0px)); }
#view { flex: 1; min-height: 0; position: relative; overflow: hidden; }
.route { position: absolute; inset: 0; }
.screen { position: absolute; inset: 0; overflow-y: auto; padding: 16px 16px 24px; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; animation: fade .18s ease-out; }
.screen.nopad { padding: 0; overflow: hidden; animation: none; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.tabs { display: grid; grid-template-columns: repeat(4, 1fr); background: var(--surface); border-top: 1px solid var(--border); padding-bottom: max(env(safe-area-inset-bottom, 0px), var(--tg-safe-area-inset-bottom, 0px)); }
.tabs[hidden] { display: none; }
.tabs a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 56px; color: var(--muted); text-decoration: none; }
.tabs .pill { width: 48px; height: 28px; border-radius: 999px; display: grid; place-items: center; }
.tabs .ic { width: 24px; height: 24px; }
.tabs .lbl { font-size: .75rem; line-height: 1.2; }
.tabs a.on { color: var(--primary); font-weight: 600; }
.tabs a.on .pill { background: var(--primary-soft); }

/* головна кнопка й «Назад» у браузері */
.shim-main { background: var(--surface); border-top: 1px solid var(--border); padding: 8px 16px calc(8px + max(env(safe-area-inset-bottom, 0px), 0px)); position: relative; z-index: 60; }
.shim-main[hidden], .shim-back[hidden] { display: none; }
.main-btn { width: 100%; min-height: 50px; border: 0; border-radius: 14px; background: var(--primary); color: var(--on-primary); font-weight: 600; font-size: 1.0625rem; display: flex; align-items: center; justify-content: center; gap: 10px; }
.main-btn:disabled { background: var(--disabled); cursor: default; }
.main-btn .spin { display: none; }
.main-btn.busy .spin { display: inline-block; }
.shim-back { background: var(--bg); padding: 6px 8px; }
.back-btn { display: inline-flex; align-items: center; gap: 4px; min-height: 44px; padding: 0 12px 0 6px; background: none; border: 0; color: var(--primary); font-weight: 600; }

/* ---------- спільні елементи ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px; box-shadow: var(--shadow); }
.sec { font-size: .875rem; font-weight: 600; color: var(--muted); letter-spacing: .02em; text-transform: uppercase; margin: 22px 0 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding: 2px; margin: -2px; }
.chip { min-height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font-size: .9375rem; white-space: nowrap; }
.chip.on { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); font-weight: 600; }
.chip:disabled { opacity: .55; }
.badge { display: inline-flex; align-items: center; gap: 4px; min-height: 24px; padding: 0 8px; border-radius: 999px; font-size: .875rem; font-weight: 600; white-space: nowrap; }
.badge .ic { width: 16px; height: 16px; }
.badge.success { background: var(--success-soft); color: var(--success); }
.badge.warning { background: var(--warning-soft); color: var(--warning); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.info { background: var(--elevated); color: var(--info); border: 1px solid var(--border); }
.badge.lg { min-height: 32px; padding: 0 12px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 48px; padding: 0 16px; border-radius: 14px; border: 1px solid var(--border-strong); background: var(--surface); font-weight: 600; text-align: left; }
.btn.secondary { background: var(--surface); border-color: var(--border-strong); width: 100%; justify-content: flex-start; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn.danger { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.btn.ghost { background: none; border-color: var(--border-strong); }
.btn.small { min-height: 36px; margin-top: 8px; }
.btn:disabled { opacity: .6; cursor: default; }
.danger-b { color: var(--danger); width: 100%; margin-top: 20px; }
.spin { display: none; width: 18px; height: 18px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: rot .8s linear infinite; flex: none; }
.spin.on { display: inline-block; }
@keyframes rot { to { transform: rotate(360deg); } }
.list > li { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.list > li:last-child { border-bottom: 0; }
.kv { display: flex; justify-content: space-between; gap: 16px; padding: 6px 0; }
.kv > span:last-child { text-align: right; }
.disclaimer { color: var(--muted); font-size: .875rem; margin: 20px 0 0; }
.banner { display: flex; gap: 12px; padding: 12px 14px; border-radius: 14px; margin: 12px 0; align-items: flex-start; }
.banner .ic { margin-top: 2px; }
.banner.warning { background: var(--warning-soft); color: var(--warning); border: 1px solid var(--warning); }
.banner.danger { background: var(--danger-soft); color: var(--danger); border: 1px solid var(--danger); }
.banner .sm { color: var(--text); }
.banner .btn { color: var(--text); }
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 24px 16px; color: var(--muted); }
.empty .ic { width: 36px; height: 36px; margin-bottom: 8px; }
.empty.big { padding-top: 56px; }
.note { margin-top: 12px; }
.link { color: var(--primary); font-weight: 600; text-decoration: none; }
.link.row { display: flex; justify-content: space-between; align-items: center; width: 100%; min-height: 28px; }

/* ---------- S1 ---------- */
.hero { text-align: center; padding: 0 0 2px; }
.hero h1 { font-size: 1.5rem; margin: 12px 0 6px; }
.logo { width: 64px; height: 64px; margin: 0 auto; border-radius: 20px; background: var(--primary); color: var(--on-primary); display: grid; place-items: center; }
.logo .ic { width: 36px; height: 36px; }
.lead { color: var(--muted); margin: 0 auto; max-width: 32ch; }
.intro { margin: 14px 0; display: grid; gap: 8px; }
.intro li { display: flex; gap: 12px; align-items: center; color: var(--text); }
.intro .ic { color: var(--primary); background: var(--primary-soft); width: 36px; height: 36px; padding: 8px; border-radius: 12px; }
.consent .check { display: flex; gap: 12px; align-items: flex-start; min-height: 28px; }
.consent input { width: 24px; height: 24px; margin: 0; accent-color: var(--primary); flex: none; }
.consent .note { margin: 8px 0 0 36px; }
.lead2 { margin: -4px 0 10px; }
.idbtns[hidden] { display: none; }
.idbtns { display: grid; gap: 10px; }
.idstatus { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 12px; min-height: 8px; }

/* ---------- S2 ---------- */
.balance .amt { font-size: 2.5rem; line-height: 1.1; font-weight: 600; margin: 4px 0 8px; }
.balance.is-debt .amt { color: var(--danger); }
.balance p { display: flex; gap: 8px; margin: 0; }
.balance p .ic { margin-top: 1px; }
.cardrow { display: flex; gap: 12px; align-items: center; margin-top: 12px; }
.cardrow .ic { width: 28px; height: 28px; color: var(--primary); }
.tx .txic { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex: none; }
.tx .txic.pos { background: var(--success-soft); color: var(--success); }
.tx .txic.neg { background: var(--select); color: var(--text); }

/* ---------- S3 ---------- */
.mapwrap { position: absolute; inset: 0; isolation: isolate; z-index: 0; }
.map { width: 100%; height: 100%; background: var(--bg); font: inherit; }
.leaflet-container { background: var(--bg); font: inherit; }
:root[data-theme="light"] .leaflet-tile-pane { filter: saturate(.55) sepia(.18) brightness(1.03); }
:root[data-theme="dark"] .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) saturate(.5) brightness(.9) contrast(.95); }
.leaflet-control-attribution { background: var(--elevated) !important; color: var(--muted) !important; font-size: .75rem !important; padding: 2px 8px !important; border-radius: 0 0 0 8px; border-left: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.leaflet-control-attribution a { color: var(--info) !important; text-decoration: none; }
.maptop { position: absolute; top: 32px; left: 12px; right: 12px; z-index: 5; pointer-events: none; }
.maptop .chips { pointer-events: auto; }
.maptop .chips { gap: 6px; }
.maptop .chip { background: var(--elevated); box-shadow: var(--shadow); padding: 0 12px; font-size: .875rem; }
.maptop .chip.on { background: var(--primary-soft); }
.fabs { position: absolute; right: 12px; bottom: calc(40% + 12px); z-index: 9; display: flex; flex-direction: column; gap: 8px; transition: opacity .2s; }
.fabs.hide { opacity: 0; pointer-events: none; }
.fab { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--border-strong); background: var(--elevated); color: var(--text); display: grid; place-items: center; box-shadow: var(--shadow); padding: 0; }
.fab.pri { color: var(--primary); }

.sheet { position: absolute; left: 0; right: 0; bottom: 0; height: 40%; z-index: 10; display: flex; flex-direction: column; background: var(--elevated); border: 1px solid var(--border); border-bottom: 0; border-radius: 20px 20px 0 0; box-shadow: var(--shadow); transition: height .25s ease; }
.sheet[data-state="full"] { height: 85%; }
.sheet-head { background: none; border: 0; padding: 8px 16px 2px; width: 100%; text-align: left; flex: none; }
.handle { display: block; width: 36px; height: 4px; border-radius: 4px; background: var(--border-strong); margin: 0 auto 8px; }
.sheet-title { display: flex; justify-content: space-between; align-items: center; font-size: 1.0625rem; font-weight: 600; min-height: 28px; }
.sheet-title .exp { color: var(--muted); display: flex; transition: transform .25s; }
.sheet[data-state="full"] .exp { transform: rotate(180deg); }
.sortrow { flex-wrap: wrap; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 2px 16px 8px; border-bottom: 1px solid var(--line); flex: none; }
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 999px; padding: 2px; background: var(--surface); }
.seg-b { min-height: 32px; padding: 0 12px; border: 0; background: none; border-radius: 999px; font-size: .9375rem; color: var(--text); }
.seg-b.on { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.offers { flex: 1; overflow-y: auto; padding: 8px 12px 12px; touch-action: pan-y; overscroll-behavior: contain; }
.offer { display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; align-items: end; width: 100%; text-align: left; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 12px; margin-bottom: 8px; box-shadow: var(--shadow); }
.offer.sel { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary); }
.o-head { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; }
.o-title { flex: 1; display: flex; gap: 8px; align-items: baseline; min-width: 0; white-space: nowrap; overflow: hidden; }
.o-title b { font-size: 1.0625rem; }
.o-title .muted { font-size: .875rem; overflow: hidden; text-overflow: ellipsis; }
.o-left { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.o-walk { display: flex; gap: 6px; align-items: center; font-size: .875rem; }
.o-walk .ic { width: 16px; height: 16px; color: var(--muted); }
.o-tariff { font-size: .875rem; }
.o-est { font-weight: 600; font-size: 1.0625rem; white-space: nowrap; text-align: right; }
.o-mark { display: block; line-height: 0; }
.o-mark.big { width: 56px; }
.skel { height: 84px; border-radius: 14px; background: var(--select); margin-bottom: 8px; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .55; } }
.foot { display: block !important; }

.mk { background: none; border: 0; }
.mk-svg { display: block; overflow: visible; transition: transform .15s; }
.mk-svg .shape { fill: var(--c); stroke: var(--surface); stroke-width: 4; paint-order: stroke; }
.mk-svg .glyph { stroke: var(--on-op); fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; color: var(--on-op); }
.mk-svg .ring { fill: none; stroke: var(--primary); stroke-width: 2.4; transform-origin: 18px 18px; transform: scale(1.32); display: none; }
.mk-svg .lowdot { fill: var(--warning); stroke: var(--surface); stroke-width: 1.8; }
.mk.sel .ring { display: block; }
.mk.sel .mk-svg { transform: scale(1.15); }
:root[data-theme="light"] .mk-svg { filter: drop-shadow(0 1px 2px rgba(50, 60, 40, .35)); }
.mk:focus-visible .shape { stroke: var(--primary); }
.me { background: none; border: 0; }
.me-dot { display: block; width: 22px; height: 22px; border-radius: 50%; background: var(--info); border: 4px solid var(--elevated); box-shadow: 0 0 0 1.5px var(--info); }
.acc { fill: var(--info); fill-opacity: .12; stroke: var(--info); stroke-opacity: .5; stroke-width: 1; }

/* ---------- S4 ---------- */
.ride-head { display: flex; justify-content: center; margin: 4px 0 12px; }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--info); animation: pulse 1.4s ease-in-out infinite; }
.ride-card { padding: 18px 16px; }
.ride-id { display: flex; gap: 14px; align-items: center; }
.timer { font-size: 2.5rem; line-height: 1.1; font-weight: 600; text-align: center; margin: 22px 0 18px; }
.calc { margin-top: 12px; }
.calc h2 { font-size: .875rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .02em; margin-bottom: 4px; }
.kv.tot { border-top: 1px dashed var(--border-strong); margin-top: 6px; padding-top: 10px; font-weight: 600; }
.kv > span:first-child { flex: none; }
.rows { border-top: 1px solid var(--line); padding-top: 8px; }

/* ---------- чек та історія ---------- */
.ride-row { display: flex; gap: 12px; align-items: center; width: 100%; color: var(--text); text-decoration: none; min-height: 48px; }
.rides > li { display: block; padding: 4px 12px; margin-bottom: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); }
.rides > li:last-child { border-bottom: 1px solid var(--border); }
.receipt-head { text-align: center; margin-bottom: 12px; }
.receipt-head h1 { margin: 8px 0 2px; }
.okmark { width: 48px; height: 48px; border-radius: 50%; background: var(--success-soft); color: var(--success); display: inline-grid; place-items: center; }
.okmark .ic { width: 28px; height: 28px; }
.okic { color: var(--success); width: 18px; height: 18px; vertical-align: -3px; }
.rno { font-weight: 600; border-bottom: 1px dashed var(--border-strong); padding-bottom: 10px; margin-bottom: 6px; }
.total { display: flex; justify-content: space-between; align-items: baseline; font-size: 1.25rem; font-weight: 600; border-top: 1px dashed var(--border-strong); margin-top: 8px; padding-top: 12px; }
.total .num { font-size: 1.5rem; }
.after { margin-top: 4px; }
#print { margin-top: 12px; width: 100%; }

/* ---------- профіль ---------- */
.who { display: flex; gap: 14px; align-items: center; margin-bottom: 8px; }
.avatar { width: 52px; height: 52px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; font-size: 1.375rem; font-weight: 600; flex: none; }
.kvlist > li { justify-content: space-between; gap: 16px; }
.kvlist > li > span:last-child { text-align: right; }
.switchrow { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.switch { width: 52px; height: 32px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface); padding: 2px; flex: none; position: relative; }
.switch span { display: block; width: 26px; height: 26px; border-radius: 50%; background: var(--border-strong); transition: transform .2s; }
.switch[aria-checked="true"] { background: var(--primary); border-color: var(--primary); }
.switch[aria-checked="true"] span { transform: translateX(20px); background: var(--on-primary); }
.acc { margin-top: 12px; padding: 0; }
.acc summary { padding: 14px; font-weight: 600; cursor: pointer; min-height: 48px; display: flex; align-items: center; list-style: none; }
.acc summary::-webkit-details-marker { display: none; }
.acc summary::after { content: ""; margin-left: auto; width: 8px; height: 8px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); transition: transform .2s; }
.acc[open] summary::after { transform: rotate(225deg); }
.tools { padding: 0 14px 14px; display: grid; gap: 8px; }
.evlog { padding: 0 14px 12px; max-height: 280px; overflow-y: auto; }
.evlog li { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-top: 1px solid var(--line); font-size: .875rem; }
.legal p { margin-bottom: 4px; }

/* ---------- вікна, аркуш поповнення, тости ---------- */
#layer { position: fixed; inset: 0; z-index: 50; pointer-events: none; }
#layer > * { pointer-events: auto; }
.modal { position: absolute; inset: 0; background: var(--scrim); display: flex; align-items: center; justify-content: center; padding: 24px; }
.dialog { width: 100%; max-width: 340px; background: var(--elevated); border: 1px solid var(--border); border-radius: 20px; padding: 20px; box-shadow: var(--shadow); }
.dialog h2 { font-size: 1.125rem; margin-bottom: 8px; }
.dialog p { color: var(--muted); }
.dlg-btns { display: grid; gap: 8px; margin-top: 16px; }
.dlg-btns .btn { justify-content: center; text-align: center; }
.modal.sheetm { align-items: flex-end; justify-content: stretch; padding: 0; bottom: var(--shim-main-h, 0px); }
.panel { width: 100%; background: var(--elevated); border: 1px solid var(--border); border-bottom: 0; border-radius: 20px 20px 0 0; padding: 8px 16px 12px; animation: up .22s ease-out; }
.panel h2 { font-size: 1.125rem; margin: 6px 0 12px; }
.grab { width: 36px; height: 4px; border-radius: 4px; background: var(--border-strong); margin: 0 auto; }
.pay-state { display: flex; gap: 10px; align-items: center; min-height: 28px; margin: 14px 0 4px; font-weight: 600; }
.pay-state .okic { width: 22px; height: 22px; }
.panel .close { width: 100%; justify-content: center; border: 0; color: var(--muted); }
@keyframes up { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.toasts { position: fixed; left: 16px; right: 16px; bottom: calc(76px + max(env(safe-area-inset-bottom, 0px), 0px)); z-index: 70; pointer-events: none; display: flex; justify-content: center; }
.toast { background: var(--elevated); color: var(--text); border: 1px solid var(--border-strong); border-radius: 14px; padding: 12px 16px; box-shadow: var(--shadow); max-width: 420px; font-size: .9375rem; animation: up .2s ease-out; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

@media (min-width: 720px) {
  #app { max-width: 480px; margin: 0 auto; border-left: 1px solid var(--border); border-right: 1px solid var(--border); }
  #layer { left: 50%; right: auto; width: 480px; transform: translateX(-50%); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .spin { animation: rot 1.6s linear infinite !important; animation-iteration-count: infinite !important; animation-duration: 1.6s !important; }
}
@media print {
  #tabs, #shim-main, #shim-back, #print, #layer, #toasts { display: none !important; }
  body, #app, #view, .screen, .route { overflow: visible; position: static; height: auto; }
  .card { box-shadow: none; }
}
