/* Светлая «дорожная» тема: белые карточки, бирюзово-голубой акцент, крупные скруглённые элементы. */
:root {
  --bg: #eef3f8;
  --surface: #ffffff;
  --surface-2: #f2f6fa;
  --line: #e1e8ef;
  --text: #13263b;
  --muted: #687a8d;
  --primary: #33ccff;
  --primary-strong: #12a8e0;
  --primary-ink: #052c40;
  --primary-soft: #e3f7ff;
  --route: #1a9fff;
  --ok: #19a35b;
  --bad: #e5484d;
  --gold: #ffc928;
  --shadow: 0 4px 18px rgba(19, 38, 59, .16);
  --shadow-sm: 0 2px 8px rgba(19, 38, 59, .14);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --peek: 200px;          /* JS выставляет по фактической высоте шапки панели */
  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text);
  font: 15px/1.35 "Nunito", "Segoe UI Rounded", "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button { font: inherit; color: inherit; cursor: pointer; }
sup { font-size: .62em; }

#map { position: fixed; inset: 0; background: #e8eef3; }
.leaflet-container { font: inherit; background: #e8eef3; }
/* Спокойнее стандартные тайлы OSM: меньше насыщенности, чуть светлее — маркеры и маршрут читаются лучше */
/* запасная растровая карта OSM (если нет WebGL) — чуть приглушить цвета */
.leaflet-tile { filter: saturate(.55) brightness(1.04) contrast(.92); }
.leaflet-control-attribution { background: rgba(255,255,255,.8) !important; color: var(--muted) !important; font-size: 10px;
  border-radius: 8px 0 0 0; }
.leaflet-control-attribution a { color: var(--primary-strong) !important; }
/* Свёрнутые источники карты: маленькая кнопка «i», по нажатию — полный текст. */
.leaflet-control-attribution.compact { cursor: pointer; margin: 0 6px 6px 0 !important; border-radius: 14px; }
.leaflet-control-attribution.compact:not(.open) { width: 24px; height: 24px; padding: 0 !important; font-size: 0;
  border-radius: 50%; box-shadow: var(--shadow-sm); background: var(--surface) !important; }
.leaflet-control-attribution.compact:not(.open)::before { content: "i"; display: grid; place-items: center; height: 100%;
  font: italic 800 14px Georgia, serif; color: var(--muted); }
.leaflet-control-attribution.compact.open { max-width: calc(100vw - 24px); padding: 6px 10px !important; font-size: 11px;
  box-shadow: var(--shadow-sm); }
.leaflet-bottom { bottom: calc(var(--peek) + var(--safe-bottom)); }
.leaflet-top.leaflet-right { top: var(--top-h, 112px); }
.leaflet-bar { border: 0 !important; box-shadow: var(--shadow-sm) !important; border-radius: 14px !important; overflow: hidden; }
.leaflet-bar a { background: var(--surface) !important; color: var(--text) !important; border-color: var(--line) !important;
  width: 40px !important; height: 40px !important; line-height: 40px !important; font-size: 20px !important; }
.leaflet-popup-content-wrapper { border-radius: 18px; box-shadow: var(--shadow); }
.leaflet-popup-content { margin: 8px; }

/* ---------- верхняя панель ---------- */
.topbar { position: fixed; top: 0; left: 0; right: 0; z-index: 1000; padding: calc(10px + var(--safe-top)) 10px 0;
  pointer-events: none; display: grid; gap: 8px; max-width: 640px; margin: 0 auto; }
.topbar > * { pointer-events: auto; }
.search { display: flex; align-items: center; gap: 2px; background: var(--surface); border-radius: 26px;
  padding: 0 4px 0 16px; height: 52px; box-shadow: var(--shadow); }
.search { position: relative; }
.suggest { position: absolute; left: 0; right: 0; top: calc(100% + 6px); margin: 0; padding: 6px; list-style: none;
  background: var(--surface); border-radius: 20px; box-shadow: var(--shadow); z-index: 5; max-height: 60vh; overflow-y: auto; }
.suggest li { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 14px; cursor: pointer; }
.suggest li:hover, .suggest li.active { background: var(--surface-2); }
.suggest .s-ico { font-size: 16px; flex: none; }
.suggest .s-txt { display: grid; min-width: 0; }
.suggest b { font-size: 15px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.suggest small { color: var(--muted); font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-ico { font-size: 15px; opacity: .55; }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; color: var(--text);
  font: inherit; font-size: 16px; font-weight: 600; padding: 0 8px; height: 100%; }
.search input::placeholder { color: var(--muted); font-weight: 500; }
.ico-btn { width: 44px; height: 44px; border: 0; border-radius: 50%; background: none; font-size: 21px;
  display: grid; place-items: center; flex: none; color: var(--text); }
.ico-btn:hover, .ico-btn:focus-visible { background: var(--surface-2); outline: none; }
.ico-btn.active { color: var(--primary-strong); }
.ico-btn:disabled { opacity: .4; }
.ico-btn.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.filters { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 2px 2px 6px; }
.filters::-webkit-scrollbar { display: none; }
.seg { display: flex; flex: none; background: var(--surface); border-radius: 22px; padding: 4px; box-shadow: var(--shadow-sm); }
.seg button { border: 0; background: none; padding: 7px 12px; border-radius: 18px; font-size: 14px; font-weight: 700;
  white-space: nowrap; color: var(--muted); }
.seg button.on { background: var(--primary); color: var(--primary-ink); font-weight: 800; box-shadow: 0 2px 6px rgba(51,204,255,.45); }
.seg.small { box-shadow: none; background: var(--surface-2); }
.seg.small button { padding: 5px 11px; font-size: 13px; }
.seg.small button.on { box-shadow: none; }

.banner { background: #fff6d6; color: #6b4e00; font-size: 13px; padding: 9px 14px; border-radius: 16px; box-shadow: var(--shadow-sm); }
.banner.error { background: #ffe8e6; color: #a8231f; }
.banner .hint-line { margin-top: 4px; font-size: 12px; opacity: .9; }
.banner a, .banner button { color: inherit; font-weight: 800; text-decoration: underline; background: none; border: 0; padding: 0; }

/* ---------- маркеры ---------- */
.pin-wrap { background: none; border: 0; }
.pin { position: absolute; left: 0; bottom: 8px; transform: translateX(-50%); background: var(--c, #8a97a5);
  color: #fff; font-weight: 800; font-size: 13px; line-height: 1; padding: 6px 9px; border-radius: 14px;
  white-space: nowrap; box-shadow: 0 3px 8px rgba(19,38,59,.3); border: 2.5px solid #fff;
  font-variant-numeric: tabular-nums; transition: transform .15s; }
.pin::after { content: ""; position: absolute; left: 50%; bottom: -8px; transform: translateX(-50%);
  border: 7px solid transparent; border-top-color: #fff; border-bottom: 0; }
.pin sup { font-size: 9px; }
.pin.closed { opacity: .6; filter: grayscale(.7); }
.pin.none { background: #9aa6b2; font-weight: 600; }
.pin.dot { width: 16px; height: 16px; padding: 0; border-radius: 50%; bottom: -8px; font-size: 0; border-width: 2.5px; }
.pin.dot::after, .pin.dot .tag { display: none; }
.pin.sel { transform: translateX(-50%) scale(1.22); outline: 3px solid var(--route); outline-offset: 1px; }
.pin.best { font-size: 16px; padding: 8px 11px; border-width: 3px; }
.pin.best .tag { position: absolute; left: 50%; top: -20px; transform: translateX(-50%); background: var(--gold);
  color: #3b2b00; font-size: 10px; font-weight: 900; letter-spacing: .04em; padding: 3px 7px; border-radius: 10px;
  box-shadow: 0 2px 5px rgba(0,0,0,.2); white-space: nowrap; }
.pin.best::before { content: ""; position: absolute; inset: -9px; border-radius: 20px; border: 3px solid var(--gold);
  animation: pulse 1.8s ease-out infinite; pointer-events: none; }
@keyframes pulse { from { opacity: .9; transform: scale(.9); } to { opacity: 0; transform: scale(1.35); } }

.me-dot { width: 20px; height: 20px; border-radius: 50%; background: var(--route); border: 3.5px solid #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,.3); position: relative; }
.me-dot::after { content: ""; position: absolute; inset: -12px; border-radius: 50%; background: rgba(26,159,255,.25);
  animation: pulse 2s ease-out infinite; }
.center-pin { font-size: 28px; line-height: 1; filter: drop-shadow(0 2px 2px rgba(0,0,0,.35)); }

/* ---------- нижняя панель ---------- */
.sheet { --sheet-h: calc(100dvh - var(--top-h, 120px) - 8px);
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 900; max-width: 640px; margin: 0 auto;
  height: var(--sheet-h); background: var(--surface); border-radius: 24px 24px 0 0;
  box-shadow: 0 -6px 24px rgba(19,38,59,.16); display: flex; flex-direction: column;
  transform: translateY(calc(100% - var(--peek) - var(--safe-bottom))); transition: transform .28s cubic-bezier(.2,.8,.2,1);
  touch-action: none; }
.sheet[data-state="half"] { transform: translateY(45%); }
/* В режиме «половина» нижние 45% панели за краем экрана — добавляем столько же отступа,
   чтобы последнюю заправку можно было прокрутить в видимую часть (над системной панелью телефона). */
.sheet[data-state="half"] .list { padding-bottom: calc(var(--sheet-h) * .45 + 16px + max(var(--safe-bottom), 40px)); }
.sheet[data-state="full"] { transform: translateY(0); }
.sheet.dragging { transition: none; }
.sheet.hidden-by-card { transform: translateY(100%); }
.sheet-head { padding: 6px 14px 10px; cursor: grab; user-select: none; flex: none; }
.grip { width: 44px; height: 5px; border-radius: 3px; background: #d3dce5; margin: 2px auto 10px; }
.sheet-row { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.sheet-row + .sheet-row { margin-top: 6px; }
.sheet-title { min-width: 0; }
.sheet-title > div:first-child { font-weight: 800; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sub { color: var(--muted); font-size: 12px; font-weight: 600; }

/* блок «Лучший выбор» */
.best-card { display: flex; align-items: center; gap: 12px; background: linear-gradient(135deg, #e3f7ff, #f2fbff);
  border: 2px solid #bfeeff; border-radius: 20px; padding: 10px 10px 10px 12px; margin-bottom: 10px; cursor: pointer; }
.best-card { gap: 10px; }
.best-card .bp { flex: none; min-width: 64px; text-align: center; background: var(--c, var(--ok)); color: #fff;
  font-weight: 900; font-size: 17px; padding: 8px 5px; border-radius: 14px; font-variant-numeric: tabular-nums;
  border: 2.5px solid #fff; box-shadow: var(--shadow-sm); }
.best-card .bi { flex: 1; min-width: 0; }
.best-card .bi > div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.best-card .bt { font-size: 11px; font-weight: 900; color: #8a6400; text-transform: uppercase; letter-spacing: .03em; }
.best-card .btn.go { padding: 10px 13px; font-size: 14px; }
.best-card .bn { font-weight: 800; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.best-card .bm { font-size: 13px; color: var(--text); font-weight: 700; }
.best-card .bm .muted { color: var(--muted); font-weight: 600; }

.list { list-style: none; margin: 0; padding: 4px 8px calc(16px + max(var(--safe-bottom), 40px)); overflow-y: auto; flex: 1;
  touch-action: pan-y; overscroll-behavior: contain; border-top: 1px solid var(--line); }
.list li { display: flex; align-items: center; gap: 12px; padding: 10px 8px; border-radius: 16px; cursor: pointer; }
.list li + li { margin-top: 2px; }
.list li:hover { background: var(--surface-2); }
.list li.sel { background: var(--primary-soft); }
.list .price { flex: none; min-width: 68px; text-align: center; padding: 7px 4px; border-radius: 12px;
  background: var(--c, #9aa6b2); color: #fff; font-weight: 800; font-variant-numeric: tabular-nums; }
.list .price sup { font-size: 9px; }
.list .info { flex: 1; min-width: 0; }
.list .name { font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list .name .star { color: #d89b00; }
.list .addr { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list .meta { flex: none; text-align: right; font-size: 12px; font-weight: 700; }
.list .go-mini { flex: none; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center;
  background: var(--primary-soft); color: var(--primary-strong); text-decoration: none; font-size: 17px; }
.list .go-mini:hover { background: var(--primary); color: var(--primary-ink); }
.list .empty { justify-content: center; color: var(--muted); cursor: default; padding: 28px 14px; text-align: center; }
.list .empty:hover { background: none; }
.open { color: var(--ok); }
.closed-txt { color: var(--bad); }

/* ---------- карточка ---------- */
.card { position: fixed; left: 0; right: 0; bottom: 0; z-index: 950; max-width: 640px; margin: 0 auto;
  background: var(--surface); border-radius: 24px 24px 0 0; box-shadow: 0 -6px 24px rgba(19,38,59,.2);
  padding: 16px 16px calc(16px + var(--safe-bottom)); animation: up .22s ease-out;
  max-height: min(75dvh, calc(100dvh - var(--top-h, 116px) - 8px)); overflow-y: auto; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.card-head { display: flex; gap: 10px; align-items: flex-start; }
.card-head .t { flex: 1; min-width: 0; }
.card h2 { margin: 0; font-size: 20px; line-height: 1.2; font-weight: 900; }
.card .brand { color: var(--primary-strong); font-size: 12px; font-weight: 900; text-transform: uppercase; letter-spacing: .05em; }
.card .best-badge { display: inline-block; background: var(--gold); color: #3b2b00; font-size: 11px; font-weight: 900;
  padding: 2px 8px; border-radius: 10px; margin-bottom: 4px; }
.card .addr { color: var(--muted); font-size: 14px; margin-top: 2px; }
.card .chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0; font-size: 13px; font-weight: 700; }
.card .chip { background: var(--surface-2); border-radius: 12px; padding: 5px 10px; }
.card .chip.route { background: var(--primary-soft); color: #075e86; }
.fuels { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.fuel { background: var(--surface-2); border-radius: 16px; padding: 10px 6px; text-align: center; border: 2.5px solid transparent; }
.fuel.sel { border-color: var(--primary); background: var(--primary-soft); }
.fuel .n { color: var(--muted); font-size: 12px; font-weight: 700; }
.fuel .p { font-size: 22px; font-weight: 900; margin: 2px 0; font-variant-numeric: tabular-nums; }
.fuel .p sup { font-size: 11px; }
.fuel .u { color: var(--muted); font-size: 11px; font-weight: 600; }
.fuel .up { color: var(--bad); }
.fuel .down { color: var(--ok); }
.card .row-btns { display: flex; gap: 8px; margin-top: 14px; }

.btn { border: 0; border-radius: 24px; padding: 12px 18px; font-weight: 800; text-decoration: none; white-space: nowrap;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn.primary { background: var(--primary); color: var(--primary-ink); flex: 1; box-shadow: 0 3px 10px rgba(51,204,255,.45); }
.btn.primary:hover { background: var(--primary-strong); color: #fff; }
.btn.go { background: var(--primary); color: var(--primary-ink); padding: 11px 16px; flex: none;
  box-shadow: 0 3px 10px rgba(51,204,255,.5); font-size: 15px; }
.btn.go:hover { background: var(--primary-strong); color: #fff; }
.btn.text { background: none; color: var(--primary-strong); }
.btn.tonal { background: var(--surface-2); color: var(--text); }

/* ---------- настройки ---------- */
dialog { border: 0; border-radius: 24px; padding: 22px; width: min(440px, calc(100% - 24px));
  background: var(--surface); color: var(--text); box-shadow: 0 12px 40px rgba(19,38,59,.3); }
dialog::backdrop { background: rgba(19,38,59,.35); }
dialog h2 { margin: 0 0 14px; font-size: 21px; font-weight: 900; }
/* переключатель языка на карте (справа, где раньше были +/−) */
.lang-ctl { display: flex; flex-direction: column; background: var(--surface); border-radius: 14px; padding: 3px;
  box-shadow: var(--shadow-sm); gap: 3px; }
.lang-ctl button { width: 40px; height: 34px; border: 0; border-radius: 11px; background: none; cursor: pointer;
  display: grid; place-items: center; font: 900 13px system-ui, sans-serif; color: var(--muted); padding: 0; }
.lang-ctl button.on { background: var(--primary); color: var(--primary-ink); }
.flag-de { display: block; width: 24px; height: 15px; border-radius: 3px; box-shadow: 0 0 0 1px rgba(0,0,0,.12);
  background: linear-gradient(#000 0 33.3%, #dd0000 33.3% 66.6%, #ffce00 66.6%); }
.lang-ctl button:not(.on) .flag-de { opacity: .75; }
dialog { max-height: calc(100dvh - 24px); overflow-y: auto; }
.morning { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.morning h3 { margin: 0 0 4px; font-size: 16px; font-weight: 900; }
.morning .hint { margin: 6px 0; }
.m-point { margin: 4px 0 8px; font-weight: 800; font-size: 14px; }
.btn.wide { display: block; width: 100%; margin-top: 6px; }
.m-actions { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.m-actions .btn { flex: 1; padding: 10px 12px; }
.field { display: grid; gap: 6px; font-size: 13px; color: var(--muted); font-weight: 700; }
.field input { padding: 12px 14px; border: 2px solid var(--line); border-radius: 14px; background: var(--surface-2);
  color: var(--text); font: 14px ui-monospace, monospace; }
.field input:focus { outline: none; border-color: var(--primary); }
.hint { color: var(--muted); font-size: 12px; }
.hint a { color: var(--primary-strong); }
.check { display: flex; align-items: center; gap: 8px; margin: 6px 0; font-weight: 700; }
.check input { width: 18px; height: 18px; accent-color: var(--primary-strong); }
.actions { display: flex; justify-content: flex-end; gap: 6px; margin-top: 12px; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--peek) + 16px + var(--safe-bottom));
  z-index: 1100; background: var(--text); color: #fff; padding: 11px 18px; border-radius: 16px; font-size: 14px;
  font-weight: 700; box-shadow: var(--shadow); max-width: calc(100% - 32px); text-align: center; }

@media (min-width: 900px) {
  /* На широком экране панель слева, карта справа видна целиком */
  .sheet, .card { left: 10px; right: auto; width: 400px; margin: 0; bottom: 10px; border-radius: 24px;
    top: calc(var(--top-h, 130px) + 8px); height: auto; }
  .card { top: auto; max-height: calc(100dvh - var(--top-h, 130px) - 18px); }
  .sheet[data-state] { transform: none; }
  .sheet[data-state] .list { padding-bottom: 16px; }
  .card { z-index: 960; }
  .topbar { margin: 0; width: 420px; }
  .leaflet-bottom { bottom: 0; }
  .leaflet-top.leaflet-right { top: 0; }
  .toast { bottom: 24px; }
}

/* утреннее уведомление: время + выходные, статус */
.m-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin: 4px 0 2px; }
.m-time { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.m-time select { font: 700 15px system-ui, sans-serif; padding: 7px 10px; border: 2px solid var(--line); border-radius: 12px;
  background: var(--surface-2); color: var(--text); }
.m-status { margin: 10px 0 4px; font-weight: 800; color: var(--ok, #1f9d3a); }
.ico-btn svg { display: block; }
