:root {
  --bg: #0b1117;
  --panel: rgba(16, 24, 32, 0.82);
  --panel-border: rgba(255, 255, 255, 0.09);
  --text: #e8eef4;
  --muted: #93a4b4;
  --accent: #35c3a0;
  --danger: #ff6b6b;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
}

#cesiumContainer {
  position: absolute;
  inset: 0;
}

.cesium-viewer-bottom {
  display: none;
}

.panel {
  position: absolute;
  z-index: 5;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  backdrop-filter: blur(10px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

.panel--top {
  top: 16px;
  left: 16px;
  padding: 12px 16px;
  max-width: min(420px, calc(100vw - 32px));
}

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

.panel__title h1 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.panel__title p {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #f2b84b;
  box-shadow: 0 0 0 4px rgba(242, 184, 75, 0.15);
  flex: none;
}

.dot.is-ready {
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(53, 195, 160, 0.16);
}

.dot.is-error {
  background: var(--danger);
  box-shadow: 0 0 0 4px rgba(255, 107, 107, 0.16);
}

.panel--capas {
  top: 16px;
  right: 16px;
  padding: 10px 14px 12px;
  width: 210px;
}

.panel--capas h2 {
  margin: 0 0 8px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
}

.capas {
  display: grid;
  gap: 6px;
}

.capa {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}

.capa input {
  accent-color: var(--accent);
  cursor: pointer;
}

.capa.is-error {
  color: var(--danger);
}

.capa.is-error::after {
  content: "error";
  margin-left: auto;
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.capa__ver {
  margin-left: auto;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.capa__ver:hover {
  color: var(--accent);
  background: rgba(53, 195, 160, 0.12);
  border-color: rgba(53, 195, 160, 0.35);
}

.panbtn {
  position: absolute;
  top: 96px;
  left: 16px;
  z-index: 6;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  border: 1px solid var(--panel-border);
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
  backdrop-filter: blur(10px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.panbtn:hover {
  color: var(--accent);
  border-color: rgba(53, 195, 160, 0.5);
}

.panbtn.is-activo {
  background: #e39b3d;
  border-color: #f0b45c;
  color: #1a1206;
}

#btnZoomIn {
  top: 96px;
}

#btnZoomOut {
  top: 148px;
}

#btnVista32 {
  top: 200px;
}

#btnHome {
  top: 252px;
}

#btnPan {
  top: 304px;
}

#btnRot {
  top: 356px;
}

.panel--controls {
  left: 16px;
  bottom: 16px;
  padding: 12px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 10px;
  width: 300px;
}

.btn {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  border-radius: 9px;
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.btn:hover {
  background: rgba(53, 195, 160, 0.18);
  border-color: rgba(53, 195, 160, 0.5);
}

.field {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}

.field input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.field output {
  font-variant-numeric: tabular-nums;
  color: var(--text);
  min-width: 22px;
  text-align: right;
}

.check {
  grid-column: 1 / -1;
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}

.check input {
  accent-color: var(--accent);
}

.note {
  grid-column: 1 / -1;
  margin: 0;
  font-size: 10px;
  line-height: 1.4;
  color: rgba(147, 164, 180, 0.75);
}

.credits-bar {
  position: absolute;
  left: 50%;
  bottom: 6px;
  transform: translateX(-50%);
  z-index: 5;
  max-width: calc(100vw - 360px);
  text-align: center;
  font-size: 10px;
  color: rgba(147, 164, 180, 0.85);
  pointer-events: auto;
}

.credits-bar .cesium-widget-credits,
.credits-bar .cesium-credit-wrapper,
.credits-bar .cesium-credit-expand-link {
  font-size: 10px;
  color: rgba(147, 164, 180, 0.85);
  cursor: pointer;
}

.credits-bar img {
  display: none;
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 50% 40%, rgba(20, 40, 50, 0.9), rgba(6, 10, 14, 0.96));
  transition: opacity 0.4s ease;
}

.overlay.hidden {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

.overlay__card {
  width: min(420px, calc(100vw - 40px));
  text-align: center;
  padding: 28px 26px;
}

.overlay__card h2 {
  margin: 0 0 6px;
  font-size: 17px;
  font-weight: 600;
}

.overlay__card p {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.overlay__card code {
  background: rgba(255, 255, 255, 0.08);
  padding: 1px 5px;
  border-radius: 5px;
  font-size: 12px;
}

.overlay--error .overlay__card h2 {
  color: var(--danger);
}

.hint {
  font-size: 12px !important;
}

.spinner {
  width: 34px;
  height: 34px;
  margin: 0 auto 14px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.14);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.bar {
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

.bar__fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #2f9d86, var(--accent));
  transition: width 0.25s ease;
}

.popup {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  background: rgba(4, 8, 12, 0.55);
  backdrop-filter: blur(2px);
  transition: opacity 0.2s ease;
}

.popup.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.popup__card {
  position: relative;
  display: grid;
  grid-template-columns: 420px 1fr;
  gap: 26px;
  width: min(1160px, calc(100vw - 40px));
  min-height: 640px;
  max-height: 94vh;
  overflow: auto;
  padding: 26px 30px;
  background: #0f1820;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}

.popup__close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.popup__close:hover {
  background: rgba(255, 255, 255, 0.14);
}

.popup__edificio {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 6px;
}

.popup__pista {
  margin: 0;
  font-size: 10.5px;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.popup__pisos {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}

.chip-piso {
  border: 1px solid rgba(53, 195, 160, 0.45);
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 3px 9px;
  font-family: inherit;
  font-size: 10px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.chip-piso:hover {
  color: var(--text);
  border-color: rgba(53, 195, 160, 0.8);
}

.chip-piso.is-activo {
  background: rgba(53, 195, 160, 0.22);
  border-color: #35c3a0;
  color: #dff6ef;
  font-weight: 600;
}

.edificio3d {
  position: relative;
  width: 100%;
  height: 380px;
  border-radius: 12px;
  overflow: hidden;
}

.edificio3d canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.edificio3d__iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  background: #031018;
}

.ficha__top {
  display: flex;
  gap: 24px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.ficha__label {
  display: block;
  font-size: 15px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 2px;
}

.ficha__num {
  font-size: 44px;
  line-height: 1;
  font-weight: 700;
}

.ficha__codigo {
  font-size: 30px;
  line-height: 1.1;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--accent);
}

.ficha__badge {
  display: inline-block;
  margin: 10px 0 12px;
  padding: 3px 10px;
  border: 1px solid rgba(53, 195, 160, 0.55);
  border-radius: 999px;
  font-size: 12px;
  color: #a9f0de;
}

.ficha__badge--observado {
  margin-left: 8px;
  border-color: rgba(255, 217, 40, 0.7);
  background: rgba(255, 217, 40, 0.14);
  color: #ffe36b;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.ficha__alerta {
  margin: -4px 0 12px;
  padding: 8px 10px;
  border-radius: 0 8px 8px 0;
  border-left: 3px solid #ffd928;
  background: rgba(255, 217, 40, 0.08);
  color: #ffe9a3;
  font-size: 12px;
  line-height: 1.45;
}

.ficha__grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px 16px;
}

.ficha__grid div {
  min-width: 0;
}

.ficha__grid strong {
  display: block;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.ficha__piso {
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(53, 195, 160, 0.35);
  background: rgba(53, 195, 160, 0.08);
  font-size: 15px;
}

.ficha__piso strong {
  font-size: 15px;
}

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

  .edificio3d {
    height: 300px;
  }

  .ficha__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .panel--controls {
    width: calc(100vw - 32px);
  }
}
