:root {
  --bg: var(--tg-theme-bg-color, #0b0d12);
  --surface: var(--tg-theme-secondary-bg-color, #14171f);
  --surface-strong: #1b1f2a;
  --text: var(--tg-theme-text-color, #f5f7fb);
  --hint: var(--tg-theme-hint-color, #8d94a5);
  --button: var(--tg-theme-button-color, #6f5cff);
  --button-text: var(--tg-theme-button-text-color, #ffffff);
  --accent: #8b7cff;
  --success: #53d995;
  --warning: #ffb457;
  --danger: #ff6f7d;
  --line: rgba(255, 255, 255, 0.075);
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.24);
  color-scheme: dark;
}

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

html,
body {
  margin: 0;
  min-height: 100%;
  height: auto !important;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 90% -10%, rgba(111, 92, 255, 0.18), transparent 34%),
    var(--bg);
  color: var(--text);
}

body {
  padding-bottom: max(24px, env(safe-area-inset-bottom));
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 20px 18px 10px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 14px;
  background: linear-gradient(145deg, #897aff, #5542dd);
  box-shadow: 0 10px 30px rgba(89, 67, 223, 0.35);
  color: #fff;
  font-size: 19px;
  font-weight: 900;
}

.eyebrow {
  display: block;
  margin-bottom: 3px;
  color: var(--hint);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.12em;
}

h1,
h2 {
  margin: 0;
  letter-spacing: -0.025em;
}

h1 {
  font-size: 22px;
  line-height: 1.15;
}

h2 {
  font-size: 21px;
}

.badges {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
}

.badge {
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(20, 23, 31, 0.8);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.06em;
}

.badge.ok {
  color: var(--success);
}

.badge.warn {
  color: var(--warning);
}

.status-card {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 4px 18px 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(20, 23, 31, 0.66);
}

.status-card p {
  margin: 0;
  color: var(--hint);
  font-size: 12px;
}

.status-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 7px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 4px rgba(83, 217, 149, 0.12);
}

.status-card-error {
  border-color: rgba(255, 111, 125, 0.4);
  background: rgba(52, 18, 24, 0.78);
}

.status-card-error .status-dot {
  background: var(--danger);
  box-shadow: 0 0 0 4px rgba(255, 111, 125, 0.16);
}

.status-card-error p {
  color: #ffc2c8;
}

.tabs {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin: 0 16px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: rgba(20, 23, 31, 0.9);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
  backdrop-filter: blur(16px);
}

.tab {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 3px;
  border: 0;
  border-radius: 11px;
  padding: 10px 8px;
  background: transparent;
  color: var(--hint);
  font-size: 10px;
  font-weight: 750;
}

.tab.active {
  background: var(--surface-strong);
  box-shadow: 0 3px 14px rgba(0, 0, 0, 0.22);
  color: var(--text);
}

.tab-icon {
  font-size: 15px;
  line-height: 1;
}

.panel {
  display: none;
  padding: 22px 16px 36px;
  animation: panel-in 0.2s ease-out;
}

.panel.active {
  display: block;
}

.hidden {
  display: none !important;
}

@keyframes panel-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
}

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

.catalog-heading {
  margin-bottom: 16px;
}

.round-action {
  width: 38px;
  height: 38px;
  border: 1px solid rgba(139, 124, 255, 0.35);
  border-radius: 13px;
  background: rgba(111, 92, 255, 0.15);
  color: #bdb4ff;
  font-size: 25px;
  line-height: 1;
}

.hint {
  margin: 5px 0 16px;
  color: var(--hint);
  font-size: 13px;
  line-height: 1.45;
}

.search-wrap {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  margin-bottom: 14px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--hint);
}

.search-wrap:focus-within {
  border-color: rgba(139, 124, 255, 0.58);
  box-shadow: 0 0 0 3px rgba(111, 92, 255, 0.1);
}

.search-wrap.compact {
  margin-bottom: 7px;
  border-radius: 11px;
  background: var(--bg);
}

.search {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  padding: 13px 0;
  background: transparent;
  color: var(--text);
  font-size: 15px;
}

.search::placeholder {
  color: var(--hint);
}

.list {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.card,
.row {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  overflow: hidden;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(145deg, rgba(27, 31, 42, 0.96), rgba(20, 23, 31, 0.96));
}

.card {
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.card:active {
  transform: scale(0.985);
}

.card-copy,
.row-copy {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.collection-avatar {
  position: relative;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 13px;
  background: linear-gradient(145deg, rgba(139, 124, 255, 0.26), rgba(70, 181, 255, 0.13));
  overflow: hidden;
  color: #d9d4ff;
  font-size: 14px;
  font-weight: 850;
}

.collection-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: var(--surface-strong);
  object-fit: cover;
}

.collection-image.failed {
  display: none;
}

.card strong,
.row strong {
  display: block;
  overflow: hidden;
  color: var(--text);
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card small,
.row small {
  display: block;
  overflow: hidden;
  margin-top: 4px;
  color: var(--hint);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-arrow {
  color: var(--hint);
  font-size: 22px;
}

.watched-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 5px;
  border-radius: 50%;
  background: var(--success);
  vertical-align: 1px;
}

.watch-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 7px;
}

.watch-tag {
  padding: 3px 7px;
  border-radius: 7px;
  background: rgba(139, 124, 255, 0.11);
  color: #bbb3ff;
  font-size: 10px;
  font-weight: 700;
}

.danger,
.primary,
.ghost,
.back {
  border: 0;
}

.danger {
  flex: 0 0 auto;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(255, 111, 125, 0.11);
  color: var(--danger);
  font-size: 11px;
  font-weight: 750;
}

.back {
  display: flex;
  align-items: center;
  gap: 5px;
  margin: -5px 0 17px;
  padding: 6px 0;
  background: transparent;
  color: #b8b0ff;
  font-size: 13px;
  font-weight: 700;
}

.back span {
  font-size: 23px;
  line-height: 0;
}

.collection-hero {
  margin-bottom: 15px;
}

.selection-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  padding: 12px 13px;
  border: 1px solid rgba(139, 124, 255, 0.22);
  border-radius: 13px;
  background: rgba(111, 92, 255, 0.09);
  color: var(--hint);
  font-size: 12px;
}

.selection-summary strong {
  color: #c9c3ff;
  font-size: 12px;
}

.limit-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  margin-bottom: 7px;
}

.limit-field {
  display: block;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface);
  color: var(--hint);
  font-size: 11px;
  font-weight: 700;
}

.ton-input {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 7px;
}

.ton-input input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  padding: 0;
  background: transparent;
  color: var(--text);
  font-size: 16px;
  font-weight: 780;
}

.ton-input input::placeholder {
  color: var(--hint);
  font-size: 11px;
  font-weight: 500;
}

.ton-input strong {
  color: #bdb4ff;
  font-size: 10px;
}

.text-input {
  margin-top: 7px;
}

.text-input input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  padding: 0;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  font-weight: 780;
}

.text-input input::placeholder {
  color: var(--hint);
  font-size: 11px;
  font-weight: 500;
}

.faq {
  margin-top: 12px;
  padding: 12px 12px 14px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(20, 23, 31, 0.66);
}

.faq summary {
  cursor: pointer;
  color: var(--hint);
  font-size: 11px;
  font-weight: 900;
}

.faq-steps {
  margin: 10px 0 0 18px;
  padding: 0;
}

.faq-steps li {
  margin: 8px 0;
  color: var(--text);
  font-size: 11px;
  line-height: 1.35;
}

.faq-img {
  display: block;
  width: 100%;
  max-width: 680px;
  margin-top: 10px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.15);
}

.limit-note {
  margin: 0 2px 12px;
  color: var(--hint);
  font-size: 10px;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  margin-bottom: 18px;
}

.stat-card {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--surface);
}

.stat-card span,
.stat-card small {
  display: block;
  color: var(--hint);
  font-size: 10px;
}

.stat-card strong {
  display: block;
  margin: 6px 0 4px;
  font-size: 17px;
  font-variant-numeric: tabular-nums;
}

.profit-card {
  grid-column: 1 / -1;
  border-color: rgba(83, 217, 149, 0.22);
  background: rgba(83, 217, 149, 0.07);
}

.profit-card strong {
  color: var(--success);
}

.history-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(145deg, rgba(27, 31, 42, 0.96), rgba(20, 23, 31, 0.96));
}

.history-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.history-title {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.history-title strong {
  color: var(--text);
  font-size: 14px;
}

.history-price {
  flex: 0 0 auto;
  color: var(--text);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.history-price.positive {
  color: var(--success);
}

.history-meta {
  color: var(--hint);
  font-size: 12px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.history-status {
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--hint);
  font-size: 12px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.history-status-ok {
  background: rgba(83, 217, 149, 0.1);
  color: var(--success);
}

.history-status-error {
  background: rgba(255, 92, 92, 0.1);
  color: var(--danger);
}

.history-kind {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  border-radius: 11px;
  background: rgba(111, 92, 255, 0.13);
  color: #bbb3ff;
  font-weight: 900;
}

.history-kind.sale {
  background: rgba(83, 217, 149, 0.11);
  color: var(--success);
}

.history-kind.offer {
  background: rgba(255, 196, 86, 0.12);
  color: #ffd27a;
}

.history-price.offer {
  color: #ffd27a;
}

.history-status-offer {
  background: rgba(255, 196, 86, 0.1);
  color: #ffd27a;
}

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

.settings-title {
  display: block;
  margin-bottom: 11px;
  color: var(--text);
  font-size: 14px;
  font-weight: 780;
}

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

.toggle-row strong,
.toggle-row small {
  display: block;
}

.toggle-row strong {
  font-size: 14px;
}

.toggle-row small {
  margin-top: 4px;
  color: var(--hint);
  font-size: 11px;
}

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

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

.switch span {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: #323643;
  transition: background 0.2s ease;
}

.switch span::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  content: "";
  transition: transform 0.2s ease;
}

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

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

.settings-save {
  margin-top: 14px;
}

.settings-warning {
  color: var(--hint);
  font-size: 10px;
  text-align: center;
}

.watch-pricing {
  display: block;
  margin-top: 4px;
  color: var(--hint);
  font-size: 11px;
}

.filter-pricing {
  margin-bottom: 8px;
}

.filter-pricing .limit-field:last-child {
  grid-column: auto;
}

.formula-preview {
  margin: 4px 0 0;
  padding: 10px 11px;
  border-radius: 11px;
  background: rgba(111, 92, 255, 0.09);
  color: #c9c3ff;
  font-size: 11px;
  line-height: 1.45;
}

.ghost {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin-bottom: 12px;
  padding: 12px;
  border: 1px dashed rgba(255, 255, 255, 0.14);
  border-radius: 13px;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

.ghost-icon {
  color: var(--accent);
}

.filter-block {
  margin-top: 9px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--surface);
}

.acc-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  border: 0;
  padding: 13px;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.acc-title,
.acc-tail {
  display: flex;
  align-items: center;
}

.acc-title {
  gap: 9px;
  font-size: 14px;
  font-weight: 780;
}

.acc-tail {
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}

.step {
  display: grid;
  place-items: center;
  width: 23px;
  height: 23px;
  border-radius: 8px;
  background: rgba(139, 124, 255, 0.13);
  color: #bbb3ff;
  font-size: 11px;
}

.acc-meta {
  max-width: 115px;
  overflow: hidden;
  color: var(--hint);
  font-size: 11px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chevron {
  color: var(--hint);
  font-size: 16px;
  transition: transform 0.18s ease;
}

.filter-block.open .chevron {
  transform: rotate(180deg);
}

.acc-body {
  display: none;
  padding: 0 11px 11px;
}

.filter-block.open .acc-body {
  display: block;
}

.option-list {
  display: flex;
  flex-direction: column;
  max-height: 330px;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  margin-top: 6px;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--bg);
  color: var(--text);
  text-align: left;
  transition: transform 80ms ease, filter 80ms ease;
  touch-action: manipulation;
}

.option:active {
  transform: scale(0.985) translateY(1px);
  filter: brightness(1.08);
}

.option.on {
  border-color: rgba(139, 124, 255, 0.58);
  background: rgba(111, 92, 255, 0.18);
  box-shadow: inset 3px 0 0 var(--accent);
  color: #e4e0ff;
}

.option-main {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.model-avatar {
  position: relative;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: linear-gradient(145deg, rgba(139, 124, 255, 0.2), rgba(70, 181, 255, 0.1));
  color: #c9c3ff;
  font-size: 11px;
  font-weight: 850;
}

.model-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: var(--surface-strong);
  object-fit: cover;
}

.model-image.failed {
  display: none;
}

.option .pct {
  color: inherit;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  opacity: 0.7;
}

.action-dock {
  position: sticky;
  bottom: 0;
  z-index: 15;
  margin: 12px -16px -36px;
  padding: 12px 16px max(14px, env(safe-area-inset-bottom));
  background: linear-gradient(transparent, var(--bg) 24%);
}

.primary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 14px 16px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--button), #8877ff);
  box-shadow: 0 12px 32px rgba(92, 70, 224, 0.3);
  color: var(--button-text);
  font-size: 14px;
  font-weight: 800;
  transition: transform 80ms ease, filter 80ms ease;
  touch-action: manipulation;
}

.primary:active,
.danger:active,
.ghost:active,
.back:active {
  transform: scale(0.985) translateY(1px);
  filter: brightness(1.08);
}

.toast {
  position: fixed;
  z-index: 100;
  right: 16px;
  bottom: max(18px, env(safe-area-inset-bottom));
  left: 16px;
  max-width: 500px;
  margin: auto;
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 13px;
  background: rgba(20, 23, 31, 0.96);
  box-shadow: var(--shadow);
  color: #fff;
  font-size: 13px;
  text-align: center;
  backdrop-filter: blur(18px);
}

.empty {
  padding: 32px 12px;
  border: 1px dashed var(--line);
  border-radius: 15px;
  color: var(--hint);
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
}

@media (min-width: 560px) {
  .top,
  .panel {
    padding-right: 24px;
    padding-left: 24px;
  }

  .tabs,
  .status-card {
    margin-right: 24px;
    margin-left: 24px;
  }

  .catalog-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
