:root {
  --bg: #0b0f15;
  --panel: rgba(13, 18, 27, .82);
  --line: rgba(255, 255, 255, .08);
  --text: #e8eef6;
  --muted: #8a97a8;
  --accent: #4cc9f0;
  --green: #26d07c;
  --red: #ff4d6d;
  --amber: #ffb703;
  --radius: 14px;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
  --sans: 'Inter', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text); font-family: var(--sans); }
#app { position: fixed; inset: 0; }
#app canvas { display: block; touch-action: none; }
.labels { position: absolute; inset: 0; pointer-events: none; }
.labels.hidden { display: none; }

.glass {
  background: var(--panel);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .35);
}

/* ---------- top HUD ---------- */
.hud-top {
  position: fixed; top: 16px; left: 16px; right: 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  pointer-events: none;
}
.hud-top > * { pointer-events: auto; }

.brand { display: flex; gap: 12px; align-items: center; padding: 10px 16px 10px 10px; }
.logo {
  width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(135deg, #4cc9f0, #7b61ff);
}
.logo::before { content: ''; width: 12px; height: 12px; background: #fff; border-radius: 2px; transform: rotate(45deg); }
.brand strong { display: block; font-weight: 800; font-size: 14px; letter-spacing: .1em; }
.brand span { font-size: 12px; color: var(--muted); }

.kpis { display: flex; align-items: center; padding: 6px; }
.kpi { padding: 4px 16px; border-right: 1px solid var(--line); }
.kpi:nth-last-child(2) { border-right: 0; }
.kpi label { display: block; font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; }
.kpi b { font: 700 15px var(--mono); }
.ok { color: var(--green); }
.pill {
  margin: 0 8px; padding: 5px 10px; border-radius: 999px;
  font: 700 11px var(--mono); letter-spacing: .12em;
  color: var(--amber); background: rgba(255, 183, 3, .12); border: 1px solid rgba(255, 183, 3, .4);
}

.clock { padding: 10px 16px; text-align: right; }
.clock b { font: 700 18px var(--mono); }
.clock small { margin-left: 8px; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.sessions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 4px; font-size: 11px; color: var(--muted); }
.sessions span::before {
  content: ''; display: inline-block; width: 6px; height: 6px; margin-right: 5px; vertical-align: 1px;
  border-radius: 50%; background: #4a5363;
}
.sessions .open { color: var(--text); }
.sessions .open::before { background: var(--green); box-shadow: 0 0 8px var(--green); }

/* ---------- toolbar ---------- */
.toolbar { position: fixed; left: 16px; bottom: 16px; display: flex; gap: 4px; padding: 6px; }
.toolbar button {
  width: 40px; height: 40px; display: grid; place-items: center; cursor: pointer;
  border: 0; border-radius: 10px; background: transparent; color: var(--muted);
  transition: background .15s, color .15s;
}
.toolbar button:hover { background: rgba(255, 255, 255, .06); color: var(--text); }
.toolbar button.on { color: var(--accent); background: rgba(76, 201, 240, .12); }
.toolbar svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.hint { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); padding: 8px 14px; font-size: 12px; color: var(--muted); white-space: nowrap; }

/* ---------- 3D labels ---------- */
.nameplate { text-align: center; white-space: nowrap; pointer-events: none; }
.np-main {
  display: inline-flex; align-items: center; gap: 7px; padding: 4px 10px 4px 4px;
  border-radius: 999px; background: rgba(9, 13, 19, .82);
  border: 1px solid color-mix(in srgb, var(--accent) 55%, transparent);
  font-size: 12px; font-weight: 700; letter-spacing: .08em;
  transition: box-shadow .2s, transform .2s;
}
.np-num { font: 700 10px var(--mono); color: #061018; background: var(--accent); border-radius: 999px; padding: 2px 6px; }
.np-dot { width: 6px; height: 6px; border-radius: 50%; background: #6b7584; }
.np-sub { margin-top: 3px; font-size: 10.5px; color: rgba(232, 238, 246, .75); text-shadow: 0 1px 3px #000; }
.nameplate.sel .np-main { transform: scale(1.08); box-shadow: 0 0 0 2px var(--accent), 0 0 22px color-mix(in srgb, var(--accent) 60%, transparent); }
.nameplate.risk .np-main { padding-left: 10px; }
.nameplate.risk .np-dot { background: var(--green); box-shadow: 0 0 8px var(--green); }
.zone-label { font: 700 11px var(--sans); letter-spacing: .2em; color: rgba(255, 255, 255, .6); text-shadow: 0 1px 4px rgba(0, 0, 0, .8); }

/* ---------- side panel ---------- */
.panel {
  position: fixed; top: 96px; right: 16px; bottom: 16px; width: min(380px, calc(100vw - 32px));
  padding: 20px; overflow-y: auto;
  transform: translateX(calc(100% + 24px)); transition: transform .35s cubic-bezier(.2, .8, .2, 1);
}
.panel.open { transform: none; }
.close {
  position: absolute; top: 14px; right: 14px; width: 32px; height: 32px; cursor: pointer;
  border: 1px solid var(--line); border-radius: 9px; background: transparent; color: var(--muted); font-size: 18px;
}
.close:hover { color: var(--text); background: rgba(255, 255, 255, .06); }
.p-head { display: flex; gap: 14px; align-items: center; margin-bottom: 16px; }
.avatar { width: 52px; height: 52px; flex: none; border-radius: 14px; display: grid; place-items: center; font: 800 18px var(--mono); color: #061018; background: var(--accent); }
.p-head h2 { margin: 0; font-size: 22px; letter-spacing: .08em; }
.p-head p { margin: 2px 0 0; font: 500 12px var(--mono); color: var(--muted); }
.status { display: flex; align-items: center; gap: 8px; padding: 10px 12px; font-size: 13px; border-radius: 10px; background: rgba(255, 255, 255, .04); border: 1px solid var(--line); }
.status span { width: 8px; height: 8px; border-radius: 50%; background: #6b7584; }
.status.armed span { background: var(--green); box-shadow: 0 0 10px var(--green); }
.spec { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 16px 0 0; }
.spec div { padding: 10px 12px; border-radius: 10px; background: rgba(255, 255, 255, .03); border: 1px solid var(--line); }
.spec dt { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; }
.spec dd { margin: 4px 0 0; font-size: 13px; font-weight: 600; }
.panel h3 { margin: 20px 0 8px; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .12em; }
.metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.metrics div { padding: 10px; border-radius: 10px; background: rgba(255, 255, 255, .03); border: 1px solid var(--line); }
.metrics span { display: block; font-size: 10.5px; color: var(--muted); }
.metrics b { font: 700 15px var(--mono); }
.empty { padding: 14px; font-size: 12.5px; line-height: 1.5; color: var(--muted); border: 1px dashed rgba(255, 255, 255, .12); border-radius: 10px; }
.actions { display: flex; gap: 8px; margin-top: 20px; }
.actions button { flex: 1; height: 40px; border: 0; border-radius: 10px; font: 700 13px var(--sans); background: var(--accent); color: #061018; }
.actions button.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.actions button:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- toast & loader ---------- */
.toast {
  position: fixed; left: 50%; top: 100px; max-width: min(520px, calc(100vw - 32px));
  padding: 11px 16px; font-size: 13px; line-height: 1.45;
  opacity: 0; transform: translate(-50%, -8px); transition: opacity .25s, transform .25s; pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.loader { position: fixed; inset: 0; display: grid; place-content: center; justify-items: center; gap: 14px; background: var(--bg); color: var(--muted); font-size: 13px; transition: opacity .6s; }
.loader.done { opacity: 0; pointer-events: none; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, .1); border-top-color: var(--accent); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 1100px) { .kpis { display: none; } }
@media (max-width: 760px) { .hint { display: none; } .panel { top: 84px; } }
@media (max-width: 520px) {
  .hud-top { top: 12px; left: 12px; right: 12px; }
  .brand span, .sessions { display: none; }
  .toolbar { left: 12px; bottom: 12px; }
}
