* { box-sizing: border-box; }

html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: "Segoe UI", system-ui, sans-serif;
  color: #d7ebff;
  background: radial-gradient(circle at center, #0d1530 0%, #05080f 72%);
}

#stage-3d {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1;
}

.device-auth-panel {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(3, 8, 18, 0.84);
  padding: 16px;
}

.device-auth-panel.visible {
  display: flex;
}

.device-auth-card {
  width: min(560px, 95vw);
  border-radius: 12px;
  border: 1px solid #315680;
  background: #0a1426f2;
  padding: 14px;
  display: grid;
  gap: 10px;
}

.device-auth-card h2 {
  margin: 0;
  font-size: 1rem;
  color: #b7d3f2;
}

.device-auth-card p {
  margin: 0;
  font-size: 0.82rem;
  color: #9ec6ee;
}

.device-auth-card input,
.device-auth-card textarea {
  width: 100%;
  border-radius: 8px;
  border: 1px solid #315680;
  background: #0b1729;
  color: #b7d3f2;
  padding: 8px;
  font-size: 0.78rem;
  font-family: Consolas, monospace;
}

.device-auth-card textarea {
  resize: vertical;
}

.device-auth-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.device-auth-card button {
  border-radius: 8px;
  border: 1px solid #315680;
  background: #10233d;
  color: #b7d3f2;
  padding: 8px;
  font-size: 0.78rem;
  cursor: pointer;
}

.device-auth-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.overlay-root {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  opacity: 0;
  transition: opacity 260ms ease;
  pointer-events: none;
}

.overlay-root.visible {
  opacity: 1;
}

.overlay-status {
  border: 1px solid #2e507c;
  background: #0d1b31cc;
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 0.76rem;
  letter-spacing: 0.08em;
  color: #9ec6ee;
  text-transform: uppercase;
}

.floating-feed {
  position: fixed;
  right: 16px;
  bottom: 16px;
  width: min(420px, 90vw);
  z-index: 6;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.floating-line {
  border-radius: 10px;
  border: 1px solid #315680;
  background: #0a1426d6;
  padding: 9px 11px;
  font-size: 0.78rem;
  color: #a7c9ef;
  opacity: 0;
  transform: translateY(8px);
  animation: fade-floating var(--life, 2600ms) ease forwards;
}

.floating-line.warn {
  border-color: #8a6b3d;
  color: #f0d4a6;
}

.floating-line.error {
  border-color: #925059;
  color: #ffc0c8;
}

.technical-panel {
  position: fixed;
  left: 14px;
  right: 14px;
  bottom: 14px;
  max-height: 42vh;
  z-index: 7;
  border-radius: 12px;
  border: 1px solid #315680;
  background: #0a1426de;
  padding: 10px;
  display: none;
}

.technical-panel.visible {
  display: block;
}

.technical-header {
  font-size: 0.74rem;
  color: #8cb6dd;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}

.admin-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.admin-tab-button {
  border-radius: 8px;
  border: 1px solid #315680;
  background: #0b1729;
  color: #9ec6ee;
  padding: 8px;
  font-size: 0.74rem;
  letter-spacing: 0.04em;
  cursor: pointer;
  font-family: Consolas, monospace;
}

.admin-tab-button.active {
  background: #10233d;
  color: #d6ebff;
}

.admin-tab-content {
  display: none;
  margin-top: 8px;
}

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

#technical-content {
  margin: 0;
  max-height: 33vh;
  overflow: auto;
  font-size: 0.76rem;
  line-height: 1.34;
  color: #b0cced;
  font-family: Consolas, monospace;
}

.runtime-health-card {
  border-radius: 8px;
  border: 1px solid #315680;
  background: #0b1729;
  padding: 8px;
  margin-bottom: 8px;
}

.runtime-health-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.runtime-health-item {
  border-radius: 6px;
  border: 1px solid #315680;
  background: #0a1426;
  padding: 6px 8px;
  display: grid;
  gap: 2px;
}

.runtime-health-item span {
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  color: #8cb6dd;
  text-transform: uppercase;
}

.runtime-health-item strong {
  font-size: 0.78rem;
  font-weight: 600;
  color: #d6ebff;
  font-family: Consolas, monospace;
}

.runtime-health-item strong.runtime-health-fresh {
  color: #b8f3c9;
}

.runtime-health-item strong.runtime-health-warn {
  color: #f0d4a6;
}

.runtime-health-item strong.runtime-health-stale {
  color: #ffc0c8;
}

.runtime-trace-actions {
  margin-top: 8px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  align-items: center;
}

.runtime-trace-actions button {
  border-radius: 8px;
  border: 1px solid #315680;
  background: #10233d;
  color: #b7d3f2;
  padding: 6px 10px;
  font-size: 0.74rem;
  cursor: pointer;
  font-family: Consolas, monospace;
}

.credential-form {
  margin-top: 10px;
  display: grid;
  gap: 8px;
}

.credential-title {
  font-size: 0.74rem;
  color: #8cb6dd;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.credential-form input,
.credential-form textarea,
.credential-form select {
  width: 100%;
  border-radius: 8px;
  border: 1px solid #315680;
  background: #0b1729;
  color: #b7d3f2;
  padding: 8px;
  font-size: 0.78rem;
  font-family: Consolas, monospace;
}

.credential-form textarea {
  resize: vertical;
}

.credential-voice-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.credential-webcam-row {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 8px;
}

.credential-webcam-row button {
  border-radius: 8px;
  border: 1px solid #315680;
  background: #10233d;
  color: #b7d3f2;
  padding: 8px;
  font-size: 0.78rem;
  cursor: pointer;
  font-family: Consolas, monospace;
}

.credential-webcam-preview-wrap {
  border-radius: 8px;
  border: 1px solid #315680;
  background: #0b1729;
  padding: 8px;
  display: grid;
  gap: 6px;
}

#cred-webcam-preview {
  width: 100%;
  max-height: 180px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid #315680;
  background: #071120;
  display: none;
}

#cred-webcam-preview.visible {
  display: block;
}

.credential-form button {
  border-radius: 8px;
  border: 1px solid #315680;
  background: #10233d;
  color: #b7d3f2;
  padding: 8px;
  font-size: 0.78rem;
  cursor: pointer;
}

.credential-feedback {
  min-height: 16px;
  font-size: 0.74rem;
  color: #9ec6ee;
}

.credential-feedback.error {
  color: #ffc0c8;
}

.credential-feedback.success {
  color: #b8f3c9;
}

.mic-diagnostics {
  margin-top: 10px;
  display: grid;
  gap: 8px;
}

.mic-diagnostics button,
.mic-diagnostics select {
  width: 100%;
  border-radius: 8px;
  border: 1px solid #315680;
  background: #0b1729;
  color: #b7d3f2;
  padding: 8px;
  font-size: 0.78rem;
  font-family: Consolas, monospace;
}

.mic-diagnostics button {
  cursor: pointer;
  background: #10233d;
}

.cred-management {
  margin-top: 10px;
  display: grid;
  gap: 8px;
}

.cred-management button,
.cred-management select {
  width: 100%;
  border-radius: 8px;
  border: 1px solid #315680;
  background: #0b1729;
  color: #b7d3f2;
  padding: 8px;
  font-size: 0.78rem;
  font-family: Consolas, monospace;
}

.cred-management button {
  cursor: pointer;
  background: #10233d;
}

.device-monitoring {
  margin-top: 10px;
  display: grid;
  gap: 8px;
}

.device-monitoring button,
.device-monitoring select {
  width: 100%;
  border-radius: 8px;
  border: 1px solid #315680;
  background: #0b1729;
  color: #b7d3f2;
  padding: 8px;
  font-size: 0.78rem;
  font-family: Consolas, monospace;
}

.device-monitoring button {
  cursor: pointer;
  background: #10233d;
}

.device-map-wrapper {
  width: 100%;
  min-height: 220px;
  border-radius: 8px;
  border: 1px solid #315680;
  overflow: hidden;
  background: #071120;
}

#devices-map {
  width: 100%;
  height: 220px;
  border: 0;
  display: block;
}

.devices-map-meta {
  border-radius: 8px;
  border: 1px solid #315680;
  background: #0b1729;
  color: #9ec6ee;
  padding: 8px;
  font-size: 0.75rem;
  font-family: Consolas, monospace;
}

.devices-location-stream {
  max-height: 130px;
  overflow: auto;
  border-radius: 8px;
  border: 1px solid #315680;
  background: #0b1729;
  padding: 6px;
  display: grid;
  gap: 6px;
}

.device-location-item {
  border-radius: 6px;
  border: 1px solid #315680;
  background: #0a1426;
  padding: 6px 8px;
  font-size: 0.72rem;
  color: #b7d3f2;
  font-family: Consolas, monospace;
}

.device-location-item.warn {
  border-color: #8a6b3d;
  color: #f0d4a6;
}

@keyframes fade-floating {
  0% {
    opacity: 0;
    transform: translateY(10px);
  }
  10% {
    opacity: 1;
    transform: translateY(0);
  }
  85% {
    opacity: 1;
    transform: translateY(0);
  }
  100% {
    opacity: 0;
    transform: translateY(-6px);
  }
}
