:root {
  --bg: #070b18;
  --glass: rgba(14, 20, 38, 0.78);
  --glass-2: rgba(26, 34, 60, 0.7);
  --line: rgba(160, 180, 230, 0.16);
  --text: #e8ecf6;
  --muted: #9aa5c0;
  --gold: #e0b866;
  --working: #4ade80;
  --waiting: #fbbf24;
  --reviewing: #60a5fa;
  --radius: 14px;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; }

#app { position: fixed; inset: 0; }
#stage { position: absolute; inset: 0; overflow: hidden; }
#c { display: block; width: 100%; height: 100%; touch-action: none; outline: none; }
.labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 1; }

/* ---------- верхняя панель ---------- */
#topbar {
  position: absolute; top: 16px; left: 16px; display: flex; align-items: center; gap: 12px;
  pointer-events: none; z-index: 5; max-width: calc(100% - 410px);
}
#topbar > * { pointer-events: auto; }
.brand {
  display: flex; align-items: center; gap: 10px; padding: 9px 14px 9px 10px;
  background: var(--glass); border: 1px solid var(--line); border-radius: var(--radius);
  backdrop-filter: blur(10px);
}
.brand b { display: block; font-size: 15px; letter-spacing: .2px; }
.brand small { display: block; font-size: 12px; color: var(--muted); }
.logo {
  width: 28px; height: 28px; border-radius: 8px; flex: none;
  background: linear-gradient(160deg, #f3d08a, #b8862f);
  -webkit-mask: linear-gradient(#000 0 0) center/40% 100% no-repeat, linear-gradient(#000 0 0) 15% 100%/22% 60% no-repeat, linear-gradient(#000 0 0) 85% 100%/22% 75% no-repeat;
          mask: linear-gradient(#000 0 0) center/40% 100% no-repeat, linear-gradient(#000 0 0) 15% 100%/22% 60% no-repeat, linear-gradient(#000 0 0) 85% 100%/22% 75% no-repeat;
}
#crumb {
  font-size: 13px; color: var(--muted); padding: 6px 12px; border-radius: 999px;
  background: rgba(10, 14, 28, .55); border: 1px solid var(--line);
}
#btn-back {
  display: none; padding: 10px 16px; border-radius: var(--radius); border: 1px solid rgba(224,184,102,.5);
  background: linear-gradient(180deg, rgba(224,184,102,.25), rgba(224,184,102,.12)); font-weight: 600;
  backdrop-filter: blur(10px);
}
#btn-back:hover { background: rgba(224,184,102,.35); }
body[data-scene="office"] #btn-back { display: block; }

/* ---------- подсказки ---------- */
#hint {
  position: absolute; left: 16px; bottom: 16px; z-index: 4; max-width: min(640px, calc(100% - 410px));
  font-size: 12.5px; color: var(--muted); line-height: 1.5;
  padding: 8px 12px; border-radius: 10px; background: rgba(8, 12, 24, .6); border: 1px solid var(--line);
}
#hint b { color: var(--text); font-weight: 600; }
#fps { position: absolute; left: 16px; top: 84px; font: 12px/1 ui-monospace, Consolas, monospace; background: rgba(0,0,0,.6); padding: 5px 8px; border-radius: 6px; z-index: 6; }

/* ---------- всплывающая подпись этажа ---------- */
.tip {
  position: absolute; left: 0; top: 0; z-index: 6; pointer-events: none;
  padding: 9px 13px; border-radius: 12px; min-width: 150px;
  background: rgba(12, 18, 36, .92); border: 1px solid rgba(127,176,255,.45);
  box-shadow: 0 10px 30px rgba(0,0,0,.4);
}
.tip b { display: block; font-size: 15px; }
.tip span { display: block; font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.tip.active { border-color: rgba(224,184,102,.8); }
.tip.active span { color: var(--gold); }

.floor-tag {
  pointer-events: auto; display: flex; align-items: center; gap: 8px; white-space: nowrap;
  padding: 6px 12px 6px 6px; border-radius: 999px; border: 1px solid rgba(224,184,102,.75);
  background: rgba(20, 16, 8, .78); color: #fff; font-size: 13px; box-shadow: 0 0 24px rgba(224,184,102,.35);
  transform: translateX(50%); animation: tagPulse 2.4s ease-in-out infinite;
}
.floor-tag b { background: var(--gold); color: #1b1404; border-radius: 999px; padding: 2px 8px; font-size: 12px; }
.floor-tag em { font-style: normal; color: var(--gold); font-weight: 600; }
.floor-tag:hover { background: rgba(60, 44, 14, .9); }
@keyframes tagPulse { 50% { box-shadow: 0 0 36px rgba(224,184,102,.6); } }

/* ---------- офис: подписи ---------- */
.room-label, .zone-label {
  font-size: 11px; letter-spacing: .6px; text-transform: uppercase; color: #1e2433; font-weight: 700;
  background: rgba(255,255,255,.82); padding: 3px 8px; border-radius: 6px; white-space: nowrap;
}
.zone-label { background: rgba(255,255,255,.55); font-weight: 600; color: #2b3345; }
.agent-tag {
  pointer-events: auto; cursor: pointer; display: flex; align-items: center; gap: 5px; flex-wrap: wrap;
  max-width: 220px; padding: 3px 8px 3px 6px; border-radius: 999px; font-size: 12px;
  background: rgba(10, 14, 28, .82); border: 1px solid rgba(255,255,255,.18); white-space: nowrap;
}
.agent-tag i { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.agent-tag .act { display: none; }
.agent-tag:hover { border-color: rgba(255,255,255,.5); }
.agent-tag.is-followed {
  border-radius: 12px; border-color: var(--gold); white-space: normal; padding: 6px 10px; max-width: 240px;
  box-shadow: 0 6px 24px rgba(0,0,0,.4);
}
.agent-tag.is-followed .act { display: block; width: 100%; color: #d7deee; font-size: 12px; line-height: 1.35; }

#follow-hud {
  position: absolute; top: 16px; left: 50%; transform: translateX(-50%); z-index: 6;
  display: flex; align-items: center; gap: 8px; padding: 7px 8px 7px 14px; border-radius: 999px;
  background: rgba(20, 16, 8, .85); border: 1px solid rgba(224,184,102,.6); font-size: 13px; white-space: nowrap;
}
#follow-hud span { color: var(--muted); }
#follow-hud button { border: 0; border-radius: 999px; padding: 5px 10px; background: rgba(255,255,255,.12); font-size: 12px; }
#follow-hud button:hover { background: rgba(255,255,255,.22); }
#follow-hud[hidden] { display: none; }

/* ---------- панель специалистов ---------- */
#panel {
  position: absolute; top: 16px; right: 16px; bottom: 16px; width: 370px; z-index: 7;
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--glass); border: 1px solid var(--line); border-radius: 18px;
  backdrop-filter: blur(14px); box-shadow: 0 20px 60px rgba(0,0,0,.45);
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 16px 10px; }
.panel-title small { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .8px; }
.panel-title h2 { margin: 2px 0 0; font-size: 19px; }
.btn-enter {
  border: 1px solid rgba(224,184,102,.6); background: rgba(224,184,102,.16); border-radius: 10px;
  padding: 8px 12px; font-weight: 600; font-size: 13px; white-space: nowrap;
}
.btn-enter:hover { background: rgba(224,184,102,.3); }
#panel[data-scene="office"] .btn-enter { display: none; }
.panel-stats { display: flex; gap: 6px; padding: 0 16px 12px; flex-wrap: wrap; }
.st { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); padding: 4px 9px; border-radius: 999px; background: rgba(255,255,255,.05); }
.st b { color: var(--text); }
.st i { width: 7px; height: 7px; border-radius: 50%; }
.s-working i { background: var(--working); } .s-waiting i { background: var(--waiting); } .s-reviewing i { background: var(--reviewing); }

.cards { list-style: none; margin: 0; padding: 0 10px 10px; overflow-y: auto; flex: 1; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.2) transparent; }
.card {
  margin: 0 0 8px; border-radius: 12px; background: var(--glass-2); border: 1px solid transparent;
  transition: border-color .2s, background .2s;
}
.card:hover { border-color: rgba(255,255,255,.14); }
.card.selected { border-color: var(--gold); background: rgba(40, 36, 30, .75); }
.card.flash .doing { animation: flash 1.2s ease-out; }
@keyframes flash { from { color: #fff3cf; } }
.card-main { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 10px 4px; background: none; border: 0; text-align: left; }
.avatar {
  width: 36px; height: 36px; border-radius: 10px; flex: none; display: grid; place-items: center;
  background: var(--c, #456); font-weight: 700; font-size: 13px; color: #fff;
  box-shadow: inset 0 -3px 0 rgba(0,0,0,.25);
}
.who { flex: 1; min-width: 0; }
.who b { display: block; font-size: 14.5px; }
.who small { display: block; font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge { font-size: 11.5px; font-weight: 600; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.badge.s-working { background: rgba(74,222,128,.15); color: var(--working); }
.badge.s-waiting { background: rgba(251,191,36,.15); color: var(--waiting); }
.badge.s-reviewing { background: rgba(96,165,250,.17); color: var(--reviewing); }
.doing { padding: 2px 12px 2px 56px; font-size: 13px; line-height: 1.4; color: #d5dbea; cursor: pointer; }
.where { padding: 2px 12px 10px 56px; font-size: 11.5px; color: var(--muted); }
.where::before { content: "● "; color: rgba(255,255,255,.25); }
.card.walking .where { color: var(--gold); }
.details { display: none; padding: 0 12px 12px 56px; }
.card.selected .details { display: block; }
.about { margin: 0 0 8px; font-size: 12.5px; color: var(--muted); }
.details h4 { margin: 0 0 6px; font-size: 11.5px; text-transform: uppercase; letter-spacing: .7px; color: var(--muted); }
.hist { list-style: none; margin: 0; padding: 0; border-left: 2px solid rgba(224,184,102,.35); }
.hist li { position: relative; padding: 0 0 7px 12px; font-size: 12.5px; line-height: 1.35; }
.hist li::before { content: ""; position: absolute; left: -5px; top: 5px; width: 8px; height: 8px; border-radius: 50%; background: var(--gold); }
.hist time { display: block; font-size: 11px; color: var(--muted); }
.hist .empty { color: var(--muted); }
.follow-note { margin-top: 6px; font-size: 11.5px; color: var(--gold); }
#panel[data-scene="city"] .follow-note { display: none; }
kbd { font: 11px ui-monospace, Consolas, monospace; padding: 1px 5px; border-radius: 4px; border: 1px solid rgba(255,255,255,.3); }
.panel-foot { padding: 10px 16px 14px; font-size: 11.5px; color: var(--muted); border-top: 1px solid var(--line); }
.panel-foot .demo { color: var(--gold); }
.panel-foot .live { color: var(--working); }
.panel-foot .live i { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--working); margin-right: 4px; animation: tagPulse 1.5s infinite; }
.panel-foot .err { color: #fca5a5; }

/* ---------- переход и загрузка ---------- */
#fade { position: fixed; inset: 0; background: #03050c; opacity: 0; pointer-events: none; transition: opacity .5s ease; z-index: 50; }
#fade.on { opacity: 1; }
#loader { position: fixed; inset: 0; z-index: 60; display: grid; place-content: center; justify-items: center; gap: 14px; background: var(--bg); color: var(--muted); transition: opacity .6s; }
#loader.done { opacity: 0; pointer-events: none; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid rgba(224,184,102,.2); border-top-color: var(--gold); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.load-err { max-width: 520px; padding: 24px; text-align: left; background: var(--glass-2); border-radius: 16px; color: var(--text); line-height: 1.5; }
.load-err code { background: rgba(255,255,255,.1); padding: 1px 6px; border-radius: 4px; }

/* ---------- телефон ---------- */
@media (max-width: 760px) {
  #app { display: flex; flex-direction: column; }
  #stage { position: relative; inset: auto; flex: 0 0 56%; }
  #panel { position: relative; inset: auto; width: auto; flex: 1; border-radius: 18px 18px 0 0; margin-top: -14px; border-bottom: 0; }
  #topbar { top: 10px; left: 10px; max-width: calc(100% - 20px); flex-wrap: wrap; gap: 8px; }
  #crumb { display: none; }
  .brand { padding: 6px 10px 6px 8px; }
  .brand b { font-size: 13px; }
  #hint { display: none; }
  #follow-hud { top: auto; bottom: 24px; font-size: 12px; max-width: calc(100% - 20px); }
  #follow-hud span { display: none; }
  .panel-head { padding: 12px 14px 8px; }
  .panel-title h2 { font-size: 17px; }
  .agent-tag { font-size: 11px; }
  .room-label, .zone-label { font-size: 9px; }
}
