:root {
  --bg: #06101a;
  --bg-soft: #0c1624;
  --panel: #0d1826;
  --panel-2: #132235;
  --panel-3: #18283d;
  --line: #29435f;
  --line-2: #3f6286;
  --text: #eef7ff;
  --muted: #9eb3c7;
  --accent: #5da7ff;
  --accent-2: #7ae1a2;
  --warn: #ffd166;
  --danger: #ff8770;
  --pixel-shadow: 0 6px 0 rgba(0, 0, 0, 0.35), 0 12px 22px rgba(0, 0, 0, 0.3);
  --radius: 0;
}

* { box-sizing: border-box; }

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top, rgba(40, 73, 112, 0.28), transparent 28%),
    linear-gradient(180deg, #09131e, var(--bg));
  color: var(--text);
  font-family: "Trebuchet MS", "Segoe UI", Tahoma, sans-serif;
}

body { image-rendering: pixelated; }
button, input, select { font: inherit; }
button { cursor: pointer; }

.shell {
  max-width: 1540px;
  margin: 0 auto;
  padding: 20px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 8px;
  color: #89c4ff;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 12px;
}

.topbar h1 {
  margin: 0;
  font-size: 34px;
  line-height: 1.05;
}

.subtitle {
  margin: 10px 0 0;
  color: var(--muted);
  max-width: 780px;
  line-height: 1.55;
}

.topbar-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.grid {
  display: grid;
  grid-template-columns: minmax(760px, 1.35fr) minmax(360px, 0.65fr);
  gap: 18px;
  align-items: start;
}

.card {
  background: linear-gradient(180deg, rgba(17, 29, 43, 0.95), rgba(10, 18, 29, 0.98));
  border: 2px solid var(--line);
  box-shadow: var(--pixel-shadow);
  position: relative;
}

.card::before {
  content: "";
  position: absolute;
  inset: 4px;
  border: 1px solid rgba(159, 197, 238, 0.08);
  pointer-events: none;
}

.office-card { padding: 16px; }

.office-head,
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
}

.office-head h2,
.section-head h2 {
  margin: 0 0 6px;
  font-size: 20px;
}

.office-head p,
.section-head p {
  margin: 0;
  color: var(--muted);
}

.legend {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

.legend span {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
}

.dot {
  width: 10px;
  height: 10px;
  display: inline-block;
  margin-right: 8px;
  border: 1px solid #09121d;
}

.dot.blue { background: #5da7ff; }
.dot.orange { background: #ffb84d; }
.dot.green { background: #6de28f; }

.office-stage {
  position: relative;
  margin-top: 14px;
  border: 2px solid var(--line);
  overflow: hidden;
  background: #050a10;
  aspect-ratio: 16 / 10;
}

.office-stage::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent 18%, transparent 82%, rgba(0, 0, 0, 0.14)),
    radial-gradient(circle at center, transparent 55%, rgba(0, 0, 0, 0.1));
  pointer-events: none;
}

.office-bg {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  image-rendering: pixelated;
}

#spriteLayer {
  position: absolute;
  inset: 0;
  z-index: 2;
}

.agent-sprite {
  position: absolute;
  transform: translate(-50%, -50%);
  background: transparent;
  border: 0;
  padding: 0;
  width: 112px;
  min-height: 104px;
  user-select: none;
  --sprite-bob: 0px;
  --sprite-flip: 1;
}

.agent-sprite:hover,
.agent-sprite:focus-visible {
  outline: none;
}

.agent-canvas-wrap {
  position: relative;
  width: 62px;
  height: 62px;
  margin: 0 auto;
  display: grid;
  place-items: center;
  transform: translateY(var(--sprite-bob));
}

.agent-canvas {
  width: 62px;
  height: 62px;
  image-rendering: pixelated;
  filter: drop-shadow(0 2px 0 rgba(0,0,0,0.48)) drop-shadow(0 5px 8px rgba(0,0,0,0.2));
  transform: scaleX(var(--sprite-flip));
  transform-origin: center;
}

.agent-shadow {
  width: 26px;
  height: 7px;
  margin: -2px auto 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.34);
  filter: blur(1px);
  opacity: 0.78;
}

.agent-sprite.moving .agent-shadow {
  transform: scaleX(0.86);
  opacity: 0.62;
}

.agent-badge {
  min-width: 86px;
  max-width: 158px;
  margin: 0 auto 3px;
  padding: 5px 7px;
  background: rgba(8, 16, 28, 0.94);
  border: 2px solid #d9e9f9;
  color: var(--text);
  text-align: center;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.35);
  line-height: 1.15;
}

.agent-badge::after {
  content: "";
  display: block;
  width: 10px;
  height: 5px;
  margin: 5px auto -10px;
  background: rgba(8, 16, 28, 0.94);
  border-left: 2px solid #d9e9f9;
  border-right: 2px solid #d9e9f9;
  border-bottom: 2px solid #d9e9f9;
}

.agent-badge strong {
  display: block;
  font-size: 13px;
  margin-bottom: 2px;
}

.agent-badge span {
  display: block;
  font-size: 10px;
  line-height: 1.2;
  color: #d2deec;
}

.agent-sprite.active .agent-badge,
.agent-sprite:hover .agent-badge {
  border-color: #7ec3ff;
  box-shadow: 0 0 0 2px rgba(93, 167, 255, 0.15), 0 3px 0 rgba(0, 0, 0, 0.35);
}

/* Force-hide old colored tags/pins from previous versions */
.agent-pin,
.agent-tag,
.agent-dot,
.agent-color {
  display: none !important;
}

.sidebar {
  display: grid;
  gap: 18px;
}

.details-card,
.admin-card {
  padding: 16px;
}

.staff-detail.empty {
  color: var(--muted);
  padding: 16px 0 2px;
}

.detail-hero {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 12px;
}

.detail-hero h3 {
  margin: 0 0 4px;
  font-size: 24px;
}

.detail-sprite-preview {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  border: 2px solid var(--line-2);
  background: linear-gradient(180deg, var(--panel-3), var(--panel));
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.06);
}

.detail-sprite-preview canvas {
  width: 56px;
  height: 56px;
  image-rendering: pixelated;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0;
}

.meta-grid .box {
  padding: 10px;
  border: 2px solid var(--line);
  background: rgba(255,255,255,0.03);
}

.meta-grid .box.wide { grid-column: span 2; }

.meta-grid .box span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.project-tags,
.project-meta,
.message-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag,
.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 8px;
  border: 1px solid var(--line-2);
  background: rgba(16, 28, 44, 0.92);
  color: var(--text);
  font-size: 12px;
}

.project-list,
.message-list {
  display: grid;
  gap: 10px;
  padding: 0 16px 16px;
}

.project-card,
.message-card {
  padding: 12px;
  border: 2px solid var(--line);
  background: linear-gradient(180deg, rgba(21, 35, 52, 0.96), rgba(12, 21, 33, 0.98));
}

.focus-card { margin-top: 14px; }

.project-card-head,
.message-card-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
  margin-bottom: 8px;
}

.project-card h3 {
  margin: 0;
  font-size: 16px;
}

.project-card p,
.message-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
  font-size: 13px;
}

.btn {
  appearance: none;
  padding: 10px 14px;
  border: 2px solid var(--line-2);
  color: var(--text);
  background: linear-gradient(180deg, #1a2f49, #132235);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.28);
}

.btn:hover { transform: translateY(-1px); }

.btn:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.28);
}

.btn.primary {
  background: linear-gradient(180deg, #348fff, #2167d4);
  border-color: #7ebfff;
}

.admin-form {
  display: grid;
  gap: 12px;
}

.admin-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.admin-form input,
.admin-form select {
  height: 42px;
  padding: 0 11px;
  border: 2px solid var(--line);
  background: rgba(7, 12, 20, 0.96);
  color: var(--text);
  outline: none;
}

.admin-form input:focus,
.admin-form select:focus { border-color: #7ec3ff; }

.actions-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.muted {
  color: var(--muted);
  font-size: 12px;
}

.status-good { color: #90edb2; }
.status-risk { color: var(--warn); }
.status-bad { color: var(--danger); }

@media (max-width: 1180px) {
  .grid { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .shell { padding: 14px; }
  .topbar { flex-direction: column; }
  .topbar h1 { font-size: 28px; }
  .office-head,
  .section-head { flex-direction: column; }
  .legend {
    text-align: left;
    justify-items: start;
  }
  .agent-badge {
    max-width: 120px;
    min-width: 78px;
    padding: 4px 6px;
  }
  .agent-badge strong { font-size: 12px; }
  .agent-badge span { font-size: 9px; }
  .agent-canvas-wrap {
    width: 56px;
    height: 56px;
  }
  .agent-canvas {
    width: 56px;
    height: 56px;
  }
}
