:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel2: #1e222b;
  --border: #2a2f3a;
  --text: #e8eaed;
  --muted: #98a0ac;
  --accent: #ffcc33;
  --accent2: #ffb800;
  --good: #37c26f;
  --bad: #ef5350;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  min-height: 76px;
  z-index: 45;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

/* Компенсируем то место, которое раньше занимала панель в потоке —
   сдвигаем вниз первый элемент после неё, чтобы контент не прятался под ней. */
.topbar + * {
  margin-top: 76px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 22px;
}

.circle-btn {
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--panel2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  color: var(--text);
  font-size: 20px;
  line-height: 1;
  text-decoration: none;
}
.circle-btn:hover { border-color: var(--accent); background: var(--panel); }

.menu-btn {
  flex-direction: column;
  gap: 5px;
}
.menu-btn span {
  display: block;
  width: 20px;
  height: 2px;
  border-radius: 1px;
  background: var(--text);
}

.topbar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 18px;
  color: var(--accent);
}
.topbar .brand-logo {
  width: 20px;
  height: 20px;
  border-radius: 5px;
  object-fit: cover;
}

.topbar .who { color: var(--muted); font-size: 14px; }

.btn {
  display: inline-block;
  border: none;
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  background: var(--accent);
  color: #1a1a1a;
}
.btn:hover { background: var(--accent2); }
.btn.secondary { background: var(--panel2); color: var(--text); border: 1px solid var(--border); }
.btn.danger { background: var(--bad); color: white; }
.btn.good { background: var(--good); color: white; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.small { padding: 6px 10px; font-size: 12px; }

.bottom-bar .btn {
  display: block;
  width: 100%;
  border-radius: 0;
  font-weight: 800;
  font-size: 16px;
  letter-spacing: 0.3px;
  padding: 20px 22px calc(20px + env(safe-area-inset-bottom));
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
}

/* Блок во всю ширину экрана (без отступов контейнера по бокам) */
.card-full {
  width: 100%;
  border-radius: 0;
  border-left: none;
  border-right: none;
  padding: 18px 20px;
  margin-bottom: 0;
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 800px) {
  .grid { grid-template-columns: 1fr; }
}

#map {
  height: 380px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}

#map.map-full {
  width: 100%;
  /* во всю высоту экрана за вычетом шапки и закреплённой нижней панели */
  height: calc(100vh - 76px - 84px);
  min-height: 320px;
  border-radius: 0;
  border: none;
  border-bottom: 1px solid var(--border);
  position: relative;
  /* Важно: z-index здесь не декоративный — без него #map не создаёт
     собственный контекст наложения, и внутренние слои/контролы Яндекс.Карт
     (у них самих часто выставлен большой z-index) "протекают" наружу и
     перекрывают собой плавающую кнопку "Куда поедем?" и нижнюю панель,
     из-за чего кнопка визуально видна, но клики по ней не доходят. */
  z-index: 1;
}

/* Лёгкое затемнение снизу карты — просто смягчает контраст в этой зоне,
   не закрывает и не перекрывает логотип/копирайт Яндекса (это запрещено
   условиями использования API) и не мешает работе с картой. */
/* Тёмная тема карты: инвертируем только слой тайлов (ground-pane) —
   иконки меток/машин, копирайт и элементы управления Яндекс.Карт остаются
   как есть (их трогать нельзя — условия использования API это запрещают). */
#map [class*="ground-pane"] {
  filter: invert(92%) hue-rotate(180deg) brightness(0.92) contrast(0.85) saturate(0.75);
}

#map.map-full::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 64px;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.28));
  pointer-events: none;
}

/* Карта на весь экран без резерва под нижнюю панель (используется, когда
   вместо .bottom-bar над картой плавает .floating-cta + выезжающая .sheet) */
#map.map-full.no-bottom-bar {
  height: calc(100vh - 76px);
}

/* Круглая кнопка "моё местоположение" над картой — висит чуть выше
   плавающей кнопки "Куда поедем?", справа */
.locate-btn {
  position: fixed;
  right: 16px;
  bottom: calc(108px + env(safe-area-inset-bottom));
  z-index: 49;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #fff;
  border: none;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

/* Плавающая белая кнопка поверх карты снизу ("Куда поедем?") —
   открывает выезжающую снизу панель заказа */
.floating-cta {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 50;
  display: block;
  width: calc(100% - 32px);
  background: #fff;
  color: #14161b;
  border: none;
  border-radius: 16px;
  padding: 16px 20px;
  font-size: 16px;
  font-weight: 800;
  text-align: left;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.4);
  cursor: pointer;
}
.floating-cta .sub {
  display: block;
  font-weight: 500;
  font-size: 13px;
  color: #6b7280;
  margin-top: 2px;
}

/* Выезжающая снизу панель с формой заказа / статусом поездки */
.sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 90;
}
.sheet-overlay.open { opacity: 1; pointer-events: auto; }

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 85vh;
  overflow-y: auto;
  background: var(--panel);
  border-top: 1px solid var(--border);
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -6px 24px rgba(0, 0, 0, 0.35);
  transform: translateY(100%);
  transition: transform 0.3s ease;
  z-index: 91;
  padding: 10px 20px calc(20px + env(safe-area-inset-bottom));
}
.sheet.open { transform: translateY(0); }

.sheet-handle {
  width: 40px;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  margin: 4px auto 14px;
}

/* Карточки выбора класса автомобиля — иконка + название + коэффициент */
.car-class-row {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 14px;
}
.car-class-item {
  flex: 0 0 auto;
  min-width: 84px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--panel2);
  color: var(--text);
  cursor: pointer;
}
.car-class-item.active { border-color: var(--accent); background: rgba(255, 204, 51, 0.14); }
.car-class-icon { font-size: 26px; line-height: 1; }
.car-class-label { font-size: 13px; font-weight: 600; }
.car-class-mult { font-size: 11px; color: var(--muted); }
.car-class-item.active .car-class-mult { color: var(--accent); }

/* Кнопка "Заказать такси" внутри панели — белая и крупнее остальных, чтобы
   выделяться как основное действие, с ценой прямо на кнопке */
#orderSubmitBtn {
  background: #fff;
  color: #14161b;
  font-size: 17px;
  font-weight: 800;
  padding: 18px 22px;
}
#orderSubmitBtn:hover { background: #f0f0f0; }

/* ---- Карточки "Откуда"/"Куда" в стиле Яндекс.Такси ---- */
.order-address-card {
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 10px;
}
.order-address-row {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}
.order-dot {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 4px solid var(--bad);
  background: transparent;
}
.order-dot.dropoff {
  width: 22px;
  height: 22px;
  border: none;
  background: #4fa3ff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  line-height: 1;
}
.order-address-text { flex: 1; min-width: 0; }
.order-address-label { font-size: 12px; color: var(--muted); }
.order-address-value {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.order-address-eta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.order-chevron { flex: 0 0 auto; color: var(--muted); font-size: 22px; line-height: 1; }
.order-edit-wrap { margin-top: 10px; }
.order-meeting-input { margin-top: 10px; }

/* ---- Сетка "Наличные / Сейчас / Класс / Детали" ---- */
.order-options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 4px 0 10px;
}
.order-option-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--panel2);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
}
.order-option-btn.active { border-color: var(--accent); background: rgba(255, 204, 51, 0.14); color: var(--accent); }
.order-option-icon { font-size: 16px; }
.order-expand {
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 10px;
}

/* Кнопка заказа с ценой слева и "ЗАКАЗАТЬ" справа, как в референсе */
.order-submit-btn {
  width: 100%;
  margin-top: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.order-submit-btn.has-price { justify-content: space-between; }
.order-submit-price { font-size: 18px; font-weight: 800; }
.order-submit-label { font-size: 15px; font-weight: 800; letter-spacing: 0.4px; }

.bottom-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  padding: 0;
  background: var(--panel);
  border-top: 1px solid var(--border);
  box-shadow: 0 -6px 20px rgba(0, 0, 0, 0.35);
  z-index: 40;
}

label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
input, select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel2);
  color: var(--text);
  font-size: 14px;
}
input:focus, select:focus { outline: 1px solid var(--accent); }

.row { display: flex; gap: 10px; align-items: center; }
.row.between { justify-content: space-between; }
.muted { color: var(--muted); }
.tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  background: var(--panel2);
  border: 1px solid var(--border);
}
.tag.searching { color: var(--accent); background: rgba(255, 204, 51, 0.14); font-weight: 700; }
.tag.accepted, .tag.arrived, .tag.in_progress { color: #4fa3ff; }
.tag.completed { color: var(--good); }
.tag.cancelled { color: var(--bad); }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; }

.tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.tabs .btn.secondary.active { border-color: var(--accent); color: var(--accent); background: rgba(255, 204, 51, 0.12); font-weight: 700; }

/* Переиспользуемая "пилюля" для выбора (класс авто, режим сейчас/заранее) —
   тот же стиль активного состояния, но без обязательной обёртки .tabs */
.btn.secondary.active { border-color: var(--accent); color: var(--accent); background: rgba(255, 204, 51, 0.12); font-weight: 700; }
.tabs.tabs-split { justify-content: space-between; }
.tabs.tabs-split .btn { flex: 0 0 auto; }

.stat {
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
}
.stat .value { font-size: 26px; font-weight: 700; color: var(--accent); }
.stat .label { color: var(--muted); font-size: 13px; margin-top: 4px; }
.stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
@media (max-width: 800px) { .stats-row { grid-template-columns: repeat(2, 1fr); } }

.error { color: var(--bad); font-size: 13px; margin-top: 8px; min-height: 16px; }
.hint { color: var(--muted); font-size: 12px; margin-top: 6px; }

.center-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.auth-card { width: 100%; max-width: 380px; }
.auth-logo { display: flex; justify-content: center; margin-bottom: 16px; }
.auth-logo img { width: 120px; height: 120px; border-radius: 20px; object-fit: cover; }

.autocomplete-wrap { position: relative; }
.suggestions-box {
  display: none;
  position: absolute;
  left: 0; right: 0; top: 100%;
  z-index: 50;
  background: var(--panel2);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 10px 10px;
  max-height: 220px;
  overflow-y: auto;
}
.suggestion-item {
  padding: 9px 12px;
  font-size: 13px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.suggestion-item:last-child { border-bottom: none; }
.suggestion-item:hover { background: var(--panel); color: var(--accent); }

.request-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 10px;
  background: var(--panel2);
}

/* ---- Выезжающее боковое меню ---- */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 90;
}
.drawer-overlay.open { opacity: 1; pointer-events: auto; }

.drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 290px;
  max-width: 84vw;
  background: var(--panel);
  border-right: 1px solid var(--border);
  transform: translateX(-100%);
  transition: transform 0.25s ease;
  z-index: 91;
  display: flex;
  flex-direction: column;
  padding: 18px 0;
  overflow-y: auto;
}
.drawer.open { transform: translateX(0); }

.drawer-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 18px 16px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.drawer-logo { width: 44px; height: 44px; border-radius: 12px; object-fit: cover; }
.drawer-balance { color: var(--accent); font-weight: 700; font-size: 13px; margin-top: 3px; }

.drawer-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 18px;
  color: var(--text);
  text-decoration: none;
  font-size: 15px;
  border-left: 3px solid transparent;
}
.drawer-item:hover { background: var(--panel2); border-left-color: var(--accent); }
.drawer-icon { font-size: 18px; width: 22px; text-align: center; }

.drawer-logout { margin: 14px 18px 0; }

/* ---- Подстраницы (чат, инфо, баланс, авто, настройки) ---- */
.chat-wrap {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 76px);
}
.chat-messages { flex: 1; overflow-y: auto; padding: 16px 16px 8px; }
.chat-msg { margin-bottom: 12px; max-width: 78%; }
.chat-msg .meta { font-size: 12px; color: var(--muted); margin-bottom: 3px; }
.chat-msg .bubble {
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 9px 13px;
  font-size: 14px;
  line-height: 1.4;
  word-break: break-word;
}
.chat-msg.mine { margin-left: auto; }
.chat-msg.mine .bubble { background: rgba(255, 204, 51, 0.16); border-color: var(--accent); }
.chat-input-row {
  display: flex;
  gap: 10px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: var(--panel);
}
.chat-input-row input { flex: 1; }
