/* =========================================================
   RustWarden — дизайн «Карта»: графит + малиновый.
   Главный экран — живая карта, управление в выдвижном листе.
   Шрифты: Barlow Condensed (заголовки), Barlow (текст), JetBrains Mono (цифры).
   ========================================================= */
:root {
  --bg: #1f2024;
  --bg2: #25272b;
  --card: #2a2b30;
  --card2: #34363c;
  --line: #3a3c42;
  --line2: #4a4c53;
  --text: #f1efe9;
  --muted: #a39f97;
  --dim: #6f6c66;
  --sig: #dc1f44;          /* малиновый: действие, активно, внимание */
  --sig-rgb: 220, 31, 68;
  --sig-ink: #ffffff;
  --ok: #7fe3a0;           /* зелёный: в сети, связь есть */
  --ok-rgb: 127, 227, 160;
  --threat: #ff4d6a;       /* тревога */
  --threat-rgb: 255, 77, 106;
  --warn: #f0b429;         /* внимание: ночь, АФК, не проверено */
  --warn-rgb: 240, 180, 41;
  --info: #9ec3ff;
  --violet: #c58cff;
  /* старые имена — для совместимости модулей */
  --amber: var(--sig); --amber2: var(--sig); --red: var(--threat); --green: var(--ok); --blue: var(--info);
  --r: 16px;
  --sans: 'Barlow', system-ui, -apple-system, sans-serif;
  --display: 'Barlow Condensed', 'Barlow', system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --dock-h: 66px;
  --ease: cubic-bezier(.2, .8, .2, 1);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 var(--sans); }
body { min-height: 100vh; overscroll-behavior: none; }
/* лёгкое зерно бетона на фоне */
body::before { content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 0; opacity: .5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .05 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E"); }
body > * { position: relative; z-index: 1; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--sig); }
h1, h2, h3 { font-family: var(--display); font-weight: 800; margin: 0; text-transform: uppercase; letter-spacing: .01em; line-height: 1.05; }
h1 { font-size: 26px; }
.row > h1 { flex: 1; min-width: 0; }
.row > .btn { flex: none; }
h2 { font-size: 22px; }
h3 { font-size: 17px; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.small { font-size: 13px; }
.cap { font: 700 10.5px var(--mono); letter-spacing: .18em; text-transform: uppercase; color: var(--muted); }
[hidden] { display: none !important; }
svg.i { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
svg.i.sm { width: 16px; height: 16px; }
svg.i.lg { width: 24px; height: 24px; }
::selection { background: rgba(var(--sig-rgb), .4); }

/* появление экрана */
#view > * { animation: fadeUp .35s var(--ease) both; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } }

/* ---------- шапка ---------- */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 16px 10px; background: rgba(31, 32, 36, .9); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
body.mapmode .top { display: none; } /* на карте своя шапка-оверлей */
.server-btn { display: flex; flex-direction: column; align-items: flex-start; background: none; border: 0; padding: 0; cursor: pointer; min-width: 0; text-align: left; }
.server-btn .cap { color: var(--sig); }
.server-btn .name { display: flex; align-items: center; gap: 6px; font: 800 22px var(--display); text-transform: uppercase; max-width: 62vw; }
.server-btn .name span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.link-chip { display: flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 6px; font: 600 11px var(--mono); letter-spacing: .08em; white-space: nowrap;
  background: var(--card); border: 1px solid var(--line2); color: var(--muted); }
.link-chip.on { background: rgba(var(--ok-rgb), .1); border-color: rgba(var(--ok-rgb), .4); color: var(--ok); }
.link-chip.err { background: rgba(var(--threat-rgb), .1); border-color: rgba(var(--threat-rgb), .4); color: var(--threat); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--dim); flex: none; }
.dot.on { background: var(--ok); box-shadow: 0 0 8px rgba(var(--ok-rgb), .7); animation: blink 2s ease-in-out infinite; }
.dot.err { background: var(--threat); }
.dot.warn { background: var(--warn); }
@keyframes blink { 50% { opacity: .35; } }

/* ---------- док-навигация ---------- */
main { padding: 10px 16px calc(var(--dock-h) + 24px + var(--safe-b)); max-width: 760px; margin: 0 auto; }
main.full { padding: 0; max-width: none; }
.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; height: calc(var(--dock-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: center;
  background: #1c1d21; border-top: 1px solid var(--line); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
}
.dock a { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; height: var(--dock-h); color: var(--muted); text-decoration: none; transition: color .2s; }
.dock a svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform .25s var(--ease); }
.dock a .lab { font: 700 9.5px var(--mono); letter-spacing: .12em; text-transform: uppercase; }
.dock a.active { color: var(--sig); }
.dock a.active svg { transform: translateY(-2px); }
.dock a.active::before { content: ''; position: absolute; top: 0; left: 28%; right: 28%; height: 3px; background: var(--sig); border-radius: 0 0 3px 3px; box-shadow: 0 2px 10px rgba(var(--sig-rgb), .6); }
.dock a:active svg { transform: scale(.9); }
.dock .badge-dot { position: absolute; top: 12px; right: calc(50% - 16px); width: 8px; height: 8px; border-radius: 50%; background: var(--threat); box-shadow: 0 0 8px var(--threat); animation: blink 1s steps(2) infinite; }

/* ---------- карточки и элементы ---------- */
.card { background: linear-gradient(180deg, var(--card), #27282d); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; margin-bottom: 12px; box-shadow: 0 8px 24px rgba(0, 0, 0, .25), inset 0 1px 0 rgba(255, 255, 255, .04); }
.card.flat { background: var(--bg2); box-shadow: none; }
.card.threat { background: linear-gradient(180deg, #3a2027, #2a2024); border-color: rgba(var(--threat-rgb), .5); }
.card.sig { background: rgba(var(--sig-rgb), .08); border-color: rgba(var(--sig-rgb), .4); }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 8px; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 20px 2px 10px; }
.section-title h2 { font: 700 11px var(--mono); letter-spacing: .2em; text-transform: uppercase; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.section-title h2::before { content: ''; width: 14px; height: 3px; background: var(--sig); border-radius: 2px; }
.section-title .cap { color: var(--sig); text-decoration: none; }

/* сетка показателей */
.kv { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; margin-bottom: 12px; }
.kv > div { background: var(--card); padding: 10px 12px; min-width: 0; }
.kv small { display: block; font: 700 9.5px var(--mono); letter-spacing: .18em; text-transform: uppercase; color: var(--muted); }
.kv b { display: block; font: 800 24px var(--display); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: .01em; }
.kv .small { font-size: 12px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 44px;
  border: 1px solid var(--line2); background: var(--card2); border-radius: 12px; padding: 10px 16px; cursor: pointer;
  font: 700 14px var(--display); text-transform: uppercase; letter-spacing: .06em; text-decoration: none; color: var(--text); white-space: nowrap;
  transition: transform .12s var(--ease), background .2s, border-color .2s;
}
.btn:active:not(:disabled) { transform: scale(.97); }
.btn.primary { background: var(--sig); color: var(--sig-ink); border-color: transparent; box-shadow: 0 6px 18px rgba(var(--sig-rgb), .35); }
.btn.danger { color: var(--threat); border-color: rgba(var(--threat-rgb), .4); background: transparent; }
.btn.danger-fill { background: var(--threat); color: #fff; border-color: transparent; }
.btn.ghost { background: transparent; }
.btn.sm { min-height: 34px; padding: 6px 12px; font-size: 13px; border-radius: 9px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chip { flex: none; border: 1px solid var(--line2); background: var(--card); border-radius: 9px; padding: 7px 13px; font: 700 13px var(--display); text-transform: uppercase; letter-spacing: .05em; color: var(--muted); cursor: pointer; transition: all .2s; }
.chip.on { color: var(--sig-ink); background: var(--sig); border-color: transparent; }

input.f, select.f, textarea.f {
  width: 100%; background: var(--bg2); border: 1px solid var(--line2); border-radius: 10px; padding: 11px 13px; outline: none; transition: border-color .2s, box-shadow .2s;
  font: 15px var(--sans); color: var(--text);
}
input.f::placeholder, textarea.f::placeholder { color: var(--dim); }
input.f:focus, select.f:focus, textarea.f:focus { border-color: var(--sig); box-shadow: 0 0 0 3px rgba(var(--sig-rgb), .18); }
label.lbl { display: block; font: 700 10.5px var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin: 12px 0 6px; }

.switch { position: relative; width: 48px; height: 28px; flex: none; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch i { position: absolute; inset: 0; background: var(--line2); border-radius: 99px; transition: .2s; box-shadow: inset 0 1px 3px rgba(0, 0, 0, .5); }
.switch i::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #c9c6bf; transition: .22s var(--ease); box-shadow: 0 2px 4px rgba(0, 0, 0, .4); }
.switch input:checked + i { background: var(--sig); box-shadow: inset 0 1px 3px rgba(0, 0, 0, .3), 0 0 12px rgba(var(--sig-rgb), .4); }
.switch input:checked + i::after { transform: translateX(20px); background: #fff; }
.switch input:focus-visible + i { outline: 2px solid var(--sig); outline-offset: 2px; }

.list { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; margin-bottom: 12px; }
.item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-top: 1px solid var(--line); min-height: 52px; }
.item:first-child { border-top: 0; }
.item .grow { flex: 1; min-width: 0; }
.item .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .s { font-size: 13px; color: var(--muted); }
.item.tap { cursor: pointer; transition: background .15s; }
.item.tap:active { background: var(--card2); }
.ico { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; background: var(--card2); color: var(--muted); flex: none; font-size: 17px; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .05); }
.ico svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ico.amber, .ico.sig { background: rgba(var(--sig-rgb), .14); color: var(--sig); }
.ico.red { background: rgba(var(--threat-rgb), .14); color: var(--threat); }
.ico.green { background: rgba(var(--ok-rgb), .12); color: var(--ok); }
.ico.blue { background: rgba(158, 195, 255, .14); color: var(--info); }
.ico.warn { background: rgba(var(--warn-rgb), .14); color: var(--warn); }
.badge { font: 700 10.5px var(--mono); letter-spacing: .1em; padding: 3px 8px; border-radius: 5px; background: var(--card2); color: var(--muted); white-space: nowrap; text-transform: uppercase; }
.badge.on { background: rgba(var(--ok-rgb), .14); color: var(--ok); }
.badge.red { background: var(--threat); color: #fff; animation: blink 1.2s steps(2) infinite; }
.badge.amber, .badge.warn { background: rgba(var(--warn-rgb), .16); color: var(--warn); }

.empty { text-align: center; padding: 34px 16px; color: var(--muted); }
.empty .big { width: 56px; height: 56px; margin: 0 auto 10px; border-radius: 16px; display: grid; place-items: center; background: var(--card); border: 1px solid var(--line); color: var(--sig); font-size: 22px; }
.empty .big svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2; }
.steps { counter-reset: s; list-style: none; padding: 0; margin: 10px 0 0; }
.steps li { counter-increment: s; position: relative; padding: 0 0 14px 40px; }
.steps li::before { content: counter(s); position: absolute; left: 0; top: -2px; width: 28px; height: 28px; border-radius: 8px; border: 1px solid var(--sig); display: grid; place-items: center; font: 700 13px var(--display); color: var(--sig); }

.strip { display: flex; align-items: center; gap: 12px; padding: 13px 14px; border-radius: 14px; background: var(--card); border: 1px solid var(--line); margin-bottom: 8px; color: var(--text); text-decoration: none; cursor: pointer; }
.strip.threat { background: rgba(var(--threat-rgb), .08); border-color: rgba(var(--threat-rgb), .4); }
.strip .tag { font: 700 10.5px var(--mono); letter-spacing: .1em; padding: 3px 7px; border-radius: 5px; flex: none; }
.strip.threat .tag { background: var(--threat); color: #fff; }
.strip .tag.sig { border: 1px solid rgba(var(--sig-rgb), .5); color: var(--sig); }
.strip .tag.warn { border: 1px solid rgba(var(--warn-rgb), .5); color: var(--warn); }
.strip .grow { flex: 1; min-width: 0; font-weight: 600; font-size: 14px; }
.strip .grow .s { font-weight: 400; color: var(--muted); font-size: 13px; }
.meter { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; margin-top: 6px; }
.meter i { display: block; height: 100%; background: var(--sig); border-radius: 3px; animation: fill 1s var(--ease); position: relative; overflow: hidden; }
.meter i::after { content: ''; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .3), transparent); animation: shimmer 2.4s linear infinite; }
.meter i.warn { background: var(--warn); }
.meter i.threat { background: var(--threat); }
@keyframes fill { from { width: 0 !important; } }
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }

/* ---------- кольцо активности (досье) ---------- */
.clock { position: relative; width: 250px; height: 250px; margin: 10px auto 6px; }
.clock svg { width: 100%; height: 100%; }
.clock .h { position: absolute; font: 500 10px var(--mono); color: var(--muted); }
.clock .mid { position: absolute; inset: 70px 40px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.clock .mid b { font: 800 28px var(--display); }
.overlap { display: grid; grid-template-columns: 96px 1fr 40px; align-items: center; gap: 10px; font-size: 14px; padding: 4px 0; }
.overlap .meter i { background: var(--threat); }

/* ---------- карта ---------- */
.map-wrap { position: fixed; inset: 0; top: 64px; bottom: 0; overflow: hidden; background: #202125; touch-action: none; }
.map-wrap.home-map { top: 0; bottom: calc(var(--dock-h) + var(--safe-b) + var(--peek)); }
:root { --peek: 236px; }
.map-wrap::after { content: ''; position: absolute; inset: 0; pointer-events: none; box-shadow: inset 0 0 120px rgba(0, 0, 0, .55); }
.map-content { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }
.map-content img { display: block; user-select: none; -webkit-user-drag: none; pointer-events: none; filter: saturate(.75) contrast(1.05); }
.map-layer { position: absolute; inset: 0; pointer-events: none; }
.mk { position: absolute; transform: translate(-50%, -50%) scale(var(--inv, 1)); pointer-events: auto; cursor: pointer; }
.mk-player { width: 14px; height: 14px; border-radius: 50%; background: var(--ok); border: 2px solid #fff; box-shadow: 0 0 0 0 rgba(var(--ok-rgb), .6); animation: ring 2.2s ease-out infinite; }
.mk-player.off { background: var(--dim); animation: none; border-color: var(--line2); }
.mk-player.dead { background: var(--threat); animation: none; }
.mk-player.me { background: var(--sig); box-shadow: 0 0 0 0 rgba(var(--sig-rgb), .6); }
@keyframes ring { 70% { box-shadow: 0 0 0 11px rgba(var(--ok-rgb), 0); } 100% { box-shadow: 0 0 0 0 rgba(var(--ok-rgb), 0); } }
.mk-label { position: absolute; left: 50%; top: 100%; transform: translateX(-50%); margin-top: 4px; white-space: nowrap; font: 700 10px var(--mono); letter-spacing: .06em; text-transform: uppercase; color: #fff; text-shadow: 0 1px 3px #000, 0 0 2px #000; pointer-events: none; }
.mk-mon { font: 700 10px var(--display); letter-spacing: .06em; text-transform: uppercase; color: #fff; text-shadow: 0 1px 3px #000, 0 0 2px #000; white-space: nowrap; pointer-events: none; opacity: .85; }
.mk-ev { height: 26px; padding: 0 8px; border-radius: 8px; display: flex; align-items: center; gap: 5px; font: 700 10px var(--mono); background: rgba(32, 33, 36, .92); border: 1px solid var(--line2); color: var(--text); white-space: nowrap; }
.mk-ev svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; }
.mk-ev.red { border-color: var(--threat); color: var(--threat); }
.mk-ev.blue { border-color: var(--info); color: var(--info); }
.mk-ev.warn { border-color: var(--warn); color: var(--warn); }
.mk-vend { width: 16px; height: 16px; border-radius: 5px; background: var(--violet); border: 2px solid var(--bg); }
.mk-vend.out { background: var(--dim); }
.mk-note { width: 14px; height: 14px; transform: translate(-50%, -50%) rotate(45deg) scale(var(--inv, 1)); background: var(--warn); border: 2px solid var(--bg); }
.map-hud { position: absolute; left: 12px; right: 12px; top: 12px; display: flex; justify-content: space-between; gap: 8px; pointer-events: none; }
.home-map .map-hud { top: calc(80px + env(safe-area-inset-top, 0px)); justify-content: flex-start; }
.hud-box { pointer-events: auto; background: rgba(32, 33, 36, .92); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); font-size: 13px; }
.hud-box b { font-family: var(--mono); }
.map-tools { position: absolute; right: 12px; bottom: calc(var(--dock-h) + 30px + var(--safe-b)); display: flex; flex-direction: column; gap: 8px; }
.home-map .map-tools { bottom: 14px; }
.map-tools button { width: 44px; height: 44px; border-radius: 12px; background: rgba(32, 33, 36, .94); border: 1px solid var(--line2); font-size: 18px; cursor: pointer; color: var(--text); display: grid; place-items: center; transition: transform .12s; }
.map-tools button:active { transform: scale(.92); }
.map-tools button svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; }
.layers { position: absolute; left: 12px; bottom: calc(var(--dock-h) + 30px + var(--safe-b)); display: flex; flex-direction: column-reverse; align-items: flex-start; gap: 6px; max-width: calc(100% - 80px); }
.home-map .layers { bottom: 14px; }
.layers #layList { display: flex; flex-wrap: wrap; gap: 6px; }
.layers .chip { background: rgba(32, 33, 36, .94); padding: 6px 11px; font-size: 12px; }
.layers .chip.on { background: var(--sig); color: var(--sig-ink); }
.map-msg { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 24px; color: var(--muted); }

/* шапка-оверлей на карте */
.map-top { position: fixed; left: 12px; right: 12px; top: calc(12px + env(safe-area-inset-top, 0px)); z-index: 12; display: flex; gap: 10px; align-items: stretch; animation: fadeDown .4s var(--ease) both; }
@keyframes fadeDown { from { opacity: 0; transform: translateY(-10px); } }
.map-srv { flex: 1; min-width: 0; background: rgba(28, 29, 33, .92); border: 1px solid var(--line2); border-radius: 14px; padding: 9px 12px; -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); box-shadow: 0 8px 24px rgba(0, 0, 0, .4); }
.map-srv small { display: block; font: 700 9.5px var(--mono); letter-spacing: .16em; text-transform: uppercase; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.map-srv b { display: block; font: 800 17px var(--display); text-transform: uppercase; letter-spacing: .02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.map-srv.alarm { border-color: var(--threat); background: rgba(70, 20, 30, .95); animation: alarmGlow 1.2s ease-in-out infinite; }
.map-srv.alarm b { color: var(--threat); }
.map-srv.warn b { color: var(--warn); }
.map-srv.off b { color: var(--muted); }
.map-def { width: 52px; flex: none; border-radius: 14px; border: 1px solid var(--line2); background: rgba(28, 29, 33, .92); color: var(--muted); display: grid; place-items: center; cursor: pointer; transition: all .2s; }
.map-def svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; }
.map-def.on { background: var(--sig); color: #fff; border-color: transparent; box-shadow: 0 8px 22px rgba(var(--sig-rgb), .5); }
.map-def.alarm:not(.on) { border-color: var(--threat); color: var(--threat); animation: alarmGlow 1.2s ease-in-out infinite; }
.map-def:active { transform: scale(.94); }

/* выдвижной лист на карте */
.hsheet { position: fixed; left: 0; right: 0; bottom: calc(var(--dock-h) + var(--safe-b)); z-index: 11; height: calc(100vh - var(--dock-h) - var(--safe-b) - 70px);
  background: rgba(28, 29, 33, .96); border: 1px solid var(--line2); border-bottom: 0; border-radius: 22px 22px 0 0; box-shadow: 0 -14px 40px rgba(0, 0, 0, .55);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); max-width: 760px; margin: 0 auto;
  display: flex; flex-direction: column; transition: transform .38s var(--ease); animation: sheetIn .5s var(--ease) both; }
@keyframes sheetIn { from { transform: translateY(100%); } }
.hsheet[data-pos="peek"] { transform: translateY(calc(100% - var(--peek))); }
.hsheet[data-pos="half"] { transform: translateY(45%); }
.hsheet[data-pos="full"] { transform: translateY(0); }
.hs-grab { height: 24px; display: grid; place-items: center; cursor: grab; touch-action: none; flex: none; }
.hs-grab i { width: 44px; height: 4px; border-radius: 2px; background: var(--line2); transition: background .2s; }
.hs-grab:active i { background: var(--sig); }
.hs-body { flex: 1; overflow-y: auto; padding: 0 16px 30px; overscroll-behavior: contain; }
.hsheet:not([data-pos="full"]) .hs-body { overflow: hidden; }
.status-strip { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-radius: 12px; background: var(--card); border: 1px solid var(--line); margin-bottom: 10px; font-size: 13px; text-decoration: none; color: var(--text); }
.status-strip b { font-family: var(--display); font-size: 15px; text-transform: uppercase; letter-spacing: .03em; }
.status-strip span { color: var(--muted); font-size: 12.5px; }
.status-strip.warn { flex-direction: row; align-items: center; gap: 12px; border-color: rgba(var(--warn-rgb), .5); background: rgba(var(--warn-rgb), .06); }
.status-strip.warn > svg { width: 22px; height: 22px; fill: none; stroke: var(--warn); stroke-width: 2; flex: none; }
.status-strip.warn > div { flex: 1; min-width: 0; }
.status-strip.warn b { color: var(--warn); }
.status-strip.off { border-color: var(--line2); }
.status-strip.off b { color: var(--muted); }
.status-strip.alarm { border-color: var(--threat); background: rgba(var(--threat-rgb), .08); }
.status-line { display: block; margin-top: 8px; font-size: 12.5px; text-decoration: none; }
.status-line.warn { color: var(--warn); }
.status-line.threat { color: var(--threat); }

/* ---------- чат ---------- */
.chat { display: flex; flex-direction: column; gap: 6px; max-height: 46vh; overflow-y: auto; padding: 4px 2px; }
.msg { background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; padding: 8px 11px; max-width: 88%; animation: fadeUp .3s var(--ease); }
.msg.me { align-self: flex-end; background: rgba(var(--sig-rgb), .1); border-color: rgba(var(--sig-rgb), .35); }
.msg.bot { border-style: dashed; }
.msg b { font-size: 12px; color: var(--sig); }
.msg time { font-size: 11px; color: var(--dim); margin-left: 6px; font-family: var(--mono); }
.chat-input { display: flex; gap: 8px; margin-top: 10px; }

/* ---------- трекер ---------- */
.days { display: grid; gap: 4px; margin-top: 8px; }
.day { display: grid; grid-template-columns: 54px 1fr 46px; align-items: center; gap: 8px; font: 500 11.5px var(--mono); color: var(--muted); }
.bar { position: relative; height: 14px; border-radius: 4px; background: repeating-linear-gradient(90deg, var(--bg2) 0 calc(25% - 1px), var(--line) calc(25% - 1px) 25%); border: 1px solid var(--line); overflow: hidden; }
.bar i { position: absolute; top: 0; bottom: 0; background: var(--sig); border-radius: 2px; opacity: .85; }
.bar i.open { background: var(--warn); }
.target { display: flex; align-items: center; gap: 12px; }
.target .sig-bars { display: flex; align-items: flex-end; gap: 2px; height: 16px; }
.target .sig-bars i { width: 4px; border-radius: 1px; background: var(--line2); }
.target .sig-bars i.on { background: var(--ok); }

/* ---------- нижний лист (модальный) ---------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 50; }
.sheet-bg { position: absolute; inset: 0; background: rgba(0, 0, 0, .65); animation: fadeIn .2s; }
@keyframes fadeIn { from { opacity: 0; } }
.sheet { position: absolute; left: 0; right: 0; bottom: 0; max-height: 90vh; overflow-y: auto; background: var(--bg2); border-top: 1px solid var(--line2); border-radius: 22px 22px 0 0; padding: 8px 16px calc(24px + var(--safe-b)); animation: up .3s var(--ease); max-width: 760px; margin: 0 auto; box-shadow: 0 -14px 40px rgba(0, 0, 0, .5); }
.grab { width: 44px; height: 4px; border-radius: 2px; background: var(--line2); margin: 0 auto 14px; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.sheet-x { position: absolute; top: -2px; right: 0; width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--line); background: var(--card2); color: var(--muted); font-size: 14px; display: grid; place-items: center; cursor: pointer; z-index: 2; }
.sheet-x + *:not(.sheet-x), .sheet-x + .cap + * { padding-right: 44px; }
#sheetBody { position: relative; }

.toast { position: fixed; left: 50%; bottom: calc(var(--dock-h) + 20px + var(--safe-b)); transform: translateX(-50%); z-index: 60; background: var(--text); color: #111; padding: 10px 18px; border-radius: 12px; font-weight: 600; font-size: 14px; max-width: 90vw; text-align: center; animation: up .25s var(--ease); box-shadow: 0 10px 30px rgba(0, 0, 0, .4); }

/* ---------- «Ещё» ---------- */
.hub { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.hub a { display: flex; flex-direction: column; gap: 10px; padding: 16px 14px; min-height: 112px; border-radius: 16px; background: linear-gradient(180deg, var(--card), #27282d); border: 1px solid var(--line); color: var(--text); text-decoration: none; transition: transform .15s var(--ease), border-color .2s; animation: fadeUp .4s var(--ease) both; }
.hub a:nth-child(2) { animation-delay: .04s; } .hub a:nth-child(3) { animation-delay: .08s; } .hub a:nth-child(4) { animation-delay: .12s; } .hub a:nth-child(5) { animation-delay: .16s; } .hub a:nth-child(6) { animation-delay: .2s; } .hub a:nth-child(7) { animation-delay: .24s; } .hub a:nth-child(8) { animation-delay: .28s; }
.hub a:active { transform: scale(.97); border-color: var(--sig); }
.hub a .ico { width: 42px; height: 42px; }
.hub a b { font: 800 17px var(--display); text-transform: uppercase; letter-spacing: .02em; }
.hub a span { font-size: 12.5px; color: var(--muted); }
.wipe-hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.wipe-hero b { font: 800 40px var(--display); line-height: 1; letter-spacing: .01em; }

/* ---------- инструменты ---------- */
.code-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 7px; margin-top: 10px; }
.code { background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 11px; cursor: pointer; text-align: left; }
.code b { font-family: var(--mono); font-size: 13px; color: var(--sig); display: block; word-break: break-all; }
.code span { font-size: 12px; color: var(--muted); }
.code:active { border-color: var(--sig); }
.genes { display: inline-flex; gap: 3px; }
.gene { width: 22px; height: 24px; border-radius: 6px; display: grid; place-items: center; font: 700 13px var(--mono); }
.gene.G, .gene.Y, .gene.H { background: rgba(var(--ok-rgb), .16); color: var(--ok); }
.gene.W, .gene.X { background: rgba(var(--threat-rgb), .16); color: var(--threat); }
.gene.Q { background: var(--card2); color: var(--warn); }
input.f.qty { width: 74px; flex: none; text-align: right; }
.hero { background: var(--card); }
.plan { display: flex; justify-content: space-between; align-items: center; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-top: 8px; background: var(--bg2); }
.plan.best { border-color: var(--sig); box-shadow: 0 0 0 1px rgba(var(--sig-rgb), .3); }
.price { font-family: var(--display); font-weight: 800; font-size: 20px; }
.spinner { width: 22px; height: 22px; border: 2.5px solid var(--line); border-top-color: var(--sig); border-radius: 50%; animation: spin .8s linear infinite; margin: 30px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- владелец ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.stat-grid > div { background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.stat-grid small { display: block; font: 700 9.5px var(--mono); letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.stat-grid b { font-family: var(--display); font-weight: 800; font-size: 24px; }
.inv-code { font-family: var(--mono); font-weight: 600; letter-spacing: .08em; color: var(--sig); }
.row-wrap { display: flex; flex-wrap: wrap; gap: 8px; }
.row-wrap > * { flex: 1 1 120px; }
#redeemCode::placeholder { text-transform: none; }
/* ---------- камеры ---------- */
.cam-box { background: #000; border: 1px solid var(--line); border-radius: 12px; min-height: 180px; display: grid; place-items: center; overflow: hidden; margin: 10px 0; }
.cam-img { width: 100%; display: block; image-rendering: pixelated; }
.cam-pad { display: grid; grid-template-columns: repeat(3, 56px); gap: 6px; justify-content: center; }
.cam-pad button { height: 48px; border-radius: 12px; border: 1px solid var(--line); background: var(--card2); font-size: 18px; cursor: pointer; }
/* ---------- ресурсы и прогноз ---------- */
.res-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.res-grid > div { background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 7px 9px; min-width: 0; }
.res-grid small { display: block; font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.res-grid b { font-family: var(--display); font-size: 18px; }
.fc { display: flex; align-items: flex-end; gap: 2px; height: 70px; }
.fc i { flex: 1; background: var(--sig); border-radius: 2px 2px 0 0; opacity: .85; }
.fc i.low { background: var(--line2); opacity: 1; }
.fc-axis { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--dim); margin-top: 4px; }

/* ---------- пульт: карточка и плитки ---------- */
.hero-card { background: linear-gradient(180deg, var(--card), #27282d); border: 1px solid var(--line); border-radius: 18px; padding: 16px; margin: 6px 0 4px; position: relative; }
.hero-card.alarm { background: linear-gradient(180deg, #3d1f28, #2a2024); border-color: var(--threat); animation: alarmGlow 1.4s ease-in-out infinite; }
.hero-card.alarm .cap { color: var(--threat); }
.hero-title { font: 800 26px var(--display); text-transform: uppercase; margin-top: 4px; line-height: 1.1; }
.hero-card .btn.block { flex: 1; width: auto; }
.link-btn { background: none; border: 0; padding: 4px 0; color: var(--sig); font: 700 11px var(--mono); letter-spacing: .08em; text-transform: uppercase; cursor: pointer; min-height: 32px; display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.link-btn svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; }
.pult { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.tile { display: flex; flex-direction: column; align-items: stretch; gap: 6px; text-align: left; min-height: 104px; padding: 14px; border-radius: 16px; border: 1px solid var(--line2); background: linear-gradient(180deg, var(--card), #27282d); color: var(--text); cursor: pointer; position: relative; overflow: hidden; transition: transform .15s var(--ease), background .25s, border-color .25s; animation: fadeUp .4s var(--ease) both; }
.tile:nth-child(2) { animation-delay: .05s; } .tile:nth-child(3) { animation-delay: .1s; } .tile:nth-child(4) { animation-delay: .15s; } .tile:nth-child(5) { animation-delay: .2s; } .tile:nth-child(6) { animation-delay: .25s; }
.tile::after { content: ''; position: absolute; right: 10px; top: 10px; width: 10px; height: 10px; border-top: 2px solid var(--line2); border-right: 2px solid var(--line2); }
.tile b { font: 800 18px var(--display); text-transform: uppercase; letter-spacing: .02em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile .small { color: var(--muted); }
.tile .tile-ico { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--card2); color: var(--muted); transition: all .25s; }
.tile.on { background: linear-gradient(160deg, #e2244a, #a8122f); border-color: transparent; color: var(--sig-ink); box-shadow: 0 8px 24px rgba(var(--sig-rgb), .35); }
.tile.on::after { border-color: rgba(255, 255, 255, .5); }
.tile.on .small, .tile.on .mono { color: var(--sig-ink); opacity: .85; }
.tile.on .tile-ico { background: rgba(255, 255, 255, .2); color: #fff; }
.tile.mixed { border-color: rgba(var(--sig-rgb), .6); }
.tile.mixed .tile-ico { color: var(--sig); }
.tile:disabled { opacity: .6; cursor: default; }
.tile:active:not(:disabled) { transform: scale(.97); }
@keyframes alarmGlow { 50% { box-shadow: 0 0 0 5px rgba(var(--threat-rgb), .22); } }

/* лента-ограждение для тревоги */
.card.threat::before, .hero-card.alarm::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 5px; border-radius: 16px 16px 0 0; background: repeating-linear-gradient(135deg, var(--threat) 0 10px, #1a1a1a 10px 20px); }
.card.threat, .hero-card.alarm { overflow: hidden; position: relative; }
.hsheet.alarm::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 6px; border-radius: 22px 22px 0 0; background: repeating-linear-gradient(135deg, var(--threat) 0 10px, #1a1a1a 10px 20px); }

/* широкий экран (Telegram Desktop, браузер): карта слева, лист — панель справа */
@media (min-width: 900px) {
  :root { --panel: 400px; }
  .map-wrap.home-map { bottom: calc(var(--dock-h) + var(--safe-b)); right: var(--panel); }
  .map-top { right: calc(var(--panel) + 12px); }
  .hsheet, .hsheet[data-pos] { left: auto; right: 0; top: 0; bottom: calc(var(--dock-h) + var(--safe-b)); width: var(--panel); height: auto; max-width: none; margin: 0; transform: none; border-radius: 0; border: 0; border-left: 1px solid var(--line2); box-shadow: -10px 0 30px rgba(0, 0, 0, .35); animation: none; }
  .hsheet .hs-body { overflow-y: auto; padding-top: 14px; }
  .hs-grab { display: none; }
  .hsheet.alarm::before { border-radius: 0; }
}
/* вход на сайте (panel.rustwarden.org) */
body.loginmode .top { display: none; }
body.loginmode main { max-width: 980px; }
.login { min-height: calc(100vh - 40px); display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr); gap: 28px; align-items: center; padding: 24px 0; }
@media (max-width: 760px) { .login { grid-template-columns: 1fr; min-height: 0; padding-top: 40px; } }
.login-card { padding: 34px 30px; border-radius: 22px; border: 1px solid var(--line2); background: linear-gradient(180deg, var(--card), var(--bg2)); box-shadow: 0 24px 60px rgba(0, 0, 0, .35); animation: fadeUp .5s var(--ease) both; }
.login-card h1 { font-size: 40px; }
.login-card p { margin: 12px 0 0; max-width: 46ch; }
.login-btn { margin-top: 24px; min-height: 46px; }
.login-feats { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.login-feats li { display: flex; gap: 12px; align-items: center; padding: 14px 16px; border-radius: 14px; border: 1px solid var(--line); background: var(--bg2); color: var(--muted); animation: fadeUp .5s var(--ease) both; }
.login-feats li:nth-child(2) { animation-delay: .06s; } .login-feats li:nth-child(3) { animation-delay: .12s; } .login-feats li:nth-child(4) { animation-delay: .18s; }
.login-feats svg { width: 20px; height: 20px; fill: none; stroke: var(--sig); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---- полировка: движение и отклик ---- */
#view > *:nth-child(2) { animation-delay: .04s; } #view > *:nth-child(3) { animation-delay: .08s; }
#view > *:nth-child(4) { animation-delay: .12s; } #view > *:nth-child(n+5) { animation-delay: .16s; }
.card, .hub a, .tile { transition: transform .18s var(--ease), border-color .2s, box-shadow .25s; }
.hub a:active, .tile:active { transform: scale(.97); }
.hub a svg, .tile svg { transition: transform .35s cubic-bezier(.34, 1.56, .64, 1); }
.hub a:active svg, .tile:active svg { transform: scale(1.15) rotate(-6deg); }
.dock a.active svg { animation: dockPop .45s cubic-bezier(.34, 1.56, .64, 1); }
@keyframes dockPop { 0% { transform: scale(.8); } 60% { transform: scale(1.15) translateY(-3px); } 100% { transform: translateY(-2px); } }
.dock a.active::before { animation: dockBar .35s var(--ease); }
@keyframes dockBar { from { transform: scaleX(0); } }
.switch i::after { transition: transform .32s cubic-bezier(.34, 1.56, .64, 1), background .2s, width .2s; }
.switch input:active + i::after { width: 26px; }
.switch input:checked:active + i::after { transform: translateX(16px); }
.chip { transition: background .2s, border-color .2s, color .2s, transform .15s var(--ease); }
.chip:active { transform: scale(.95); }
.btn { position: relative; overflow: hidden; }
.btn.primary::after { content: ''; position: absolute; top: 0; bottom: 0; width: 40%; left: -60%; background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .22), transparent); transform: skewX(-18deg); animation: btnShine 5s var(--ease) 1.5s infinite; pointer-events: none; }
@keyframes btnShine { 0%, 70% { left: -60%; } 100% { left: 130%; } }
.toast { animation: toastIn .4s cubic-bezier(.34, 1.56, .64, 1); }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 14px) scale(.96); } }
.sheet { animation-timing-function: cubic-bezier(.22, 1.2, .36, 1); }
.login-feats li { animation: fadeUp .45s var(--ease) both; }
.login-feats li:nth-child(2) { animation-delay: .07s; } .login-feats li:nth-child(3) { animation-delay: .14s; } .login-feats li:nth-child(4) { animation-delay: .21s; }
::selection { background: rgba(var(--sig-rgb), .4); }
@media (prefers-reduced-motion: reduce) { .btn.primary::after, .dock a.active svg { animation: none !important; } }
