:root {
  --bg: var(--tg-theme-bg-color, #fff);
  --text: var(--tg-theme-text-color, #111);
  --hint: var(--tg-theme-hint-color, #8a8f98);
  --btn: var(--tg-theme-button-color, #2481cc);
  --btn-text: var(--tg-theme-button-text-color, #fff);
  --sec: var(--tg-theme-secondary-bg-color, #f1f2f4);
  --link: var(--tg-theme-link-color, #2481cc);
  --red: #d93025;
  --green: #1e8e3e;
  --radius: 14px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}
#view {
  max-width: 640px;
  margin: 0 auto;
  padding: 12px 12px calc(84px + env(safe-area-inset-bottom));
}
h1 { font-size: 22px; margin: 4px 0 12px; }
h2 { font-size: 18px; margin: 16px 0 8px; }
a { color: var(--link); }
[hidden] { display: none !important; }

/* nav */
#nav {
  position: fixed; left: 0; right: 0; bottom: 0;
  display: flex;
  background: var(--sec);
  border-top: 1px solid rgba(128, 128, 128, .25);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 20;
}
#nav button {
  flex: 1; min-height: 56px;
  border: 0; background: none; color: var(--hint);
  font: inherit; font-size: 13px; font-weight: 600;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  cursor: pointer;
}
#nav button .ic { font-size: 22px; line-height: 1; }
#nav button.on { color: var(--btn); }

/* buttons */
.btn {
  display: block; width: 100%; min-height: 48px;
  padding: 12px 16px; margin: 8px 0;
  border: 0; border-radius: var(--radius);
  background: var(--btn); color: var(--btn-text);
  font: inherit; font-weight: 600; text-align: center; text-decoration: none;
  cursor: pointer;
}
.btn.sec { background: var(--sec); color: var(--text); }
.btn.danger { background: var(--red); color: #fff; }
.btn.small { width: auto; min-height: 40px; padding: 8px 14px; margin: 4px 6px 4px 0; display: inline-block; font-size: 14px; }
.btn:disabled { opacity: .45; cursor: default; }
.link-btn { background: none; border: 0; color: var(--link); font: inherit; padding: 12px 0; cursor: pointer; text-decoration: underline; }

/* forms */
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.filters .wide { grid-column: 1 / -1; }
select, input[type=text], textarea {
  width: 100%; min-height: 46px; padding: 10px 12px;
  border: 1px solid rgba(128, 128, 128, .35); border-radius: 12px;
  background: var(--sec); color: var(--text); font: inherit;
  appearance: none; -webkit-appearance: none;
}
select {
  background-image: linear-gradient(45deg, transparent 50%, var(--hint) 50%), linear-gradient(135deg, var(--hint) 50%, transparent 50%);
  background-position: calc(100% - 18px) 20px, calc(100% - 13px) 20px;
  background-size: 5px 5px; background-repeat: no-repeat;
  padding-right: 32px;
}
textarea { min-height: 90px; resize: vertical; }
.field { margin: 12px 0; }
.field > label { display: block; font-size: 14px; color: var(--hint); margin-bottom: 4px; }
.hint { font-size: 13px; color: var(--hint); margin-top: 4px; }
.hint.bad, .err { color: var(--red); }
.err { margin: 8px 0; font-size: 14px; }

/* cards */
.list { display: flex; flex-direction: column; gap: 10px; }
.card {
  display: flex; gap: 12px; padding: 10px;
  background: var(--sec); border-radius: var(--radius);
  cursor: pointer;
}
.card .thumb { width: 96px; height: 96px; flex: none; border-radius: 10px; object-fit: cover; background: rgba(128, 128, 128, .2); }
.card .info { min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: 4px; }
.card .title { font-weight: 600; overflow-wrap: anywhere; }
.card .price { font-size: 18px; font-weight: 700; }
.card .city { font-size: 14px; color: var(--hint); }
.card.static { cursor: default; }

/* gallery */
.gallery { position: relative; margin-bottom: 12px; }
.track {
  display: flex; overflow-x: auto; scroll-snap-type: x mandatory;
  border-radius: var(--radius); scrollbar-width: none;
}
.track::-webkit-scrollbar { display: none; }
.track img { flex: none; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; scroll-snap-align: center; background: var(--sec); }
.arrow {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 40px; height: 40px; border: 0; border-radius: 50%;
  background: rgba(0, 0, 0, .45); color: #fff; font-size: 20px; cursor: pointer;
}
.arrow.l { left: 8px; } .arrow.r { right: 8px; }
.dots { display: flex; justify-content: center; gap: 6px; margin-top: 8px; }
.dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--hint); opacity: .4; }
.dots i.on { background: var(--btn); opacity: 1; }
.noimg { aspect-ratio: 4 / 3; display: flex; align-items: center; justify-content: center; background: var(--sec); border-radius: var(--radius); font-size: 48px; }

.bigprice { font-size: 26px; font-weight: 700; margin: 4px 0 8px; }
.params { background: var(--sec); border-radius: var(--radius); padding: 4px 12px; margin: 8px 0; }
.params div { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid rgba(128, 128, 128, .2); }
.params div:last-child { border-bottom: 0; }
.params span:first-child { color: var(--hint); }
.params span:last-child { text-align: right; overflow-wrap: anywhere; }
.desc { white-space: pre-wrap; overflow-wrap: anywhere; }
.warn { background: #fff4cc; color: #5c4400; border: 1px solid #f0d36b; border-radius: 12px; padding: 10px 12px; margin: 12px 0; font-size: 14px; }
.info-box { background: var(--sec); border-radius: 12px; padding: 12px; margin: 10px 0; }
.phone { display: block; font-size: 22px; font-weight: 700; text-align: center; padding: 8px 0; }

/* states */
.empty, .msg { text-align: center; padding: 32px 12px; color: var(--hint); }
.msg.strong { color: var(--text); font-weight: 600; }
.loader { width: 28px; height: 28px; margin: 24px auto; border: 3px solid rgba(128, 128, 128, .3); border-top-color: var(--btn); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.sentinel { height: 1px; }

/* slots */
.slot { background: var(--sec); border-radius: var(--radius); padding: 12px; margin: 10px 0; }
.slot-head { display: flex; justify-content: space-between; gap: 8px; font-weight: 600; margin-bottom: 8px; }
.slot-head .time { color: var(--hint); font-weight: 400; text-align: right; }
.slot .card { background: var(--bg); cursor: default; }
.slot .badge { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 8px; background: rgba(128, 128, 128, .2); }
.actions { margin-top: 6px; }
.ask { background: #fff4cc; color: #5c4400; border-radius: 12px; padding: 10px 12px; margin: 8px 0; }
.ask b { display: block; margin-bottom: 4px; }

.radio { display: flex; gap: 10px; align-items: center; padding: 10px 12px; background: var(--sec); border-radius: 12px; margin: 6px 0; min-height: 48px; cursor: pointer; }
.radio input { width: 20px; height: 20px; flex: none; }

/* photos */
.photos { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.ph { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--sec); }
.ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ph button { position: absolute; top: 2px; right: 2px; width: 28px; height: 28px; border: 0; border-radius: 50%; background: rgba(0, 0, 0, .6); color: #fff; font-size: 16px; cursor: pointer; }
.ph.add { display: flex; align-items: center; justify-content: center; font-size: 30px; color: var(--hint); border: 2px dashed rgba(128, 128, 128, .5); background: none; cursor: pointer; }
.ph.add input { display: none; }

/* stepper */
.stepper { display: flex; align-items: center; justify-content: center; gap: 24px; margin: 16px 0; }
.stepper button { width: 52px; height: 52px; border: 0; border-radius: 50%; background: var(--sec); color: var(--text); font-size: 26px; cursor: pointer; }
.stepper button:disabled { opacity: .4; }
.stepper b { font-size: 32px; min-width: 40px; text-align: center; }
.sum { text-align: center; font-size: 22px; font-weight: 700; }

.pay { background: var(--sec); border-radius: 12px; padding: 12px; margin: 8px 0; }
.pay .st { font-weight: 600; }
.pay .st.approved { color: var(--green); }
.pay .st.rejected, .pay .st.expired { color: var(--red); }

/* modal / toast */
.overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, .5); display: flex; align-items: flex-end; justify-content: center; z-index: 50; }
.sheet { width: 100%; max-width: 640px; max-height: 90vh; overflow: auto; background: var(--bg); border-radius: 18px 18px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); }
.sheet h2 { margin-top: 0; }
.toast {
  position: fixed; left: 12px; right: 12px; top: calc(12px + env(safe-area-inset-top)); z-index: 60;
  max-width: 616px; margin: 0 auto; padding: 12px 14px; border-radius: 12px;
  background: rgba(30, 30, 30, .94); color: #fff; text-align: center; font-size: 15px;
}
.topback { background: none; border: 0; color: var(--link); font: inherit; padding: 8px 0; min-height: 40px; cursor: pointer; }
