:root {
  --bg: #0b0a1a;
  --bg2: #12112a;
  --card: rgba(255, 255, 255, .055);
  --card2: rgba(255, 255, 255, .09);
  --line: rgba(255, 255, 255, .09);
  --text: #f3f2ff;
  --muted: #9a98c0;
  --violet: #a78bfa;
  --cyan: #4fd8ff;
  --green: #4ade80;
  --red: #ff6b7a;
  --gold: #ffd166;
  --grad: linear-gradient(135deg, #8b5cf6 0%, #4fd8ff 100%);
  --radius: 18px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.4 -apple-system, "SF Pro Text", "Segoe UI", Roboto, sans-serif; }
body::before {
  content: ""; position: fixed; inset: -20% -20% auto; height: 70vh; z-index: -1;
  background: radial-gradient(closest-side, rgba(139, 92, 246, .28), transparent 70%),
              radial-gradient(closest-side at 80% 30%, rgba(79, 216, 255, .16), transparent 70%);
  filter: blur(10px);
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
#app { max-width: 640px; margin: 0 auto; min-height: 100vh; padding-bottom: calc(78px + var(--safe-b)); }

/* шапка */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: rgba(11, 10, 26, .82); backdrop-filter: blur(16px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 18px; letter-spacing: .2px; }
.logo { font-size: 22px; filter: drop-shadow(0 0 10px rgba(255, 209, 102, .5)); }
.brand-name { background: linear-gradient(90deg, #ffe08a, #ffb347); -webkit-background-clip: text; background-clip: text; color: transparent; }
.bar { color: var(--violet); -webkit-text-fill-color: var(--violet); padding: 0 1px; }
.top-status { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; max-width: 62%; }
.dot { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; color: var(--muted); padding: 3px 8px;
  border-radius: 99px; background: var(--card); }
.dot i { width: 7px; height: 7px; border-radius: 50%; background: var(--red); box-shadow: 0 0 8px var(--red); }
.dot.ok i { background: var(--green); box-shadow: 0 0 8px var(--green); }

/* нижние вкладки */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-template-columns: repeat(4, 1fr);
  max-width: 640px; margin: 0 auto; padding: 6px 6px calc(6px + var(--safe-b));
  background: rgba(14, 13, 32, .9); backdrop-filter: blur(18px); border-top: 1px solid var(--line); }
.tabs button { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; border-radius: 14px;
  color: var(--muted); font-size: 11px; font-weight: 600; transition: .2s; }
.tabs .ti { font-size: 20px; filter: grayscale(.7); transition: .2s; }
.tabs button.active { color: var(--text); background: var(--card); }
.tabs button.active .ti { filter: none; transform: translateY(-1px) scale(1.08); }

main { padding: 14px 14px 0; }
h2 { margin: 6px 2px 12px; font-size: 22px; font-weight: 800; }
.sub { color: var(--muted); font-size: 13px; margin: -6px 2px 12px; }

/* общие элементы */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 10px; }
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 12px 16px; border-radius: 14px;
  font-weight: 700; background: var(--card2); transition: transform .1s, opacity .2s; }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--grad); color: #0b0a1a; box-shadow: 0 6px 22px rgba(139, 92, 246, .35); }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn.danger { background: rgba(255, 107, 122, .14); color: var(--red); }
.btn.block { width: 100%; }
.btn.sm { padding: 8px 12px; font-size: 13px; border-radius: 12px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 10px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; padding: 8px 14px; border-radius: 99px; background: var(--card); border: 1px solid var(--line);
  font-size: 13px; font-weight: 600; color: var(--muted); }
.chip.on { background: rgba(167, 139, 250, .18); border-color: rgba(167, 139, 250, .55); color: var(--text); }
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 99px; font-size: 11.5px;
  font-weight: 700; background: var(--card2); color: var(--muted); }
.tag.green { background: rgba(74, 222, 128, .14); color: var(--green); }
.tag.violet { background: rgba(167, 139, 250, .16); color: var(--violet); }
.tag.gold { background: rgba(255, 209, 102, .14); color: var(--gold); }
.tag.red { background: rgba(255, 107, 122, .14); color: var(--red); }
.mk-tonnel { color: #4fd8ff; } .mk-mrkt { color: #ffd166; } .mk-portals { color: #a78bfa; }
.mk-fragment { color: #ff9f6b; } .mk-telegram { color: #5ec8ff; }
.input { width: 100%; padding: 12px 14px; border-radius: 14px; background: rgba(0, 0, 0, .25); border: 1px solid var(--line);
  outline: none; transition: border-color .2s; }
.input:focus { border-color: var(--violet); }
label.lbl { display: block; font-size: 12.5px; color: var(--muted); font-weight: 600; margin: 12px 2px 6px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty .big { font-size: 44px; margin-bottom: 8px; }
.skeleton { height: 96px; border-radius: var(--radius); margin-bottom: 10px;
  background: linear-gradient(90deg, var(--card) 0%, var(--card2) 50%, var(--card) 100%); background-size: 200% 100%;
  animation: sk 1.2s infinite; }
@keyframes sk { to { background-position: -200% 0; } }

/* переключатель */
.switch { position: relative; width: 48px; height: 28px; flex: none; }
.switch input { display: none; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: rgba(255, 255, 255, .14); transition: .2s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%;
  background: #fff; transition: .2s; box-shadow: 0 2px 6px rgba(0, 0, 0, .3); }
.switch input:checked + span { background: var(--grad); }
.switch input:checked + span::after { transform: translateX(20px); }

/* лента */
.nft { display: flex; gap: 12px; padding: 12px; animation: pop .35s ease; }
@keyframes pop { from { transform: translateY(8px); } }
.nft .img { width: 84px; height: 84px; flex: none; border-radius: 16px; background: var(--card2) center/cover no-repeat;
  display: grid; place-items: center; font-size: 34px; overflow: hidden; }
.nft .img img { width: 100%; height: 100%; object-fit: cover; }
.nft .name { font-weight: 800; font-size: 15.5px; }
.price { font-weight: 800; font-size: 17px; }
.price small { font-size: 11px; color: var(--muted); font-weight: 700; margin-left: 2px; }
.attrs { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 12px; color: var(--muted); margin: 4px 0 6px; }
.attrs b { color: var(--text); font-weight: 600; }
.new-pill { position: sticky; top: 64px; z-index: 10; margin: 0 auto 10px; display: block; }

/* фильтры */
.fcard .fname { font-weight: 800; font-size: 16px; }
.fsum { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.factions { display: flex; gap: 8px; margin-top: 12px; }
.tpl { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px; }
.tpl button { text-align: left; padding: 12px; border-radius: 16px; background: var(--card); border: 1px solid var(--line); }
.tpl b { display: block; font-size: 13.5px; } .tpl span { font-size: 11.5px; color: var(--muted); }
.pick { display: flex; align-items: center; gap: 10px; width: 100%; padding: 12px 14px; border-radius: 14px;
  background: rgba(0, 0, 0, .22); border: 1px solid var(--line); text-align: left; }
.pick .v { color: var(--muted); font-size: 13px; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; border-radius: 14px; background: rgba(0, 0, 0, .25); }
.seg button { padding: 9px 4px; border-radius: 10px; font-size: 13px; font-weight: 700; color: var(--muted); }
.seg button.on { background: var(--card2); color: var(--text); }
.testbox { margin-top: 12px; }

/* нижний лист выбора */
.sheet { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .55); display: flex; align-items: flex-end;
  animation: fade .2s; }
.sheet.hidden { display: none; }
@keyframes fade { from { opacity: 0; } }
.sheet-body { width: 100%; max-width: 640px; margin: 0 auto; max-height: 86vh; display: flex; flex-direction: column;
  background: var(--bg2); border-radius: 24px 24px 0 0; border: 1px solid var(--line); animation: up .25s ease;
  padding-bottom: var(--safe-b); }
@keyframes up { from { transform: translateY(40px); opacity: .4; } }
.sheet-head { padding: 14px 16px 10px; border-bottom: 1px solid var(--line); }
.sheet-head .grab { width: 40px; height: 4px; border-radius: 4px; background: var(--line); margin: 0 auto 10px; }
.sheet-list { overflow-y: auto; padding: 6px 10px; flex: 1; }
.opt { display: flex; align-items: center; gap: 12px; width: 100%; padding: 9px 8px; border-radius: 12px; text-align: left; }
.opt:active { background: var(--card); }
.opt .th { width: 40px; height: 40px; border-radius: 10px; background: var(--card2) center/cover no-repeat; flex: none; }
.opt .ck { margin-left: auto; width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--line); display: grid;
  place-items: center; font-size: 13px; flex: none; }
.opt.on .ck { background: var(--grad); border-color: transparent; color: #0b0a1a; font-weight: 900; }
.sheet-foot { padding: 10px 14px 14px; border-top: 1px solid var(--line); display: flex; gap: 8px; }

/* флоры */
.floor { display: flex; align-items: center; gap: 12px; padding: 10px 12px; }
.floor .th { width: 46px; height: 46px; border-radius: 12px; background: var(--card2) center/cover no-repeat; flex: none; }
.fm { display: flex; flex-wrap: wrap; gap: 2px 10px; font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.fm span.best { color: var(--green); font-weight: 700; }

/* калькулятор */
.kv { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.kv:last-child { border-bottom: 0; }
.feetable { width: 100%; border-collapse: collapse; font-size: 13px; }
.feetable td, .feetable th { padding: 8px 4px; border-bottom: 1px solid var(--line); text-align: left; }
.feetable th { color: var(--muted); font-weight: 600; font-size: 12px; }

/* профиль */
.hero { display: flex; align-items: center; gap: 14px; }
.avatar { width: 58px; height: 58px; border-radius: 50%; background: var(--grad); display: grid; place-items: center;
  font-size: 26px; font-weight: 900; color: #0b0a1a; flex: none; }
.stats3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; }
.stat { text-align: center; padding: 10px 4px; border-radius: 14px; background: rgba(0, 0, 0, .22); }
.stat b { display: block; font-size: 20px; } .stat span { font-size: 11px; color: var(--muted); }
.setrow { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.setrow:last-child { border-bottom: 0; }

.toast { position: fixed; left: 50%; bottom: calc(92px + var(--safe-b)); transform: translateX(-50%); z-index: 60;
  padding: 10px 16px; border-radius: 14px; background: #1f1d3d; border: 1px solid var(--line); font-weight: 600;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .4); max-width: 90vw; animation: up .2s; }
.toast.hidden { display: none; }
.gate { text-align: center; padding: 60px 24px; }
.gate .big { font-size: 56px; }

/* аналитика */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.tile { padding: 12px 14px; border-radius: 16px; background: var(--card); border: 1px solid var(--line); }
.tile span { display: block; font-size: 12px; color: var(--muted); }
.tile b { font-size: 22px; font-weight: 800; }
.mbar { display: grid; grid-template-columns: 64px 1fr auto; align-items: center; gap: 8px; margin-top: 10px; font-size: 13px; }
.mtrack { height: 10px; border-radius: 6px; background: rgba(255, 255, 255, .06); overflow: hidden; }
.mtrack i { display: block; height: 100%; border-radius: 6px; }
.mv { color: var(--muted); font-size: 12px; white-space: nowrap; }
.th.big { width: 56px; height: 56px; border-radius: 14px; background: var(--card2) center/cover no-repeat; flex: none; }
.chart { margin-top: 8px; }
.cwrap { position: relative; }
.svgc { width: 100%; height: auto; display: block; overflow: visible; }
.svgc .grid { stroke: rgba(255, 255, 255, .07); stroke-width: 1; }
.svgc .ax { fill: var(--muted); font-size: 10px; }
.svgc .xh { stroke: rgba(255, 255, 255, .35); stroke-width: 1; stroke-dasharray: 3 3; }
.svgc .bar { fill: #8662ec; }
.svgc .bar:hover { fill: #a78bfa; }
.tip { position: absolute; top: 0; min-width: 110px; padding: 8px 10px; border-radius: 12px; background: #1f1d3d;
  border: 1px solid var(--line); font-size: 12px; pointer-events: none; box-shadow: 0 8px 24px rgba(0, 0, 0, .4); }
.tip div { display: flex; align-items: center; gap: 5px; margin-top: 3px; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.legend > span { display: inline-flex; align-items: center; gap: 5px; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; flex: none; }
.agg td, .agg th { padding: 7px 3px; font-size: 12px; }
.agg th { white-space: nowrap; }
.agg td.best { color: var(--green); font-weight: 700; }
.sale { padding: 8px 0; border-bottom: 1px solid var(--line); }
.sale:last-child { border-bottom: 0; }
.sale .th { width: 40px; height: 40px; border-radius: 10px; background: var(--card2) center/cover no-repeat; flex: none; }
/* кабинет */
.plans { display: grid; gap: 8px; }
.plan { padding: 12px; border-radius: 16px; background: rgba(0, 0, 0, .22); border: 1px solid var(--line); }
.brand-name { white-space: nowrap; }
.top { gap: 10px; }
.top-status { gap: 3px; max-width: 58%; }
.top-status .dot { padding: 2px 6px; font-size: 10px; }
.hscroll { overflow-x: auto; margin: 0 -4px; padding: 0 4px; }
.agg { min-width: 420px; }

/* плашка «нет связи» (туннель сменил адрес или сервер недоступен) */
.netbar { position: fixed; left: 12px; right: 12px; top: calc(10px + env(safe-area-inset-top, 0px)); z-index: 80;
  background: #1b1530; border: 1px solid rgba(255, 107, 122, .45); border-radius: 16px; padding: 14px;
  box-shadow: 0 12px 34px rgba(0, 0, 0, .5); }
.netbar .nb-t { font-weight: 700; margin-bottom: 4px; }
.netbar .nb-s { color: var(--muted); font-size: 13px; line-height: 1.35; }
.netbar .nb-b { display: flex; gap: 8px; margin-top: 10px; justify-content: flex-end; }

/* оценка подарка */
.gq .input { margin: 0; }
.gimg { width: 96px; height: 96px; flex: 0 0 96px; border-radius: 20px; overflow: hidden; background: var(--card);
  display: flex; align-items: center; justify-content: center; font-size: 36px; }
.gimg img { width: 100%; height: 100%; object-fit: cover; }
.gest { background: var(--grad); color: #0b0a1a; border: 0; }
.gest .small { color: #0b0a1a; }
.gfair { font-size: 30px; font-weight: 800; letter-spacing: -.5px; margin-top: 2px; }
.gfair small { font-size: 15px; font-weight: 700; }
.mdot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.agg.gtab { min-width: 0; width: 100%; margin-top: 8px; }
.agg.gtab td, .agg.gtab th { text-align: right; }
.agg.gtab td:first-child, .agg.gtab th:first-child { text-align: left; white-space: nowrap; }

/* избранное */
.wrow { padding: 8px 0; }
.wrow .th { width: 42px; height: 42px; border-radius: 11px; background: var(--card2) center/cover no-repeat; flex: none; }
.wth { width: 48px; height: 48px; border-radius: 12px; flex: none; background: var(--card) center/cover no-repeat; }
.btn.sm { white-space: nowrap; }
