:root {
  color-scheme: dark;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  color: #f7f3ea;
  background: #091018;
  --panel: rgba(11, 18, 25, 0.78);
  --panel-strong: rgba(11, 18, 25, 0.92);
  --line: rgba(255, 255, 255, 0.14);
  --text-soft: rgba(247, 243, 234, 0.7);
  --accent: #38d4c3;
  --warning: #ffb74a;
  --danger: #ff5c5c;
  --blue: #78cfff;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.38);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #091018;
}

button {
  font: inherit;
  cursor: pointer;
}

.viewer-shell {
  position: relative;
  width: 100vw;
  height: 100vh;
  min-height: 720px;
  overflow: hidden;
  background: #080d12;
}

.roadview-stage,
#viewer {
  position: absolute;
  inset: 0;
}

.roadview-stage::after {
  position: absolute;
  inset: 0;
  content: "";
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(5, 9, 13, 0.72), transparent 30%, transparent 68%, rgba(5, 9, 13, 0.58)),
    linear-gradient(180deg, rgba(5, 9, 13, 0.38), transparent 38%, rgba(5, 9, 13, 0.54));
}

#viewer {
  background: #070b10;
  cursor: grab;
}

#viewer:active {
  cursor: grabbing;
}

#viewer canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.panel,
.summary-strip article,
.scene-strip,
.roadview-toolbar,
.status-pill {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.topbar {
  position: absolute;
  top: 22px;
  left: 24px;
  right: 24px;
  z-index: 5;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  pointer-events: none;
}

.eyebrow,
.panel-heading span {
  margin: 0 0 7px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  max-width: 720px;
  margin: 0;
  color: #fff;
  font-size: clamp(32px, 4.4vw, 62px);
  line-height: 0.98;
  letter-spacing: 0;
  text-shadow: 0 2px 24px rgba(0, 0, 0, 0.75);
}

#sceneSubtitle {
  max-width: 620px;
  margin: 10px 0 0;
  color: rgba(255, 255, 255, 0.82);
  font-size: 15px;
  font-weight: 800;
  line-height: 1.45;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.76);
}

.status-pill {
  min-width: 82px;
  padding: 11px 14px;
  border-radius: 999px;
  color: #fff;
  font-weight: 900;
  text-align: center;
}

.summary-strip {
  position: absolute;
  top: 148px;
  left: 24px;
  right: 24px;
  z-index: 4;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  max-width: 720px;
}

.summary-strip article {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 54px;
  padding: 10px 13px;
  border-radius: 10px;
}

.summary-strip span {
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 900;
}

.summary-strip strong {
  color: #fff;
  font-size: 27px;
  line-height: 1;
}

.panel {
  z-index: 6;
  border-radius: 10px;
  padding: 13px;
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.panel-heading div {
  display: grid;
  gap: 3px;
}

.panel-heading strong {
  color: #fff;
  font-size: 14px;
}

.panel-heading > strong {
  flex: 0 0 auto;
}

.panel-heading button,
.action-row button {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 8px;
  color: #fff;
  background: rgba(56, 212, 195, 0.15);
  font-size: 12px;
  font-weight: 900;
}

.panel-heading button:hover,
.panel-heading button:focus-visible,
.action-row button:hover,
.action-row button:focus-visible,
.action-row button.is-done {
  border-color: rgba(56, 212, 195, 0.82);
  outline: none;
}

.map-overlay {
  position: absolute;
  left: 24px;
  bottom: 112px;
  width: min(360px, calc(100vw - 48px));
}

#cesiumContainer {
  height: 228px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: #101923;
}

.cesium-viewer-bottom,
.cesium-viewer-toolbar,
.cesium-viewer-animationContainer,
.cesium-viewer-timelineContainer {
  display: none !important;
}

.cesium-fallback {
  display: grid;
  height: 100%;
  place-items: center;
  color: var(--warning);
  font-weight: 900;
}

.map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 11px;
  margin-top: 9px;
  color: var(--text-soft);
  font-size: 11px;
  font-weight: 800;
}

.map-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.map-legend i {
  width: 9px;
  height: 9px;
  border-radius: 999px;
}

.cyan { background: var(--accent); }
.orange { background: var(--warning); }
.red { background: var(--danger); }
.blue { background: var(--blue); }

.info-overlay {
  position: absolute;
  top: 150px;
  right: 24px;
  z-index: 9;
  width: 330px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 36px;
  align-items: center;
  gap: 10px;
  padding: 10px;
}

.event-overlay {
  position: absolute;
  top: 220px;
  right: 24px;
  bottom: 112px;
  width: 330px;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto auto;
  gap: 8px;
}

.meta-grid {
  display: grid;
  gap: 8px;
  margin: 0;
}

.meta-grid div {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  gap: 8px;
}

.meta-grid dt {
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 800;
}

.meta-grid dd {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  color: #fff;
  font-size: 12px;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.evidence-timeline {
  display: grid;
  gap: 7px;
  min-width: 0;
  margin-top: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.evidence-timeline.is-disabled {
  opacity: 0.58;
}

.evidence-timeline.is-disabled input {
  cursor: not-allowed;
}

.evidence-timeline[hidden] {
  display: grid;
}

.info-trigger {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border: 1px solid rgba(56, 212, 195, 0.22);
  border-radius: 999px;
  color: #fff;
  background: rgba(56, 212, 195, 0.16);
  font-size: 16px;
  font-weight: 900;
}

.info-trigger:hover,
.info-trigger:focus-visible {
  border-color: rgba(56, 212, 195, 0.85);
  outline: none;
}

.info-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 30;
  width: 330px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-strong);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-4px);
  transition:
    opacity 140ms ease,
    transform 140ms ease;
}

.info-overlay:hover .info-popover,
.info-overlay:focus-within .info-popover,
.info-trigger:hover + .info-popover,
.info-trigger:focus-visible + .info-popover {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.evidence-timeline div {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: rgba(255, 255, 255, 0.78);
  font-size: 10px;
  font-weight: 900;
}

.evidence-timeline input {
  width: 100%;
  accent-color: var(--accent);
}

.anomaly-list {
  display: grid;
  align-content: start;
  gap: 8px;
  min-height: 0;
  overflow: auto;
  padding-right: 2px;
}

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

.event-filter button {
  min-height: 30px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  color: var(--text-soft);
  background: rgba(255, 255, 255, 0.06);
  font-size: 11px;
  font-weight: 900;
}

.event-filter button:hover,
.event-filter button:focus-visible,
.event-filter button.is-active {
  border-color: rgba(56, 212, 195, 0.76);
  color: #fff;
  background: rgba(56, 212, 195, 0.17);
  outline: none;
}

.anomaly-card {
  display: grid;
  gap: 5px;
  width: 100%;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: #fff;
  background: rgba(255, 255, 255, 0.07);
  text-align: left;
}

.anomaly-card:hover,
.anomaly-card:focus-visible,
.anomaly-card.is-selected {
  border-color: rgba(255, 183, 74, 0.9);
  outline: none;
}

.severity {
  width: fit-content;
  padding: 3px 8px;
  border-radius: 999px;
  color: #1d1200;
  background: var(--warning);
  font-size: 11px;
  font-weight: 900;
}

.severity.critical {
  color: #fff;
  background: var(--danger);
}

.severity.done {
  color: #06251f;
  background: var(--accent);
}

.anomaly-card strong {
  font-size: 14px;
}

.anomaly-card small,
.anomaly-card em {
  color: var(--text-soft);
  font-size: 12px;
  font-style: normal;
  font-weight: 800;
}

.anomaly-detail {
  display: grid;
  gap: 7px;
  min-height: 132px;
  padding: 9px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(5, 9, 13, 0.46);
}

.anomaly-detail p {
  display: none;
}

.detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.detail-head strong {
  color: #fff;
  font-size: 12px;
}

.detail-head span {
  flex: 0 0 auto;
  padding: 3px 7px;
  border-radius: 999px;
  color: #1d1200;
  background: var(--warning);
  font-size: 10px;
  font-weight: 900;
}

.detail-head span.done {
  color: #06251f;
  background: var(--accent);
}

.step-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.step-row span {
  padding: 3px 6px;
  border: 1px solid rgba(56, 212, 195, 0.22);
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.82);
  background: rgba(56, 212, 195, 0.1);
  font-size: 10px;
  font-weight: 900;
}

.image-compare {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.image-compare figure {
  min-width: 0;
  margin: 0;
}

.evidence-shot {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 7px;
  background: #101923;
}

.evidence-shot:hover,
.evidence-shot:focus-visible {
  border-color: rgba(255, 183, 74, 0.9);
  outline: none;
}

.evidence-crop {
  position: absolute;
  inset: 0;
  background-image: var(--shot);
  background-position: var(--shot-position);
  background-size: 245%;
}

.evidence-shot.defect .evidence-crop {
  filter: saturate(0.92) contrast(1.08);
}

.evidence-shot.repaired .evidence-crop {
  filter: saturate(1.1) contrast(1.04);
}

.evidence-overlay {
  position: absolute;
  left: 24%;
  top: 58%;
  width: 54%;
  height: 13%;
  border-radius: 999px;
  transform: rotate(-8deg);
  transform-origin: center;
}

.evidence-shot.defect .evidence-overlay {
  border: 2px dashed rgba(255, 183, 74, 0.95);
  background: linear-gradient(90deg, rgba(255, 183, 74, 0.1), rgba(255, 183, 74, 0.42));
  box-shadow: 0 0 20px rgba(255, 92, 92, 0.35);
}

.evidence-shot.repaired .evidence-overlay {
  height: 10%;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.92), rgba(56, 212, 195, 0.9));
  box-shadow: 0 0 18px rgba(56, 212, 195, 0.38);
}

.evidence-alert {
  position: absolute;
  left: 64%;
  top: 38%;
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 2px solid rgba(255, 255, 255, 0.82);
  border-radius: 999px;
  color: #fff;
  background: var(--danger);
  box-shadow: 0 0 0 8px rgba(255, 92, 92, 0.22);
  font-size: 18px;
  font-weight: 900;
}

.evidence-time {
  position: absolute;
  left: 6px;
  right: 6px;
  bottom: 6px;
  overflow: hidden;
  padding: 4px 5px;
  border-radius: 5px;
  color: #fff;
  background: rgba(0, 0, 0, 0.58);
  font-size: 9px;
  font-weight: 900;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.evidence-empty {
  display: grid;
  gap: 5px;
}

.evidence-empty div {
  display: grid;
  width: 100%;
  aspect-ratio: 4 / 3;
  place-items: center;
  border: 1px dashed rgba(255, 255, 255, 0.18);
  border-radius: 7px;
  color: var(--text-soft);
  background: rgba(255, 255, 255, 0.04);
  font-size: 10px;
  font-weight: 900;
}

.image-compare figcaption,
.anomaly-detail p,
.empty-detail span {
  margin: 5px 0 0;
  color: var(--text-soft);
  font-size: 10px;
  font-weight: 800;
  line-height: 1.25;
}

.empty-detail {
  display: grid;
  place-content: center;
  gap: 4px;
  min-height: 114px;
  text-align: center;
}

.empty-detail strong {
  color: #fff;
  font-size: 13px;
}

.action-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 2px;
}

.scene-strip {
  position: absolute;
  left: 50%;
  bottom: 24px;
  z-index: 7;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 140px));
  gap: 8px;
  padding: 8px;
  border-radius: 10px;
  transform: translateX(-50%);
}

.scene-button {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-height: 56px;
  padding: 6px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: #fff;
  background: rgba(255, 255, 255, 0.07);
  text-align: left;
}

.scene-button:hover,
.scene-button:focus-visible,
.scene-button.is-active {
  border-color: rgba(255, 183, 74, 0.9);
  outline: none;
}

.scene-button b {
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
}

.thumb {
  display: block;
  width: 52px;
  height: 42px;
  border-radius: 6px;
  background-position: center;
  background-size: cover;
}

.thumb-market { background-image: url("../assets/reffen-copenhagen.jpg"); }
.thumb-trail { background-image: url("../assets/san-diego-trail.jpg"); }
.thumb-lake { background-image: url("../assets/lake-byllesby.jpg"); }

.roadview-toolbar {
  position: absolute;
  left: 50%;
  bottom: 98px;
  z-index: 7;
  display: flex;
  gap: 8px;
  padding: 8px;
  border-radius: 999px;
  transform: translateX(-50%);
}

.icon-button {
  display: inline-grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
  font-size: 23px;
  font-weight: 900;
}

.icon-button.wide {
  width: 72px;
  font-size: 12px;
  text-transform: uppercase;
}

.icon-button:hover,
.icon-button:focus-visible {
  border-color: rgba(255, 183, 74, 0.9);
  background: rgba(255, 183, 74, 0.18);
  outline: none;
}

.hotspot-label {
  position: absolute;
  z-index: 8;
  display: none;
  min-width: 142px;
  max-width: 230px;
  padding: 9px 11px;
  border: 1px solid rgba(56, 212, 195, 0.65);
  border-radius: 8px;
  color: #fff;
  background: rgba(6, 11, 14, 0.88);
  box-shadow: 0 14px 44px rgba(0, 0, 0, 0.4);
  font-size: 13px;
  font-weight: 900;
  line-height: 1.25;
  pointer-events: none;
  transform: translate(-50%, -130%);
}

@media (max-width: 980px) {
  .viewer-shell {
    min-height: 100svh;
  }

  .summary-strip {
    display: none;
  }

  .topbar {
    top: 16px;
    left: 16px;
    right: 16px;
  }

  h1 {
    max-width: calc(100vw - 96px);
    font-size: 32px;
  }

  #sceneSubtitle {
    display: none;
  }

  .info-overlay {
    display: none;
  }

  .event-overlay {
    left: 16px;
    right: 16px;
    top: auto;
    bottom: 378px;
    width: auto;
    max-height: 190px;
  }

  .map-overlay {
    left: 16px;
    right: 16px;
    bottom: 182px;
    width: auto;
  }

  #cesiumContainer {
    height: 110px;
  }

  .scene-strip {
    left: 16px;
    right: 16px;
    bottom: 16px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    transform: none;
  }

  .scene-button {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
  }

  .thumb {
    width: 100%;
  }

  .roadview-toolbar {
    bottom: 100px;
  }
}

@media (min-width: 981px) and (max-height: 760px) {
  .summary-strip {
    display: none;
  }

  .info-overlay {
    top: 134px;
    padding: 10px;
  }

  .info-overlay + .event-overlay {
    top: 204px;
  }

  .event-overlay {
    bottom: 104px;
  }
}

@media (max-width: 520px) {
  .panel {
    padding: 10px;
  }

  .event-overlay {
    bottom: 360px;
  }

  .event-overlay .action-row {
    display: none;
  }

  .map-overlay {
    bottom: 178px;
  }

  .scene-button b {
    font-size: 11px;
  }
}
