:root {
  --bg: #050505;
  --card: #0e0e10;
  --card2: #141417;
  --line: #222226;
  --line2: #1a1a1d;
  --text: #f4f4f5;
  --muted: #8b8b94;
  --accent: #8b7bff;
  --accent-d: #5f4bff;
  --cyan: #38bdf8;
  --ok: #34d399;
  --bad: #f87171;
  --r: 18px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
}
body { min-height: 100vh; padding-bottom: calc(96px + env(safe-area-inset-bottom)); overflow-x: hidden; }
button { font: inherit; color: inherit; cursor: pointer; }

/* фон */
.bg-glow {
  position: fixed; left: -30%; right: -30%; top: -25vh; height: 70vh; z-index: 0; pointer-events: none;
  background:
    radial-gradient(closest-side at 35% 50%, rgba(139, 123, 255, .20), transparent 70%),
    radial-gradient(closest-side at 70% 40%, rgba(56, 189, 248, .10), transparent 70%);
  filter: blur(30px);
  animation: drift 14s ease-in-out infinite alternate;
}
@keyframes drift { to { transform: translate3d(4%, 5vh, 0) scale(1.08); } }

/* шапка */
header.top { position: relative; z-index: 1; padding: 20px 16px 8px; }
.logo { font-weight: 800; font-size: 21px; letter-spacing: .4px; display: flex; align-items: center; gap: 10px; }
.eye {
  width: 12px; height: 12px; border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 0 4px rgba(139, 123, 255, .15), 0 0 18px var(--accent);
  animation: pulse 2.4s ease-in-out infinite;
}
@keyframes pulse { 50% { transform: scale(.75); opacity: .55; } }
.sub { color: var(--muted); font-size: 13px; margin-top: 2px; }

main { position: relative; z-index: 1; padding: 8px 16px; }
.page { display: none; }
.page.active { display: block; animation: pageIn .4s var(--ease); }
@keyframes pageIn { from { opacity: 0; transform: translateY(12px); } }
.page-title { font-size: 22px; font-weight: 700; margin: 6px 0 4px; }

/* поиск */
.search-card {
  background: linear-gradient(180deg, var(--card2), var(--card));
  border: 1px solid var(--line); border-radius: var(--r); padding: 12px;
  box-shadow: 0 20px 50px -30px rgba(139, 123, 255, .35);
}
.input-wrap { display: flex; gap: 8px; }
#q {
  flex: 1; min-width: 0; background: #09090a; border: 1px solid var(--line); border-radius: 14px;
  color: var(--text); padding: 13px 14px; font-size: 16px; outline: none;
  transition: border-color .25s, box-shadow .25s;
}
#q::placeholder { color: #5c5c64; }
#q:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(139, 123, 255, .14); }
.go {
  width: 52px; flex: none; border: 0; border-radius: 14px; color: #fff; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-d));
  box-shadow: 0 8px 24px -8px rgba(95, 75, 255, .7);
  transition: transform .15s var(--ease), filter .2s;
}
.go svg { width: 22px; height: 22px; }
.go:active { transform: scale(.9); filter: brightness(1.15); }
.chips { display: flex; gap: 6px; overflow-x: auto; margin-top: 10px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; padding: 7px 13px; border-radius: 999px; border: 1px solid var(--line);
  background: transparent; color: var(--muted); font-size: 13px;
  transition: background .25s var(--ease), color .25s, border-color .25s, transform .15s;
}
.chip:active { transform: scale(.94); }
.chip.on { background: var(--text); color: #000; border-color: var(--text); }

/* примеры */
.hint { color: var(--muted); font-size: 13px; margin: 18px 2px 8px; }
.examples { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ex {
  display: flex; align-items: center; gap: 8px; padding: 12px; border-radius: 14px;
  background: var(--card); border: 1px solid var(--line); font: 13px var(--mono); text-align: left;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  opacity: 0; animation: cardIn .5s var(--ease) forwards;
  transition: border-color .2s, transform .15s;
}
.ex:nth-child(2) { animation-delay: 60ms; } .ex:nth-child(3) { animation-delay: 120ms; } .ex:nth-child(4) { animation-delay: 180ms; }
.ex:active { transform: scale(.97); border-color: var(--accent); }
.ex span { font-family: initial; }

/* карточки */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px;
  margin-top: 12px; opacity: 0; transform: translateY(14px);
  animation: cardIn .55s var(--ease) forwards;
}
@keyframes cardIn { to { opacity: 1; transform: none; } }
.card h3 {
  margin: 0 0 8px; font-size: 12px; color: var(--muted); font-weight: 600;
  display: flex; gap: 8px; align-items: center; text-transform: uppercase; letter-spacing: .7px;
}
.card h3 span { font-size: 15px; }
.card p { margin: 0; color: var(--muted); font-size: 14px; }
.card.error { border-color: rgba(248, 113, 113, .35); color: var(--bad); }
.row { display: flex; justify-content: space-between; gap: 14px; padding: 10px 0; border-top: 1px solid var(--line2); }
.row:first-of-type { border-top: 0; }
.row .k { color: var(--muted); flex: none; max-width: 48%; font-size: 14px; }
.row .v { text-align: right; word-break: break-word; font: 13px/1.5 var(--mono); }
.row .v a { color: var(--cyan); text-decoration: none; }
.bullets { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tag {
  font: 12px var(--mono); padding: 6px 9px; border-radius: 9px; background: var(--card2);
  border: 1px solid var(--line); transition: border-color .2s;
}
.tag:active { border-color: var(--accent); }

.hero { position: relative; overflow: hidden; }
.hero::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, .05) 50%, transparent 70%);
  transform: translateX(-100%); animation: shine 1.4s .3s var(--ease) forwards;
}
@keyframes shine { to { transform: translateX(100%); } }
.badge {
  display: inline-block; font-size: 11px; font-weight: 600; padding: 4px 9px; border-radius: 7px;
  background: rgba(139, 123, 255, .14); color: #c0b6ff; text-transform: uppercase; letter-spacing: .7px;
}
.hero .q { font: 600 20px/1.3 var(--mono); margin-top: 10px; word-break: break-all; }
.hero .meta { color: var(--muted); font-size: 13px; margin-top: 4px; }
.actions { display: flex; gap: 8px; margin-top: 14px; }
.btn {
  flex: 1; padding: 12px; border-radius: 13px; border: 1px solid var(--line); background: var(--card2);
  font-size: 14px; transition: transform .15s var(--ease), background .2s;
}
.btn:active { transform: scale(.96); background: #1b1b1f; }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent-d)); border: 0; color: #fff; }

/* загрузка */
.scan-wrap { text-align: center; padding: 24px 0 4px; }
.scanner {
  position: relative; width: 132px; height: 132px; margin: 0 auto 14px; border-radius: 50%;
  border: 1px solid var(--line); background: radial-gradient(circle, rgba(139, 123, 255, .10), transparent 70%);
}
.scanner::before {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  background: conic-gradient(from 0deg, rgba(139, 123, 255, .6), transparent 28%);
  animation: spin 1.3s linear infinite;
}
.scanner::after { content: ""; position: absolute; inset: 22px; border-radius: 50%; border: 1px dashed #2c2c33; }
.scanner i {
  position: absolute; width: 6px; height: 6px; border-radius: 50%; background: var(--cyan);
  box-shadow: 0 0 10px var(--cyan); animation: blip 1.3s ease-out infinite;
}
.scanner i:nth-child(1) { top: 30%; left: 62%; }
.scanner i:nth-child(2) { top: 64%; left: 30%; animation-delay: .45s; }
.scanner i:nth-child(3) { top: 48%; left: 78%; animation-delay: .9s; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes blip { 0% { opacity: 0; transform: scale(.4); } 30% { opacity: 1; transform: scale(1); } 100% { opacity: 0; } }
.scan-text { color: var(--muted); font-size: 14px; }
.skeleton {
  height: 86px; border-radius: var(--r); margin-top: 12px; border: 1px solid var(--line2);
  background: linear-gradient(90deg, #0d0d0f 0%, #17171a 50%, #0d0d0f 100%); background-size: 200% 100%;
  animation: shimmer 1.2s linear infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* граф */
.graph-head { display: flex; justify-content: space-between; align-items: center; margin: 6px 0 10px; }
.graph-head .title { font-size: 22px; font-weight: 700; }
.icon-btn {
  width: 42px; height: 42px; border-radius: 12px; border: 1px solid var(--line); background: var(--card);
  display: grid; place-items: center; transition: transform .15s;
}
.icon-btn:active { transform: scale(.92); }
.icon-btn svg { width: 20px; height: 20px; }
#cy {
  height: calc(100vh - 250px); min-height: 320px; border: 1px solid var(--line); border-radius: var(--r);
  background: radial-gradient(circle at 50% 40%, #0d0d12, #060607 70%);
}
.empty { text-align: center; color: var(--muted); padding: 60px 20px; }
.empty-ico { font-size: 38px; margin-bottom: 10px; opacity: .8; }

/* история */
.hist {
  width: 100%; display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; gap: 4px 10px;
  align-items: center; text-align: left; padding: 13px 14px; margin-top: 8px; border-radius: 15px;
  background: var(--card); border: 1px solid var(--line);
  opacity: 0; animation: cardIn .45s var(--ease) forwards; transition: transform .15s, border-color .2s;
}
.hist:active { transform: scale(.98); border-color: var(--accent); }
.hist .badge { grid-row: 1 / 3; }
.hist .hq { font: 14px var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hist .ht { color: var(--muted); font-size: 12px; }

/* профиль */
.profile-head { display: flex; align-items: center; gap: 14px; }
.avatar {
  width: 58px; height: 58px; border-radius: 50%; flex: none; display: grid; place-items: center;
  font-size: 24px; font-weight: 700; background: linear-gradient(135deg, var(--accent), var(--cyan)); color: #000;
  background-size: cover; background-position: center;
}
.pname { font-size: 18px; font-weight: 700; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.stat { background: var(--card2); border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.stat b { display: block; font-size: 22px; }
.stat span { color: var(--muted); font-size: 12px; }

/* нижнее меню */
nav.tabs {
  position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 5;
  display: flex; padding: 6px; border-radius: 22px;
  background: rgba(14, 14, 16, .78); backdrop-filter: blur(18px) saturate(1.4); -webkit-backdrop-filter: blur(18px) saturate(1.4);
  border: 1px solid var(--line); box-shadow: 0 10px 40px -10px rgba(0, 0, 0, .8);
}
.tab-ind {
  position: absolute; top: 6px; bottom: 6px; left: 6px; border-radius: 16px; background: #1c1c20;
  transition: transform .4s var(--ease), width .4s var(--ease);
}
.tab {
  position: relative; flex: 1; border: 0; background: none; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 11px; padding: 8px 0;
  transition: color .25s;
}
.tab svg { width: 22px; height: 22px; transition: transform .3s var(--ease); }
.tab.on { color: var(--text); }
.tab.on svg { transform: translateY(-1px) scale(1.08); }

/* нижний лист */
#sheet-bg { position: fixed; inset: 0; z-index: 20; background: rgba(0, 0, 0, .55); opacity: 0; pointer-events: none; transition: opacity .3s; }
#sheet-bg.show { opacity: 1; pointer-events: auto; }
#sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 21; padding: 10px 16px calc(20px + env(safe-area-inset-bottom));
  background: #101013; border-top: 1px solid var(--line); border-radius: 22px 22px 0 0;
  transform: translateY(105%); transition: transform .4s var(--ease);
}
#sheet.show { transform: none; }
.grab { width: 40px; height: 4px; border-radius: 4px; background: #333; margin: 0 auto 14px; }
.sheet-type { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .7px; }
.sheet-val { font: 600 17px/1.4 var(--mono); margin-top: 6px; word-break: break-all; }

/* уведомление */
#toast {
  position: fixed; left: 50%; bottom: calc(100px + env(safe-area-inset-bottom)); z-index: 30;
  transform: translate(-50%, 16px); opacity: 0; pointer-events: none;
  background: #1c1c20; border: 1px solid var(--line); padding: 10px 16px; border-radius: 12px; font-size: 13px;
  transition: opacity .3s var(--ease), transform .3s var(--ease);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

.shot { padding: 0; overflow: hidden; }
.shot img { display: block; width: 100%; height: auto; }
.btn:disabled { opacity: .6; }

/* админка */
.tab[hidden] { display: none; }
.seg { display: flex; gap: 6px; overflow-x: auto; margin: 10px 0 2px; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg button {
  flex: none; padding: 8px 13px; border-radius: 11px; border: 1px solid var(--line); background: var(--card);
  color: var(--muted); font-size: 13px; transition: all .25s var(--ease);
}
.seg button.on { background: var(--text); color: #000; border-color: var(--text); }
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.kpi {
  background: linear-gradient(180deg, var(--card2), var(--card)); border: 1px solid var(--line); border-radius: 16px; padding: 14px;
  opacity: 0; animation: cardIn .5s var(--ease) forwards;
}
.kpi b { display: block; font-size: 26px; font-weight: 700; letter-spacing: -.5px; }
.kpi span { color: var(--muted); font-size: 12px; }
.bar { display: flex; align-items: center; gap: 10px; padding: 7px 0; font-size: 14px; }
.bar .lbl { width: 92px; flex: none; color: var(--muted); }
.bar .track { flex: 1; height: 8px; border-radius: 6px; background: #17171a; overflow: hidden; }
.bar .fill { height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--accent-d), var(--accent)); width: 0; transition: width .9s var(--ease); }
.bar .n { width: 40px; text-align: right; font: 13px var(--mono); }
.field { display: flex; gap: 8px; margin-top: 12px; }
.field input, .field textarea {
  flex: 1; min-width: 0; background: #09090a; border: 1px solid var(--line); border-radius: 13px; color: var(--text);
  padding: 12px 13px; font-size: 15px; outline: none; transition: border-color .25s, box-shadow .25s; font-family: inherit;
}
.field textarea { min-height: 120px; resize: vertical; }
.field input:focus, .field textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(139, 123, 255, .14); }
.field .btn { flex: none; }
.person {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; margin-top: 8px; border-radius: 15px;
  background: var(--card); border: 1px solid var(--line); opacity: 0; animation: cardIn .45s var(--ease) forwards;
}
.person .ava {
  width: 38px; height: 38px; border-radius: 50%; flex: none; display: grid; place-items: center; font-weight: 700;
  background: #1c1c22; color: var(--accent);
}
.person .info { flex: 1; min-width: 0; }
.person .nm { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person .ds { color: var(--muted); font: 12px var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini {
  flex: none; padding: 8px 11px; border-radius: 10px; border: 1px solid var(--line); background: var(--card2); font-size: 12px;
  transition: transform .15s, background .2s;
}
.mini:active { transform: scale(.94); }
.mini.danger { color: var(--bad); border-color: rgba(248, 113, 113, .3); }
.mini.ok { color: var(--ok); border-color: rgba(52, 211, 153, .3); }
.pill { font-size: 10px; padding: 2px 6px; border-radius: 5px; margin-left: 6px; vertical-align: middle; text-transform: uppercase; letter-spacing: .5px; }
.pill.own { background: rgba(251, 191, 36, .15); color: #fbbf24; }
.pill.adm { background: rgba(139, 123, 255, .15); color: #c0b6ff; }
.pill.ban { background: rgba(248, 113, 113, .15); color: var(--bad); }
.more { width: 100%; margin-top: 10px; }

@media (prefers-reduced-motion: reduce) {
  .kpi, .person { opacity: 1; transform: none; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .card, .ex, .hist { opacity: 1; transform: none; }
}
