:root {
  --navy: #013974;
  --navy-2: #0a4f9c;
  --blue: #1668c7;
  --sky: #3fa4f0;
  --sky-soft: #e6f2fd;
  --bg: #eef4fb;
  --card: #ffffff;
  --line: #d7e3f1;
  --text: #0e1c33;
  --muted: #5a6b84;
  --green: #18a54a;
  --green-2: #12893c;
  --danger: #c62828;
  --radius: 16px;
  --shadow: 0 2px 10px rgba(1, 57, 116, .08), 0 1px 2px rgba(1, 57, 116, .06);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh;
  overscroll-behavior-y: none;
}
.hidden { display: none !important; }
a { color: var(--blue); text-decoration: none; font-weight: 600; }

/* ---------- шапка ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px;
  background: linear-gradient(120deg, var(--navy) 0%, var(--navy-2) 60%, var(--blue) 100%);
  color: #fff;
  box-shadow: 0 2px 12px rgba(1, 57, 116, .25);
}
.topbar-logo { width: 42px; height: auto; display: block; }
.topbar-name { font-size: 22px; font-weight: 800; letter-spacing: .3px; }
.topbar-sub { font-size: 13px; opacity: .85; text-transform: uppercase; letter-spacing: 2px; margin-top: 4px; }

.view { padding: 14px 14px calc(110px + var(--safe-bottom)); max-width: 720px; margin: 0 auto; }

/* ---------- карточки и текст сообщений ---------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin: 0 0 14px;
  overflow: hidden;
}
.card-pad { padding: 14px 16px; }
.msg { white-space: pre-wrap; word-wrap: break-word; }
.msg blockquote {
  margin: 8px 0 0; padding: 8px 12px;
  border-left: 4px solid var(--sky);
  background: var(--sky-soft);
  border-radius: 0 10px 10px 0;
  color: var(--muted);
}
.msg code { font: 14px/1.4 ui-monospace, Menlo, Consolas, monospace; background: var(--sky-soft); padding: 1px 5px; border-radius: 6px; }
/* водяной знак фирмы под текстом — бледный, но сквозной */
.wm {
  background-color: #fff;
  background-image: url("wm_card.png");
  background-size: 300px auto;
  background-repeat: repeat;
}
.protect { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }

.notice {
  background: #fff8e1; border: 1px solid #ffe08a; color: #6b4e00;
  border-radius: 12px; padding: 10px 14px; margin: 0 0 14px;
}

/* ---------- кнопки ---------- */
.btn {
  appearance: none; border: 0; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 50px; padding: 12px 16px;
  border-radius: 14px;
  font-family: inherit; font-size: 16px; font-weight: 600; line-height: 1.25;
  transition: transform .06s ease, filter .15s ease, background .15s ease;
  text-align: center;
}
.btn:active { transform: scale(.985); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-green { background: linear-gradient(180deg, #1fb954, var(--green)); color: #fff; box-shadow: 0 4px 14px rgba(24, 165, 74, .35); }
.btn-green:active { background: var(--green-2); }
.btn-blue { background: linear-gradient(135deg, var(--navy) 0%, var(--blue) 100%); color: #fff; box-shadow: 0 4px 14px rgba(1, 57, 116, .25); }
.btn-light { background: #fff; color: var(--navy); border: 1.5px solid var(--line); }
.btn-ghost { background: transparent; color: var(--navy); border: 1.5px solid var(--line); }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }
.stack > * + * { margin-top: 10px; }

.option-btn {
  text-align: left; justify-content: flex-start;
  min-height: 64px; font-size: 17px; padding: 14px 18px;
}

/* нижняя панель с главной кнопкой */
.bottombar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 15;
  padding: 10px 14px calc(10px + var(--safe-bottom));
  background: linear-gradient(180deg, rgba(238, 244, 251, 0) 0%, rgba(238, 244, 251, .96) 28%);
}
.bottombar-inner { max-width: 720px; margin: 0 auto; }

/* ---------- список фильтров ---------- */
.rows { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; margin: 0 0 14px; }
.row {
  appearance: none; border: 0; background: #fff; width: 100%;
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px; min-height: 54px;
  font-family: inherit; font-size: 15.5px; line-height: 1.35; color: var(--text); text-align: left;
  cursor: pointer;
}
.row + .row { border-top: 1px solid var(--line); }
.row:active { background: var(--sky-soft); }
.row-text { flex: 1; min-width: 0; }
.row-chev { color: var(--sky); font-size: 22px; line-height: 1; }

/* ---------- выбор значений ---------- */
.search {
  width: 100%; padding: 12px 14px; border-radius: 12px;
  border: 1.5px solid var(--line); background: #fff;
  font-family: inherit; font-size: 16px; color: var(--text); outline: none;
  margin: 0 0 12px;
}
.search:focus { border-color: var(--sky); }
.check {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 16px; min-height: 52px; cursor: pointer; background: #fff;
}
.check + .check { border-top: 1px solid var(--line); }
.check input { position: absolute; opacity: 0; pointer-events: none; }
.box {
  flex: 0 0 24px; height: 24px; border-radius: 7px;
  border: 2px solid #9fb6d1; background: #fff;
  display: grid; place-items: center; transition: background .12s, border-color .12s;
}
.check input:checked + .box { background: var(--blue); border-color: var(--blue); }
.check input:checked + .box::after { content: ""; width: 6px; height: 11px; border: solid #fff; border-width: 0 3px 3px 0; transform: rotate(45deg) translate(-1px, -1px); }
.check-label { flex: 1; }
.empty-search { padding: 16px; color: var(--muted); text-align: center; }
.picked-count { color: var(--muted); font-size: 14px; margin: -4px 2px 10px; }

.text-input-wrap { margin: 0 0 14px; }
.text-input-wrap .msg { margin: 0 0 10px; }
.error { color: var(--danger); margin: 8px 2px 0; font-weight: 600; }

.sort-opt { display: flex; align-items: center; gap: 12px; }
.sort-opt .tick { margin-left: auto; color: var(--green); font-weight: 800; font-size: 18px; }

/* ---------- выдача ---------- */
.results-head { display: flex; align-items: center; gap: 10px; margin: 0 0 12px; }
.results-head .msg { flex: 1; font-size: 16px; }
.mini-btns { display: flex; gap: 8px; }
.mini-btns .btn { min-height: 40px; width: auto; padding: 8px 12px; font-size: 14px; border-radius: 12px; }

.car { position: relative; }
.gallery { position: relative; background: #dfe9f5; }
.track {
  display: flex; overflow-x: auto; scroll-snap-type: x mandatory;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.track::-webkit-scrollbar { display: none; }
.slide { flex: 0 0 100%; scroll-snap-align: center; aspect-ratio: 4 / 3; position: relative; }
.slide img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.slide.loading::before {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, #dfe9f5 25%, #eef4fb 50%, #dfe9f5 75%);
  background-size: 200% 100%; animation: shimmer 1.2s infinite;
}
.slide .nophoto { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 14px; }
@keyframes shimmer { to { background-position: -200% 0; } }
.counter {
  position: absolute; right: 10px; bottom: 10px;
  background: rgba(1, 57, 116, .78); color: #fff;
  font-size: 13px; font-weight: 600; padding: 3px 9px; border-radius: 20px;
}
.arrow {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 38px; height: 38px; border-radius: 50%; border: 0;
  background: rgba(255, 255, 255, .88); color: var(--navy);
  font-size: 20px; font-weight: 700; cursor: pointer; box-shadow: var(--shadow);
}
.arrow.prev { left: 8px; } .arrow.next { right: 8px; }
.car .card-pad { padding: 14px 16px 16px; }
.car .btn-green { margin-top: 14px; }
.end-note { text-align: center; color: var(--muted); padding: 10px 0 4px; }

/* ---------- загрузка и подсказки ---------- */
.loader { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: rgba(238, 244, 251, .82); backdrop-filter: blur(2px); }
.loader-box { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px 26px; text-align: center; max-width: 300px; }
.spinner { width: 42px; height: 42px; margin: 0 auto 12px; border-radius: 50%; border: 4px solid var(--sky-soft); border-top-color: var(--blue); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed; left: 50%; bottom: calc(90px + var(--safe-bottom)); transform: translateX(-50%);
  z-index: 60; background: var(--navy); color: #fff; padding: 10px 16px; border-radius: 12px;
  font-weight: 600; box-shadow: 0 6px 20px rgba(1, 57, 116, .35); max-width: 90%; text-align: center;
}

.outside { text-align: center; padding: 40px 18px; }
.outside img { width: 120px; margin-bottom: 14px; }
