:root {
  --bg: #08090c;
  --bg2: #0f1116;
  --card: #14171d;
  --line: rgba(255, 255, 255, 0.08);
  --line2: rgba(255, 255, 255, 0.14);
  --text: #f2f3f5;
  --muted: #8d939e;
  --ember: #ff5a36;
  --ember2: #ff8a3d;
  --live: #34e39a;
  --warn: #ffc046;
  --glass: rgba(14, 16, 21, 0.72);
  --r: 20px;
  --display: 'Unbounded', 'Manrope', system-ui, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 500 16px/1.45 'Manrope', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
a { color: inherit; text-decoration: none; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--ember); outline-offset: 3px; }

/* ---------- общее ---------- */
#app { min-height: 100%; }
.boot { height: 100vh; display: grid; place-items: center; }
.home, .page {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: max(20px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.page.center { align-items: center; text-align: center; justify-content: center; position: relative; }
.page.center .tl { position: absolute; top: max(20px, env(safe-area-inset-top)); left: 20px; }
.h1 { font: 600 28px/1.15 var(--display); letter-spacing: -0.01em; }
.sub { color: var(--muted); max-width: 34ch; }
.hint { color: var(--muted); font-size: 13px; }
.err { color: #ff7b66; font-size: 14px; min-height: 20px; }

.brand { display: flex; align-items: center; gap: 12px; padding: 6px 0 14px; }
.brand b { font: 600 22px var(--display); letter-spacing: -0.01em; }
.logo { width: 34px; height: 34px; border-radius: 11px; background: #15100e; display: grid; place-items: center; position: relative; box-shadow: inset 0 0 0 1px rgba(255, 90, 54, 0.25); }
.logo i { width: 10px; height: 10px; border-radius: 50%; background: var(--ember); box-shadow: 0 0 0 5px rgba(255, 90, 54, 0.22), 0 0 0 10px rgba(255, 90, 54, 0.08); }
.boot .logo { width: 56px; height: 56px; border-radius: 18px; animation: breathe 1.6s ease-in-out infinite; }
@keyframes breathe { 50% { transform: scale(0.92); opacity: 0.7; } }

/* ---------- кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  height: 54px; padding: 0 22px; border-radius: 16px; font-weight: 700; font-size: 16px;
  transition: transform 0.15s, background 0.2s, opacity 0.2s;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.6; }
.btn-wide { width: 100%; }
.btn-primary { background: linear-gradient(180deg, var(--ember2), var(--ember)); color: #1a0702; box-shadow: 0 10px 30px -10px rgba(255, 90, 54, 0.6); }
.btn-ghost { background: var(--card); box-shadow: inset 0 0 0 1px var(--line); }
.btn-danger { background: rgba(255, 70, 50, 0.1); color: #ff7b66; }
.ibtn { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; flex: none; }
.ibtn.ghost { background: var(--card); box-shadow: inset 0 0 0 1px var(--line); }
.ibtn[aria-pressed='true'] { color: #4aa8ff; }

/* ---------- аватары ---------- */
.ava {
  width: 48px; height: 48px; border-radius: 50%; flex: none; overflow: hidden;
  display: grid; place-items: center; font: 600 19px var(--display); color: #fff;
  background: #2a2f3a;
}
.ava img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ava.sm { width: 38px; height: 38px; font-size: 15px; }
.ava.xl { width: 96px; height: 96px; font-size: 38px; }
.ava-0 { background: linear-gradient(140deg, #ff8a3d, #e5432a); }
.ava-1 { background: linear-gradient(140deg, #3ddc97, #1b8f6a); }
.ava-2 { background: linear-gradient(140deg, #4aa8ff, #2961d8); }
.ava-3 { background: linear-gradient(140deg, #ffc046, #e08a12); }
.ava-4 { background: linear-gradient(140deg, #ff6fa5, #c9356f); }
.ava-5 { background: linear-gradient(140deg, #9aa4b5, #5b6475); }

/* ---------- главная ---------- */
.people { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.card {
  display: flex; align-items: center; gap: 14px; padding: 14px 14px 14px 16px;
  background: var(--card); border-radius: var(--r); box-shadow: inset 0 0 0 1px var(--line);
  transition: transform 0.15s, background 0.2s;
}
.card:active { transform: scale(0.985); background: #181b22; }
.card-t { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.card-t b { font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-t small { color: var(--muted); font-size: 14px; }
.card-t .st-pending { color: var(--warn); }
.card-t .st-expired, .card-t .st-revoked { color: #ff7b66; }
.card > svg { color: var(--muted); }

.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 14px; padding: 30px 0 10px; flex: 1; justify-content: center; }
.radar { position: relative; width: 190px; height: 190px; margin-bottom: 10px; }
.radar.sm { width: 150px; height: 150px; }
.radar i { position: absolute; inset: 0; border-radius: 50%; border: 1.5px solid rgba(255, 90, 54, 0.5); animation: ping 3s cubic-bezier(0.2, 0.6, 0.3, 1) infinite; opacity: 0; }
.radar i:nth-child(2) { animation-delay: 1s; }
.radar i:nth-child(3) { animation-delay: 2s; }
.radar span { position: absolute; left: 50%; top: 50%; width: 18px; height: 18px; margin: -9px; border-radius: 50%; background: var(--ember); box-shadow: 0 0 24px 4px rgba(255, 90, 54, 0.55); }
@keyframes ping { 0% { transform: scale(0.15); opacity: 1; } 100% { transform: scale(1); opacity: 0; } }

.foot { margin-top: auto; padding-top: 18px; display: flex; flex-direction: column; gap: 12px; color: var(--muted); font-size: 13px; }
.foot p, .foot a { display: flex; gap: 10px; align-items: center; }
.foot svg { width: 18px; height: 18px; }
.foot a { color: var(--text); font-weight: 600; }

/* ---------- формы ---------- */
.form { display: flex; flex-direction: column; gap: 16px; width: 100%; }
.code {
  width: 100%; height: 76px; border-radius: 20px; text-align: center;
  background: var(--card); border: 0; box-shadow: inset 0 0 0 1px var(--line2);
  font: 600 30px var(--display); letter-spacing: 0.12em; text-transform: uppercase;
}
.code::placeholder { color: #3a3f4a; }
.code:focus, .inp:focus { outline: none; box-shadow: inset 0 0 0 2px var(--ember); }
.lbl { display: flex; flex-direction: column; gap: 8px; text-align: left; }
.lbl span { color: var(--muted); font-size: 14px; }
.inp { height: 54px; border-radius: 16px; padding: 0 16px; background: var(--card); border: 0; box-shadow: inset 0 0 0 1px var(--line2); }
.sas { font: 600 40px var(--display); letter-spacing: 0.06em; color: var(--ember); margin: 4px 0; }
.page.center .btn-ghost { margin-top: 24px; }

/* ---------- карта ---------- */
.mapv { position: fixed; inset: 0; overflow: hidden; }
#map { position: absolute; inset: 0; background: #1c1f26; }
.glass { background: var(--glass); backdrop-filter: blur(18px) saturate(1.4); -webkit-backdrop-filter: blur(18px) saturate(1.4); box-shadow: inset 0 0 0 1px var(--line), 0 12px 40px -12px rgba(0, 0, 0, 0.6); }
.topbar {
  position: absolute; top: max(12px, env(safe-area-inset-top)); left: 12px; right: 12px; z-index: 3;
  display: flex; align-items: center; gap: 6px; padding: 6px 14px 6px 6px; border-radius: 22px;
}
.who { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; text-align: left; padding: 2px; border-radius: 14px; }
.who > span { min-width: 0; display: flex; flex-direction: column; }
.who b { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who small { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: #4a505c; flex: none; transition: background 0.3s; }
.dot.live { background: var(--live); box-shadow: 0 0 0 4px rgba(52, 227, 154, 0.2); animation: blink 2s infinite; }
.dot.wait { background: var(--warn); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: 0.45; } }

.fabs { position: absolute; right: 12px; top: calc(max(12px, env(safe-area-inset-top)) + 72px); z-index: 2; display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.seg { display: flex; padding: 4px; border-radius: 15px; gap: 2px; }
.seg button { height: 34px; padding: 0 12px; border-radius: 11px; font-size: 13px; font-weight: 700; color: var(--muted); transition: background 0.2s, color 0.2s; }
.seg button.on { background: rgba(255, 255, 255, 0.12); color: var(--text); }
.fabs .ibtn { width: 48px; height: 48px; border-radius: 16px; }

.sheet {
  position: absolute; left: 12px; right: 12px; bottom: max(12px, env(safe-area-inset-bottom)); z-index: 3;
  border-radius: 26px; padding: 16px; display: flex; flex-direction: column; gap: 12px;
  max-width: 560px; margin: 0 auto;
}
.stats { display: grid; grid-template-columns: 1.3fr 1fr 1fr 1fr; gap: 8px; }
.stat { background: rgba(255, 255, 255, 0.05); border-radius: 16px; padding: 10px 8px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-width: 0; }
.stat b { font: 600 15px var(--display); white-space: nowrap; }
.stat.big b { font-size: 30px; line-height: 1; }
.stat small { color: var(--muted); font-size: 11px; }
.arrow { color: var(--ember); transition: transform 0.8s cubic-bezier(0.2, 0.7, 0.2, 1), opacity 0.3s; display: grid; }
.arrow svg { width: 18px; height: 18px; }
.arrow.off { opacity: 0.25; }
.meta { color: var(--muted); font-size: 13px; text-align: center; min-height: 18px; }

.track {
  position: relative; height: 64px; border-radius: 20px; overflow: hidden;
  background: linear-gradient(180deg, var(--ember2), var(--ember)); color: #1a0702;
  font-weight: 800; font-size: 17px; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 14px 36px -12px rgba(255, 90, 54, 0.75); transition: transform 0.15s, background 0.3s, color 0.3s, box-shadow 0.3s;
}
.track:active { transform: scale(0.98); }
.track span { position: relative; }
.track.on { background: #1d2028; color: var(--text); box-shadow: inset 0 0 0 1px var(--line2); }
.track .ring { position: absolute; inset: 0; opacity: 0; }
.track.busy .ring { opacity: 1; background: linear-gradient(90deg, transparent, rgba(255, 90, 54, 0.25), transparent); animation: sweep 1.3s linear infinite; }
@keyframes sweep { from { transform: translateX(-100%); } to { transform: translateX(100%); } }

/* метки на карте */
.pin { width: 54px; height: 54px; position: relative; }
.pin .pin-ava { width: 54px; height: 54px; font-size: 20px; position: relative; z-index: 2; box-shadow: 0 0 0 3px #fff, 0 8px 24px rgba(0, 0, 0, 0.45); }
.pin .pulse { position: absolute; inset: 0; border-radius: 50%; background: rgba(255, 90, 54, 0.45); animation: ping 2.2s ease-out infinite; z-index: 0; }
.pin .cone {
  position: absolute; left: 50%; top: 50%; width: 70px; height: 70px; z-index: 1; opacity: 0;
  transform-origin: 50% 100%; transform: translate(-50%, -100%);
  background: radial-gradient(circle at 50% 100%, rgba(255, 90, 54, 0.7), rgba(255, 90, 54, 0) 70%);
  clip-path: polygon(50% 100%, 18% 0, 82% 0); transition: transform 0.8s cubic-bezier(0.2, 0.7, 0.2, 1), opacity 0.3s;
}
.pin.moving .cone { opacity: 1; }
.me { width: 20px; height: 20px; border-radius: 50%; background: #4aa8ff; box-shadow: 0 0 0 4px #fff, 0 0 0 12px rgba(74, 168, 255, 0.25); }

/* окно правки */
.dlg {
  margin: auto; width: min(420px, calc(100% - 32px)); border: 0; border-radius: 26px; padding: 22px;
  background: var(--bg2); color: var(--text); box-shadow: inset 0 0 0 1px var(--line2), 0 30px 80px rgba(0, 0, 0, 0.6);
}
.dlg::backdrop { background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(4px); }
.pick { display: flex; flex-direction: column; align-items: center; gap: 10px; cursor: pointer; color: var(--ember); font-weight: 700; font-size: 14px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.maplibregl-ctrl-attrib { font-size: 10px; }
.maplibregl-ctrl-bottom-right { bottom: 230px; }

@media (min-width: 900px) {
  .sheet { left: 24px; right: auto; width: 420px; bottom: 24px; }
  .topbar { left: 24px; right: auto; width: 420px; top: 24px; }
  .fabs { top: 24px; right: 24px; }
  .maplibregl-ctrl-bottom-right { bottom: 0; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
