:root {
  --panel: rgba(15, 23, 42, 0.78);
  --panel-solid: #0f172a;
  --line: rgba(148, 163, 184, 0.18);
  --text: #e2e8f0;
  --muted: #94a3b8;
  --working: #22c55e;
  --waiting: #f59e0b;
  --idle: #94a3b8;
  --error: #ef4444;
  --gold: #f5c542;
  --side-w: 330px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #0b1224;
  color: var(--text);
}
button {
  font: inherit;
  color: inherit;
}

#app,
#labels {
  position: fixed;
  inset: 0;
}
#labels {
  pointer-events: none;
}
#app canvas {
  display: block;
  touch-action: none;
}

.glass {
  background: var(--panel);
}
#hud,
#side,
#detail,
#controls button,
#legend {
  background: var(--panel);
  backdrop-filter: blur(14px) saturate(1.3);
  -webkit-backdrop-filter: blur(14px) saturate(1.3);
  border: 1px solid var(--line);
  box-shadow: 0 10px 30px rgba(2, 6, 23, 0.35);
}

/* ---------- HUD ---------- */
#hud {
  position: fixed;
  top: 14px;
  left: 14px;
  right: calc(var(--side-w) + 28px);
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 10px 16px;
  border-radius: 16px;
  z-index: 5;
}
body:not(.side-open) #hud {
  right: 14px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.brand b {
  display: block;
  font-size: 16px;
  letter-spacing: 0.02em;
}
.brand small {
  display: block;
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand small.ok::before {
  content: '';
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--working);
  box-shadow: 0 0 8px var(--working);
  animation: blink 1.6s infinite;
}
.brand small.bad {
  color: #fca5a5;
}
.brand small.warn {
  color: #fcd34d;
}

/* ---------- layar terkunci (server online) ---------- */
#lock {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: radial-gradient(circle at 50% 30%, #1e293b, #0b1224 70%);
}
#lock[hidden] {
  display: none;
}
.lock-card {
  max-width: 380px;
  padding: 26px 24px;
  border-radius: 18px;
  text-align: center;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 20px 50px rgba(2, 6, 23, 0.5);
}
.lock-card .logo {
  margin: 0 auto 14px;
}
.lock-card > b {
  font-size: 17px;
}
.lock-card p {
  margin: 12px 0 0;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--muted);
}
.lock-card code {
  padding: 1px 5px;
  border-radius: 5px;
  background: rgba(148, 163, 184, 0.16);
  color: var(--text);
}
.lock-card .lock-err {
  color: #fca5a5;
}
.logo {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-weight: 900;
  color: #111827;
  background: linear-gradient(135deg, #fde68a, #f5c542 60%, #d97706);
}
.counts {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-left: auto;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 12.5px;
  color: var(--muted);
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid var(--line);
}
.chip b {
  color: var(--text);
  font-size: 14px;
}
.chip i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--c);
  box-shadow: 0 0 8px var(--c);
}
.chip.working {
  --c: var(--working);
}
.chip.waiting {
  --c: var(--waiting);
}
.chip.idle {
  --c: var(--idle);
}
.chip.error {
  --c: var(--error);
}
.clock {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 18px;
  color: #cbd5e1;
}

/* ---------- daftar tim ---------- */
#side {
  position: fixed;
  top: 14px;
  right: 14px;
  bottom: 14px;
  width: var(--side-w);
  border-radius: 18px;
  display: flex;
  flex-direction: column;
  z-index: 5;
  transform: translateX(calc(100% + 30px));
  transition: transform 0.25s ease;
}
body.side-open #side {
  transform: none;
}
.side-head {
  padding: 14px 16px 8px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}
.side-head small {
  color: var(--muted);
  font-size: 11px;
}
#list {
  overflow-y: auto;
  padding: 0 8px 10px;
  scrollbar-width: thin;
}
.grp {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 12px 8px 6px;
}
.grp span {
  color: #64748b;
  margin-left: 4px;
}
.item {
  width: 100%;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  text-align: left;
  padding: 9px 9px;
  margin: 2px 0;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  cursor: pointer;
}
.item:hover {
  background: rgba(51, 65, 85, 0.45);
}
.item.sel {
  background: rgba(51, 65, 85, 0.7);
  border-color: rgba(255, 255, 255, 0.25);
}
.item .txt {
  flex: 1;
  min-width: 0;
}
.item b {
  display: block;
  font-size: 13.5px;
}
.item small {
  display: block;
  color: var(--muted);
  font-size: 11.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.item em {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-style: normal;
  font-size: 12px;
  color: #a7f3d0;
  margin-top: 3px;
  line-height: 1.35;
}
.item .task {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 11.5px;
  color: #cbd5e1;
  margin-top: 3px;
  line-height: 1.35;
}
.item.s-waiting em {
  color: #fde68a;
}
.item.s-idle em {
  color: #64748b;
}
.item.s-error em {
  color: #fca5a5;
}
.item .meta {
  font-size: 11px;
  color: #64748b;
  white-space: nowrap;
  padding-top: 2px;
}
.av {
  position: relative;
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 800;
  color: #fff;
  background: var(--c);
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.18);
}
.av i {
  position: absolute;
  right: -3px;
  bottom: -3px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid var(--panel-solid);
  background: var(--idle);
}
.s-working .av i {
  background: var(--working);
  box-shadow: 0 0 8px var(--working);
}
.s-waiting .av i {
  background: var(--waiting);
}
.s-error .av i {
  background: var(--error);
}
.av.big {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  font-size: 15px;
}

/* ---------- panel detail ---------- */
#detail {
  position: fixed;
  left: 14px;
  bottom: 70px;
  width: 400px;
  max-height: calc(100vh - 170px);
  overflow-y: auto;
  border-radius: 18px;
  padding: 16px 18px 14px;
  z-index: 6;
  font-size: 13px;
  line-height: 1.45;
  scrollbar-width: thin;
  animation: rise 0.2s ease;
}
.d-head {
  display: flex;
  gap: 12px;
  align-items: center;
}
.d-title {
  flex: 1;
  min-width: 0;
}
.d-title h2 {
  margin: 0;
  font-size: 18px;
}
.d-title p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
}
.x {
  border: 0;
  background: rgba(51, 65, 85, 0.6);
  width: 30px;
  height: 30px;
  border-radius: 9px;
  cursor: pointer;
}
.d-status {
  margin: 12px 0 6px;
  padding: 7px 10px;
  border-radius: 10px;
  background: rgba(30, 41, 59, 0.75);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}
.d-status i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--c);
  box-shadow: 0 0 10px var(--c);
}
.d-status.s-working {
  --c: var(--working);
}
.d-status.s-waiting {
  --c: var(--waiting);
}
.d-status.s-idle {
  --c: var(--idle);
}
.d-status.s-error {
  --c: var(--error);
}
#detail dl {
  display: grid;
  grid-template-columns: 70px 1fr;
  gap: 3px 10px;
  margin: 10px 0 4px;
}
#detail dt {
  color: var(--muted);
}
#detail dd {
  margin: 0;
  overflow-wrap: anywhere;
}
.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}
#detail h3 {
  margin: 14px 0 5px;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
#detail p {
  margin: 0 0 4px;
}
.muted {
  color: var(--muted);
}
.from {
  font-weight: 700;
  color: var(--gold);
}
.quote {
  border-left: 3px solid rgba(148, 163, 184, 0.35);
  padding-left: 10px;
  color: #cbd5e1;
}
.feed {
  list-style: none;
  margin: 0;
  padding: 0;
}
.feed li {
  padding: 5px 0;
  border-bottom: 1px solid rgba(148, 163, 184, 0.1);
  font-size: 12.5px;
  overflow-wrap: anywhere;
}
.feed li.fail {
  color: #fca5a5;
}
.feed .ic {
  display: inline-block;
  width: 20px;
}
.d-actions {
  margin-top: 12px;
  display: flex;
  gap: 8px;
}
.d-actions button,
#controls button {
  border-radius: 11px;
  padding: 8px 12px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--line);
  background: rgba(30, 41, 59, 0.8);
}
.d-actions button.on,
#controls button.on {
  background: #0e7490;
  border-color: #22d3ee;
}

/* ---------- kontrol & legenda ---------- */
#controls {
  position: fixed;
  left: 14px;
  bottom: 14px;
  display: flex;
  gap: 8px;
  z-index: 5;
  flex-wrap: wrap;
}
#legend {
  position: fixed;
  bottom: 14px;
  right: calc(var(--side-w) + 28px);
  display: flex;
  gap: 14px;
  padding: 8px 14px;
  border-radius: 12px;
  font-size: 11.5px;
  color: var(--muted);
  z-index: 4;
}
body:not(.side-open) #legend {
  right: 14px;
}
.lg {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: -1px;
}
.lg.working {
  background: var(--working);
}
.lg.waiting {
  background: var(--waiting);
}
.lg.idle {
  background: var(--idle);
}
.lg.msg {
  background: #fbbf24;
  box-shadow: 0 0 8px #fbbf24;
}
.only-mobile {
  display: none;
}

/* ---------- label 3D ---------- */
.tag {
  position: relative;
  pointer-events: none;
  padding-bottom: 4px;
}
.tag-in {
  pointer-events: auto;
  cursor: pointer;
}
.tag-stem {
  position: absolute;
  left: 50%;
  bottom: 2px;
  width: 1px;
  height: 0;
  background: linear-gradient(to bottom, rgba(226, 232, 240, 0.75), rgba(226, 232, 240, 0.15));
  pointer-events: none;
}
.tag-in {
  transform-origin: 50% 100%;
  background: rgba(15, 23, 42, 0.86);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 4px 9px 5px;
  font-size: 12px;
  line-height: 1.25;
  color: #f8fafc;
  white-space: nowrap;
  box-shadow: 0 6px 16px rgba(2, 6, 23, 0.35);
  transition: background 0.2s, border-color 0.2s;
}
.tag-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.tag .nm {
  font-weight: 700;
}
.tag .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--c, var(--idle));
  box-shadow: 0 0 8px var(--c, transparent);
}
.tag-sub {
  font-size: 11px;
  color: #a7f3d0;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}
.tag-msg {
  display: none;
  font-size: 11px;
  font-weight: 700;
  color: #fde68a;
  margin-top: 2px;
}
.tag.got-msg .tag-msg {
  display: block;
  animation: pop 0.35s ease;
}
.tag.s-working {
  --c: var(--working);
}
.tag.s-waiting {
  --c: var(--waiting);
}
.tag.s-waiting .tag-sub {
  color: #fde68a;
}
.tag.s-error {
  --c: var(--error);
}
.tag.s-error .tag-in {
  border-color: rgba(239, 68, 68, 0.7);
}
.tag.s-error .tag-sub {
  color: #fca5a5;
}
.tag.s-idle .tag-in {
  background: rgba(30, 41, 59, 0.66);
  color: #cbd5e1;
}
.tag.s-idle .tag-sub {
  color: #94a3b8;
}
.tag.ceo .tag-in {
  border-color: rgba(245, 197, 66, 0.85);
  box-shadow: 0 0 0 1px rgba(245, 197, 66, 0.25), 0 6px 18px rgba(245, 197, 66, 0.25);
}
.tag.sel .tag-in {
  border-color: #fff;
  background: rgba(14, 116, 144, 0.92);
}
.tag.lm-nama .tag-sub,
.tag.lm-aktif.s-idle .tag-sub {
  display: none;
}
.tag.sel .tag-sub {
  display: block !important;
}

@keyframes blink {
  50% {
    opacity: 0.35;
  }
}
@keyframes rise {
  from {
    transform: translateY(10px);
    opacity: 0;
  }
}
@keyframes pop {
  from {
    transform: scale(0.6);
    opacity: 0;
  }
}

/* ---------- layar kecil ---------- */
@media (max-width: 900px) {
  :root {
    --side-w: min(92vw, 360px);
  }
  #hud {
    right: 14px !important;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 12px;
  }
  .counts {
    margin-left: 0;
    order: 3;
    width: 100%;
  }
  .clock {
    margin-left: auto;
  }
  #side {
    top: auto;
    height: 62vh;
    z-index: 7;
  }
  #detail {
    left: 8px;
    right: 8px;
    width: auto;
    bottom: 64px;
    max-height: 58vh;
  }
  #legend {
    display: none;
  }
  .only-mobile {
    display: inline-block;
  }
  #controls button {
    padding: 8px 10px;
  }
}
