/* Светлая тема — база. Тёмная включается системой или выбором пользователя.
   --radius общий для обеих. */
:root {
  --page-bg: #e6eaf1;
  --bg: #f5f7fb;
  --card: #ffffff;
  --card-2: #eef1f6;
  --line: #dce1e9;
  --text: #12151b;
  --muted: #667085;
  --brand: #2f7dff;
  --brand-2: #1a5fd6;
  --green: #1a9e54;
  --amber: #b1751a;
  --red: #d93a47;
  --radius: 16px;
  color-scheme: light;
}

/* палитра тёмной темы, вынесена, чтобы включаться в трёх случаях */
:root[data-theme="dark"],
:root:not([data-theme="light"]) {
  /* по умолчанию (без явного выбора) следуем системе — см. media ниже */
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --page-bg: #05070b;
    --bg: #0f1115;
    --card: #191c23;
    --card-2: #21252e;
    --line: #2b303b;
    --text: #eef1f6;
    --muted: #9aa3b2;
    --green: #29c26b;
    --amber: #f0a92c;
    --red: #ef4d5a;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --page-bg: #05070b;
  --bg: #0f1115;
  --card: #191c23;
  --card-2: #21252e;
  --line: #2b303b;
  --text: #eef1f6;
  --muted: #9aa3b2;
  --green: #29c26b;
  --amber: #f0a92c;
  --red: #ef4d5a;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  background: var(--page-bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  display: flex;
  justify-content: center;
  min-height: 100vh;
}

#phone {
  width: 100%;
  max-width: 430px;
  min-height: 100vh;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  position: relative;
  box-shadow: 0 0 60px rgba(0, 0, 0, .6);
}

header {
  padding: 14px 16px 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 5;
}

header .back {
  background: none;
  border: 0;
  color: var(--muted);
  font-size: 22px;
  padding: 0 4px;
  cursor: pointer;
}

header h1 { font-size: 17px; margin: 0; font-weight: 600; }
header .sub { font-size: 12px; color: var(--muted); }

/* базовый запас под панель браузера; на экранах с нижней панелью
   отступ пересчитывает syncStickyPadding() в app.js */
main { flex: 1; padding: 16px; padding-bottom: 96px; }

.screen { display: none; }
.screen.active { display: block; animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } }

h2 { font-size: 22px; margin: 0 0 4px; }
.muted { color: var(--muted); font-size: 13px; }
.center { text-align: center; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}
.card.tap { cursor: pointer; transition: border-color .15s, transform .1s; }
.card.tap:active { transform: scale(.99); }
.card.tap:hover { border-color: #3a4353; }

.row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.row.top { align-items: flex-start; }
.stack { display: flex; flex-direction: column; gap: 2px; }

.big-btn {
  width: 100%;
  border: 0;
  border-radius: var(--radius);
  padding: 18px 16px;
  text-align: left;
  color: #fff;
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 10px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
}
.big-btn small { display: block; font-weight: 400; font-size: 12px; opacity: .85; margin-top: 3px; }
.big-btn.secondary { background: var(--card-2); border: 1px solid var(--line); color: var(--text); }

button.primary {
  width: 100%;
  border: 0;
  border-radius: 12px;
  background: var(--brand);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  padding: 14px;
  cursor: pointer;
}
button.primary:disabled { background: #2c3140; opacity: .6; cursor: not-allowed; }
button.ghost, a.ghost {
  display: block;
  width: 100%;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  border-radius: 12px;
  padding: 12px;
  cursor: pointer;
  margin-top: 8px;
  text-align: center;
  text-decoration: none;
  font-size: 15px;
}
/* звонок на мойку выделяем брендовым цветом — это полезное действие */
a.ghost[href^="tel:"] { color: var(--brand); border-color: var(--brand); }

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

.pill {
  display: inline-block;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 20px;
  background: var(--card-2);
  color: var(--muted);
  border: 1px solid var(--line);
}
.pill.green { color: var(--green); border-color: rgba(41,194,107,.4); }
.pill.amber { color: var(--amber); border-color: rgba(240,169,44,.4); }
.pill.red { color: var(--red); border-color: rgba(239,77,90,.4); }
.pill.blue { color: var(--brand); border-color: rgba(47,125,255,.5); }

.price { font-size: 18px; font-weight: 700; white-space: nowrap; }
.price s { color: var(--muted); font-size: 12px; font-weight: 400; margin-right: 6px; }
.ready { color: var(--green); font-weight: 600; }

.tabs { display: flex; gap: 8px; margin-bottom: 12px; }
.tabs button {
  flex: 1;
  background: var(--card-2);
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 10px;
  padding: 9px;
  cursor: pointer;
  font-size: 13px;
}
.tabs button.active { background: var(--brand); border-color: var(--brand); color: #fff; }

.days { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 10px;
        scrollbar-width: thin; }   /* тонкая полоса: мышью листать можно, но не мешает */
.days::-webkit-scrollbar { height: 4px; }
.days::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }
.days button {
  flex: 0 0 auto;
  background: var(--card-2);
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
}
.days button.active { background: var(--brand); color: #fff; border-color: var(--brand); }

.slots { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.slots button {
  background: var(--card-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 4px;
  font-size: 14px;
  cursor: pointer;
  position: relative;
}
.slots button[disabled] { color: #4c5261; text-decoration: line-through; cursor: not-allowed; }
.slots button.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.slots button .slot-price { display: block; font-size: 11px; color: var(--green); margin-top: 2px; }
.slots button.active .slot-price { color: #fff; }
.slots button .sale {
  position: absolute; top: -6px; right: -4px;
  font-size: 9px; background: var(--green); color: #04240f;
  border-radius: 6px; padding: 1px 4px; font-weight: 700;
}

.check {
  display: flex; align-items: center; gap: 10px;
  padding: 12px; border: 1px solid var(--line);
  border-radius: 12px; background: var(--card-2); margin-bottom: 8px; cursor: pointer;
}
.check.on { border-color: var(--brand); background: rgba(47,125,255,.10); }
.check .box {
  width: 22px; height: 22px; border-radius: 6px;
  border: 1.5px solid var(--muted); flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center; font-size: 14px;
  /* галочка не видна, пока пользователь не нажал — иначе легко перепутать */
  color: transparent;
}
.check.on .box { background: var(--brand); border-color: var(--brand); color: #fff; }
.check .grow { flex: 1; }
.check small { display: block; color: var(--muted); font-size: 12px; }

.sticky-total {
  position: fixed;
  bottom: 0;
  /* без left панель вставала от отступа main и вылезала за правый край */
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 430px;
  background: var(--card);
  border-top: 1px solid var(--line);
  padding: 12px 16px calc(16px + env(safe-area-inset-bottom));
  box-shadow: 0 -4px 16px rgba(0, 0, 0, .12);
}

.timeline { list-style: none; padding: 0; margin: 12px 0 0; }
.timeline li { display: flex; gap: 10px; align-items: flex-start; padding-bottom: 14px; position: relative; }
.timeline li::before {
  content: ""; width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid var(--line); margin-top: 3px; flex: 0 0 auto; background: var(--bg);
}
.timeline li.done::before { background: var(--green); border-color: var(--green); }
.timeline li.now::before { background: var(--brand); border-color: var(--brand); box-shadow: 0 0 0 4px rgba(47,125,255,.2); }
.timeline li:not(:last-child)::after {
  content: ""; position: absolute; left: 5px; top: 17px; bottom: 0; width: 2px; background: var(--line);
}
.timeline li.done:not(:last-child)::after { background: var(--green); }
.timeline .t { font-size: 14px; }
.timeline .t small { display: block; color: var(--muted); font-size: 12px; }

.stars { display: flex; gap: 6px; font-size: 26px; cursor: pointer; }
.stars span { color: #3a4353; }
.stars span.on { color: var(--amber); }
.rate-row { margin-bottom: 10px; }
.rate-row .stars { font-size: 20px; }

.map {
  position: relative;
  height: 300px;
  background:
    repeating-linear-gradient(0deg, #171b23 0 1px, transparent 1px 32px),
    repeating-linear-gradient(90deg, #171b23 0 1px, transparent 1px 32px),
    #10131a;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.map .pin {
  position: absolute; transform: translate(-50%, -100%);
  background: var(--card); border: 1px solid var(--brand);
  border-radius: 10px; padding: 4px 7px; font-size: 12px; white-space: nowrap; cursor: pointer;
}
.map .pin b { display: block; font-size: 13px; }
.map .me {
  position: absolute; width: 14px; height: 14px; border-radius: 50%;
  background: var(--brand); border: 2px solid #fff; transform: translate(-50%, -50%);
}
.map .note { position: absolute; left: 10px; bottom: 8px; font-size: 11px; color: var(--muted); }

/* Маркеры на настоящей карте (Яндекс JS API / 2ГИС MapGL) */
#map-canvas { height: 420px; padding: 0; background: #10131a; }
.map-pin {
  transform: translate(-50%, -100%);
  width: max-content;              /* в слое меток Яндекса у контейнера нет ширины */
  background: var(--card);
  border: 1px solid var(--brand);
  border-radius: 10px;
  padding: 4px 8px;
  font-size: 12px;
  line-height: 1.15;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, .5);
}
.map-pin b { display: block; font-size: 13px; color: var(--text); }
.map-pin span { color: var(--muted); font-size: 11px; }
.map-pin.now { border-color: var(--green); }
.map-pin.now span { color: var(--green); }
.map-me {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--brand); border: 3px solid #fff;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 0 6px rgba(47, 125, 255, .25);
}

/* всплывашка всегда тёмная со светлым текстом — читаема в обеих темах */
.toast {
  position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%);
  background: #23262e; border: 1px solid #3a4353; color: #eef1f6;
  padding: 10px 16px; border-radius: 20px; font-size: 13px; z-index: 50;
  max-width: 90%; text-align: center; box-shadow: 0 6px 20px rgba(0,0,0,.3);
}
.toast.err { border-color: var(--red); color: #ffd7da; }

.hold-timer { color: var(--amber); font-size: 13px; }
.hint {
  background: rgba(47,125,255,.12);
  border: 1px solid rgba(47,125,255,.35);
  border-radius: 12px; padding: 10px 12px; font-size: 13px; color: var(--text); margin-bottom: 12px;
}

/* ------------------------------------------------- кабинет автомойки (web) */
body.business { display: block; background: var(--bg); }
body.business #phone { max-width: none; box-shadow: none; }
/* env(safe-area-inset-*) — чтобы под чёлкой и полосой жестов iPhone
   не оказывались первые и последние элементы страницы. */
/* Нижний отступ с запасом: на телефоне поверх страницы висит панель
   браузера, и без него последняя карточка оказывается под ней. */
.b-wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px 20px calc(80px + env(safe-area-inset-bottom));
}
.b-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
.b-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; }
.b-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 16px; }
.b-stat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.b-stat b { display: block; font-size: 20px; margin-top: 2px; }
.b-slot { border-top: 1px solid var(--line); padding: 10px 0; }
.b-slot:first-of-type { border-top: 0; }
.b-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.b-actions button {
  background: var(--card-2); border: 1px solid var(--line); color: var(--text);
  border-radius: 8px; padding: 6px 10px; font-size: 12px; cursor: pointer;
}
.b-actions button:hover { border-color: var(--brand); }
/* Кнопки кабинета без своего класса (Сохранить, Выключить, …) — в стиле
   кабинета, а не системные серые. :where() обнуляет специфичность, поэтому
   .primary, .ghost, .tabs и прочие классы по-прежнему главнее. */
:where(body.business) button {
  background: var(--card-2); border: 1px solid var(--line); color: var(--text);
  border-radius: 10px; padding: 9px 14px; font: inherit; font-size: 14px; cursor: pointer;
}
:where(body.business) button:disabled { opacity: .55; cursor: not-allowed; }
.inline { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; }
.inline > div { flex: 1 1 140px; min-width: 0; }   /* min-width, иначе поля вылезают за край */
.inline label { margin-top: 0; }
.inline button { white-space: nowrap; }
.b-head-controls { flex: 0 1 auto; }

/* На телефоне ряды из полей и кнопок не помещаются в строку и наезжают друг
   на друга — раскладываем их столбиком во всю ширину. */
@media (max-width: 720px) {
  .b-wrap { padding: 16px 16px calc(96px + env(safe-area-inset-bottom)); }
  .b-head { align-items: stretch; }
  .b-head .inline, .b-head-controls { flex: 1 1 100%; }
  .inline { flex-direction: column; align-items: stretch; }
  /* в столбце flex-basis задаёт уже ВЫСОТУ: inline-стили вида flex:3 1 220px
     давали пустоты по 200 px — сбрасываем их */
  .inline > div { flex: 0 0 auto !important; width: 100%; }
  .inline button { width: 100% !important; }
  .b-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .b-actions button { flex: 1 1 auto; }
}

/* --------------------------------------------------- новые элементы */
/* выбор темы в настройках */
.theme-options { display: flex; gap: 8px; flex-wrap: wrap; }
.theme-options button {
  flex: 1 1 30%;
  background: var(--card-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 12px;
  padding: 14px 8px;
  font-size: 14px;
  cursor: pointer;
}
.theme-options button.active { background: var(--brand); border-color: var(--brand); color: #fff; }

/* маска госномера — моноширинно и вразрядку, как настоящий номер */
.plate-input {
  text-transform: uppercase;
  letter-spacing: 2px;
  font-weight: 600;
}

/* кнопка «позвонить на мойку» — ссылка, но выглядит как обычная кнопка */
a.ghost { text-decoration: none; }

/* select с длинным текстом не должен вылезать за карточку */
select { max-width: 100%; text-overflow: ellipsis; }

/* --------------------------------------------------- размеры под iPhone */
/* На узких экранах приложение занимает всю ширину; следим, чтобы поля,
   кнопки и карточки не переполняли контейнер и одинаково выглядели. */
@media (max-width: 460px) {
  main { padding: 14px; padding-bottom: 110px; }
  h2 { font-size: 20px; }
  .card { padding: 14px; }
  .big-btn { padding: 16px 14px; font-size: 16px; }
  /* инпуты 16px обязательно — иначе iOS зумит страницу при фокусе */
  input, select, textarea { font-size: 16px; }
  .tabs button { padding: 11px 6px; }
  .slots { grid-template-columns: repeat(3, 1fr); }
}

/* подсказка с ценами при наведении на мойку на карте (ТЗ моек) */
#map-tip {
  position: fixed; z-index: 60; pointer-events: none;
  min-width: 220px; max-width: 300px;
  background: var(--card); color: var(--text);
  border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,.35);
  padding: 10px 12px; font-size: 12.5px;
}
#map-tip[hidden] { display: none; }
#map-tip .tip-head { display: flex; flex-direction: column; margin-bottom: 6px; }
#map-tip .tip-head span { color: var(--muted); font-size: 11px; }
#map-tip .tip-row { display: flex; justify-content: space-between; gap: 10px; padding: 2px 0; }
#map-tip .tip-row i { color: var(--muted); font-style: normal; font-size: 11px; }
