:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #111111);
  --muted: var(--tg-theme-hint-color, #707070);
  --link: var(--tg-theme-link-color, #2a8de4);
  --btn: var(--tg-theme-button-color, #2a8de4);
  --btn-text: var(--tg-theme-button-text-color, #ffffff);
  --section: var(--tg-theme-secondary-bg-color, #f4f4f6);
  --border: rgba(127, 127, 127, .18);
  --have: #2fa84a;
  --want: #e7b324;
  --spare: #8e44ad;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px; line-height: 1.35; }
body { padding-bottom: env(safe-area-inset-bottom, 12px); }

.topbar { padding: 10px 12px 4px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.stat { background: var(--section); border-radius: 10px; padding: 8px 6px; text-align: center; }
.stat b { display: block; font-size: 18px; font-weight: 600; }
.stat i { font-style: normal; font-size: 11px; color: var(--muted); }
.value-bar { margin-top: 8px; padding: 8px 12px; background: var(--section); border-radius: 10px;
  font-size: 13px; color: var(--muted); text-align: center; }
.value-bar b { color: var(--text); font-size: 15px; font-weight: 700; }

.tabs { display: flex; gap: 4px; padding: 8px 12px 0; border-bottom: 1px solid var(--border); }
.tab { flex: 1; background: transparent; border: 0; padding: 10px 6px; font: inherit; color: var(--muted);
  border-bottom: 2px solid transparent; cursor: pointer; }
.tab.active { color: var(--text); border-color: var(--btn); font-weight: 600; }

.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 10px 12px; }
.filters select, .filters input { width: 100%; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--section); color: var(--text); font: inherit; }
.filters input { grid-column: 1 / -1; }

.list { padding: 4px 12px 16px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.card { background: var(--section); border-radius: 12px; padding: 8px; cursor: pointer; position: relative;
  display: flex; flex-direction: column; gap: 6px; }
.card img { width: 100%; aspect-ratio: 1 / 1; object-fit: contain; background: rgba(255,255,255,.6);
  border-radius: 8px; }
.card .title { font-size: 13px; font-weight: 600; line-height: 1.25; min-height: 32px; }
.card .meta { font-size: 11px; color: var(--muted); display: flex; justify-content: space-between; }
.card .badge { position: absolute; top: 6px; right: 6px; padding: 2px 7px; border-radius: 100px;
  font-size: 10px; font-weight: 700; color: white; text-transform: uppercase; letter-spacing: .03em; }
.card .mint { position: absolute; top: 6px; left: 6px; padding: 2px 6px; border-radius: 100px;
  font-size: 10px; font-weight: 700; letter-spacing: .05em; background: rgba(255,255,255,.85); color: #333; }
.card .mint-СПМД { background: rgba(52, 130, 220, .9); color: white; }
.card .mint-ММД { background: rgba(220, 90, 60, .9); color: white; }
.card .mint-both { background: linear-gradient(135deg, rgba(220, 90, 60, .9) 50%, rgba(52, 130, 220, .9) 50%); color: white; }
.card[data-status=have] .badge { background: var(--have); }
.card[data-status=want] .badge { background: var(--want); }
.card[data-status=spare] .badge { background: var(--spare); }
.card[data-status=have] { outline: 2px solid var(--have); }
.card[data-status=want] { outline: 2px solid var(--want); }
.card[data-status=spare] { outline: 2px solid var(--spare); }

.empty { grid-column: 1 / -1; padding: 40px 16px; text-align: center; color: var(--muted); }

.dialog { border: 0; border-radius: 16px 16px 0 0; padding: 0; width: 100%; max-width: 480px;
  background: var(--bg); color: var(--text); }
.dialog::backdrop { background: rgba(0, 0, 0, .5); }
.dialog-inner { padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.dialog .close { align-self: flex-end; width: 32px; height: 32px; border-radius: 50%; border: 0;
  background: var(--section); color: var(--text); font-size: 20px; line-height: 1; cursor: pointer; }
#d-img { width: 140px; height: 140px; object-fit: contain; align-self: center;
  background: rgba(127,127,127,.08); border-radius: 12px; padding: 8px; }
.dialog h2 { margin: 0; font-size: 18px; text-align: center; }
.muted { color: var(--muted); text-align: center; font-size: 13px; }
.props { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 4px 0; font-size: 13px; }
.props dt { color: var(--muted); }
.props dd { margin: 0; }

.status-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.status-btn { padding: 10px 6px; border-radius: 10px; border: 0; background: var(--section); color: var(--text);
  font: inherit; font-weight: 600; cursor: pointer; font-size: 13px; }
.status-btn[data-status=have].active { background: var(--have); color: white; }
.status-btn[data-status=want].active { background: var(--want); color: white; }
.status-btn[data-status=spare].active { background: var(--spare); color: white; }
.status-btn.ghost { color: var(--muted); }

.qty-row { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.qty-row input { width: 80px; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--section); color: var(--text); font: inherit; }

textarea { width: 100%; min-height: 60px; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--section); color: var(--text); font: inherit; resize: vertical; }
