:root {
  --bg: #0b0b0e;
  --sf: rgba(22, 22, 26, .76);
  --ink: #f4f4f5;
  --mut: #9b9ba4;
  --ln: rgba(255, 255, 255, .1);
  --tag: #ffb014;
  --ok: #4ade80;
  --bad: #ff5d52;
  --soft: rgba(255, 255, 255, .07);
  --dlg: #18181b;
  --disp: "Fira Sans Extra Condensed", Onest, system-ui, sans-serif;
  color-scheme: dark
}

/* ── Светлая тема ── */
[data-theme="light"] {
  --bg: #f0f0f4;
  --sf: rgba(255, 255, 255, .82);
  --ink: #111117;
  --mut: #6b6b78;
  --ln: rgba(0, 0, 0, .1);
  --soft: rgba(0, 0, 0, .05);
  --dlg: #ffffff;
  color-scheme: light
}

[data-theme="light"] html {
  background: #e8e8f0 url(images/profile-bg.png) center/cover fixed no-repeat
}

[data-theme="light"] body::before {
  background: rgba(235, 235, 245, .88)
}

[data-theme="light"] header {
  background: rgba(240, 240, 248, .88)
}

[data-theme="light"] .pfh {
  background-image: none
}

[data-theme="light"] .pfh::before {
  background: rgba(240, 240, 248, .65)
}

[data-theme="light"] input,
[data-theme="light"] select,
[data-theme="light"] textarea {
  background: rgba(0, 0, 0, .05);
  border-color: rgba(0, 0, 0, .12)
}

[data-theme="light"] input:focus,
[data-theme="light"] select:focus,
[data-theme="light"] textarea:focus {
  background: rgba(0, 0, 0, .07)
}

[data-theme="light"] option {
  background: #fff;
  color: #111
}

[data-theme="light"] .sold-item {
  background: rgba(255, 255, 255, .9)
}

[data-theme="light"] .sold-item:hover {
  background: rgba(255, 255, 255, 1)
}

[data-theme="light"] .sold-flow {
  background: rgba(0, 0, 0, .04)
}

[data-theme="light"] .meta {
  color: var(--mut)
}

[data-theme="light"] .wm {
  background: rgba(255, 255, 255, .65);
  border-color: rgba(0, 0, 0, .08)
}

/* ── Кнопка темы ── */
#theme-btn {
  background: var(--soft);
  border: 1px solid var(--ln);
  border-radius: 10px;
  padding: 3px 9px;
  font-size: 16px;
  line-height: 1.5;
  margin-bottom: 4px;
  cursor: pointer;
  flex-shrink: 0
}

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

html {
  background: #0b0b0e url(images/profile-bg.png) center/cover fixed no-repeat;
  scroll-behavior: smooth;
  min-height: 100%
}

body {
  font: 14px/1.45 Onest, system-ui, sans-serif;
  color: var(--ink);
  background: transparent;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background: rgba(4, 4, 7, .91);
  z-index: -1
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit
}

button {
  cursor: pointer
}

option {
  background: var(--dlg)
}

:focus-visible {
  outline: 2px solid var(--tag);
  outline-offset: 2px
}

[hidden] {
  display: none !important
}

.wrap {
  max-width: 1020px;
  margin: 0 auto;
  padding: 0 14px
}

h2 {
  font: italic 800 17px var(--disp);
  text-transform: uppercase;
  letter-spacing: .02em;
  margin-bottom: 10px
}

/* Шапка и навигация */
header {
  background: rgba(11, 11, 14, .85);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--ln);
  position: sticky;
  top: 0;
  z-index: 10;
  padding-top: env(safe-area-inset-top)
}

header .wrap {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-top: 8px;
  padding-bottom: 2px;
  flex-wrap: wrap
}

.logo {
  font: italic 800 20px var(--disp);
  text-transform: uppercase;
  letter-spacing: .02em;
  display: flex;
  align-items: center;
  gap: 9px;
  padding-bottom: 4px
}

.logo small {
  font: 500 11px Onest, sans-serif;
  text-transform: none;
  letter-spacing: 0;
  font-style: normal;
  color: var(--mut);
  background: var(--soft);
  padding: 2px 9px;
  border-radius: 99px
}

.mark {
  display: inline-block;
  width: 21px;
  height: 15px;
  background: var(--tag);
  clip-path: polygon(0 50%, 6px 0, 100% 0, 100% 100%, 6px 100%);
  -webkit-mask: radial-gradient(circle 2px at 6px 50%, transparent 97%, #000 100%);
  mask: radial-gradient(circle 2px at 6px 50%, transparent 97%, #000 100%)
}

header nav {
  display: flex;
  gap: 18px;
  margin: 0 auto 0 14px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none
}

header nav::-webkit-scrollbar {
  display: none
}

header nav button {
  background: none;
  border: 0;
  border-bottom: 3px solid transparent;
  padding: 9px 2px 7px;
  font: italic 700 15px var(--disp);
  text-transform: uppercase;
  letter-spacing: .03em;
  color: var(--mut);
  white-space: nowrap;
  transition: color .12s, border-color .12s
}

header nav button:hover {
  color: var(--ink)
}

header nav button.on {
  color: var(--ink);
  border-bottom-color: var(--tag)
}

.me {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--soft);
  border: 1px solid var(--ln);
  border-radius: 10px;
  padding: 3px 11px 3px 4px;
  font: italic 700 13.5px var(--disp);
  text-transform: uppercase;
  letter-spacing: .03em;
  margin-bottom: 4px;
  flex-shrink: 0
}

.me:hover {
  border-color: rgba(255, 255, 255, .3)
}

#inst {
  padding: 3px 11px;
  color: var(--tag);
  border-color: rgba(255, 176, 20, .5)
}

#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column
}

main {
  flex: 1;
  padding: 14px 0 24px
}

/* Вотермарка в подвале */
.wm {
  padding: 14px 0 calc(18px + env(safe-area-inset-bottom));
  text-align: center;
  font-size: 12px;
  color: var(--mut);
  border-top: 1px solid var(--ln);
  background: rgba(11, 11, 14, .55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  margin-top: auto
}

.wm .wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px
}

.wm b {
  color: var(--tag);
  font-weight: 700
}

.wm-dot {
  opacity: .35
}

.wm-auth {
  text-align: center;
  font-size: 11.5px;
  color: var(--mut);
  padding-top: 6px;
  border-top: 1px solid var(--ln);
  margin-top: 4px
}

.wm-auth b {
  color: var(--tag);
  font-weight: 700
}

.av {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .1);
  overflow: hidden;
  font: 700 11px Onest, sans-serif;
  font-style: normal;
  flex: none;
  vertical-align: middle;
  margin-right: 7px
}

.me .av {
  margin: 0
}

.av img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top
}

/* Кнопки и формы */
.btn {
  background: var(--tag);
  color: #1a1204;
  border: 1px solid var(--tag);
  padding: 5px 14px;
  border-radius: 9px;
  font: italic 800 14px var(--disp);
  text-transform: uppercase;
  letter-spacing: .03em;
  transition: background .12s, transform .08s
}

.btn:hover {
  background: #ffc23d
}

.btn:active {
  transform: scale(.98)
}

.btn.ghost {
  background: var(--soft);
  color: var(--ink);
  border-color: var(--ln)
}

.btn.ghost:hover {
  background: rgba(255, 255, 255, .12)
}

.btn.sm {
  padding: 2px 10px;
  font-size: 12.5px;
  border-radius: 8px
}

.btn.danger {
  background: rgba(255, 93, 82, .1);
  color: var(--bad);
  border-color: rgba(255, 93, 82, .35)
}

.btn.danger:hover {
  background: rgba(255, 93, 82, .2)
}

.btn:disabled {
  opacity: .55;
  cursor: wait
}

.bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 10px
}

.push {
  margin-left: auto
}

.bar input,
.bar select {
  width: auto
}

.bar .grow {
  flex: 1;
  min-width: 170px
}

input,
select,
textarea {
  background: rgba(255, 255, 255, .06);
  border: 1px solid var(--ln);
  border-radius: 9px;
  padding: 7px 11px;
  width: 100%;
  font-size: 14px;
  transition: border-color .15s, background .15s
}

input::placeholder,
textarea::placeholder {
  color: #6f6f78
}

input:focus,
select:focus,
textarea:focus {
  outline: 0;
  border-color: var(--tag);
  background: rgba(255, 255, 255, .09)
}

textarea {
  resize: vertical
}

/* Переключатели (.seg) */
.seg {
  display: flex;
  gap: 5px;
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  max-width: 100%;
  padding-bottom: 1px
}

.seg::-webkit-scrollbar {
  display: none
}

.seg button {
  background: var(--soft);
  border: 1px solid var(--ln);
  border-radius: 8px;
  padding: 4px 12px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  flex-shrink: 0
}

.seg button:hover {
  border-color: rgba(255, 255, 255, .3)
}

.seg button.on {
  background: var(--tag);
  color: #1a1204;
  border-color: var(--tag)
}

.seg.big button {
  padding: 5px 15px;
  font: italic 800 14px var(--disp);
  text-transform: uppercase;
  letter-spacing: .03em
}

.seg.vm button {
  padding: 3px 9px;
  font-size: 16px;
  line-height: 1
}

.cnt {
  display: inline-block;
  min-width: 20px;
  padding: 0 6px;
  margin-left: 6px;
  border-radius: 99px;
  background: rgba(127, 127, 127, .28);
  font: 700 11.5px Onest, sans-serif;
  font-style: normal;
  text-align: center
}

/* Сводка (.sum) */
.sum {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  background: var(--sf);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--ln);
  border-radius: 14px;
  padding: 10px 14px;
  margin-bottom: 12px;
  text-align: center
}

.sum>div {
  min-width: 0
}

.sum span {
  display: block;
  color: var(--mut);
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis
}

.sum b {
  display: block;
  font: italic 800 18px/1.2 var(--disp);
  letter-spacing: .01em;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap
}

/* Карточки (.card, .grid) */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(245px, 1fr));
  gap: 20px 12px
}

.card {
  background: var(--sf);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--ln);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  position: relative;
  transition: border-color .15s
}

.card:hover {
  border-color: rgba(255, 255, 255, .25)
}

.ph {
  height: 118px;
  background: #222 center/cover;
  border-radius: 13px 13px 0 0;
  cursor: zoom-in
}

.ph.none {
  cursor: default;
  display: grid;
  place-items: center;
  font: italic 800 20px var(--disp);
  text-transform: uppercase;
  color: rgba(255, 255, 255, .22)
}

.ph.car {
  background: #18222c
}

.ph.acc {
  background: #2a2218
}

.ph.skin {
  background: #231c2e
}

.ph.house {
  background: #182a1f
}

.ph.flat {
  background: #2d1c1c
}

.ph.garage {
  background: #28231c
}

.ph.cat {
  background-size: contain !important;
  background-position: center !important;
  background-repeat: no-repeat !important;
  cursor: default
}

.in {
  position: relative;
  padding: 24px 12px 11px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  flex: 1
}

.tagp {
  position: absolute;
  top: -18px;
  right: 10px;
  display: flex;
  flex-direction: column;
  padding: 4px 12px 4px 20px;
  line-height: 1.15;
  background: var(--tag);
  color: #1a1204;
  clip-path: polygon(0 50%, 14px 0, 100% 0, 100% 100%, 14px 100%);
  -webkit-mask: radial-gradient(circle 3px at 14px 50%, transparent 97%, #000 100%);
  mask: radial-gradient(circle 3px at 14px 50%, transparent 97%, #000 100%)
}

.tagp b {
  font: italic 800 16px var(--disp);
  white-space: nowrap
}

.tagp span {
  font-size: 10.5px;
  font-weight: 600;
  opacity: .8
}

.tagp.plus {
  background: var(--ok)
}

.tagp.minus {
  background: var(--bad);
  color: #fff
}

.card h3,
.rec h3 {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.25
}

.meta {
  color: var(--mut);
  font-size: 12px
}

.specs {
  display: flex;
  gap: 5px;
  flex-wrap: wrap
}

.spec {
  background: var(--soft);
  border: 1px solid var(--ln);
  border-radius: 7px;
  padding: 1px 8px;
  font-size: 12px;
  font-weight: 600
}

.spec.bad {
  color: var(--bad)
}

.spec.nick {
  background: var(--tag);
  color: #1a1204;
  border-color: var(--tag);
  font-weight: 700
}

.descr {
  font-size: 13px;
  color: #c4c4cb;
  white-space: pre-wrap
}

.money {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  padding-top: 8px;
  border-top: 1px solid var(--ln);
  margin-top: auto
}

.money .l {
  display: block;
  color: var(--mut);
  font-size: 11px
}

.money b {
  font-size: 14px;
  font-weight: 700
}

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

.ok {
  color: var(--ok)
}

.bad {
  color: var(--bad)
}

.big {
  font: italic 800 20px var(--disp);
  line-height: 1.2
}

/* KPI-карточки */
.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
  margin-bottom: 12px
}

.kpi {
  background: var(--sf);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--ln);
  padding: 9px 12px;
  border-radius: 12px;
  min-width: 0
}

.kpi b {
  display: block;
  font: italic 800 17px/1.2 var(--disp);
  margin-top: 2px;
  overflow-wrap: anywhere
}

.kpi span {
  color: var(--mut);
  font-size: 11px;
  display: block;
  line-height: 1.25
}

.kpi.hl {
  background: rgba(255, 176, 20, .14);
  border-color: rgba(255, 176, 20, .5)
}

.kpi.hl b {
  color: var(--tag)
}

.box {
  background: var(--sf);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--ln);
  border-radius: 14px;
  padding: 12px;
  margin-bottom: 12px
}

/* Таблицы */
.scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, .2) transparent
}

.scroll::-webkit-scrollbar {
  height: 4px
}

.scroll::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, .2);
  border-radius: 99px
}

.scroll table {
  min-width: 520px
}

table {
  width: 100%;
  border-collapse: collapse
}

th,
td {
  text-align: left;
  padding: 7px 6px;
  border-bottom: 1px solid var(--ln)
}

tr:last-child td {
  border-bottom: 0
}

th {
  font-weight: 500;
  color: var(--mut);
  font-size: 12px
}

td.r,
th.r {
  text-align: right
}

.hb {
  height: 7px;
  background: var(--soft);
  border-radius: 99px;
  min-width: 60px;
  overflow: hidden
}

.hb i {
  display: block;
  height: 100%;
  border-radius: 99px
}

.rk {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--soft);
  font: italic 800 13px var(--disp)
}

.rk.n1 {
  background: var(--tag);
  color: #1a1204
}

.rk.n2 {
  background: #cfd3d8;
  color: #111
}

.rk.n3 {
  background: #c98f5a;
  color: #111
}

.me-row td {
  background: rgba(255, 176, 20, .09)
}

.recs {
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr))
}

.rec {
  background: var(--sf);
  backdrop-filter: blur(10px);
  border: 1px solid var(--ln);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 5px
}

.wl {
  display: grid;
  gap: 8px
}

.wt {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  background: var(--sf);
  border: 1px solid var(--ln);
  border-radius: 12px;
  padding: 10px 12px
}

.wt.done {
  opacity: .5
}

.wt h3 {
  font-size: 15px;
  font-weight: 700
}

.wr {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px
}

.wr b {
  font: italic 800 16px var(--disp)
}

/* График */
.chart {
  position: relative;
  margin: 0 -4px
}

.tip {
  position: absolute;
  pointer-events: none;
  background: rgba(12, 12, 16, .96);
  border: 1px solid rgba(255, 255, 255, .14);
  color: #fff;
  border-radius: 12px;
  padding: 8px 12px;
  font-size: 12px;
  display: grid;
  gap: 2px;
  min-width: 130px;
  max-width: 240px;
  transform: translate(-50%, calc(-100% - 14px));
  z-index: 20;
  backdrop-filter: blur(10px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, .6)
}

.tip.l {
  transform: translate(-8%, calc(-100% - 14px))
}

.tip.r {
  transform: translate(-92%, calc(-100% - 14px))
}

.tip b {
  font-weight: 600;
  font-size: 12.5px
}

.tip span {
  font: italic 800 15px var(--disp);
  margin: 1px 0
}

.tip small {
  opacity: .55;
  font-size: 10.5px
}

/* Окна и диалоги */
dialog {
  margin: auto;
  position: fixed;
  border: 1px solid var(--ln);
  border-radius: 18px;
  padding: 0;
  width: min(460px, 96vw);
  max-height: 92vh;
  background: var(--dlg);
  color: var(--ink);
  box-shadow: 0 30px 90px rgba(0, 0, 0, .75)
}

dialog::backdrop {
  background: rgba(0, 0, 0, .68);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px)
}

.dl {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  max-height: inherit
}

.dl h2 {
  font: 800 18px Onest, sans-serif;
  text-transform: uppercase;
  letter-spacing: .01em;
  margin: 0;
  padding-right: 34px
}

.dl h2[data-k]::before {
  content: attr(data-k);
  display: block;
  font: 700 10.5px Onest, sans-serif;
  letter-spacing: .16em;
  color: var(--tag);
  margin-bottom: 3px
}

.x {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 0;
  background: var(--soft);
  color: var(--ink);
  font-size: 18px;
  line-height: 1;
  padding: 0;
  z-index: 5
}

.x:hover {
  background: rgba(255, 255, 255, .16)
}

.dl .acts [data-a=close] {
  display: none
}

.dl>.acts {
  margin-top: 4px
}

.dl>.acts .btn:not(.ghost) {
  flex: 1;
  padding: 8px
}

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

label {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 11.5px;
  color: var(--mut)
}

.fa {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 4px
}

.fa>span {
  font-size: 11.5px;
  color: var(--mut);
  min-width: 72px
}

.fl {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap
}

.fbtn {
  flex-direction: row;
  align-items: center;
  display: inline-flex;
  padding: 5px 11px;
  border-radius: 8px;
  background: var(--soft);
  border: 1px dashed rgba(255, 255, 255, .28);
  color: var(--ink);
  font-size: 12.5px;
  cursor: pointer
}

.fbtn:hover {
  border-color: var(--tag)
}

.calc {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  background: rgba(255, 176, 20, .12);
  border: 1px solid rgba(255, 176, 20, .4);
  border-radius: 10px;
  padding: 7px 12px;
  font-size: 13px
}

.calc b {
  font: italic 800 17px var(--disp);
  color: var(--tag)
}

.calc.neg {
  background: rgba(255, 93, 82, .1);
  border-color: rgba(255, 93, 82, .4)
}

.calc.neg b {
  color: var(--bad)
}

.thumbs {
  display: flex;
  gap: 7px;
  flex-wrap: wrap
}

.thumbs div {
  width: 48px;
  height: 48px;
  background: center/cover;
  border: 1px solid var(--ln);
  position: relative;
  border-radius: 8px
}

.thumbs div button {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 0;
  background: var(--bad);
  color: #fff;
  line-height: 1;
  padding: 0;
  font-size: 13px
}

.pksel {
  display: flex;
  align-items: center;
  gap: 9px;
  background: var(--soft);
  border: 1px solid var(--ln);
  border-radius: 10px;
  padding: 6px 9px
}

.pksel img {
  width: 40px;
  height: 40px;
  object-fit: contain
}

.pksel>div {
  flex: 1;
  min-width: 0
}

.pkg {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 7px;
  max-height: 56vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch
}

.pki {
  background: var(--soft);
  border: 1px solid var(--ln);
  border-radius: 9px;
  padding: 5px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  color: var(--mut);
  line-height: 1.2;
  text-align: center
}

.pki img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain
}

.pki:hover,
.pki.on {
  border-color: var(--tag);
  color: var(--ink)
}

#dlg2 {
  width: min(640px, 96vw)
}

#dlg2.wide {
  width: min(1100px, 96vw)
}

.lb {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 14px
}

.lb img {
  max-width: 100%;
  max-height: 78vh;
  border-radius: 10px;
  object-fit: contain
}

/* Профиль */
.pf {
  text-align: center;
  gap: 8px
}

.pfh {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 170px;
  margin: -18px -18px 6px;
  border-bottom: 3px solid var(--tag);
  border-radius: 18px 18px 0 0;
  overflow: hidden;
  position: relative;
  background: url('images/profile-bg.png') center/cover no-repeat
}

.pfh::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(8, 8, 11, .62);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px)
}

.pfh img {
  position: relative;
  z-index: 1;
  height: 95%;
  width: auto;
  max-width: 100%;
  object-fit: contain;
  object-position: top center;
  filter: drop-shadow(0 4px 16px rgba(0, 0, 0, .7))
}

.pfh b {
  position: relative;
  z-index: 1;
  align-self: center;
  font: italic 800 64px var(--disp);
  color: rgba(255, 255, 255, .25)
}

.pf h2 {
  padding: 0;
  font-size: 22px
}

.pb {
  height: 6px;
  background: var(--soft);
  border-radius: 9px;
  overflow: hidden
}

.pb i {
  display: block;
  height: 100%;
  background: var(--tag);
  border-radius: 9px
}

.pfg {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
  text-align: left
}

.pt {
  background: var(--soft);
  border: 1px solid var(--ln);
  border-radius: 10px;
  padding: 6px 9px;
  min-width: 0
}

.pt span {
  display: block;
  font-size: 10.5px;
  color: var(--mut)
}

.pt b {
  font: italic 800 15px var(--disp);
  overflow-wrap: anywhere
}

.auth {
  width: calc(100% - 32px);
  max-width: 350px;
  margin: 8vh auto;
  background: var(--dlg);
  border: 1px solid var(--ln);
  border-radius: 18px;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 10px
}

.auth .logo {
  font-size: 26px;
  padding: 0
}

.auth .mark {
  width: 30px;
  height: 22px
}

.err {
  color: var(--bad);
  font-size: 13px;
  min-height: 16px
}

.err:empty {
  min-height: 0
}

.empty {
  padding: 44px 0;
  text-align: center;
  color: var(--mut);
  max-width: 420px;
  margin: 0 auto
}

#cats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  width: 100%;
  overflow: visible
}

#cats button {
  padding: 6px 4px;
  font-size: 12.5px;
  text-align: center;
  width: 100%
}

#pksf {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin: 2px 0 6px
}

#pksf button {
  background: var(--soft);
  border: 1px solid var(--ln);
  border-radius: 8px;
  padding: 4px 11px;
  font-weight: 600;
  font-size: 12px;
  color: var(--ink);
  white-space: nowrap;
  cursor: pointer;
  transition: border-color .15s, background .15s
}

#pksf button:hover {
  border-color: rgba(255, 255, 255, .3)
}

#pksf button.on {
  background: var(--tag);
  color: #1a1204;
  border-color: var(--tag)
}

#pkw:empty,
#attrs:empty {
  display: none
}

.pf>.acts .btn {
  flex: 1
}

.tx-thumb {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--soft) center/contain no-repeat;
  flex-shrink: 0;
  border: 1px solid var(--ln)
}

.tx-item {
  display: flex;
  align-items: center;
  gap: 9px
}

.tx-item h4 {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.25
}

.tx-user {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600
}

/* Проданное: адаптивный список (режим таблицы) */
.sold-list {
  display: flex;
  flex-direction: column;
  gap: 6px
}

.sold-head {
  display: grid;
  grid-template-columns: minmax(140px, 2fr) 140px 140px 175px 200px;
  gap: 12px;
  padding: 8px 14px;
  color: var(--mut);
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  border-bottom: 1px solid var(--ln);
  min-width: 820px
}

.sold-head .r {
  text-align: right
}

.sold-item {
  display: grid;
  grid-template-columns: minmax(140px, 2fr) 140px 140px 175px 200px;
  gap: 12px;
  align-items: center;
  padding: 10px 14px;
  background: var(--dlg);
  border: 1px solid var(--ln);
  border-radius: 12px;
  transition: background .15s;
  min-width: 820px
}

.sold-item:hover {
  background: var(--soft)
}

.sold-main {
  grid-column: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0
}

.sold-info {
  min-width: 0;
  flex: 1
}

.sold-info h4 {
  font-size: 13.5px;
  margin: 0 0 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap
}

.sold-profit-m {
  display: none
}

.sold-flow {
  display: none
}

.sold-col-buy {
  grid-column: 2
}

.sold-col-sell {
  grid-column: 3
}

.sold-col-profit {
  grid-column: 4
}

.sold-col {
  font-size: 12.5px;
  text-align: right
}

.sold-col-profit b {
  font-size: 13px
}

.sold-acts {
  grid-column: 5;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
  flex-wrap: wrap
}

/* ==============================================================
   КЕЙСЫ — ОПТОВАЯ ТОРГОВЛЯ
   ============================================================== */

.case-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(68px, 1fr));
  gap: 6px;
  max-height: 240px;
  overflow-y: auto;
  overflow-x: hidden;
  width: 100%
}

.case-item {
  background: var(--soft);
  border: 1px solid var(--ln);
  border-radius: 9px;
  padding: 5px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  color: var(--mut);
  text-align: center;
  cursor: pointer;
  transition: border-color .15s
}

.case-item img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain
}

.case-item:hover,
.case-item.on {
  border-color: var(--tag);
  color: var(--ink)
}

.case-item.on {
  background: rgba(255, 195, 0, .08)
}

.case-sell-info {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  background: var(--soft);
  border: 1px solid var(--ln);
  border-radius: 12px;
  padding: 10px 14px;
  text-align: center
}

.case-sell-info div {
  display: flex;
  flex-direction: column;
  gap: 2px
}

.case-sell-info span {
  font-size: 10.5px;
  color: var(--mut)
}

.case-sell-info b {
  font-size: 14px;
  font-weight: 800
}

.case-banner {
  background: rgba(255, 195, 0, .08);
  border: 1px solid rgba(255, 195, 0, .25);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 13px;
  display: flex;
  flex-direction: column;
  gap: 6px
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px
}

.chip-btn {
  background: var(--soft);
  border: 1px solid var(--ln);
  border-radius: 7px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap
}

.chip-btn:hover {
  border-color: rgba(255, 255, 255, .3)
}

.spec.bold {
  font-weight: 800;
  font-size: 13px
}

/* ==============================================================
   АДАПТИВНОСТЬ ПОД МОБИЛЬНЫЕ УСТРОЙСТВА
   ============================================================== */

@media(max-width:640px) {
  .wrap {
    padding: 0 10px
  }

  header .wrap {
    gap: 8px;
    padding-top: 6px;
    padding-bottom: 2px
  }

  .logo {
    font-size: 18px
  }

  .logo small {
    display: none
  }

  .me {
    margin-left: auto;
    margin-bottom: 0;
    padding: 2px 8px 2px 3px;
    font-size: 12px
  }

  #inst {
    padding: 2px 8px;
    font-size: 12px
  }

  header nav {
    order: 3;
    width: 100%;
    margin: 0;
    gap: 12px;
    padding-bottom: 2px
  }

  header nav button {
    padding: 6px 2px 5px;
    font-size: 13.5px
  }

  main {
    padding: 10px 0 16px
  }

  /* Сводка на мобиле */
  .sum {
    padding: 8px 10px;
    margin-bottom: 10px;
    gap: 6px
  }

  .sum span {
    font-size: 10px
  }

  .sum b {
    font-size: 15px
  }

  /* Панели фильтров */
  .bar {
    gap: 6px;
    margin-bottom: 8px
  }

  .bar .grow {
    width: 100%;
    flex: 1 1 100%;
    min-width: 100%
  }

  .bar select {
    flex: 1 1 calc(50% - 4px);
    min-width: 120px;
    font-size: 13px;
    padding: 6px 8px
  }

  .seg {
    gap: 4px
  }

  .seg.big button {
    padding: 5px 12px;
    font-size: 13px
  }

  .seg button {
    padding: 4px 9px;
    font-size: 12px
  }

  .push {
    margin-left: 0
  }

  /* Сетка карточек */
  .grid {
    grid-template-columns: 1fr;
    gap: 12px
  }

  .ph {
    height: 112px
  }

  .in {
    padding: 20px 10px 10px;
    gap: 6px
  }

  .tagp {
    top: -16px;
    right: 8px;
    padding: 3px 10px 3px 17px
  }

  .tagp b {
    font-size: 14.5px
  }

  .money {
    gap: 10px;
    padding-top: 6px
  }

  .money b {
    font-size: 13px
  }

  .money .l {
    font-size: 10px
  }

  /* Проданное в режиме списка: мобильные аккуратные плашки без горизонтального скролла */
  .sold-list {
    overflow-x: visible;
    gap: 8px
  }

  .sold-head {
    display: none !important
  }

  /* каждая строка → вертикальная карточка */
  .sold-item {
    display: flex !important;
    flex-direction: column !important;
    gap: 0 !important;
    padding: 0 !important;
    border-radius: 14px;
    min-width: 0 !important;
    overflow: hidden
  }

  /* верхняя строка: картинка + инфо + прибыль-бейдж */
  .sold-main {
    grid-column: unset !important;
    display: flex !important;
    flex-direction: row !important;
    align-items: flex-start;
    justify-content: space-between;
    gap: 9px;
    width: 100%;
    padding: 10px 12px 8px;
    box-sizing: border-box
  }

  /* thumbnail: фиксированный размер, не сжимается */
  .sold-main .tx-thumb {
    width: 42px !important;
    height: 42px !important;
    border-radius: 9px !important;
    flex-shrink: 0 !important;
    flex-grow: 0 !important;
    display: block !important
  }

  /* инфо-блок — растягивается, не переполняется */
  .sold-info {
    flex: 1 1 0;
    min-width: 0
  }

  /* бейдж прибыли — правый верхний угол */
  .sold-profit-m {
    display: flex !important;
    flex-direction: column;
    align-items: flex-end;
    text-align: right;
    flex-shrink: 0;
    padding-top: 1px;
    max-width: 40%
  }

  .sold-profit-val {
    font: italic 800 14px/1.1 var(--disp);
    word-break: break-all
  }

  /* скрываем десктопные числовые колонки */
  .sold-col-buy {
    grid-column: unset !important;
    display: none !important
  }

  .sold-col-sell {
    grid-column: unset !important;
    display: none !important
  }

  .sold-col-profit {
    grid-column: unset !important;
    display: none !important
  }

  .sold-col {
    display: none !important
  }

  /* строка цены: Купил → Продал */
  .sold-flow {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 255, 255, .04);
    border-top: 1px solid var(--ln);
    border-radius: 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
    padding: 7px 12px;
    font-size: 12px;
    gap: 6px;
    width: 100%;
    box-sizing: border-box;
    flex-wrap: wrap
  }

  .sold-flow-part {
    display: flex;
    align-items: baseline;
    gap: 4px
  }

  .sold-flow-arrow {
    color: var(--mut);
    font-weight: 700;
    font-size: 14px
  }

  .sold-lbl {
    color: var(--mut);
    font-size: 11px
  }

  /* кнопки действий — нижняя полоса */
  .sold-acts {
    grid-column: unset !important;
    display: flex !important;
    gap: 5px;
    width: 100%;
    padding: 7px 10px 9px;
    border-top: 1px solid var(--ln);
    margin-top: 0 !important;
    flex-wrap: nowrap;
    box-sizing: border-box
  }

  .sold-acts .btn {
    flex: 1;
    text-align: center;
    padding: 6px 4px;
    font-size: 11.5px;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis
  }

  .sold-acts [data-a="del"] {
    flex: 0 0 36px;
    padding: 6px 0;
    font-size: 13px
  }

  /* Таблицы транзакций на мобиле */
  .scroll table {
    min-width: 480px
  }

  th,
  td {
    padding: 6px 4px;
    font-size: 12px
  }

  th {
    font-size: 11px
  }

  .tx-thumb {
    width: 30px;
    height: 30px;
    border-radius: 6px
  }

  .tx-item {
    gap: 7px
  }

  .tx-item h4 {
    font-size: 12.5px;
    max-width: 130px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap
  }

  .tx-user {
    font-size: 11.5px;
    gap: 4px
  }

  .tx-user .av {
    width: 20px;
    height: 20px;
    font-size: 9.5px;
    margin-right: 0
  }

  /* KPI карточки: ровная сетка 2 на 2 */
  .kpis {
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
    margin-bottom: 10px
  }

  .kpi {
    padding: 7px 9px;
    border-radius: 10px
  }

  .kpi span {
    font-size: 10.5px
  }

  .kpi b {
    font-size: 14.5px
  }

  /* Окна / Bottom Sheet на мобиле */
  dialog {
    width: 100vw;
    max-width: 100vw;
    max-height: 88vh;
    border-radius: 18px 18px 0 0;
    top: auto;
    bottom: 0;
    margin: 0
  }

  dialog[open] {
    animation: sheetUp .2s cubic-bezier(.16, 1, .3, 1)
  }

  .dl {
    padding: 14px 14px calc(16px + env(safe-area-inset-bottom));
    gap: 8px
  }

  .dl h2 {
    font-size: 17px
  }

  .row {
    grid-template-columns: 1fr;
    gap: 6px
  }

  .pkg {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    max-height: 50vh
  }

  .pki {
    padding: 4px;
    font-size: 10px
  }

  #pksf {
    gap: 4px;
    margin: 2px 0 4px
  }

  #pksf button {
    padding: 3px 8px;
    font-size: 11px
  }

  /* Профиль */
  .pfg {
    grid-template-columns: repeat(2, 1fr);
    gap: 5px
  }

  .pfh {
    height: 145px
  }

  .pt {
    padding: 5px 7px
  }

  .pt b {
    font-size: 13.5px
  }

  /* Авторизация */
  .auth {
    padding: 18px 14px;
    margin: 5vh auto;
    border-radius: 14px
  }

  #cats {
    grid-template-columns: repeat(4, 1fr);
    gap: 5px;
  }
}

@media(max-width:380px) {
  .sum b {
    font-size: 13.5px
  }

  .kpi b {
    font-size: 13px
  }

  .kpi span {
    font-size: 9.5px
  }

  .pkg {
    grid-template-columns: repeat(2, 1fr)
  }

  #cats {
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
  }

  #cats button {
    font-size: 11px;
    padding: 5px 2px
  }
}

@keyframes sheetUp {
  from {
    transform: translateY(100%)
  }

  to {
    transform: translateY(0)
  }
}

\n@keyframes pop {
  from {
    transform: translateY(8px);
    opacity: 0
  }
}

\n@media(min-width:641px) and (prefers-reduced-motion:no-preference) {
  dialog[open] {
    animation: pop .14s ease-out
  }
}