:root {
  --bg: #070707;
  --surface: #101012;
  --surface2: #18181c;
  --surface3: #202026;
  --line: #26262e;
  --text: #f2f2f4;
  --muted: #8b8b93;
  --dim: #55555e;
  --white: #ffffff;
  --radius: 16px;
  --shadow: 0 12px 40px rgba(0,0,0,.6);
  --glow: 0 0 18px rgba(255,255,255,.16);
  --glow-strong: 0 0 26px rgba(255,255,255,.28);
  --sans: "Manrope", -apple-system, "SF Pro Display", Roboto, "Segoe UI", system-ui, sans-serif;
  --mono: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  --ease: cubic-bezier(.22, 1, .36, 1);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; padding: 0; height: 100%; background: var(--bg); color: var(--text);
  font-family: var(--sans); font-feature-settings: "ss01", "cv01"; }
body { overscroll-behavior-y: none; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
svg { display: block; }
.hidden { display: none !important; }

.app { height: 100vh; height: 100dvh; display: flex; flex-direction: column; max-width: 560px; margin: 0 auto; }

/* ---------- animations ---------- */
@keyframes fadeUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { from { opacity: 0; transform: scale(.92); } to { opacity: 1; transform: scale(1); } }
@keyframes sheetUp { from { transform: translateY(40px); opacity: .3; } to { transform: none; opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes glowPulse {
  0%, 100% { box-shadow: 0 0 14px rgba(255,255,255,.10); }
  50% { box-shadow: 0 0 30px rgba(255,255,255,.26); }
}
@keyframes battPulse { 0%, 100% { opacity: .3; } 50% { opacity: .9; } }
@keyframes dotPulse { 0%, 100% { opacity: .5; } 50% { opacity: 1; } }
@keyframes shimmer { 0% { background-position: -120% 0; } 100% { background-position: 220% 0; } }

/* ---------- header ---------- */
.header {
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
  background: rgba(7,7,7,.88); backdrop-filter: blur(14px);
}
.header-main { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.brand { display: flex; align-items: center; gap: 11px; }
.logo {
  width: 38px; height: 38px; border-radius: 12px;
  background: linear-gradient(135deg, #fff, #b9b9c2);
  color: #070707; font-weight: 900; font-size: 20px;
  display: grid; place-items: center;
  animation: glowPulse 3.2s ease-in-out infinite;
}
.brand-title { font-weight: 800; font-size: 18px; letter-spacing: .3px; line-height: 1.1; }
.brand-sub { font-size: 12px; color: var(--muted); letter-spacing: .2px; }
.icon-btn {
  background: var(--surface); border: 1px solid var(--line); color: var(--muted);
  width: 38px; height: 38px; border-radius: 11px; cursor: pointer;
  display: grid; place-items: center;
  transition: color .2s, border-color .2s, box-shadow .2s, transform .15s;
}
.icon-btn:hover { color: var(--text); border-color: var(--dim); box-shadow: var(--glow); }
.icon-btn:active { transform: scale(.92); }

/* ---------- search ---------- */
.search-bar {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 13px; padding: 0 14px;
  transition: border-color .2s, box-shadow .2s;
}
.search-bar:focus-within { border-color: #6b6b75; box-shadow: 0 0 0 3px rgba(255,255,255,.07), var(--glow); }
.search-icon { color: var(--dim); }
.search-icon svg { width: 18px; height: 18px; }
input[type=search] { flex: 1; background: none; border: none; outline: none; color: var(--text);
  font-size: 15.5px; padding: 12px 0; min-width: 0; }
input[type=search]::placeholder { color: var(--dim); }
input[type=search]::-webkit-search-cancel-button { filter: invert(.6); }
.scan-btn {
  background: none; border: none; color: var(--muted); cursor: pointer;
  padding: 7px; margin-right: -8px; display: grid; place-items: center; border-radius: 9px;
  flex: 0 0 auto; transition: color .2s, box-shadow .2s, transform .15s;
}
.scan-btn:hover { color: var(--text); box-shadow: var(--glow); }
.scan-btn:active { transform: scale(.88); }
.scan-btn svg { width: 19px; height: 19px; }

/* ---------- content ---------- */
.content { flex: 1; overflow-y: auto; padding: 18px 16px calc(20px + env(safe-area-inset-bottom)); }

/* ---------- home / hero ---------- */
.home { display: flex; flex-direction: column; gap: 18px; padding-top: 6px; animation: fadeUp .5s var(--ease); }
.hero { text-align: center; padding: 26px 10px 6px; }
.hero-em {
  width: 92px; height: 92px; margin: 0 auto 20px; border-radius: 28px;
  background: radial-gradient(circle at 50% 40%, #23232a, #0c0c0f 70%);
  border: 1px solid var(--line); display: grid; place-items: center;
  color: var(--white);
  animation: glowPulse 3.2s ease-in-out infinite;
  transition: transform .3s var(--ease);
}
.hero-em:hover { transform: translateY(-3px) scale(1.03); }
.hero-em svg { width: 48px; height: 48px; filter: drop-shadow(0 0 8px rgba(255,255,255,.45)); }
.hero h2 { margin: 0 0 8px; font-size: 25px; letter-spacing: -.3px; font-weight: 800; }
.hero p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.55; }
.hero p b { color: var(--text); font-weight: 700; }
.hint-card {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; padding: 14px 16px; font-size: 13.5px; color: var(--muted); line-height: 1.5;
  animation: fadeUp .5s var(--ease) .08s backwards;
}
.hint-ic { color: var(--dim); }
.hint-ic svg { width: 18px; height: 18px; }

/* ---------- lookup / results ---------- */
.lookup-status { color: var(--muted); font-size: 13px; text-align: center; margin: 22px 0 14px; animation: fadeIn .3s; }
.results { display: grid; gap: 12px; }
.sc-item {
  display: flex; align-items: center; gap: 13px;
  background: var(--surface2); border: 1px solid var(--line);
  border-radius: 16px; padding: 14px 16px; cursor: pointer;
  animation: fadeUp .45s var(--ease) backwards;
  transition: transform .18s var(--ease), border-color .2s, box-shadow .2s, background .2s;
}
.sc-item:nth-child(1) { animation-delay: 0s; }
.sc-item:nth-child(2) { animation-delay: .05s; }
.sc-item:nth-child(3) { animation-delay: .1s; }
.sc-item:nth-child(4) { animation-delay: .15s; }
.sc-item:nth-child(n+5) { animation-delay: .2s; }
.sc-item:hover { background: var(--surface3); border-color: #3a3a44; box-shadow: var(--glow); }
.sc-item:active { transform: scale(.98); }
.sc-pin { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; flex: 0 0 auto; color: var(--muted); }
.sc-pin.pin-active { background: rgba(255,255,255,.1); color: var(--white); box-shadow: var(--glow); }
.sc-pin.pin-idle { background: var(--surface3); color: var(--muted); }
.sc-info { flex: 1; min-width: 0; }
.sc-id { font-weight: 800; font-size: 16px; letter-spacing: .3px; }
.sc-line { color: var(--muted); font-size: 12.5px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sc-right { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; flex: 0 0 auto; }
.ic-warn { color: var(--white); filter: drop-shadow(0 0 5px rgba(255,255,255,.6)); animation: dotPulse 1.4s infinite; }

/* ---------- status vignette ---------- */
.vbadge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; padding: 2px 0; }
.vbdot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.vbadge-green { color: var(--text); } .vbadge-green .vbdot { background: var(--white); box-shadow: 0 0 8px rgba(255,255,255,.8); animation: dotPulse 1.8s infinite; }
.vbadge-red { color: var(--dim); } .vbadge-red .vbdot { background: var(--dim); }
.vbadge-idle { color: var(--muted); } .vbadge-idle .vbdot { background: var(--dim); }

/* ---------- battery icon ---------- */
.battery { display: inline-flex; align-items: center; gap: 7px; vertical-align: middle; }
.batt {
  position: relative; display: inline-block; width: 42px; height: 20px;
  border: 2px solid var(--text); border-radius: 5px; overflow: hidden;
}
.batt::after {  /* контакт-клемма */
  content: ""; position: absolute; right: -5px; top: 5px; width: 3px; height: 10px;
  border-radius: 0 2px 2px 0; background: var(--text);
}
.batt-fill {
  position: absolute; left: 2px; top: 2px; bottom: 2px; width: 0;
  border-radius: 2px; background: var(--white);
  box-shadow: 0 0 10px rgba(255,255,255,.55);
  transition: width .8s var(--ease);
}
.batt.mid .batt-fill { background: #c9c9d1; box-shadow: none; }
.batt.low { border-color: var(--dim); }
.batt.low::after { background: var(--dim); }
.batt.low .batt-fill { background: var(--dim); box-shadow: none; animation: battPulse 1.5s infinite; }
.batt-pct { font-variant-numeric: tabular-nums; font-weight: 700; }

/* ---------- modal card ---------- */
.modal { position: absolute; inset: 0; background: rgba(3,3,5,.62); backdrop-filter: blur(6px); z-index: 800; display: flex; align-items: flex-end; animation: fadeIn .25s; }
.modal-card {
  width: 100%; background: var(--surface); border-top: 1px solid var(--line);
  border-radius: 24px 24px 0 0; padding: 18px 18px calc(22px + env(safe-area-inset-bottom));
  box-shadow: 0 -12px 44px rgba(0,0,0,.65); max-height: 86%; overflow-y: auto;
  animation: sheetUp .34s var(--ease);
}
.modal-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; position: sticky; top: -18px; background: var(--surface); padding-top: 6px; }
.modal-close { background: var(--surface2); border: 1px solid var(--line); color: var(--muted);
  width: 32px; height: 32px; border-radius: 10px; cursor: pointer; display: grid; place-items: center;
  transition: color .2s, box-shadow .2s, transform .15s; }
.modal-close:hover { color: var(--text); box-shadow: var(--glow); }
.modal-close:active { transform: scale(.9); }
.modal-close svg { width: 17px; height: 17px; }
.modal-id { font-size: 19px; font-weight: 800; letter-spacing: .4px; flex: 1; }

.card-hero { display: flex; gap: 14px; margin-bottom: 18px; animation: fadeUp .4s var(--ease); }
.big-em { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; flex: 0 0 auto; transition: box-shadow .3s; }
.big-em.em-moving { background: linear-gradient(135deg, #2c2c34, #141417); color: var(--white); box-shadow: var(--glow); }
.big-em.em-idle { background: var(--surface2); color: var(--muted); }
.big-em svg { width: 30px; height: 30px; }
.card-hero h3 { margin: 2px 0 0; font-size: 20px; font-weight: 800; letter-spacing: .3px; }
.card-hero .sub { color: var(--muted); font-size: 13px; line-height: 1.6; }
.sub-badge { margin-top: 4px; }

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 18px; }
.stat {
  background: var(--surface2); border: 1px solid var(--line); border-radius: 14px; padding: 13px 14px;
  animation: popIn .35s var(--ease) backwards;
  transition: border-color .2s, box-shadow .2s;
}
.stat:nth-child(1) { animation-delay: .02s; } .stat:nth-child(2) { animation-delay: .07s; }
.stat:nth-child(3) { animation-delay: .12s; } .stat:nth-child(4) { animation-delay: .17s; }
.stat:hover { border-color: #3a3a44; box-shadow: var(--glow); }
.stat .v { font-size: 17px; font-weight: 800; }
.stat .k { font-size: 11.5px; color: var(--muted); margin-top: 3px; letter-spacing: .2px; text-transform: uppercase; }
.stat.col-span { grid-column: 1 / -1; }

.lock-row { display: inline-flex; align-items: center; gap: 6px; }
.lock-row .luc { color: var(--muted); }
.coords { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; }
.coords .ico { display: inline-flex; align-items: center; color: var(--muted); }
.map-link { color: var(--text); text-decoration: none; font-weight: 700; }
.coord { color: var(--muted); font-family: var(--mono); font-size: 11.5px; letter-spacing: .2px; }

/* ---------- controls: Скорость 25 full-width + 3 ниже ---------- */
.controls { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.ctrl {
  background: var(--surface2); border: 1px solid var(--line); border-radius: 15px;
  padding: 13px 8px; color: var(--text); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  transition: transform .16s var(--ease), border-color .2s, box-shadow .2s, background .2s;
  animation: popIn .35s var(--ease) backwards;
}
.ctrl:nth-child(1) { animation-delay: .2s; } .ctrl:nth-child(2) { animation-delay: .24s; }
.ctrl:nth-child(3) { animation-delay: .28s; } .ctrl:nth-child(4) { animation-delay: .32s; }
.ctrl:hover:not(:disabled) { background: var(--surface3); border-color: #45454f; box-shadow: var(--glow); transform: translateY(-2px); }
.ctrl:active:not(:disabled) { transform: scale(.94); }
.ctrl:disabled { opacity: .4; cursor: not-allowed; }
.ctrl .luc { color: var(--muted); }
.ctrl .cl { font-size: 12.5px; font-weight: 700; letter-spacing: .1px; }
.ctrl-hero {
  grid-column: 1 / -1;
  flex-direction: row; gap: 12px;
  padding: 16px 12px;
  background: linear-gradient(135deg, #ffffff, #d4d4dd);
  color: #070707; border: none;
  box-shadow: 0 4px 22px rgba(255,255,255,.18);
}
.ctrl-hero .luc, .ctrl-hero .cl { color: #070707; }
.ctrl-hero .cl { font-size: 15px; font-weight: 800; letter-spacing: .3px; }
.ctrl-hero:hover:not(:disabled) { box-shadow: 0 6px 30px rgba(255,255,255,.32); transform: translateY(-2px); }
.ctrl-hero:active:not(:disabled) { transform: scale(.97); }

/* ---------- QR scanner ---------- */
#scan-modal { align-items: center; justify-content: center; background: rgba(2,2,4,.85); backdrop-filter: blur(8px); }
.scan-card {
  width: calc(100% - 32px); max-width: 430px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 24px; overflow: hidden;
  box-shadow: var(--shadow), var(--glow-strong);
  animation: popIn .32s var(--ease);
}
.scan-head { display: flex; align-items: center; gap: 12px; padding: 16px 16px 6px; }
.scan-title { font-weight: 800; font-size: 16px; letter-spacing: .2px; flex: 1; }
.scan-body { padding: 12px 16px 18px; }
.scan-viewport {
  position: relative; aspect-ratio: 1 / 1; border-radius: 18px; overflow: hidden;
  background: #000;
}
#scan-video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scan-frame {
  position: absolute; inset: 11%; width: 78%; height: 78%; pointer-events: none;
  filter: drop-shadow(0 0 7px rgba(255,255,255,.85));
}
.scan-line {
  position: absolute; left: 13%; right: 13%; top: 11%; height: 2px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.95), transparent);
  box-shadow: 0 0 14px rgba(255,255,255,.9);
  opacity: 0; pointer-events: none;
}
.scan-viewport.scanning .scan-line { opacity: 1; animation: scanMove 2.6s ease-in-out infinite; }
@keyframes scanMove {
  0%, 100% { top: 11%; }
  50% { top: calc(89% - 2px); }
}
.scan-hint { text-align: center; color: var(--muted); font-size: 13.5px; margin-top: 14px; line-height: 1.55; }
.scan-hint.error { color: #cfcfd6; }
.scan-hint.ok { color: var(--white); font-weight: 700; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%);
  background: var(--surface3); color: var(--text); padding: 12px 18px; border-radius: 13px;
  box-shadow: var(--shadow), var(--glow); font-size: 13.5px; z-index: 900;
  border: 1px solid #3a3a44; max-width: 88%;
  animation: toastIn .3s var(--ease);
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 14px); } to { opacity: 1; transform: translate(-50%,0); } }

/* ---------- splash ---------- */
.splash { position: fixed; inset: 0; display: flex; flex-direction: column; gap: 16px;
  align-items: center; justify-content: center; background: var(--bg); z-index: 1000; color: var(--muted); }
.splash p { margin: 0; font-size: 14px; letter-spacing: .2px; }
.spinner {
  width: 42px; height: 42px; border-radius: 50%;
  border: 2px solid var(--line); border-top-color: var(--white);
  box-shadow: 0 0 16px rgba(255,255,255,.15);
  animation: spin .9s linear infinite;
}

/* ---------- misc ---------- */
.luc, .search-icon svg, .hint-ic svg, .modal-close svg { display: inline-block; vertical-align: middle; }
.empty { text-align: center; color: var(--muted); padding: 34px 0; font-size: 14px; animation: fadeIn .3s; }