/* Перевозки Camp Soul — нативный вид внутри Telegram: системный шрифт, цвета темы Telegram (светлая и тёмная),
   карта сверху и лист снизу, как в Картах. Цвета Telegram приходят переменными --tg-theme-*, свои — запасные. */
:root {
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --bg: var(--tg-theme-secondary-bg-color, #f2f2f7);
  --card: var(--tg-theme-section-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #000000);
  --sub: var(--tg-theme-subtitle-text-color, #6c6c70);
  --hint: var(--tg-theme-hint-color, #8e8e93);
  --link: var(--tg-theme-link-color, #007aff);
  --accent: var(--tg-theme-button-color, #007aff);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --sep: var(--tg-theme-section-separator-color, #c6c6c8);
  --danger: var(--tg-theme-destructive-text-color, #ff3b30);
  --fill: rgba(118, 118, 128, .12);
  --fill-strong: rgba(118, 118, 128, .2);
  --blue: #007aff;
  --blue-bg: rgba(0, 122, 255, .12);
  --green: #248a3d;
  --green-bg: rgba(52, 199, 89, .16);
  --orange: #ff9500;
  --halo: #ffffff;
  --shadow: 0 1px 3px rgba(0, 0, 0, .1), 0 6px 20px rgba(0, 0, 0, .1);
}
:root[data-theme="dark"] {
  --bg: var(--tg-theme-secondary-bg-color, #000000);
  --card: var(--tg-theme-section-bg-color, #1c1c1e);
  --text: var(--tg-theme-text-color, #ffffff);
  --sub: var(--tg-theme-subtitle-text-color, #aeaeb2);
  --hint: var(--tg-theme-hint-color, #8e8e93);
  --link: var(--tg-theme-link-color, #0a84ff);
  --accent: var(--tg-theme-button-color, #0a84ff);
  --sep: var(--tg-theme-section-separator-color, #38383a);
  --danger: var(--tg-theme-destructive-text-color, #ff453a);
  --fill: rgba(118, 118, 128, .24);
  --fill-strong: rgba(118, 118, 128, .34);
  --blue: #0a84ff;
  --blue-bg: rgba(10, 132, 255, .2);
  --green: #30d158;
  --green-bg: rgba(48, 209, 88, .16);
  --orange: #ff9f0a;
  --halo: #1c1c1e;
  --shadow: 0 1px 3px rgba(0, 0, 0, .5), 0 6px 20px rgba(0, 0, 0, .4);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body {
  margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none;
  background: var(--bg); color: var(--text);
  font: 400 15px/1.35 var(--font); -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: 100%;
}
button, a { font: inherit; color: inherit; background: none; border: 0; padding: 0; margin: 0; cursor: pointer; text-decoration: none; }
.ic { width: 20px; height: 20px; flex: none; }

/* ---------- карта */
#map { position: fixed; inset: 0; background: var(--bg); }
.maplibregl-ctrl-top-left .maplibregl-ctrl { margin: 12px 0 0 12px; }
.maplibregl-ctrl-attrib.maplibregl-compact { background: var(--card); color: var(--hint); }
.maplibregl-ctrl-attrib a { color: var(--hint) !important; }

.pin { display: flex; align-items: center; gap: 6px; pointer-events: none; }
.pin i { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--pc, #8e8e93); color: #fff; border: 2px solid #fff; box-shadow: 0 1px 5px rgba(0, 0, 0, .3); }
.pin i .ic { width: 14px; height: 14px; stroke-width: 2.2; }
.pin.camp i { width: 32px; height: 32px; }
.pin.camp i .ic { width: 16px; height: 16px; }
.pin b { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; line-height: 1.15;
  text-shadow: 0 0 3px var(--halo), 0 0 3px var(--halo), 0 0 6px var(--halo); }
.pin b small { display: block; font-size: 11px; font-weight: 500; color: var(--hint); }
.pin.off { display: none; }
body.far .pin.city b { display: none; }

/* машина на карте: силуэт сверху поворачивается по дороге, ярлык с номером — нет */
/* без position: карта сама ставит маркеру absolute — ярлык позиционируется от него */
.carpin { width: 44px; height: 52px; display: grid; place-items: center; cursor: pointer; }
.car-body { display: grid; place-items: center; transition: transform .35s ease;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .35)) drop-shadow(0 0 1px rgba(0, 0, 0, .25)); }
:root[data-theme="dark"] .car-body { filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .6)) drop-shadow(0 0 1.5px rgba(255, 255, 255, .55)); }
.car-tag { position: absolute; right: -2px; bottom: 4px; display: inline-flex; align-items: center; gap: 2px; height: 18px;
  min-width: 18px; padding: 0 5px; border-radius: 6px; background: var(--c); color: #fff; border: 1.5px solid #fff;
  font: 700 11px/1 var(--font); box-shadow: 0 1px 3px rgba(0, 0, 0, .3); }
.car-tag .ic { width: 12px; height: 12px; margin-left: -2px; }
/* рисунки и значки — прямо на фоне карточки, без подложек */
.art { flex: none; width: 60px; display: grid; place-items: center; }
.art svg { display: block; overflow: visible; }
.art.lg { width: auto; margin-right: 4px; }
.glyph { flex: none; width: 28px; height: 28px; display: grid; place-items: center; }
.glyph .ic { width: 26px; height: 26px; }
.row .glyph .ic { width: 22px; height: 22px; }
.alert .glyph .ic { width: 28px; height: 28px; }
.row.action .t1 { color: var(--link); font-weight: 500; }
.wrap .t3 { white-space: normal; }
.t3.geo .on { color: var(--green); }

/* ---------- кнопки поверх карты */
.controls { position: fixed; top: 12px; right: 12px; z-index: 3; display: flex; gap: 8px; }
.ctl { height: 38px; min-width: 38px; padding: 0 13px; border-radius: 19px; display: inline-flex; align-items: center;
  justify-content: center; gap: 6px; background: var(--card); color: var(--text); box-shadow: var(--shadow);
  font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; transition: transform .12s; }
.ctl.icon { width: 38px; padding: 0; }
.ctl .ic { width: 18px; height: 18px; }
.ctl:active { transform: scale(.95); }

.timecard { position: fixed; top: 60px; left: 12px; right: 12px; z-index: 6; max-width: 400px; margin-left: auto;
  padding: 14px 16px 12px; border-radius: 16px; background: var(--card); box-shadow: var(--shadow); }
.tc-head { display: flex; align-items: center; justify-content: space-between; }
.tc-label { font-size: 13px; color: var(--hint); }
.tc-time { font-size: 30px; font-weight: 600; letter-spacing: -.5px; font-variant-numeric: tabular-nums; }
.tc-play { width: 44px; height: 44px; border-radius: 22px; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-text); }
.tc-play .ic { width: 18px; height: 18px; }
.range { --p: 50%; width: 100%; height: 28px; margin: 12px 0 2px; background: transparent;
  -webkit-appearance: none; appearance: none; }
.range::-webkit-slider-runnable-track { height: 4px; border-radius: 2px;
  background: linear-gradient(var(--accent), var(--accent)) 0 / var(--p) 100% no-repeat, var(--fill-strong); }
.range::-webkit-slider-thumb { -webkit-appearance: none; width: 26px; height: 26px; margin-top: -11px; border-radius: 50%;
  background: #fff; box-shadow: 0 .5px 4px rgba(0, 0, 0, .14), 0 6px 13px rgba(0, 0, 0, .14); }
.range::-moz-range-track { height: 4px; border-radius: 2px; background: var(--fill-strong); }
.range::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--accent); }
.range::-moz-range-thumb { width: 26px; height: 26px; border: 0; border-radius: 50%; background: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .2); }
.tc-scale { display: flex; justify-content: space-between; font-size: 12px; color: var(--hint); font-variant-numeric: tabular-nums; }
.tc-actions { display: flex; gap: 8px; margin-top: 12px; }
.tc-actions button { flex: 1; height: 40px; border-radius: 10px; background: var(--fill); color: var(--link);
  font-size: 15px; font-weight: 600; }

/* ---------- лист снизу */
.sheet { position: fixed; left: 0; right: 0; bottom: 0; top: 44px; z-index: 4; display: flex; flex-direction: column;
  background: var(--bg); border-radius: 14px 14px 0 0; transform: translate3d(0, 100%, 0); will-change: transform;
  box-shadow: 0 -.5px 0 var(--sep), 0 -6px 24px rgba(0, 0, 0, .1); }
.grab-zone { flex: none; height: 20px; display: flex; align-items: center; justify-content: center; touch-action: none; cursor: grab; }
.grabber { width: 36px; height: 5px; border-radius: 3px; background: var(--fill-strong); }
.views { position: relative; flex: 1; min-height: 0; overflow: hidden; }
.view { position: absolute; inset: 0; display: flex; flex-direction: column; }
.view.push { animation: push .32s cubic-bezier(.22, 1, .36, 1); }
.view.pop { animation: pop .32s cubic-bezier(.22, 1, .36, 1); }
@keyframes push { from { transform: translateX(36px); opacity: 0; } }
@keyframes pop { from { transform: translateX(-36px); opacity: 0; } }
.vh { flex: none; padding: 0 16px 12px; touch-action: none; }
.vb { flex: 1; min-height: 0; overflow: hidden; overscroll-behavior: contain;
  padding: 0 16px calc(32px + env(safe-area-inset-bottom)); }
.sheet.full .vb { overflow-y: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.vb::-webkit-scrollbar { display: none; }
body.has-main .sheet { bottom: calc(68px + env(safe-area-inset-bottom)); }

h1 { margin: 0; font-size: 22px; line-height: 1.2; font-weight: 700; letter-spacing: -.3px; }
.subtitle { margin: 3px 0 0; font-size: 15px; color: var(--sub); }
.backbtn { display: inline-flex; align-items: center; height: 34px; margin: 0 0 4px -8px; padding-right: 8px;
  color: var(--link); font-size: 17px; }
.backbtn .ic { width: 24px; height: 24px; }

.days { display: flex; gap: 4px; margin: 0 -16px 10px; padding: 0 16px; overflow-x: auto; scrollbar-width: none; touch-action: pan-x; }
.days::-webkit-scrollbar { display: none; }
.day { flex: none; width: 46px; height: 54px; border-radius: 12px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 1px; }
.day .wd { font-size: 12px; font-weight: 500; color: var(--hint); }
.day .dn { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.day.on { background: var(--accent); }
.day.on .wd, .day.on .dn { color: var(--accent-text); }
.day:not(.on):active { background: var(--fill); }
.days .gap { flex: none; width: 1px; margin: 12px 6px; background: var(--sep); }

.trip-head { display: flex; align-items: center; gap: 12px; }
.trip-head .tx { min-width: 0; }

/* ---------- содержимое: сгруппированные списки */
.section { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 24px 4px 8px; }
.section h2 { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -.2px; }
.section span { font-size: 15px; color: var(--hint); white-space: nowrap; }
.vb > .section:first-child { margin-top: 8px; }
.group { background: var(--card); border-radius: 12px; overflow: hidden; }
.foot { margin: 8px 4px 0; font-size: 13px; line-height: 1.4; color: var(--hint); }

.row { position: relative; display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px;
  padding: 10px 14px; text-align: left; }
.row + .row::before { content: ''; position: absolute; top: 0; right: 0; left: var(--inset, 60px); height: .5px; background: var(--sep); }
.row.plain + .row.plain::before { left: 14px; }
button.row:active, a.row:active { background: var(--fill); }
.tx { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.t1 { font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.t1 .muted { font-weight: 400; color: var(--hint); }
.t2 { margin-top: 2px; font-size: 14px; color: var(--sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.t3 { margin-top: 3px; font-size: 13px; color: var(--hint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wrap .t2 { white-space: normal; }
.end { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.line { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-width: 0; }
.line > .t1, .line > .t3 { min-width: 0; }
.line > .badge { flex: none; margin-top: 4px; }
.line > .time { flex: none; }
.end .t3 { margin: 0; }
.time { font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; }
.chev { width: 16px; height: 16px; flex: none; margin-left: -4px; color: var(--hint); opacity: .6; }
.link { color: var(--link); }
.row.action .t1 { color: var(--link); font-weight: 500; }
.row.action .avatar { background: var(--blue-bg); color: var(--link); }

.avatar { flex: none; width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  background: var(--c, var(--fill-strong)); color: #fff; font-size: 15px; font-weight: 700; }
.avatar .ic { width: 18px; height: 18px; }
.avatar.lg { width: 48px; height: 48px; border-radius: 14px; font-size: 21px; }
.avatar.person { border-radius: 50%; background: var(--fill-strong); color: var(--sub); font-size: 13px; font-weight: 600; }
.avatar.muted { background: var(--fill); color: var(--sub); }
.avatar.red { background: var(--danger); }
.avatar.orange { background: var(--orange); }
.avatar.green { background: #34c759; }

.badge { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 6px; white-space: nowrap;
  font-size: 12px; font-weight: 600; background: var(--fill); color: var(--sub); }
.badge.go { background: var(--blue-bg); color: var(--blue); }
.badge.done { background: var(--green-bg); color: var(--green); }

.alert { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 14px; border-radius: 12px;
  background: var(--card); text-align: left; }
.alert + .alert { margin-top: 8px; }
.alert:active { background: var(--fill); }
.alert .t2 { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.vb > .alert:first-child { margin-top: 4px; }

.status { padding: 14px; }
.st-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.st-top .when { font-size: 13px; color: var(--hint); }
.st-main { margin-top: 10px; font-size: 17px; font-weight: 600; }
.st-sub { margin-top: 2px; font-size: 14px; color: var(--sub); }
.progress { height: 4px; margin-top: 12px; border-radius: 2px; overflow: hidden; background: var(--fill-strong); }
.progress i { display: block; height: 100%; border-radius: 2px; background: var(--blue); }
.st-scale { display: flex; justify-content: space-between; margin-top: 6px; font-size: 13px; color: var(--hint);
  font-variant-numeric: tabular-nums; }

.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile { padding: 12px 14px; border-radius: 12px; background: var(--card); }
.tile .k { font-size: 13px; color: var(--hint); }
.tile .v { margin-top: 2px; font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }
.tile .v small { font-size: 15px; font-weight: 400; color: var(--hint); }
.tile .progress { margin-top: 10px; }
.tile .progress.full i { background: var(--orange); }

.empty { padding: 18px 14px; color: var(--hint); font-size: 15px; }
.segmented { display: flex; padding: 2px; border-radius: 9px; background: var(--fill); }
.segmented button { flex: 1; height: 32px; border-radius: 7px; font-size: 14px; font-weight: 500; }
.segmented button.on { background: var(--card); font-weight: 600; box-shadow: 0 1px 3px rgba(0, 0, 0, .14); }

.state { padding: 36px 24px; text-align: center; color: var(--hint); font-size: 15px; }
.state b { display: block; margin-bottom: 4px; font-size: 17px; color: var(--text); }
.state button { margin-top: 14px; color: var(--link); font-weight: 600; }
.spinner { width: 22px; height: 22px; margin: 0 auto 12px; border-radius: 50%; border: 2.5px solid var(--fill-strong);
  border-top-color: var(--hint); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- главная кнопка вне Telegram (в Telegram — его MainButton) */
.mainbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 7; padding: 8px 16px calc(10px + env(safe-area-inset-bottom));
  background: var(--bg); box-shadow: 0 -.5px 0 var(--sep); }
.mainbar button { width: 100%; height: 50px; border-radius: 12px; background: var(--accent); color: var(--accent-text);
  font-size: 17px; font-weight: 600; }
.mainbar button:active { opacity: .85; }

.toast { position: fixed; top: 12px; left: 12px; right: 12px; z-index: 20; max-width: 420px; margin: 0 auto;
  display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 14px;
  background: var(--card); color: var(--text); box-shadow: var(--shadow); font-size: 14px; animation: drop .25s ease-out; }
.toast .ic { width: 18px; height: 18px; margin-top: 1px; color: var(--link); }
@keyframes drop { from { transform: translateY(-8px); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  .view.push, .view.pop, .toast { animation: none; }
}
