/* ============================================================
   ReloApp — стили прототипа
   Все цвета собраны в токенах ниже: меняете токен —
   меняется всё приложение. Тёмная тема переключается
   автоматически по настройке системы.
   ============================================================ */

:root {
  /* Поверхности */
  --surface-0: #f6f5f1;   /* фон страницы */
  --surface-1: #edebe4;   /* плитки, второстепенные блоки */
  --surface-2: #ffffff;   /* карточки, шапка, модальные окна */

  /* Текст */
  --text-primary: #201f1c;
  --text-secondary: #605e57;
  --text-muted: #908e86;

  /* Границы */
  --border: #e3e1da;
  --border-strong: #cfcdc5;

  /* Акцент и статусы (пары «фон + текст») */
  --bg-accent: #e6f1fb;  --text-accent: #185fa5;  --border-accent: #b5d4f4;
  --bg-success: #eaf3de; --text-success: #3b6d11;
  --bg-warning: #faeeda; --text-warning: #854f0b;
  --bg-danger: #fcebeb;  --text-danger: #a32d2d;  --border-danger: #f7c1c1;
  --bg-escrow: #eeedfe;  --text-escrow: #3c3489;  --text-escrow-strong: #26215c;

  /* Кнопка-«примари» */
  --fill-primary: #201f1c;
  --on-primary: #ffffff;

  --radius: 8px;
  --radius-card: 12px;
  --font: "Inter", "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --surface-0: #1a1a18;
    --surface-1: #242422;
    --surface-2: #2d2d2a;
    --text-primary: #f0efea;
    --text-secondary: #b8b6ad;
    --text-muted: #8a887f;
    --border: #3b3b37;
    --border-strong: #4c4c46;
    --bg-accent: #0c447c;  --text-accent: #b5d4f4; --border-accent: #185fa5;
    --bg-success: #27500a; --text-success: #c0dd97;
    --bg-warning: #633806; --text-warning: #fac775;
    --bg-danger: #791f1f;  --text-danger: #f7c1c1; --border-danger: #a32d2d;
    --bg-escrow: #3c3489;  --text-escrow: #cecbf6; --text-escrow-strong: #eeedfe;
    --fill-primary: #f0efea;
    --on-primary: #1a1a18;
  }
}

/* ---------- База ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--surface-0);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
}
#app { max-width: 1080px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; }
main { flex: 1; }
h1, h2, h3 { font-weight: 600; margin: 0; }
button { font-family: inherit; }
img { max-width: 100%; }

/* Элементы форм */
input, select, textarea {
  font-family: inherit;
  font-size: 13.5px;
  color: var(--text-primary);
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 9px 12px;
  outline: none;
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--text-accent);
  box-shadow: 0 0 0 3px var(--bg-accent);
}
::placeholder { color: var(--text-muted); }

/* ---------- Шапка ---------- */
.nav-root { position: sticky; top: 0; z-index: 20; }
.nav {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 12px 18px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.logo { display: inline-flex; align-items: center; gap: 7px; font-size: 16px; font-weight: 600; }
.logo .sub { font-size: 12px; color: var(--text-muted); font-weight: 400; }
.nlink {
  background: none; border: none; cursor: pointer;
  font-size: 13.5px; color: var(--text-secondary);
  padding: 6px 2px; border-bottom: 2px solid transparent;
}
.nlink.on { color: var(--text-primary); font-weight: 600; border-bottom-color: var(--fill-primary); }
.spacer { flex: 1; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11.5px; font-weight: 600;
  background: var(--bg-accent); color: var(--text-accent);
}

/* ---------- Общие компоненты ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2); color: var(--text-secondary);
  font-size: 12.5px; cursor: pointer; white-space: nowrap;
}
.chip:hover { border-color: var(--text-muted); }
.chip.on { background: var(--fill-primary); color: var(--on-primary); border-color: var(--fill-primary); }

.card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  overflow: hidden;
}

.btn {
  padding: 10px 16px; border-radius: var(--radius);
  font-size: 13.5px; font-weight: 600; cursor: pointer;
  border: 1px solid var(--border-strong);
  background: var(--surface-2); color: var(--text-primary);
}
.btn:hover { background: var(--surface-1); }
.btn.pri { background: var(--fill-primary); color: var(--on-primary); border-color: var(--fill-primary); }
.btn.pri:hover { opacity: 0.9; }
.btn.sm { padding: 8px 12px; font-size: 12.5px; }
.btn.block { width: 100%; }

.icon-btn {
  width: 32px; height: 32px; border-radius: 999px; flex-shrink: 0;
  background: var(--surface-2); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text-secondary);
}
.icon-btn.fav-on { color: var(--text-danger); border-color: var(--border-danger); background: var(--bg-danger); }

.status {
  font-size: 11.5px; padding: 4px 10px; border-radius: 999px; white-space: nowrap;
}

.tag {
  font-size: 12px; background: var(--surface-1);
  border-radius: 999px; padding: 4px 10px; color: var(--text-secondary);
}

.field-label { font-size: 12px; color: var(--text-secondary); display: block; margin: 12px 0 4px; }

.hint-banner {
  display: flex; gap: 10px; align-items: flex-start;
  margin: 14px 18px 0; padding: 12px 14px;
  background: var(--bg-accent); color: var(--text-accent);
  border-radius: var(--radius-card); font-size: 13px; line-height: 1.5;
}
.hint-banner .icon-btn { background: transparent; border: none; color: inherit; width: 24px; height: 24px; }

.empty { text-align: center; padding: 48px 24px; color: var(--text-secondary); }
.empty i { font-size: 30px; color: var(--text-muted); }

.footer {
  padding: 18px; text-align: center;
  font-size: 12px; color: var(--text-muted);
  border-top: 1px solid var(--border); margin-top: 24px;
}

/* ---------- Каталог ---------- */
.toolbar { padding: 16px 18px 0; display: flex; flex-direction: column; gap: 12px; }
.toolbar-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.search-wrap { flex: 1; min-width: 190px; position: relative; }
.search-wrap input { padding-left: 34px; }
.search-wrap i {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  font-size: 15px; color: var(--text-muted);
}
.select-inline { width: auto; }
.cats { display: flex; gap: 6px; flex-wrap: wrap; }

.results-meta { font-size: 12px; color: var(--text-muted); margin: 0 0 10px; }
.results-wrap { padding: 14px 18px 8px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 14px;
}
.listing { cursor: pointer; }
.listing:hover { border-color: var(--border-strong); }
.listing .thumb {
  height: 104px; position: relative;
  display: flex; align-items: center; justify-content: center;
}
.listing .thumb i { font-size: 34px; }
.listing .body { padding: 10px 12px 12px; }
.listing .title { font-size: 13.5px; font-weight: 600; line-height: 1.35; }
.listing .meta { font-size: 11.5px; color: var(--text-muted); margin-top: 3px; }
.listing .row { display: flex; justify-content: space-between; align-items: center; margin-top: 7px; }
.listing .price { font-size: 13px; font-weight: 600; }
.listing .rating { font-size: 12px; color: var(--text-secondary); display: inline-flex; align-items: center; gap: 3px; }

/* Карта-схема */
.map-box {
  margin: 14px 18px 8px; position: relative; height: 380px;
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: var(--radius-card); overflow: hidden;
}
.map-road-h, .map-road-v { position: absolute; border-color: var(--border-strong) !important; }
.map-pin {
  position: absolute; transform: translate(-50%, -100%);
  background: var(--surface-2); border: 1px solid var(--text-muted);
  border-radius: 999px; padding: 4px 10px;
  font-size: 12px; font-weight: 600; cursor: pointer; color: var(--text-primary);
}
.map-note {
  position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%);
  font-size: 11.5px; color: var(--text-muted);
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 999px; padding: 3px 10px; white-space: nowrap;
}

/* ---------- Страница объекта ---------- */
.detail-wrap { padding: 16px 18px 20px; }
.back-link {
  background: none; border: none; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13.5px; color: var(--text-secondary); padding: 4px 0;
}
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 18px; margin-top: 12px; }
.hero {
  height: 220px; border-radius: var(--radius-card); position: relative;
  display: flex; align-items: center; justify-content: center;
}
.hero i { font-size: 58px; }
.hero .badge {
  position: absolute; bottom: 10px; left: 12px;
  font-size: 11.5px; background: var(--surface-2); color: var(--text-secondary);
  border-radius: 999px; padding: 3px 10px;
}
.hero .icon-btn { position: absolute; top: 10px; right: 10px; }
.provider-card {
  display: flex; align-items: center; gap: 10px;
  margin-top: 16px; padding: 12px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-card);
}
.provider-card .avatar { width: 36px; height: 36px; font-size: 13px; }
.booking-card { padding: 14px; align-self: start; position: sticky; top: 74px; }
.booking-card .price { font-size: 18px; font-weight: 600; }
.escrow-note {
  display: flex; gap: 8px; margin-top: 12px;
  font-size: 11.5px; color: var(--text-secondary); line-height: 1.5;
}

/* ---------- Заявки ---------- */
.deal-row { padding: 13px 16px; display: flex; justify-content: space-between; align-items: center; gap: 14px; flex-wrap: wrap; }
.deal-row .who { cursor: pointer; min-width: 170px; }
.deal-row .title { font-size: 13.5px; font-weight: 600; }
.deal-row .meta { font-size: 12px; color: var(--text-muted); margin-top: 3px; }
.deal-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.deal-note { font-size: 11.5px; color: var(--text-muted); margin-top: 5px; text-align: right; }

/* ---------- Кабинет поставщика ---------- */
.prov-grid { display: grid; grid-template-columns: 172px minmax(0, 1fr); gap: 16px; padding: 16px 18px 18px; }
.prov-side { background: var(--surface-1); border-radius: var(--radius-card); padding: 8px; align-self: start; }
.pnav {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 9px 10px; border: none; background: none; border-radius: var(--radius);
  font-size: 13px; color: var(--text-secondary); cursor: pointer; text-align: left;
}
.pnav.on { background: var(--surface-2); color: var(--text-primary); font-weight: 600; }
.metric {
  flex: 1; min-width: 110px;
  background: var(--surface-1); border-radius: var(--radius); padding: 12px 14px;
}
.metric .label { font-size: 11.5px; color: var(--text-muted); display: flex; align-items: center; gap: 4px; }
.metric .value { font-size: 20px; font-weight: 600; margin-top: 2px; }
.metric.escrow { background: var(--bg-escrow); }
.metric.escrow .label { color: var(--text-escrow); }
.metric.escrow .value { color: var(--text-escrow-strong); }
.mylisting { padding: 12px 14px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.mylisting .tile {
  width: 44px; height: 44px; border-radius: var(--radius); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}

/* ---------- Модальные окна и тосты ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0, 0, 0, 0.45);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.dialog {
  background: var(--surface-2); border-radius: var(--radius-card);
  padding: 18px; width: 100%; max-width: 420px;
  max-height: 90vh; overflow-y: auto;
}
.dialog-head { display: flex; justify-content: space-between; align-items: center; }
.dialog-title { font-size: 15px; font-weight: 600; }
.escrow-step { display: flex; gap: 10px; align-items: flex-start; }
.escrow-step .num {
  width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0;
  background: var(--bg-escrow); color: var(--text-escrow);
  display: flex; align-items: center; justify-content: center;
}
.escrow-step .text { font-size: 12.5px; line-height: 1.5; color: var(--text-secondary); padding-top: 3px; }

.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%);
  z-index: 60;
  background: var(--fill-primary); color: var(--on-primary);
  font-size: 12.5px; padding: 9px 16px; border-radius: 999px;
  white-space: nowrap; max-width: 92vw; overflow: hidden; text-overflow: ellipsis;
}

/* ---------- Адаптив ---------- */
@media (max-width: 640px) {
  .detail-grid { grid-template-columns: 1fr; }
  .booking-card { position: static; }
  .prov-grid { grid-template-columns: 1fr; }
  .prov-side { display: flex; gap: 4px; }
  .pnav { width: auto; flex: 1; justify-content: center; }
  .nav { gap: 10px; padding: 10px 14px; }
}
