:root {
  --bg: #f4f5fb;
  --surface: #ffffff;
  --surface-2: #f8f9fe;
  --border: #e7e8f2;
  --text: #1a1c2e;
  --muted: #6b7089;
  --brand: #5b5ef4;
  --brand-2: #8b5cf6;
  --brand-ink: #ffffff;
  --green: #17a673;
  --green-bg: #e6f7f0;
  --red: #e5484d;
  --red-bg: #fdeaea;
  --amber: #b7791f;
  --amber-bg: #fdf3e2;
  --shadow: 0 6px 24px rgba(29, 30, 61, .07);
  --shadow-lg: 0 18px 50px rgba(29, 30, 61, .14);
  --radius: 16px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
h1, h2, h3 { margin: 0 0 .4em; line-height: 1.2; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }

/* Layout ------------------------------------------------------------------ */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255,255,255,.85);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1080px; margin: 0 auto; padding: .7rem 1.1rem;
  display: flex; align-items: center; gap: 1rem;
}
.brand { display: flex; align-items: center; gap: .55rem; font-weight: 800; font-size: 1.12rem; }
.brand .coin {
  width: 30px; height: 30px; border-radius: 9px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff; display: grid; place-items: center; font-weight: 800;
  box-shadow: 0 4px 12px rgba(91,94,244,.4);
}
.nav { display: flex; gap: .25rem; margin-left: .5rem; flex-wrap: wrap; }
.nav a {
  padding: .45rem .7rem; border-radius: 10px; color: var(--muted); font-weight: 600; font-size: .92rem;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: #eef0ff; color: var(--brand); }
.spacer { flex: 1; }
.balance-chip {
  display: inline-flex; align-items: center; gap: .4rem;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff; padding: .4rem .8rem; border-radius: 999px; font-weight: 800;
  box-shadow: 0 6px 16px rgba(91,94,244,.35); white-space: nowrap;
}
.usermenu { display: flex; align-items: center; gap: .5rem; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--surface-2); border: 1px solid var(--border);
  display: grid; place-items: center; font-weight: 700; color: var(--brand);
}

.container { max-width: 1080px; margin: 0 auto; padding: 1.4rem 1.1rem 3rem; }

/* Cards ------------------------------------------------------------------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.1rem 1.2rem;
}
.grid { display: grid; gap: 1rem; }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.store { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }

/* Balance hero ------------------------------------------------------------ */
.hero {
  background: linear-gradient(135deg, #5b5ef4 0%, #8b5cf6 55%, #a855f7 100%);
  color: #fff; border-radius: 22px; padding: 1.6rem 1.5rem; position: relative;
  overflow: hidden; box-shadow: var(--shadow-lg);
}
.hero::after {
  content: ""; position: absolute; right: -40px; top: -60px;
  width: 220px; height: 220px; border-radius: 50%;
  background: rgba(255,255,255,.12);
}
.hero .label { opacity: .85; font-weight: 600; font-size: .9rem; }
.hero .amount { font-size: 2.7rem; font-weight: 800; letter-spacing: -1px; margin-top: .1rem; }
.hero .amount small { font-size: 1.3rem; opacity: .8; }
.hero .sub { margin-top: .6rem; opacity: .9; font-size: .92rem; }

.stat { display: flex; flex-direction: column; gap: .2rem; }
.stat .n { font-size: 1.5rem; font-weight: 800; }
.stat .t { color: var(--muted); font-size: .85rem; font-weight: 600; }

/* Buttons ----------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: .55rem .9rem; border-radius: 11px; font-weight: 700; font-size: .92rem;
  cursor: pointer; transition: .12s; font-family: inherit;
}
.btn:hover { border-color: #cfd1e6; }
.btn-primary {
  background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; border: none;
  box-shadow: 0 6px 16px rgba(91,94,244,.35);
}
.btn-primary:hover { filter: brightness(1.05); }
.btn-danger { background: var(--red-bg); color: var(--red); border-color: #f6cccd; }
.btn-ghost { background: transparent; }
.btn-sm { padding: .35rem .6rem; font-size: .84rem; border-radius: 9px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-block { width: 100%; }

/* Forms ------------------------------------------------------------------- */
label { font-weight: 600; font-size: .86rem; color: var(--muted); display: block; margin-bottom: .3rem; }
input, select, textarea {
  width: 100%; padding: .55rem .7rem; border: 1px solid var(--border); border-radius: 10px;
  font-family: inherit; font-size: .95rem; background: var(--surface); color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid #d6d8ff; border-color: var(--brand); }
textarea { resize: vertical; line-height: 1.5; font-size: .9rem; }
.field { margin-bottom: .8rem; }
.row { display: flex; gap: .7rem; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 0; }
.checkbox { display: flex; align-items: center; gap: .5rem; }
.checkbox input { width: auto; }

/* Table ------------------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: .6rem .5rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--muted); font-weight: 700; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }
tbody tr:hover { background: var(--surface-2); }
td.wrap, th.wrap { white-space: normal; }

/* Badges & amounts -------------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: .3rem; padding: .18rem .55rem;
  border-radius: 999px; font-weight: 700; font-size: .78rem;
}
.badge.green { background: var(--green-bg); color: var(--green); }
.badge.red { background: var(--red-bg); color: var(--red); }
.badge.amber { background: var(--amber-bg); color: var(--amber); }
.badge.gray { background: var(--surface-2); color: var(--muted); }
.badge.blue { background: #e4f0fe; color: #1b6ec2; }
.badge.violet { background: #eef0ff; color: var(--brand); }
.amount-pos { color: var(--green); font-weight: 800; }
.amount-neg { color: var(--red); font-weight: 800; }

/* Store cards ------------------------------------------------------------- */
.lot {
  display: flex; flex-direction: column; gap: .5rem; padding: 1rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); transition: .14s;
}
.lot:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.lot .title { font-weight: 700; }
.lot .desc { color: var(--muted); font-size: .86rem; }
.lot .price { font-weight: 800; font-size: 1.15rem; color: var(--brand); }

/* кликабельная область плитки */
.lot-link { display: flex; flex-direction: column; gap: .5rem; flex: 1; color: inherit; }
.lot-link:hover .title { color: var(--brand); }
.lot-media {
  height: 150px; border-radius: 12px; background: var(--surface-2);
  display: grid; place-items: center; overflow: hidden;
}
.lot-media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.lot-emoji { font-size: 3rem; }
.limit-note { font-size: .78rem; color: var(--amber); font-weight: 700; }

/* анонсы */
.upcoming-block {
  background: linear-gradient(135deg, #f3f0ff, #eef4ff);
  border: 1px dashed #c9c8f5; border-radius: var(--radius);
  padding: 1rem 1.1rem 1.2rem; margin-bottom: 1.4rem;
}
.lot-soon .lot-media { position: relative; }
.lot-soon .lot-media img, .lot-soon .lot-emoji { opacity: .72; }
.soon-tag {
  position: absolute; top: .5rem; left: .5rem;
  background: var(--brand); color: #fff; font-size: .72rem; font-weight: 800;
  padding: .2rem .5rem; border-radius: 999px; letter-spacing: .02em;
}
.soon-banner {
  background: #eef0ff; color: var(--brand); border-radius: 11px;
  padding: .8rem .9rem; margin-bottom: .9rem; font-size: .9rem;
}
.soon-banner b { display: block; margin-bottom: .15rem; }

/* --- карточка товара --- */
.breadcrumb { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap;
  font-size: .86rem; margin-bottom: 1rem; color: var(--muted); }
.breadcrumb a { color: var(--brand); font-weight: 600; }
.breadcrumb span { color: var(--muted); }

.lot-page { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 1.4rem; align-items: start; }
.gallery-main {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  aspect-ratio: 4 / 3; display: grid; place-items: center; overflow: hidden; box-shadow: var(--shadow);
}
.gallery-main img { width: 100%; height: 100%; object-fit: contain; display: block; }
.gallery-placeholder { font-size: 6rem; }
.thumbs { display: flex; gap: .5rem; margin-top: .6rem; flex-wrap: wrap; }
.thumb {
  width: 68px; height: 68px; padding: 0; border-radius: 10px; overflow: hidden;
  border: 2px solid var(--border); background: var(--surface); cursor: pointer;
}
.thumb.active { border-color: var(--brand); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.buy-box {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.1rem; box-shadow: var(--shadow); margin-top: .6rem;
}
.buy-price { font-size: 2rem; font-weight: 800; color: var(--brand); letter-spacing: -.5px; }
.restrictions {
  background: var(--amber-bg); color: var(--amber); border-radius: 11px;
  padding: .7rem .9rem; margin-bottom: .9rem; font-size: .88rem;
}
.restrictions b { display: block; margin-bottom: .2rem; }

/* --- управление фото в админке --- */
.photo-manage { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: .7rem; }
.photo-item { position: relative; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.photo-item img { width: 100%; height: 110px; object-fit: cover; display: block; }
.photo-tag { position: absolute; top: .35rem; left: .35rem; }
.photo-actions { position: absolute; top: .35rem; right: .35rem; display: flex; gap: .25rem; }
.photo-actions form { display: inline; }
.section-title { margin: 1.4rem 0 .6rem; font-size: 1.05rem; color: var(--muted); font-weight: 700; }

/* Greeting ---------------------------------------------------------------- */
.greeting { margin-bottom: 1.1rem; }
.greeting h1 { font-size: 1.7rem; margin: 0 0 .15rem; letter-spacing: -.4px; }
.greeting p { margin: 0; font-size: .93rem; }

/* Info page --------------------------------------------------------------- */
.info-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
.info-grid .wide { grid-column: 1 / -1; }
.prose p { margin: .5rem 0; font-size: .92rem; }
.prose ul, .prose ol { margin: .5rem 0; padding-left: 1.2rem; font-size: .92rem; }
.prose li { margin: .25rem 0; }
.prose a { color: var(--brand); font-weight: 700; }
.prose code { background: var(--surface-2); padding: .1rem .3rem; border-radius: 5px; font-size: .88em; }
.prose details p { margin: .4rem 0 0; }

/* Misc -------------------------------------------------------------------- */
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.1rem; flex-wrap: wrap; }
.alert { padding: .7rem .9rem; border-radius: 11px; margin-bottom: 1rem; font-weight: 600; font-size: .9rem; }
.alert.ok { background: var(--green-bg); color: var(--green); }
.alert.err { background: var(--red-bg); color: var(--red); }
.alert.info { background: #eef0ff; color: var(--brand); }
.empty { text-align: center; color: var(--muted); padding: 2.5rem 1rem; }
.divider { height: 1px; background: var(--border); margin: 1rem 0; }
.tabs { display: flex; gap: .4rem; margin-bottom: 1rem; flex-wrap: wrap; }
.tabs a { padding: .4rem .8rem; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); font-weight: 600; font-size: .88rem; color: var(--muted); }
.tabs a.active { background: var(--brand); color: #fff; border-color: var(--brand); }

/* Login ------------------------------------------------------------------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1.2rem;
  background: radial-gradient(1200px 600px at 20% -10%, #e9eaff, transparent),
              radial-gradient(900px 500px at 100% 0%, #f0e6ff, transparent), var(--bg); }
.login-card { width: 100%; max-width: 400px; }
.login-brand { text-align: center; margin-bottom: 1.2rem; }
.login-brand .coin { width: 54px; height: 54px; border-radius: 16px; font-size: 1.5rem; margin: 0 auto .6rem; }

@media (max-width: 760px) {
  .grid.cols-3, .grid.cols-2, .info-grid, .lot-page { grid-template-columns: 1fr; }
  .nav { order: 3; width: 100%; }
  .hero .amount { font-size: 2.2rem; }
}
