:root {
  --bg: #121311;
  --bg2: #191a17;
  --card: #1e201c;
  --card2: #252722;
  --line: #2f322c;
  --text: #ece8dc;
  --muted: #929486;
  --dim: #63655b;
  --amber: #f2a93b;
  --amber2: #d9822b;
  --red: #e5533d;
  --green: #7fc35b;
  --blue: #5aa9d6;
  --violet: #a98bd8;
  --r: 14px;
  --display: 'Unbounded', 'Manrope', system-ui, sans-serif;
  --sans: 'Manrope', system-ui, -apple-system, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
  --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.45 var(--sans); }
body { min-height: 100vh; overscroll-behavior: none; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--amber); }
h1, h2, h3 { font-family: var(--display); font-weight: 600; letter-spacing: .01em; margin: 0; }
h2 { font-size: 17px; }
h3 { font-size: 14px; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.small { font-size: 12.5px; }
[hidden] { display: none !important; }

/* ---------- шапка ---------- */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 14px; background: rgba(18, 19, 17, .92); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 9px; }
.brand b { font-family: var(--display); font-size: 15px; display: block; line-height: 1.1; }
.brand span { font-size: 11px; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; }
.server-pill {
  display: flex; align-items: center; gap: 7px; max-width: 58%;
  background: var(--card); border: 1px solid var(--line); border-radius: 99px; padding: 6px 10px 6px 9px; cursor: pointer;
}
.server-pill span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; font-weight: 600; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--dim); flex: none; }
.dot.on { background: var(--green); box-shadow: 0 0 0 3px rgba(127, 195, 91, .18); }
.dot.err { background: var(--red); }

/* ---------- нижние вкладки ---------- */
main { padding: 14px 14px calc(92px + var(--safe-b)); max-width: 760px; margin: 0 auto; }
main.full { padding: 0; max-width: none; }
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(6, 1fr);
  padding: 6px 4px calc(6px + var(--safe-b)); background: rgba(22, 23, 20, .96); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
}
.tabs a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 5px 0; color: var(--dim); text-decoration: none; font-size: 10.5px; font-weight: 600; }
.tabs svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linejoin: round; stroke-linecap: round; }
.tabs a.active { color: var(--amber); }

/* ---------- карточки и элементы ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; margin-bottom: 12px; }
.card.flat { background: var(--bg2); }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 8px; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; margin: 18px 2px 10px; }
.section-title h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-family: var(--sans); font-weight: 700; }
.kv { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.kv > div { background: var(--bg2); border: 1px solid var(--line); border-radius: 11px; padding: 9px 10px; }
.kv small { display: block; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.kv b { font-family: var(--mono); font-size: 16px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid var(--line); background: var(--card2); border-radius: 11px; padding: 10px 14px; font-weight: 700; cursor: pointer;
}
.btn.primary { background: linear-gradient(180deg, var(--amber), var(--amber2)); color: #1a1408; border-color: transparent; }
.btn.danger { color: var(--red); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 6px 10px; 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(--line); background: var(--card); border-radius: 99px; padding: 6px 12px; font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; }
.chip.on { color: #1a1408; background: var(--amber); border-color: transparent; }

input.f, select.f, textarea.f {
  width: 100%; background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; outline: none;
}
input.f:focus, select.f:focus, textarea.f:focus { border-color: var(--amber2); }
label.lbl { display: block; font-size: 12px; color: var(--muted); margin: 10px 0 5px; font-weight: 600; }

.switch { position: relative; width: 46px; 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(--card2); border: 1px solid var(--line); border-radius: 99px; transition: .2s; }
.switch i::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--muted); transition: .2s; }
.switch input:checked + i { background: rgba(242, 169, 59, .22); border-color: var(--amber2); }
.switch input:checked + i::after { transform: translateX(18px); background: var(--amber); }

.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); }
.item:first-child { border-top: 0; }
.item .grow { flex: 1; min-width: 0; }
.item .t { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .s { font-size: 12.5px; color: var(--muted); }
.item.tap { cursor: pointer; }
.ico { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--card2); flex: none; font-size: 17px; }
.ico.amber { background: rgba(242, 169, 59, .14); color: var(--amber); }
.ico.red { background: rgba(229, 83, 61, .14); color: var(--red); }
.ico.green { background: rgba(127, 195, 91, .14); color: var(--green); }
.ico.blue { background: rgba(90, 169, 214, .14); color: var(--blue); }
.badge { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 99px; background: var(--card2); color: var(--muted); }
.badge.on { background: rgba(127, 195, 91, .16); color: var(--green); }
.badge.red { background: rgba(229, 83, 61, .16); color: var(--red); }
.badge.amber { background: rgba(242, 169, 59, .16); color: var(--amber); }

.empty { text-align: center; padding: 34px 16px; color: var(--muted); }
.empty .big { font-size: 34px; margin-bottom: 8px; }
.steps { counter-reset: s; list-style: none; padding: 0; margin: 10px 0 0; }
.steps li { counter-increment: s; position: relative; padding: 0 0 12px 36px; }
.steps li::before { content: counter(s); position: absolute; left: 0; top: -1px; width: 25px; height: 25px; border-radius: 8px; background: var(--card2); border: 1px solid var(--line); display: grid; place-items: center; font: 700 12px var(--mono); color: var(--amber); }

/* ---------- карта ---------- */
.map-wrap { position: fixed; inset: 0; top: 55px; bottom: calc(60px + var(--safe-b)); overflow: hidden; background: #0d1b22; touch-action: none; }
.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; }
.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: 16px; height: 16px; border-radius: 50%; background: var(--green); border: 2px solid #0d1b22; box-shadow: 0 0 0 2px var(--green); }
.mk-player.off { background: var(--dim); box-shadow: 0 0 0 2px var(--dim); }
.mk-player.dead { background: var(--red); box-shadow: 0 0 0 2px var(--red); }
.mk-label { position: absolute; left: 50%; top: 100%; transform: translateX(-50%); margin-top: 4px; white-space: nowrap; font: 700 11px var(--sans); color: #fff; text-shadow: 0 1px 3px #000, 0 0 2px #000; pointer-events: none; }
.mk-mon { font: 700 10.5px var(--sans); color: #fff; text-shadow: 0 1px 3px #000, 0 0 2px #000; white-space: nowrap; pointer-events: none; opacity: .9; }
.mk-ev { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; font-size: 15px; background: rgba(18, 19, 17, .85); border: 1.5px solid var(--amber); }
.mk-ev.red { border-color: var(--red); }
.mk-ev.blue { border-color: var(--blue); }
.mk-vend { width: 18px; height: 18px; border-radius: 5px; background: var(--blue); border: 2px solid #0d1b22; }
.mk-vend.out { background: var(--dim); }
.mk-note { width: 14px; height: 14px; transform: translate(-50%, -50%) rotate(45deg) scale(var(--inv, 1)); background: var(--violet); border: 2px solid #0d1b22; }
.map-hud { position: absolute; left: 10px; right: 10px; top: 10px; display: flex; justify-content: space-between; gap: 8px; pointer-events: none; }
.hud-box { pointer-events: auto; background: rgba(18, 19, 17, .88); border: 1px solid var(--line); border-radius: 12px; padding: 7px 10px; backdrop-filter: blur(6px); }
.hud-box b { font-family: var(--mono); }
.map-tools { position: absolute; right: 10px; bottom: 10px; display: flex; flex-direction: column; gap: 6px; }
.map-tools button { width: 40px; height: 40px; border-radius: 12px; background: rgba(18, 19, 17, .9); border: 1px solid var(--line); font-size: 18px; cursor: pointer; }
.layers { position: absolute; left: 10px; bottom: 10px; display: flex; flex-direction: column-reverse; align-items: flex-start; gap: 5px; max-width: calc(100% - 70px); }
#layList { display: flex; flex-wrap: wrap; gap: 5px; }
#layBtn { background: rgba(18, 19, 17, .9); color: var(--text); }
.layers .chip { background: rgba(18, 19, 17, .9); padding: 5px 10px; font-size: 12px; }
.layers .chip.on { background: var(--amber); }
.map-msg { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 24px; color: var(--muted); }

/* ---------- чат ---------- */
.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: 7px 10px; max-width: 88%; }
.msg.me { align-self: flex-end; background: rgba(242, 169, 59, .1); border-color: rgba(242, 169, 59, .3); }
.msg.bot { border-style: dashed; }
.msg b { font-size: 12px; color: var(--amber); }
.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(--green); border-radius: 2px; opacity: .85; }
.bar i.open { background: var(--amber); }

/* ---------- нижний лист ---------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 50; }
.sheet-bg { position: absolute; inset: 0; background: rgba(0, 0, 0, .55); }
.sheet { position: absolute; left: 0; right: 0; bottom: 0; max-height: 86vh; overflow-y: auto; background: var(--bg2); border-top: 1px solid var(--line); border-radius: 20px 20px 0 0; padding: 8px 16px calc(20px + var(--safe-b)); animation: up .22s ease; max-width: 760px; margin: 0 auto; }
.grab { width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 0 auto 12px; }
@keyframes up { from { transform: translateY(30px); opacity: 0; } }

.toast { position: fixed; left: 50%; bottom: calc(80px + var(--safe-b)); transform: translateX(-50%); z-index: 60; background: var(--text); color: var(--bg); padding: 9px 16px; border-radius: 12px; font-weight: 700; font-size: 14px; max-width: 90vw; text-align: center; }

/* ---------- инструменты ---------- */
.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: 9px 10px; cursor: pointer; text-align: left; }
.code b { font-family: var(--mono); font-size: 13px; color: var(--amber); display: block; word-break: break-all; }
.code span { font-size: 12px; color: var(--muted); }
.code:active { border-color: var(--amber); }
.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 { background: #2f5d2c; color: #b5ec9a; } .gene.Y { background: #2f5d2c; color: #b5ec9a; } .gene.H { background: #2f5d2c; color: #b5ec9a; }
.gene.W { background: #5d2c2c; color: #f0a59a; } .gene.X { background: #5d2c2c; color: #f0a59a; }
.gene.Q { background: var(--card2); color: var(--amber); }
.qty { width: 74px; text-align: right; }
.hero { background: radial-gradient(120% 140% at 100% 0%, rgba(242, 169, 59, .16), transparent 60%), 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(--amber2); }
.price { font-family: var(--mono); font-weight: 700; font-size: 17px; }
.spinner { width: 22px; height: 22px; border: 2.5px solid var(--line); border-top-color: var(--amber); border-radius: 50%; animation: spin .8s linear infinite; margin: 30px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
