* {
  box-sizing: border-box;
}

:root {
  /* Accent colors - Cyan */
  --accent-primary: #00d4ff;
  --accent-secondary: #00b8e6;
  --accent-dark: #0099cc;
  --accent-rgb: 0, 212, 255;
}

body {
  margin: 0;
  padding: 0;
  background-color: #0a0a0a;
  font-family:
    -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  overflow: hidden;
  color: #fff;
}

#container {
  position: relative;
  width: 100vw;
  height: 100vh;
}

/* Bottom Logo */
#footer {
  position: fixed;
  bottom: 20px;
  left: 20px;
  /*
  left: 50%;
  transform: translateX(-50%);*/
  display: flex;
  flex-direction: column;
}

.bottom-logo {
  display: flex;
  align-items: center;
  gap: 6px;
  z-index: 50;
  pointer-events: none;
}

.bottom-logo img {
  opacity: 0.5;
  width: 16px;
  height: 16px;
}

#footer span,
.bottom-logo span {
  font-size: 11px;
  font-weight: 400;
  color: #444;
  letter-spacing: 0.5px;
}

.panel {
  background: rgba(15, 15, 20, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  z-index: 100;
  backdrop-filter: blur(10px);
}

.panel.hidden,
#controls.hidden,
#status.hidden {
  display: none !important;
}

/* Panel Wrapper Layout */
.panel-wrapper {
  position: absolute;
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 100;
}

.panel-wrapper.left {
  top: 20px;
  left: 20px;
  width: 380px;
  max-height: calc(100vh - 40px);
}

.panel-wrapper.right {
  top: 20px;
  right: 20px;
  width: 300px;
}

/* Controls Panel (inside left wrapper) */
#controls {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 200px);
  overflow: hidden;
}

/* Status Panel (inside right wrapper) */
#status {
  padding: 16px;
}

/* Room Join Panel */
.room-join-panel {
  padding: 12px;
}

/* Room Panel Header */
.room-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.room-panel-header .current-room-info {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.room-panel-header .no-room-info {
  flex: 1;
}

.room-panel-header .no-room-info .room-id-value {
  color: #666;
  font-size: 14px;
}

.no-room-hint {
  margin-top: 12px;
  padding: 12px;
  background: rgba(var(--accent-rgb), 0.1);
  border: 1px solid rgba(var(--accent-rgb), 0.2);
  border-radius: 8px;
  transition: all 0.2s ease;
}

.no-room-hint.error {
  background: rgba(255, 100, 100, 0.1);
  border-color: rgba(255, 100, 100, 0.3);
}

.no-room-hint.error strong {
  color: #ff8888;
}

.no-room-hint p {
  margin: 0;
  font-size: 13px;
  color: #aaa;
  line-height: 1.5;
}

.no-room-hint strong {
  color: var(--accent-primary);
}

.no-room-hint.error strong:first-child {
  color: #ff6666;
}

.room-header-buttons {
  display: flex;
  gap: 4px;
}

.icon-btn {
  width: 32px;
  height: 32px;
  padding: 0 !important;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  background: rgba(255, 255, 255, 0.1) !important;
  color: #fff !important;
  border-radius: 6px !important;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.2) !important;
  transform: scale(1.05);
}

.icon-btn.add-btn {
  background: linear-gradient(
    135deg,
    var(--accent-primary),
    var(--accent-dark)
  ) !important;
  color: #000 !important;
  font-size: 20px;
  font-weight: bold;
}

.icon-btn.add-btn:hover {
  box-shadow: 0 2px 8px rgba(var(--accent-rgb), 0.4);
}

.icon-btn.small {
  width: 24px;
  height: 24px;
  font-size: 12px;
  border-radius: 4px !important;
}

/* Room Join Collapsible */
.room-join-collapsible {
  margin-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 10px;
}

.room-join-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  cursor: pointer;
  font-size: 12px;
  color: #888;
  user-select: none;
}

.room-join-toggle:hover {
  color: #aaa;
}

.room-join-toggle .toggle-icon {
  font-size: 10px;
  transition: transform 0.3s ease;
}

.room-join-collapsible.collapsed .toggle-icon {
  transform: rotate(-90deg);
}

.room-join-form {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  transition: all 0.3s ease;
}

.room-join-collapsible.collapsed .room-join-form {
  display: none;
}

.room-join-form input[type='text'] {
  flex: 1;
  font-family: monospace;
  font-size: 13px;
  letter-spacing: 1px;
  padding: 8px 10px;
}

.room-join-form button {
  padding: 8px 14px;
  font-size: 12px;
  white-space: nowrap;
}

/* Current room value styling */
.room-id-wrapper {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
}

.room-id-value {
  font-family: monospace;
  font-size: 14px;
  font-weight: 600;
  color: var(--accent-primary);
  letter-spacing: 1px;
  text-transform: uppercase;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.room-name-subtitle {
  font-size: 12px;
  color: #888;
  font-weight: 400;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tab-navigation {
  display: flex;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(20, 20, 25, 0.9);
  border-radius: 12px 12px 0 0;
}

.tab-button {
  flex: 1;
  padding: 14px 12px;
  background: transparent;
  border: none;
  color: #666;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}

.tab-button:hover {
  background: rgba(255, 255, 255, 0.03);
  color: #888;
}

.tab-button.active {
  color: var(--accent-primary);
  border-bottom-color: var(--accent-primary);
  background: rgba(var(--accent-rgb), 0.05);
}

.tab-button svg {
  width: 16px;
  height: 16px;
}

.tab-button .badge {
  background: var(--accent-primary);
  color: #000;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 10px;
  font-weight: 600;
}

.tab-content {
  display: none;
  padding: 16px;
  padding-right: 10px; /* Extra padding for scrollbar space */
  overflow-y: scroll;
  max-height: calc(100vh - 120px);
  scrollbar-gutter: stable; /* Reserve space for scrollbar */
}

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

/* Sub-tabs for assigned devices */
.sub-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
  background: rgba(255, 255, 255, 0.03);
  padding: 4px;
  border-radius: 8px;
}

.sub-tab-button {
  flex: 1;
  padding: 8px 12px;
  background: transparent;
  border: none;
  color: #888;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.sub-tab-button:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.05);
}

.sub-tab-button.active {
  color: #fff;
  background: rgba(var(--accent-rgb), 0.15);
}

.sub-tab-button .badge {
  background: rgba(255, 255, 255, 0.15);
  color: #aaa;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 10px;
  font-weight: 600;
}

.sub-tab-button.active .badge {
  background: var(--accent-primary);
  color: #000;
}

.sub-tab-content {
  display: none;
}

.sub-tab-content.active {
  display: block;
}

.tab-content::-webkit-scrollbar {
  width: 6px;
}

.tab-content::-webkit-scrollbar-track {
  background: transparent;
}

.tab-content::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

.tab-content::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

.section-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-primary);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin: 16px 0 10px 0;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(var(--accent-rgb), 0.2);
}

.section-title:first-child {
  margin-top: 0;
}

.control-group {
  margin-bottom: 12px;
}

.control-group label {
  display: block;
  font-size: 12px;
  color: #888;
  margin-bottom: 6px;
}

.control-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.control-row input[type='range'] {
  flex: 1;
}

.control-row span {
  min-width: 45px;
  text-align: right;
  font-size: 12px;
  color: #aaa;
  font-family: monospace;
}

input[type='text'],
input[type='number'],
input[type='password'],
select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  font-size: 13px;
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--accent-primary);
  background: rgba(var(--accent-rgb), 0.05);
}

input[type='range'] {
  -webkit-appearance: none;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  background: var(--accent-primary);
  border-radius: 50%;
  cursor: pointer;
}

input[type='checkbox'] {
  width: 18px;
  height: 18px;
  margin-right: 8px;
  accent-color: var(--accent-primary);
}

button {
  padding: 10px 16px;
  border: none;
  border-radius: 8px;
  background: linear-gradient(
    135deg,
    var(--accent-primary),
    var(--accent-dark)
  );
  color: #000;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(var(--accent-rgb), 0.3);
}

button:disabled {
  background: #333;
  color: #666;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

button.secondary {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

button.secondary:hover {
  background: rgba(255, 255, 255, 0.15);
  box-shadow: none;
}

button.danger {
  background: linear-gradient(135deg, #ff4444, #cc0000);
  color: #fff;
}

button.danger:hover {
  background: linear-gradient(135deg, #ff6666, #dd2222);
  box-shadow: 0 5px 15px rgba(255, 68, 68, 0.3);
}

.hint-text {
  font-size: 12px;
  color: #888;
  margin-top: 8px;
  line-height: 1.4;
}

.device-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.device-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  transition: all 0.2s;
}

.device-item:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.1);
}

/* Make anchor items in device list clickable */
#anchorList .device-item.anchor {
  cursor: pointer;
}

#anchorList .device-item.anchor:hover {
  background: rgba(0, 255, 136, 0.1);
  border-color: rgba(0, 255, 136, 0.3);
}

#anchorList .device-item.anchor.editing {
  background: rgba(0, 255, 136, 0.15);
  border-color: rgba(0, 255, 136, 0.5);
  border-left-width: 4px;
}

/* Inline mapping form styling */
#anchorList .mapping-form {
  margin: 0;
  border-radius: 0 0 10px 10px;
  border-top: none;
  margin-top: -1px;
}

.device-item.anchor {
  border-left: 3px solid #00ff88;
}

.device-item.tag {
  border-left: 3px solid #ff8800;
}

.device-item.mapped {
  background: rgba(0, 255, 136, 0.05);
}

.device-item.needs-position,
.device-item.not-positioned {
  background: rgba(255, 200, 0, 0.08);
  border-left-color: #ffaa00;
}

.device-item.needs-position .device-meta,
.device-item.not-positioned .device-meta {
  color: #ffaa00;
}

.device-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.device-icon.anchor {
  background: rgba(0, 255, 136, 0.15);
}

.device-icon.tag {
  background: rgba(255, 136, 0, 0.15);
}

.device-info {
  flex: 1;
  min-width: 0;
}

.device-name {
  font-size: 13px;
  font-weight: 500;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.device-meta {
  font-size: 11px;
  color: #666;
  margin-top: 2px;
}

.device-position {
  font-size: 11px;
  color: #666;
  margin-top: 2px;
}

.device-status {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #00ff88;
}

.device-status.offline {
  background: #ff4444;
}

.device-status.stale {
  background: #ffaa00;
}

.device-actions {
  display: flex;
  gap: 6px;
}

.device-actions button {
  padding: 6px 10px;
  font-size: 11px;
}

.mapping-form {
  background: rgba(var(--accent-rgb), 0.05);
  border: 1px solid rgba(var(--accent-rgb), 0.2);
  border-radius: 10px;
  padding: 14px;
  margin-top: 12px;
}

/*all h4 in .panel-wrapper*/
.panel-wrapper h4 {
  margin: 0 0 12px 0;
  font-size: 14px;
  color: #fff;
}

.form-row {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
}

.form-group {
  flex: 1;
}

.form-group label {
  font-size: 11px;
  color: #666;
  margin-bottom: 4px;
  display: block;
}

.form-group input,
.form-group select {
  padding: 8px 10px;
  font-size: 12px;
}

.form-buttons {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.form-buttons button {
  flex: 1;
}

.ranging-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
}

.ranging-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 6px;
  font-size: 12px;
}

.ranging-item .anchor-name {
  color: #00ff88;
}

.ranging-item .distance {
  font-family: monospace;
  color: var(--accent-primary);
}

.ranging-item .rssi {
  color: #888;
  font-size: 11px;
}

#status h4 {
  margin: 0 0 12px 0;
  font-size: 14px;
  color: #fff;
}

.status-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 12px;
}

.status-row:last-child {
  border-bottom: none;
}

.status-label {
  color: #666;
}

.status-value {
  color: #fff;
  font-family: monospace;
}

.status-indicator {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
}

.status-indicator.connected {
  background: #00ff88;
}

.status-indicator.disconnected {
  background: #ff4444;
}

.status-indicator.connecting {
  background: #ffaa00;
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.tag-position {
  background: rgba(255, 136, 0, 0.1);
  border: 1px solid rgba(255, 136, 0, 0.3);
  border-radius: 10px;
  padding: 14px;
  margin-top: 12px;
}

.tag-position h5 {
  margin: 0 0 10px 0;
  font-size: 12px;
  color: #ff8800;
}

.position-coords {
  display: flex;
  gap: 16px;
  font-family: monospace;
  font-size: 14px;
}

.position-coords span {
  color: #888;
}

.position-coords strong {
  color: #fff;
}

.empty-state {
  text-align: center;
  padding: 30px 20px;
  color: #444;
}

.empty-state p {
  margin: 0;
  font-size: 13px;
}

.info-box {
  background: rgba(var(--accent-rgb), 0.05);
  border-left: 3px solid var(--accent-primary);
  border-radius: 0 8px 8px 0;
  padding: 12px;
  margin-bottom: 16px;
  font-size: 12px;
  color: #888;
  line-height: 1.5;
}

.info-box strong {
  color: var(--accent-primary);
}

.trilateration-details {
  margin-top: 14px;
  border-top: 1px solid rgba(255, 136, 0, 0.2);
  padding-top: 10px;
}

.trilateration-details summary {
  cursor: pointer;
  font-size: 12px;
  color: #ff8800;
  padding: 6px 0;
  user-select: none;
  outline: none;
}

.trilateration-details summary:hover {
  color: #ffaa44;
}

.trilateration-details[open] summary {
  margin-bottom: 12px;
}

.trilateration-explanation {
  background: rgba(0, 0, 0, 0.3);
  border-radius: 8px;
  padding: 12px;
  font-size: 11px;
}

.math-section {
  margin-bottom: 14px;
}

.math-section:last-child {
  margin-bottom: 0;
}

.math-section h6 {
  margin: 0 0 8px 0;
  font-size: 11px;
  color: var(--accent-primary);
  font-weight: 600;
}

.explanation-text {
  color: #999;
  line-height: 1.5;
  margin: 6px 0;
}

.mono-box {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  padding: 10px;
  font-family: 'SF Mono', 'Consolas', monospace;
  font-size: 11px;
  overflow-x: auto;
  white-space: pre;
  color: #ccc;
}

.matrix-display {
  margin-bottom: 8px;
  line-height: 1.6;
}

.result-box {
  background: rgba(0, 255, 136, 0.1);
  border-color: rgba(0, 255, 136, 0.3);
  color: #00ff88;
}

.formula {
  background: rgba(var(--accent-rgb), 0.1);
  border: 1px solid rgba(var(--accent-rgb), 0.2);
  border-radius: 6px;
  padding: 10px 14px;
  font-family: 'Times New Roman', serif;
  font-size: 14px;
  color: #fff;
  text-align: center;
  margin: 8px 0;
}

.formula sub,
.formula sup {
  font-size: 10px;
}

.anchor-label {
  color: #00ff88;
}

.distance-label {
  color: var(--accent-primary);
}

.calc-step {
  color: #888;
  font-size: 10px;
  margin-top: 4px;
}

.hover-highlight {
  cursor: pointer;
  padding: 2px 4px;
  margin: -2px -4px;
  border-radius: 4px;
  transition: all 0.15s ease;
  display: inline-block;
}

.hover-highlight:hover {
  background: rgba(var(--accent-rgb), 0.2);
  color: #fff !important;
  transform: scale(1.02);
}

.hover-highlight.dim {
  opacity: 0.6;
}

.hover-highlight.dim:hover {
  opacity: 1;
}

.hover-highlight[data-highlight='anchor']:hover {
  background: rgba(0, 255, 136, 0.25);
  box-shadow: 0 0 8px rgba(0, 255, 136, 0.3);
}

.hover-highlight[data-highlight='range']:hover {
  background: rgba(var(--accent-rgb), 0.25);
  box-shadow: 0 0 8px rgba(var(--accent-rgb), 0.3);
}

.hover-highlight[data-highlight='tag']:hover {
  background: rgba(255, 136, 0, 0.25);
  box-shadow: 0 0 8px rgba(255, 136, 0, 0.3);
}

.hover-highlight[data-highlight='equation']:hover {
  background: rgba(255, 255, 0, 0.2);
  box-shadow: 0 0 8px rgba(255, 255, 0, 0.3);
}

/* Stable trilateration display wrappers */
.trilat-data-wrapper {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.trilat-anchor-entry {
  padding: 8px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 6px;
  border-left: 3px solid var(--anchor-color, #00ff88);
}

.trilat-anchor-name {
  font-weight: 600;
  margin-bottom: 4px;
}

.trilat-anchor-pos,
.trilat-anchor-dist {
  font-size: 11px;
  color: #888;
  font-family: monospace;
}

.trilat-anchor-dist .distance-value {
  color: var(--accent-primary);
  font-weight: 500;
}

.matrix-wrapper,
.result-wrapper {
  white-space: pre;
  font-family: 'SF Mono', 'Consolas', monospace;
}

.result-wrapper {
  padding: 8px;
  background: rgba(0, 255, 136, 0.1);
  border-radius: 6px;
}

.result-x,
.result-y {
  color: #ff8800;
  font-weight: 600;
}

/* Keyboard Legend */
#keyboard-legend {
  position: absolute;
  bottom: 20px;
  right: 20px;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.5);
  z-index: 50;
  backdrop-filter: blur(5px);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.legend-item:last-child {
  margin-bottom: 0;
}

.legend-item .key {
  background: rgba(255, 255, 255, 0.15);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 10px;
  min-width: 20px;
  text-align: center;
}

.panel {
  transition:
    opacity 0.3s ease,
    transform 0.3s ease;
}

/* Toast Notification */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: rgba(var(--accent-rgb), 0.95);
  color: #000;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  z-index: 10000;
  opacity: 0;
  transition: all 0.3s ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Tag Position in Status */
.tag-position-box {
  margin-top: 16px;
  padding: 12px;
  background: rgba(255, 136, 0, 0.1);
  border: 1px solid rgba(255, 136, 0, 0.3);
  border-radius: 8px;
}

.tag-position-box h5 {
  margin: 0 0 8px 0;
  font-size: 12px;
  color: #ff8800;
}

.tag-position-box .position-values {
  display: flex;
  gap: 16px;
  font-size: 13px;
}

.tag-position-box .position-values strong {
  color: #fff;
  font-family: monospace;
}

/* Trilateration Panel (collapsible right side) */
.trilateration-panel {
  width: 100%;
  display: flex;
  flex-direction: column;
  background: rgba(15, 15, 20, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  overflow: hidden;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
}

.trilateration-panel.collapsed .trilateration-content {
  max-height: 0;
  padding: 0 16px;
  overflow: hidden;
}

.trilateration-panel.collapsed .collapse-icon {
  transform: rotate(-90deg);
}

.trilateration-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: rgba(0, 0, 0, 0.3);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  cursor: pointer;
  user-select: none;
}

.trilateration-header:hover {
  background: rgba(255, 255, 255, 0.05);
}

.trilateration-header h4 {
  margin: 0;
  font-size: 14px;
  color: #fff;
}

.trilateration-header .collapse-icon {
  color: #666;
  font-size: 12px;
  transition: transform 0.3s ease;
}

.trilateration-content {
  padding: 16px;
  overflow-y: auto;
  max-height: 400px;
  transition:
    max-height 0.3s ease,
    padding 0.3s ease;
}

.tag-selector-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.tag-selector-wrapper label {
  font-size: 12px;
  color: #888;
}

.tag-selector-wrapper select {
  flex: 1;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  padding: 6px 10px;
  color: #fff;
  font-size: 12px;
}

.tag-selector-wrapper select:focus {
  outline: none;
  border-color: var(--accent-primary);
}

.trilateration-content .placeholder {
  color: #888;
  font-style: italic;
  text-align: center;
  padding: 20px 0;
}

/* Trilateration Live Panel Styles */
.trilat-live-section {
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.trilat-live-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

.trilat-live-section h6 {
  margin: 0 0 10px 0;
  font-size: 11px;
  color: var(--accent-primary);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.trilat-anchor-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.trilat-live-anchor {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 6px;
  font-size: 12px;
}

.trilat-live-anchor .anchor-name {
  flex: 1;
  font-weight: 500;
  color: #fff;
}

.trilat-live-anchor .anchor-pos {
  color: #666;
  font-family: monospace;
  font-size: 11px;
}

.trilat-live-anchor .anchor-dist {
  color: var(--accent-primary);
  font-family: monospace;
  font-weight: 600;
}

.matrix-display-live {
  font-family: monospace;
  font-size: 12px;
  background: rgba(0, 0, 0, 0.3);
  padding: 10px;
  border-radius: 6px;
}

.matrix-display-live .matrix-row {
  color: #888;
  margin: 2px 0;
}

.result-section {
  background: rgba(var(--accent-rgb), 0.05);
  border: 1px solid rgba(var(--accent-rgb), 0.2);
  border-radius: 8px;
  padding: 12px !important;
  margin-top: 12px;
}

.result-display-live {
  display: flex;
  gap: 20px;
  font-size: 14px;
}

.result-display-live .coord {
  color: #888;
}

.result-display-live strong {
  color: var(--accent-primary);
  font-family: monospace;
}

.tab-navigation {
  position: relative;
  z-index: 100;
}

/* Room management modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: rgba(20, 20, 25, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 24px;
  min-width: 400px;
  max-width: 90vw;
  max-height: 80vh;
  overflow-y: auto;
}

.modal h3 {
  margin: 0 0 20px 0;
  font-size: 16px;
  color: #fff;
}

.modal-buttons {
  display: flex;
  gap: 10px;
  margin-top: 20px;
  justify-content: flex-end;
}

/* Trilateration Display - Improved */
.trilat-section {
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.trilat-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

.trilat-section h6 {
  margin: 0 0 8px 0;
  font-size: 11px;
  color: var(--accent-primary);
  font-weight: 600;
}

.trilat-explanation {
  font-size: 11px;
  color: #888;
  margin: 0 0 8px 0;
  line-height: 1.4;
}

.trilat-formula {
  background: rgba(var(--accent-rgb), 0.1);
  border: 1px solid rgba(var(--accent-rgb), 0.2);
  border-radius: 6px;
  padding: 10px 14px;
  font-family: 'Times New Roman', serif;
  font-size: 14px;
  color: #fff;
  text-align: center;
}

.trilat-formula sub,
.trilat-formula sup {
  font-size: 10px;
}

.trilat-data-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
}

.trilat-anchor-card {
  background: rgba(0, 0, 0, 0.3);
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.2s ease;
}

.trilat-anchor-card:hover {
  background: rgba(0, 0, 0, 0.5);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.anchor-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-left: 3px solid #00ff88;
  background: rgba(255, 255, 255, 0.03);
}

.anchor-index {
  background: rgba(255, 255, 255, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 9px;
  font-weight: 600;
}

.anchor-name {
  font-size: 11px;
  font-weight: 500;
  color: #fff;
}

.anchor-data {
  padding: 8px 10px;
}

.data-row {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  margin-bottom: 4px;
}

.data-row:last-child {
  margin-bottom: 0;
}

.data-row .label {
  color: #666;
}

.data-row .value {
  color: #aaa;
  font-family: monospace;
}

.data-row .value.distance {
  color: var(--accent-primary);
  font-weight: 500;
}

.highlight-hover {
  padding: 1px 4px;
  margin: -1px -4px;
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.highlight-hover:hover {
  background: rgba(var(--accent-rgb), 0.3);
  color: #fff !important;
}

.trilat-equations {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 6px;
  padding: 10px;
}

.equation-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  margin-bottom: 4px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.equation-row:hover {
  background: rgba(255, 255, 255, 0.05);
}

.equation-row:last-child {
  margin-bottom: 0;
}

.eq-label {
  color: #666;
  font-size: 10px;
  min-width: 35px;
}

.eq-content {
  font-family: monospace;
  font-size: 11px;
  color: #aaa;
}

.matrix-display {
  display: flex;
  gap: 20px;
  align-items: flex-start;
}

.matrix-block {
  display: flex;
  align-items: center;
  gap: 8px;
}

.matrix-label {
  font-family: monospace;
  color: #666;
  font-size: 12px;
}

.matrix-content {
  background: rgba(0, 0, 0, 0.3);
  border-radius: 4px;
  padding: 8px;
  font-family: monospace;
  font-size: 10px;
  color: #aaa;
}

.matrix-row {
  white-space: nowrap;
}

.result-display {
  background: rgba(0, 255, 136, 0.1);
  border: 1px solid rgba(0, 255, 136, 0.3);
  border-radius: 8px;
  padding: 12px;
  margin-top: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.result-display:hover {
  background: rgba(0, 255, 136, 0.2);
  transform: scale(1.02);
}

.result-label {
  color: #888;
  font-size: 11px;
  margin-right: 10px;
}

.result-coords {
  font-family: monospace;
  font-size: 14px;
  color: #fff;
}

.coord-x,
.coord-y {
  color: #ff8800;
  font-weight: 600;
}

/* Quality Metrics Section */
.quality-metrics {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 6px;
  padding: 10px;
  margin-bottom: 10px;
}

.metric-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.metric-row:last-child {
  border-bottom: none;
}

.metric-label {
  color: #888;
  font-size: 11px;
  min-width: 70px;
}

.metric-value {
  font-family: monospace;
  font-size: 12px;
  font-weight: 600;
  min-width: 60px;
}

.metric-value.good {
  color: #00ff88;
}

.metric-value.medium {
  color: #ffaa00;
}

.metric-value.bad {
  color: #ff4444;
}

.metric-desc {
  color: #555;
  font-size: 9px;
  flex: 1;
  text-align: right;
}

.quality-bar {
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 6px;
}

.quality-indicator {
  height: 100%;
  background: linear-gradient(90deg, #ff4444, #ffaa00, #00ff88);
  border-radius: 2px;
  transition: width 0.3s ease;
}

.quality-label {
  text-align: center;
  font-size: 11px;
  color: #888;
}

/* Residuals Section */
.residuals-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.residual-row {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 6px;
  padding: 10px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.residual-row:hover {
  background: rgba(255, 255, 255, 0.05);
}

.res-anchor {
  display: block;
  font-size: 11px;
  color: #aaa;
  margin-bottom: 6px;
  font-weight: 500;
}

.res-values {
  display: flex;
  gap: 12px;
  font-size: 10px;
  margin-bottom: 6px;
}

.res-measured {
  color: #666;
}

.res-expected {
  color: #888;
}

.res-diff {
  font-weight: 600;
  font-family: monospace;
}

.res-bar-container {
  height: 3px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  overflow: hidden;
}

.res-bar {
  height: 100%;
  border-radius: 2px;
  transition: width 0.3s ease;
}

/* Additional modal styles */
.modal-description {
  color: #888;
  font-size: 13px;
  margin: 0 0 16px 0;
}

.error-message {
  color: #ff4444;
  font-size: 12px;
  margin-top: 8px;
  padding: 8px;
  background: rgba(255, 68, 68, 0.1);
  border-radius: 4px;
}

/* Device group label */
.device-group-label {
  font-size: 10px;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin: 12px 0 6px 0;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.device-group-label:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

/* Available device styling */
.available-device {
  opacity: 0.7;
  border-left-color: #666 !important;
}

.available-device:hover {
  opacity: 1;
}

/* Assigned device in current room - subtle highlight */
.device-item.assigned-to-room {
  opacity: 1;
  border-left: 3px solid var(--accent-primary) !important;
  background: rgba(var(--accent-rgb), 0.05);
}

.device-item.assigned-to-room:hover {
  background: rgba(var(--accent-rgb), 0.08);
}

/* Small button */
button.small {
  padding: 4px 10px;
  font-size: 14px;
  min-width: 28px;
}

/* Protected room indicator */
.room-protected {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.room-protected::before {
  content: '🔒';
  font-size: 10px;
}

/* Unassign button in device list */
.device-item .unassign-btn {
  opacity: 0;
  transition: opacity 0.2s;
}

.device-item:hover .unassign-btn {
  opacity: 1;
}
