:root {
  --bg: #0f1115;
  --surface: #171a21;
  --surface-2: #1f232c;
  --border: #2a2f3a;
  --text: #e8eaf0;
  --muted: #9aa2b1;
  --accent: #4f8cff;
  --accent-dim: #2a4d99;
  --ok: #35c26a;
  --warn: #f0a92a;
  --danger: #e5484d;
  --radius: 14px;
  --tap: 44px;
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  overscroll-behavior-y: none;
}

body { min-height: 100dvh; }

button, input, textarea, select { font-family: inherit; font-size: 16px; color: inherit; }
button { cursor: pointer; border: none; background: none; }
a { color: var(--accent); text-decoration: none; }

/* ---------- app shell ---------- */

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  position: relative;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(15,17,21,.94);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar h1 { font-size: 17px; margin: 0; font-weight: 650; flex: 1; }

.role-switch { display: flex; background: var(--surface-2); border-radius: 10px; padding: 3px; }
.role-switch button {
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--muted);
  font-weight: 550;
}
.role-switch button.active { background: var(--accent); color: #fff; }

/* Отступ снизу = таббар (≈76) + FAB (78 + 44), иначе последняя карточка
   не уезжает из-под плавающей кнопки. Для мастера вкладок больше, но
   высота таббара та же. */
.screen { flex: 1; padding: 16px 16px 156px; animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------- bottom nav ---------- */

.tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 30;
  max-width: 480px;
  margin: 0 auto;
  background: rgba(23,26,33,.97);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  display: grid;
  /* 3 вкладки у заказчика, 4 у мастера — сетка тянется под любое число */
  grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
  padding: 6px 0 max(6px, env(safe-area-inset-bottom));
}

.tabbar button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 550;
  position: relative;
}
.tabbar button.active { color: var(--accent); }
.tabbar .ico { font-size: 19px; line-height: 1; }

.badge {
  position: absolute;
  top: 4px;
  right: calc(50% - 20px);
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 9px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------- generic pieces ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}

.card.tappable:active { background: var(--surface-2); }

.card-top { display: flex; align-items: flex-start; gap: 10px; }
.card-top .body { flex: 1; min-width: 0; }
.card-top h3 { margin: 0 0 4px; font-size: 16px; font-weight: 620; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 11.5px; }

.row { display: flex; align-items: center; gap: 8px; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.mt8 { margin-top: 8px; }
.mt12 { margin-top: 12px; }
.mt16 { margin-top: 16px; }
.mb0 { margin-bottom: 0; }

.avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--accent-dim);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 650;
  font-size: 15px;
  flex-shrink: 0;
}
.avatar.lg { width: 52px; height: 52px; font-size: 19px; }

/* ---------- chips / badges ---------- */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted);
  font-weight: 550;
}
.chip.ok { color: var(--ok); border-color: rgba(53,194,106,.35); background: rgba(53,194,106,.1); }
.chip.warn { color: var(--warn); border-color: rgba(240,169,42,.35); background: rgba(240,169,42,.1); }
.chip.danger { color: var(--danger); border-color: rgba(229,72,77,.35); background: rgba(229,72,77,.1); }
.chip.accent { color: var(--accent); border-color: rgba(79,140,255,.35); background: rgba(79,140,255,.1); }

.verified { color: var(--ok); font-weight: 700; }

/* ---------- price / deadline ---------- */

.price { font-size: 19px; font-weight: 700; letter-spacing: -.3px; }
.price .cur { font-size: 13px; font-weight: 600; color: var(--muted); margin-left: 2px; }
.deadline { color: var(--warn); font-size: 13px; font-weight: 600; }

/* ---------- forms ---------- */

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; font-weight: 550; }

.input, .textarea, select.input {
  width: 100%;
  min-height: var(--tap);
  padding: 11px 13px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 11px;
  outline: none;
}
.input:focus, .textarea:focus { border-color: var(--accent); }
.textarea { min-height: 92px; resize: vertical; line-height: 1.5; }

.hint { font-size: 12px; color: var(--muted); margin-top: 5px; }

/* ---------- category picker ---------- */

.cat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.cat {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 13px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  font-size: 11.5px;
  text-align: center;
  font-weight: 550;
  min-height: 78px;
  justify-content: center;
}
.cat .ico { font-size: 23px; }
.cat.selected { border-color: var(--accent); background: rgba(79,140,255,.12); color: var(--accent); }

/* ---------- photo upload ---------- */

.photo-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.photo {
  aspect-ratio: 1;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 21px;
  position: relative;
  overflow: hidden;
}
.photo.add { border-style: dashed; color: var(--muted); }
.photo .del {
  position: absolute; top: 3px; right: 3px;
  width: 19px; height: 19px;
  border-radius: 50%;
  background: rgba(0,0,0,.7);
  color: #fff;
  font-size: 12px;
  display: flex; align-items: center; justify-content: center;
}

/* ---------- buttons ---------- */

.btn {
  min-height: var(--tap);
  padding: 12px 18px;
  border-radius: 12px;
  font-weight: 620;
  font-size: 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
}
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:active { background: #3d78e6; }
.btn.secondary { background: var(--surface-2); border: 1px solid var(--border); color: var(--text); }
.btn.ghost { background: transparent; color: var(--accent); }
.btn.danger { background: transparent; border: 1px solid rgba(229,72,77,.4); color: var(--danger); }
.btn:disabled { opacity: .45; }

/* Затемнение под модальным окном */
.modal-back { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.62); }

/* ---------- offer list ---------- */

.offer { border-left: 3px solid var(--border); }
.offer.active { border-left-color: var(--accent); }
.offer.accepted { border-left-color: var(--ok); background: rgba(53,194,106,.06); }

.offer .meta { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 8px; }

.stat-row { display: flex; border: 1px solid var(--border); border-radius: 11px; overflow: hidden; }
.stat { flex: 1; padding: 11px 6px; text-align: center; }
.stat + .stat { border-left: 1px solid var(--border); }
.stat .n { font-size: 17px; font-weight: 700; }
.stat .l { font-size: 10.5px; color: var(--muted); margin-top: 2px; }

/* ---------- thread ---------- */

.thread { display: flex; flex-direction: column; gap: 10px; padding-bottom: 8px; }
.msg { max-width: 80%; padding: 10px 12px; border-radius: 14px; font-size: 14.5px; }
.msg.me { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.msg.them { align-self: flex-start; background: var(--surface-2); border-bottom-left-radius: 4px; }
.msg .t { font-size: 10.5px; opacity: .7; margin-top: 4px; }

.offer-msg { align-self: center; width: 100%; max-width: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px; }
.offer-msg .label { font-size: 11.5px; color: var(--muted); margin-bottom: 6px; }

.composer {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 30;
  max-width: 480px;
  margin: 0 auto;
  background: rgba(23,26,33,.97);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  padding: 8px 12px max(8px, env(safe-area-inset-bottom));
  display: flex;
  gap: 8px;
}
.composer .input { flex: 1; }
.icon-btn {
  width: var(--tap); height: var(--tap);
  border-radius: 11px;
  background: var(--accent);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 19px;
  flex-shrink: 0;
}

/* ---------- steps ---------- */

.steps { display: flex; align-items: center; gap: 6px; margin-bottom: 16px; }
.step { flex: 1; height: 3px; border-radius: 2px; background: var(--border); }
.step.on { background: var(--accent); }

/* ---------- empty ---------- */

.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty .ico { font-size: 42px; margin-bottom: 12px; opacity: .55; }

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 50%; bottom: 92px;
  transform: translateX(-50%);
  z-index: 60;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 11px 16px;
  border-radius: 11px;
  font-size: 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,.5);
  max-width: 440px;
  text-align: center;
  animation: fade .2s ease;
}

.modal-back {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0,0,0,.62);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade .18s ease;
}
.modal {
  background: var(--surface);
  border-top-left-radius: 18px;
  border-top-right-radius: 18px;
  padding: 18px 16px max(18px, env(safe-area-inset-bottom));
  width: 100%;
  max-width: 480px;
  max-height: 86dvh;
  overflow-y: auto;
}
/* ---------- направления мастера ---------- */

.spec { border-left: 3px solid var(--border); }
.spec.on { border-left-color: var(--accent); background: rgba(79,140,255,.04); }

.spec-meta { display: flex; flex-wrap: wrap; gap: 6px; }

/* Переключатель направления. */
.switch {
  flex-shrink: 0;
  min-width: 52px;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  text-align: center;
}
.switch.on { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---------- вход по PIN ---------- */

.pin-dots { display: flex; justify-content: center; gap: 14px; padding: 26px 0 14px; }
.pin-dot {
  width: 15px; height: 15px; border-radius: 50%;
  border: 1.5px solid var(--border); background: transparent;
  transition: background .12s, border-color .12s;
}
.pin-dot.on { background: var(--accent); border-color: var(--accent); }

.pin-error { text-align: center; color: var(--danger); font-size: 13px; min-height: 18px; margin-bottom: 6px; }

.pin-pad {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 10px; max-width: 300px; margin: 0 auto;
}
.pin-key {
  min-height: 58px; border-radius: 12px;
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text); font-size: 21px; font-weight: 550;
  display: flex; align-items: center; justify-content: center;
}
.pin-key:active { background: var(--surface); border-color: var(--accent); }
.pin-key.ghost { background: transparent; border-color: transparent; color: var(--muted); font-size: 19px; }

/* ---------- админка и поддержка ---------- */

.admin-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
}
.admin-row:last-child { border-bottom: none; }
.admin-row .body { flex: 1; min-width: 0; }
.admin-name { font-size: 13.5px; font-weight: 600; }

.admin-input {
  width: 96px;
  min-height: 38px;
  padding: 6px 10px;
  text-align: right;
  font-weight: 600;
}

.admin-field { flex: 1; }
.admin-field label {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 4px;
}

.admin-tabs {
  display: flex;
  gap: 4px;
  margin-top: 14px;
  padding: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.admin-tabs button {
  flex: 1;
  min-height: 36px;
  border: none;
  background: transparent;
  color: var(--muted);
  border-radius: 9px;
  font-size: 13.5px;
  font-weight: 550;
}
.admin-tabs button.on { background: var(--surface); color: var(--text); }

.admin-ico { width: 64px; text-align: center; font-size: 18px; }
.card.editing { border-color: var(--accent); }
.spec-price { text-align: right; flex-shrink: 0; }
.spec-price .price { font-size: 16px; font-weight: 650; }

.chip.tap { cursor: pointer; }
.chip.tap:active { transform: scale(.96); }

/* ---------- первый запуск ---------- */

.ob-hero {
  text-align: center;
  padding: 30px 0 10px;
}
.ob-logo {
  font-size: 60px;
  line-height: 1;
  margin-bottom: 12px;
}
.ob-name {
  font-size: 27px;
  font-weight: 780;
  letter-spacing: -0.5px;
}
.ob-tagline {
  color: var(--muted);
  font-size: 13.5px;
  margin-top: 6px;
}

.ob-role.on { border-color: var(--accent); background: rgba(79,140,255,.06); }

.ob-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 0;
  cursor: pointer;
}
.ob-check + .ob-check { border-top: 1px solid var(--border); }
.ob-check input {
  width: 19px;
  height: 19px;
  margin-top: 1px;
  accent-color: var(--accent);
  flex-shrink: 0;
}
.ob-check u { color: var(--accent); text-decoration: none; border-bottom: 1px dashed currentColor; }

/* ---------- подсказки по городам ---------- */

.city-on { border-color: var(--accent); background: rgba(79,140,255,.07); }

#city-q, #f-city-q {
  font-size: 16px;   /* на iPhone иначе Safari зумит страницу при фокусе */
  min-height: 48px;
}

/* ---------- оценка и отзывы ---------- */

.stars {
  display: flex;
  gap: 8px;
  justify-content: center;
  font-size: 34px;
  line-height: 1;
}
.stars span { color: var(--border); cursor: pointer; }
.stars span.on { color: var(--warn); }
/* Внутри карточки это уже результат, а не приглашение нажать. */
.card .stars { justify-content: flex-start; }
.card .stars span { cursor: default; font-size: 24px; }
/* А вот на экране оценки звезды выбирают — по центру. */
.card .stars-pick { justify-content: center; }
.card .stars-pick span { cursor: pointer; font-size: 34px; }

/* Скрытая точка входа: удержание названия приложения в профиле. */
.hold {
  position: relative;
  overflow: hidden;
  margin-top: 24px;
  padding: 16px 14px;
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: 14px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.hold.holding { border-color: var(--accent); }
.hold-fill {
  position: absolute;
  top: 0; bottom: 0; left: 0;
  width: 0;
  background: rgba(79,140,255,.18);
}
.hold.holding .hold-fill { animation: holdFill 2s linear forwards; }
@keyframes holdFill { from { width: 0; } to { width: 100%; } }

.faq { padding: 12px 14px; }
.faq .faq-mark {
  color: var(--accent);
  font-size: 17px;
  font-weight: 600;
  flex-shrink: 0;
  line-height: 1;
}
.faq.open { border-color: var(--accent-dim); background: rgba(79,140,255,.05); }

/* Тарифы и оплата ---------- */

.plan { position: relative; overflow: hidden; }
.plan.best { border-color: var(--accent); }
.plan.active { border-color: var(--accent-dim); background: rgba(79,140,255,.05); }

.plan-flag {
  position: absolute;
  top: 0; right: 0;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 3px 10px;
  border-bottom-left-radius: 10px;
}

/* У карточки с бейджем сдвигаем содержимое вниз, чтобы «популярный»
   не наезжал на цену. */
.plan.best { padding-top: 30px; }

.plan-feats { display: flex; flex-direction: column; gap: 5px; }
.plan-feat { font-size: 12.5px; color: var(--muted); }
.plan.active .plan-feat { color: var(--text); }

.pay-method { padding: 12px; }
.pay-method.sel { border-color: var(--accent); background: rgba(79,140,255,.08); }

.radio {
  width: 20px; height: 20px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px;
  color: var(--accent);
  flex-shrink: 0;
}
.pay-method.sel .radio { border-color: var(--accent); }

/* Заглушка QR: в бою приходит от провайдера СБП. */
.qr {
  width: 128px; height: 128px;
  margin: 12px auto 0;
  background:
    repeating-linear-gradient(0deg, var(--text) 0 6px, transparent 6px 12px),
    repeating-linear-gradient(90deg, var(--text) 0 6px, transparent 6px 12px);
  background-blend-mode: difference;
  border: 8px solid #fff;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: #000;
  font-weight: 700;
  font-size: 13px;
}

.modal h3 { margin: 0 0 4px; font-size: 18px; }
