:root {
  --bg-void: #070b12;
  --bg-panel: rgba(15, 23, 38, 0.88);
  --bg-card: rgba(23, 34, 56, 0.78);
  --border-gold: rgba(241, 196, 15, 0.35);
  --border-subtle: rgba(148, 163, 184, 0.16);
  --gold: #f1c40f;
  --gold-bright: #ffe50c;
  --jade: #00f5d4;
  --danger: #ef4444;
  --success: #10b981;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: radial-gradient(circle at 50% 25%, #131d31 0%, #070b12 100%);
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  user-select: none;
}

/* TOP DESKTOP / MOBILE STATUS BAR */
.os-topbar {
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  background: rgba(9, 13, 22, 0.92);
  border-bottom: 1px solid var(--border-gold);
  backdrop-filter: blur(14px);
  z-index: 30;
}

.brand-cluster {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-logo-img {
  height: 38px;
  width: 38px;
  border-radius: 50%;
  object-fit: contain;
  background: #ffffff;
  padding: 2px;
  border: 1.5px solid var(--gold-bright);
  box-shadow: 0 0 14px rgba(241, 196, 15, 0.45);
  display: block;
}

.brand-orb {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: linear-gradient(135deg, #f1c40f, #d97706);
  color: #090d16;
  font-weight: 900;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 14px rgba(241, 196, 15, 0.45);
}

.brand-title {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.4px;
  color: var(--gold-bright);
}

.brand-sub {
  font-size: 11px;
  color: var(--text-muted);
}

.top-badges {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pill-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid var(--border-subtle);
}

.pill-badge.gpu-ok {
  border-color: rgba(0, 245, 212, 0.45);
  color: var(--jade);
}

.pill-badge.tailscale {
  border-color: rgba(241, 196, 15, 0.45);
  color: var(--gold);
}

.dot-live {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--jade);
  box-shadow: 0 0 8px var(--jade);
  animation: pulseDot 1.6s infinite;
}

@keyframes pulseDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(1.25); }
}

/* QUICK AVATAR STRIP FOR 14 AGENTS (MOBILE & DESKTOP JUMP BAR) */
.agent-strip {
  height: 54px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 12px;
  overflow-x: auto;
  background: rgba(11, 16, 28, 0.85);
  border-bottom: 1px solid var(--border-subtle);
  scrollbar-width: none;
}
.agent-strip::-webkit-scrollbar { display: none; }

.agent-chip {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 10px;
  background: rgba(22, 32, 52, 0.8);
  border: 1px solid rgba(148, 163, 184, 0.2);
  cursor: pointer;
  transition: all 0.18s ease;
  font-size: 11.5px;
}

.agent-chip:hover {
  border-color: var(--gold);
  transform: translateY(-1px);
}

.agent-chip.selected {
  background: rgba(241, 196, 15, 0.18);
  border-color: var(--gold-bright);
  box-shadow: 0 0 12px rgba(241, 196, 15, 0.28);
}

.agent-chip.active-stage {
  border-color: var(--jade);
  box-shadow: 0 0 12px rgba(0, 245, 212, 0.35);
}

.agent-chip.failed {
  border-color: var(--danger);
  background: rgba(239, 68, 68, 0.22);
}

.chip-code {
  font-weight: 800;
  padding: 2px 5px;
  border-radius: 5px;
  font-size: 10px;
  color: #070b12;
}

/* REAL PROJECT SELECTOR IN TOPBAR */
.project-selector {
  background: rgba(15, 23, 42, 0.95);
  color: var(--gold-bright);
  border: 1px solid var(--border-gold);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 11.5px;
  font-weight: 700;
  max-width: 280px;
  cursor: pointer;
  outline: none;
}
.project-selector option {
  background: #090d16;
  color: #fff;
}

/* MODAL KẾT NỐI ĐIỆN THOẠI */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(10px);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-backdrop.open {
  display: flex;
}
.modal-box {
  background: #0d1527;
  border: 2px solid var(--gold);
  border-radius: 18px;
  max-width: 540px;
  width: 100%;
  padding: 22px;
  box-shadow: 0 0 45px rgba(241, 196, 15, 0.28);
  max-height: 90vh;
  overflow-y: auto;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}
.modal-title {
  font-size: 15px;
  font-weight: 800;
  color: var(--gold-bright);
}
.btn-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
}

.qr-cluster {
  display: flex;
  align-items: center;
  gap: 16px;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 14px;
}
#qrCanvas {
  width: 130px;
  height: 130px;
  border-radius: 10px;
  border: 4px solid #fff;
}

.net-link-card {
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(22, 34, 56, 0.85);
  border: 1px solid rgba(241, 196, 15, 0.3);
  margin-bottom: 8px;
}
.net-link-title {
  font-size: 11.5px;
  font-weight: 800;
  color: var(--gold);
  margin-bottom: 4px;
}
.net-link-val {
  font-family: monospace;
  font-size: 12px;
  color: #38bdf8;
  word-break: break-all;
}

/* ACCOUNT MATRIX TABLE */
.matrix-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11.5px;
  margin-top: 8px;
}
.matrix-table th {
  text-align: left;
  padding: 8px 6px;
  color: var(--gold);
  border-bottom: 1px solid var(--border-subtle);
  font-size: 11px;
}
.matrix-table td {
  padding: 8px 6px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.1);
  vertical-align: middle;
}
.matrix-select {
  width: 100%;
  background: #090e1a;
  color: #fff;
  border: 1px solid var(--border-gold);
  border-radius: 6px;
  padding: 5px 7px;
  font-size: 11px;
}

.btn-mini-test {
  background: rgba(0, 245, 212, 0.15);
  border: 1px solid rgba(0, 245, 212, 0.45);
  color: var(--jade);
  font-weight: 700;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 10.5px;
  cursor: pointer;
  white-space: nowrap;
}
.btn-mini-test:hover {
  background: rgba(0, 245, 212, 0.3);
}
.studio-workspace {
  height: calc(100vh - 106px);
  display: grid;
  grid-template-columns: 1fr 410px;
  position: relative;
  overflow: hidden;
}

/* 2.5D ISOMETRIC VIEWPORT */
.iso-stage-container {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: radial-gradient(circle at 50% 45%, #162238 0%, #070b12 85%);
}

#isoCanvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}
#isoCanvas:active {
  cursor: grabbing;
}

/* FLOATING HUD CONTROLS ON 2.5D CANVAS */
.canvas-hud-top {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  pointer-events: none;
}

.hud-card {
  pointer-events: auto;
  background: rgba(10, 15, 26, 0.86);
  border: 1px solid var(--border-gold);
  backdrop-filter: blur(12px);
  border-radius: 12px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* WORKSPACE LINUX GPU HUD CARD (KHÔNG GIAN LÀM VIỆC CHÍNH) */
.workspace-gpu-card {
  position: absolute;
  bottom: 18px;
  left: 18px;
  width: 390px;
  max-width: calc(100% - 36px);
  background: rgba(8, 13, 23, 0.94);
  border: 1.5px solid rgba(0, 245, 212, 0.55);
  border-radius: 14px;
  padding: 12px 14px;
  backdrop-filter: blur(16px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.75), 0 0 20px rgba(0, 245, 212, 0.18);
  z-index: 20;
  pointer-events: auto;
  transition: all 0.25s ease;
}

.workspace-gpu-card:hover {
  border-color: rgba(0, 245, 212, 0.9);
  box-shadow: 0 10px 36px rgba(0, 0, 0, 0.85), 0 0 28px rgba(0, 245, 212, 0.32);
}

.gpu-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.gpu-card-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.gpu-title-text {
  font-size: 13px;
  font-weight: 800;
  color: #00f5d4;
  letter-spacing: 0.5px;
}

.gpu-badge-sub {
  font-size: 10px;
  font-weight: 700;
  color: #94a3b8;
  background: rgba(148, 163, 184, 0.12);
  padding: 2px 6px;
  border-radius: 4px;
}

.gpu-metrics-row {
  display: grid;
  grid-template-columns: 1fr 1.3fr 1.25fr;
  gap: 8px;
  margin-bottom: 10px;
  background: rgba(15, 23, 42, 0.65);
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.gpu-metric-item {
  display: flex;
  flex-direction: column;
}

.gpu-metric-label {
  font-size: 9.5px;
  font-weight: 700;
  color: #94a3b8;
  margin-bottom: 2px;
  text-transform: uppercase;
}

.gpu-metric-val {
  font-size: 14px;
  font-weight: 900;
  line-height: 1.2;
}

.gpu-metric-val.highlight {
  color: #ffe50c;
}

.gpu-metric-val.cyan {
  color: #00f5d4;
}

.gpu-metric-val.text-gold {
  color: #f1c40f;
}

.gpu-metric-sub {
  font-size: 9px;
  color: #64748b;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gpu-bar-container {
  margin-bottom: 8px;
}

.gpu-bar-track {
  width: 100%;
  height: 6px;
  background: rgba(15, 23, 42, 0.85);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid rgba(0, 245, 212, 0.25);
}

.gpu-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #00f5d4, #f1c40f);
  border-radius: 999px;
  transition: width 0.4s ease;
  box-shadow: 0 0 10px rgba(0, 245, 212, 0.6);
}

.gpu-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 9.5px;
  color: #64748b;
}

.btn-action {
  background: rgba(30, 41, 59, 0.9);
  color: var(--text-main);
  border: 1px solid rgba(241, 196, 15, 0.4);
  border-radius: 8px;
  padding: 6px 11px;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.15s ease;
}

.btn-action:hover {
  background: rgba(241, 196, 15, 0.22);
  border-color: var(--gold-bright);
}

.btn-action.primary {
  background: linear-gradient(135deg, #f1c40f, #d97706);
  color: #090d16;
  border: none;
}

.btn-action.danger {
  background: rgba(239, 68, 68, 0.18);
  border-color: #ef4444;
  color: #fca5a5;
}

.canvas-hud-bottom {
  position: absolute;
  bottom: 12px;
  left: 12px;
  right: 12px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  pointer-events: none;
}

/* RIGHT SIDEBAR: DESKTOP OS INSPECTOR & MULTI-TAB DOCK */
.os-inspector {
  height: 100%;
  background: var(--bg-panel);
  border-left: 1px solid var(--border-gold);
  backdrop-filter: blur(16px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.inspector-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: rgba(8, 12, 20, 0.95);
  border-bottom: 1px solid var(--border-subtle);
}

.tab-btn {
  padding: 11px 4px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
}

.tab-btn.active {
  color: var(--gold-bright);
  border-bottom-color: var(--gold-bright);
  background: rgba(241, 196, 15, 0.08);
}

.tab-pane {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: none;
  user-select: text;
}

.tab-pane.active {
  display: block;
}

.section-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 12px;
}

.section-title {
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--gold);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.rule-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px;
  border-radius: 8px;
  background: rgba(10, 15, 26, 0.65);
  border: 1px solid rgba(148, 163, 184, 0.14);
  margin-bottom: 7px;
  font-size: 12px;
  line-height: 1.4;
}

.rule-item.passed {
  border-left: 3px solid var(--success);
}

.rule-item.failed {
  border-left: 3px solid var(--danger);
  background: rgba(239, 68, 68, 0.14);
}

.terminal-box {
  background: #05080f;
  border: 1px solid rgba(0, 245, 212, 0.3);
  border-radius: 10px;
  padding: 10px;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 11.5px;
  color: #a7f3d0;
  max-height: 220px;
  overflow-y: auto;
  line-height: 1.5;
}

.chat-feed {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.chat-bubble {
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 9px 11px;
  font-size: 12px;
  line-height: 1.45;
}

.chat-bubble.guardrail_block {
  border-color: var(--danger);
  background: rgba(127, 29, 29, 0.35);
}

.chat-bubble.boss_command {
  border-color: var(--gold-bright);
  background: rgba(241, 196, 15, 0.14);
}

.chat-bubble.discussion {
  border-color: rgba(0, 245, 212, 0.4);
  background: rgba(0, 245, 212, 0.08);
}

.typing-indicator {
  display: inline-flex;
  gap: 5px;
  align-items: center;
  font-size: 11px;
  color: var(--teal-neon);
  margin-top: 2px;
}

.typing-dot {
  width: 5px;
  height: 5px;
  background: var(--teal-neon);
  border-radius: 50%;
  animation: typingBounce 1.2s infinite ease-in-out;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.3; }
  40% { transform: scale(1.2); opacity: 1; }
}

.chat-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 10.5px;
  color: var(--text-muted);
  margin-bottom: 4px;
  font-weight: 700;
}

.btn-copy-bubble {
  background: rgba(0, 245, 212, 0.12);
  border: 1px solid rgba(0, 245, 212, 0.4);
  color: #00f5d4;
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.btn-copy-bubble:hover {
  background: rgba(0, 245, 212, 0.3);
  border-color: #00f5d4;
  color: #fff;
}

.btn-copy-bubble.copied {
  background: #10b981 !important;
  color: #fff !important;
  border-color: #10b981 !important;
}

.btn-copy-bubble.prominent {
  background: rgba(241, 196, 15, 0.18);
  border-color: var(--gold-bright);
  color: #ffe50c;
  padding: 5px 12px;
  font-size: 11.5px;
  border-radius: 6px;
  box-shadow: 0 0 10px rgba(241, 196, 15, 0.2);
}

.btn-copy-bubble.prominent:hover {
  background: rgba(241, 196, 15, 0.38);
  color: #fff;
}
  font-weight: 700;
}

.boss-input-bar {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.boss-input {
  flex: 1;
  background: rgba(9, 13, 22, 0.95);
  border: 1px solid var(--border-gold);
  border-radius: 8px;
  padding: 8px 10px;
  color: #fff;
  font-size: 12px;
}

.select-box {
  width: 100%;
  background: rgba(9, 13, 22, 0.95);
  color: #fff;
  border: 1px solid var(--border-gold);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 12px;
  margin-top: 6px;
}

/* MOBILE NATIVE BOTTOM NAVIGATION (OPTIMIZED FOR SMARTPHONE OVER TAILSCALE) */
.mobile-bottom-nav {
  display: none;
}

@media (max-width: 920px) {
  .hide-mobile,
  .brand-sub {
    display: none !important;
  }

  #btnOpenMobileModal {
    display: none;
  }

  .brand-title {
    font-size: 12px;
  }

  .pill-badge {
    font-size: 10px;
    padding: 4px 8px;
  }

  .canvas-hud-top {
    top: 8px;
    left: 8px;
    right: 8px;
    gap: 5px;
  }

  .hud-card {
    padding: 5px 7px;
    gap: 4px;
    width: 100%;
    justify-content: center;
  }

  .workspace-gpu-card {
    bottom: 8px;
    left: 8px;
    right: 8px;
    width: auto;
    max-width: none;
    padding: 8px 10px;
  }

  .gpu-metrics-row {
    padding: 6px 8px;
    gap: 6px;
  }

  .gpu-metric-val {
    font-size: 12px;
  }

  .btn-action {
    padding: 4px 7px;
    font-size: 10px;
  }

  .studio-workspace {
    grid-template-columns: 1fr;
    height: calc(100vh - 164px);
  }

  .os-inspector {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 58px;
    height: 64vh;
    border-left: none;
    border-top: 2px solid var(--gold);
    border-radius: 18px 18px 0 0;
    z-index: 40;
    transform: translateY(105%);
    transition: transform 0.26s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 -12px 35px rgba(0, 0, 0, 0.75);
  }

  .os-inspector.mobile-open {
    transform: translateY(0%);
  }

  .mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 58px;
    background: rgba(8, 12, 21, 0.98);
    border-top: 1px solid var(--border-gold);
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    z-index: 50;
    padding-bottom: env(safe-area-inset-bottom);
  }

  .m-nav-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 10.5px;
    font-weight: 700;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
  }

  .m-nav-btn.active {
    color: var(--gold-bright);
  }
}
