:root {
  color-scheme: dark;
  --bg: #0d141d;
  --bg-2: #111b27;
  --panel: #172231;
  --panel-2: #1d2b3d;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.16);
  --text: #f5f8fb;
  --muted: #9cafc2;
  --blue: #40a7f2;
  --cyan: #55d3ca;
  --amber: #f2b84b;
  --green: #65d58a;
  --danger: #f06a5f;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: var(--tg-viewport-stable-height, 100vh);
  background:
    radial-gradient(circle at 50% -20%, rgba(64, 167, 242, 0.18), transparent 34%),
    linear-gradient(180deg, #0a1119 0%, var(--bg) 46%, #091018 100%);
  color: var(--text);
  font: 16px/1.35 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.ambient-grid {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.24;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.045) 1px, transparent 1px);
  background-size: 34px 34px;
  mask-image: linear-gradient(to bottom, black, transparent 72%);
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  color: inherit;
  cursor: pointer;
}

button:disabled,
input:disabled,
select:disabled {
  cursor: default;
  opacity: 0.5;
}

[hidden] {
  display: none !important;
}

.telegram-gate {
  position: relative;
  z-index: 2;
  display: none;
  width: min(420px, calc(100% - 28px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 72px 18px 40px;
  align-content: center;
  justify-items: center;
  text-align: center;
}

.telegram-locked .telegram-gate {
  display: grid;
}

.telegram-locked .app,
.telegram-locked .tabbar,
.telegram-locked .toast,
.telegram-locked dialog {
  display: none !important;
}

.telegram-gate img {
  width: min(230px, 64vw);
  aspect-ratio: 1;
  object-fit: contain;
  margin-bottom: 18px;
  filter: drop-shadow(0 24px 36px rgba(0, 0, 0, 0.44));
}

.telegram-gate h1 {
  margin: 8px 0;
  font-size: 30px;
  line-height: 1.08;
  letter-spacing: 0;
}

.telegram-gate p {
  max-width: 350px;
  margin: 0 0 22px;
  color: var(--muted);
}

.telegram-gate a {
  display: grid;
  place-items: center;
  width: min(320px, 100%);
  min-height: 54px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--blue), var(--cyan));
  color: #061018;
  font-weight: 850;
  text-decoration: none;
  box-shadow: 0 14px 34px rgba(64, 167, 242, 0.24);
}

.app {
  position: relative;
  z-index: 1;
  width: min(480px, 100%);
  min-height: var(--tg-viewport-stable-height, 100vh);
  margin: 0 auto;
  padding:
    calc(18px + max(env(safe-area-inset-top), var(--tg-content-safe-area-inset-top, 0px)))
    calc(14px + max(env(safe-area-inset-right), var(--tg-content-safe-area-inset-right, 0px)))
    calc(92px + max(env(safe-area-inset-bottom), var(--tg-content-safe-area-inset-bottom, 0px)))
    calc(14px + max(env(safe-area-inset-left), var(--tg-content-safe-area-inset-left, 0px)));
}

html.telegram-fullscreen .app {
  padding-top: calc(58px + max(env(safe-area-inset-top), var(--tg-content-safe-area-inset-top, 0px)));
}

.screen {
  display: none;
}

.screen.active {
  display: block;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0 14px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 34px;
  font-weight: 850;
  letter-spacing: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--blue), var(--cyan));
  color: #061018;
  font-size: 22px;
  box-shadow: 0 8px 24px rgba(64, 167, 242, 0.28);
}

.subtitle,
.page-head p,
.status-row p,
.plan p,
.reward-card p,
.hint-card p,
.profile-card span {
  margin: 0;
  color: var(--muted);
}

.city-button,
.quota-chip,
.section-title button,
.profile-card button {
  min-height: 42px;
  padding: 0 12px;
  border-radius: 8px;
  background: rgba(29, 43, 61, 0.84);
  border: 1px solid var(--line);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.city-button:active,
.quota-chip:active,
.section-title button:active,
.profile-card button:active,
.search-box button:active,
.plan button:active,
.reward-card button:active {
  transform: translateY(1px);
}

.deal-radar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 118px;
  gap: 12px;
  align-items: stretch;
  padding: 16px;
  margin-bottom: 12px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(64, 167, 242, 0.17), rgba(85, 211, 202, 0.07) 46%, rgba(242, 184, 75, 0.09)),
    var(--panel);
  box-shadow: var(--shadow);
}

.deal-radar h1 {
  margin: 6px 0 6px;
  font-size: 25px;
  line-height: 1.06;
  letter-spacing: 0;
}

.deal-radar p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.eyebrow {
  color: var(--cyan);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

.radar-bot {
  display: grid;
  place-items: center;
  min-height: 132px;
  overflow: visible;
}

.radar-bot > img {
  width: 116px;
  height: 116px;
  object-fit: contain;
  filter: drop-shadow(0 18px 26px rgba(0, 0, 0, 0.42));
}

.city-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.search-box {
  display: grid;
  grid-template-columns: 1fr 58px;
  gap: 8px;
}

.search-box input {
  min-width: 0;
  height: 58px;
  padding: 0 16px;
  border-radius: 8px;
  border: 1px solid var(--line);
  outline: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.045), transparent),
    #152131;
  color: var(--text);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.search-box button,
.plan button,
.reward-card button {
  min-height: 52px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--blue), var(--cyan));
  color: #061018;
  font-weight: 750;
  box-shadow: 0 12px 30px rgba(64, 167, 242, 0.24);
}

.search-box button {
  width: 58px;
  padding: 0;
  font-size: 16px;
}

.status-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 12px 0 18px;
}

.status-row p {
  font-size: 14px;
}

.summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 12px;
  margin-bottom: 16px;
  border-radius: 8px;
  background: rgba(23, 34, 49, 0.74);
  border: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.summary-label {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 13px;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.section-title h2,
.page-head h1 {
  margin: 0;
  font-size: 22px;
}

.results {
  display: grid;
  gap: 10px;
}

.empty-state {
  display: grid;
  min-height: 138px;
  place-items: center;
  padding: 24px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.result-card {
  display: grid;
  grid-template-columns: 112px 1fr 44px;
  min-height: 122px;
  overflow: hidden;
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent),
    var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
}

.thumb {
  position: relative;
  display: grid;
  place-items: center;
  background:
    linear-gradient(135deg, rgba(64, 167, 242, 0.22), rgba(242, 184, 75, 0.10)),
    #243246;
  color: #dce8f6;
  overflow: hidden;
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.thumb span {
  display: none;
  font-size: 34px;
}

.thumb.fallback img:not([src]) {
  display: none;
}

.thumb.fallback span {
  display: block;
}

.result-body {
  min-width: 0;
  padding: 12px;
}

.result-title {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 750;
}

.price {
  margin: 0 0 8px;
  color: var(--amber);
  font-size: 20px;
  font-weight: 850;
}

.saving {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  margin-bottom: 8px;
  padding: 0 7px;
  border-radius: 7px;
  background: rgba(101, 213, 138, 0.13);
  color: #99efb5;
  font-size: 12px;
  font-weight: 700;
}

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

.badge {
  padding: 4px 7px;
  border-radius: 7px;
  background: #233146;
  color: #c9d8e8;
  font-size: 12px;
}

.badge.telegram { background: rgba(64, 167, 242, 0.13); color: #79c7ff; }
.badge.facebook { background: rgba(90, 132, 255, 0.14); color: #93b2ff; }
.badge.mymarket { background: rgba(242, 184, 75, 0.14); color: #ffe08a; }
.badge.promoted { background: rgba(101, 213, 138, 0.14); color: #99efb5; }

.result-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 4px 8px 0;
}

.open-link,
.report-result {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: rgba(38, 54, 75, 0.94);
  border: 1px solid var(--line);
}

.report-result {
  color: var(--muted);
  font-size: 18px;
}

.report-result:not(:disabled):active {
  color: #ff9b8f;
  border-color: rgba(255, 112, 96, 0.55);
}

.report-result.reported {
  color: #99efb5;
  border-color: rgba(101, 213, 138, 0.45);
}

.page-head {
  padding: 8px 0 18px;
}

.page-head-bot {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 92px;
  gap: 12px;
  align-items: center;
}

.page-head-bot img {
  width: 92px;
  height: 92px;
  object-fit: contain;
  filter: drop-shadow(0 16px 24px rgba(0, 0, 0, 0.36));
}

.plans,
.profile-grid {
  display: grid;
  gap: 10px;
}

.plan,
.reward-card,
.hint-card,
.profile-card {
  padding: 16px;
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent),
    var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.18);
}

.plan.selected {
  border-color: rgba(64, 167, 242, 0.75);
  background:
    linear-gradient(135deg, rgba(64, 167, 242, 0.16), transparent 58%),
    var(--panel);
}

.plan.premium {
  border-color: rgba(101, 213, 138, 0.55);
  background:
    linear-gradient(135deg, rgba(101, 213, 138, 0.16), rgba(242, 184, 75, 0.08) 62%),
    var(--panel);
}

.plan h2,
.reward-card h2,
.hint-card h3 {
  margin: 8px 0;
}

.plan strong {
  display: block;
  margin-bottom: 6px;
  font-size: 28px;
}

.plan select,
.modal select {
  width: 100%;
  min-height: 46px;
  margin-top: 14px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  outline: 0;
  background: #111c29;
  color: var(--text);
}

.plan-badge {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  padding: 0 8px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

.plan button,
.reward-card button {
  width: 100%;
  margin-top: 14px;
}

.reward-meter {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 16px;
}

.reward-meter[data-screens="1"] { grid-template-columns: 1fr; }
.reward-meter[data-screens="2"] { grid-template-columns: repeat(2, 1fr); }

.reward-head {
  display: grid;
  grid-template-columns: 1fr 96px;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.reward-head h2 {
  margin: 8px 0 0;
}

.reward-head img {
  width: 96px;
  height: 96px;
  object-fit: contain;
  filter: drop-shadow(0 16px 24px rgba(0, 0, 0, 0.34));
}

.reward-meter span {
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  box-shadow: none;
  transition: background 180ms ease, box-shadow 180ms ease;
}

.reward-meter span.done {
  background: linear-gradient(90deg, var(--amber), var(--green));
  box-shadow: 0 0 16px rgba(101, 213, 138, 0.22);
}

.ad-status {
  min-height: 38px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.hint-card {
  margin-top: 10px;
}

.profile-grid {
  grid-template-columns: 1fr 1fr;
}

.profile-hero {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 14px;
  align-items: center;
  padding: 16px;
  margin-bottom: 12px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background:
    linear-gradient(135deg, rgba(64, 167, 242, 0.16), rgba(101, 213, 138, 0.08)),
    var(--panel);
}

.profile-hero p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.avatar {
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  border-radius: 8px;
  background:
    radial-gradient(circle at 50% 20%, rgba(85, 211, 202, 0.18), transparent 58%),
    #07111d;
  border: 1px solid var(--line-strong);
  color: var(--amber);
  font-weight: 900;
  overflow: visible;
}

.avatar img {
  width: 86px;
  height: 86px;
  object-fit: contain;
  filter: drop-shadow(0 12px 18px rgba(0, 0, 0, 0.35));
}

.profile-card.wide {
  grid-column: 1 / -1;
}

.profile-card strong {
  display: block;
  margin: 6px 0 12px;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.setting-row > div {
  min-width: 0;
}

.setting-row strong {
  overflow-wrap: anywhere;
}

.setting-help {
  max-width: 330px;
  margin: -6px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.switch {
  position: relative;
  flex: 0 0 48px;
  width: 48px;
  height: 28px;
}

.switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch span {
  position: absolute;
  inset: 0;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: #263448;
  transition: 160ms ease;
}

.switch span::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #d7e4ef;
  transition: 160ms ease;
}

.switch input:checked + span {
  background: var(--blue);
}

.switch input:checked + span::after {
  transform: translateX(20px);
  background: #061018;
}

.switch input:disabled + span {
  opacity: 0.45;
}

.tabbar {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  width: min(480px, 100%);
  transform: translateX(-50%);
  padding:
    8px
    calc(8px + max(env(safe-area-inset-right), var(--tg-content-safe-area-inset-right, 0px)))
    calc(8px + max(env(safe-area-inset-bottom), var(--tg-content-safe-area-inset-bottom, 0px)))
    calc(8px + max(env(safe-area-inset-left), var(--tg-content-safe-area-inset-left, 0px)));
  background: rgba(11, 18, 27, 0.94);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.tabbar button {
  display: grid;
  gap: 3px;
  place-items: center;
  min-height: 54px;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
}

.tabbar button span {
  font-size: 22px;
}

.tabbar button.active {
  color: var(--blue);
  background:
    linear-gradient(180deg, rgba(64, 167, 242, 0.14), rgba(64, 167, 242, 0.05));
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(82px + max(env(safe-area-inset-bottom), var(--tg-content-safe-area-inset-bottom, 0px)));
  z-index: 20;
  max-width: min(430px, calc(100% - 28px));
  padding: 12px 14px;
  border-radius: 8px;
  background: #233146;
  color: var(--text);
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  transition: 160ms ease;
}

.toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast.error {
  background: #4b2529;
  color: #ffd9d5;
}

.modal {
  width: min(420px, calc(100% - 28px));
  padding: 18px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #111b27;
  color: var(--text);
  box-shadow: var(--shadow);
}

.modal::backdrop {
  background: rgba(3, 8, 14, 0.78);
  backdrop-filter: blur(5px);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.modal-head h2 {
  margin: 0;
  font-size: 21px;
}

.modal label,
.modal > p {
  color: var(--muted);
}

.modal > p {
  margin: 0 0 16px;
  white-space: pre-line;
}

.icon-button {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 8px;
  background: #223146;
  font-size: 25px;
}

.primary-button,
.secondary-button {
  width: 100%;
  min-height: 48px;
  margin-top: 14px;
  border-radius: 8px;
  font-weight: 750;
}

.primary-button {
  background: linear-gradient(135deg, var(--blue), var(--cyan));
  color: #061018;
}

.secondary-button {
  background: #223146;
  border: 1px solid var(--line);
}

.modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.listing-details {
  grid-column: 1 / -1;
  border-top: 1px solid var(--line);
  padding: 12px;
  font-size: 14px;
  overflow-wrap: anywhere;
  max-height: 320px;
  overflow-y: auto;
}

.listing-details summary {
  cursor: pointer;
}

.listing-details p {
  white-space: pre-line;
  line-height: 1.45;
}

@media (max-width: 360px) {
  .brand {
    font-size: 29px;
  }

  .result-card {
    grid-template-columns: 92px 1fr 40px;
  }

  .deal-radar {
    grid-template-columns: 1fr;
  }

  .radar-bot {
    display: none;
  }

  .summary {
    grid-template-columns: 1fr;
  }
}
