:root {
  --bg: #08111d;
  --bg-soft: rgba(6, 17, 31, 0.76);
  --glass: rgba(10, 22, 39, 0.54);
  --glass-strong: rgba(8, 18, 34, 0.72);
  --border: rgba(171, 203, 255, 0.18);
  --text: #f4fbff;
  --muted: #b0c5e9;
  --blue: #3a93ff;
  --cyan: #00d8ff;
  --green: #20d67b;
  --orange: #ffb54d;
  --red: #ff5f5f;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --hero-height: 82px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.app,
.map {
  width: 100vw;
  height: 100vh;
}

.app {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at top left, rgba(0, 216, 255, 0.14), transparent 20%),
    radial-gradient(circle at top right, rgba(58, 147, 255, 0.12), transparent 18%),
    var(--bg);
}

.map {
  position: absolute;
  inset: 0;
  z-index: 1;
}

.glass {
  background: linear-gradient(180deg, rgba(12, 28, 49, 0.68), rgba(8, 18, 34, 0.54));
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px) saturate(1.2);
  -webkit-backdrop-filter: blur(22px) saturate(1.2);
}

.hero,
.dock,
.floating-summary,
.panel,
.bottom-sheet,
.context-menu,
.modal,
.mobile-nav {
  position: absolute;
  z-index: 30;
}

.hero {
  top: 18px;
  left: 18px;
  right: 18px;
  min-height: var(--hero-height);
  border-radius: 999px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.hero__brand {
  flex: 0 1 300px;
  min-width: 0;
}

.eyebrow,
.panel-kicker {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-weight: 700;
  font-size: 0.72rem;
  color: var(--cyan);
}

.hero__brand h1,
.hero__brand p,
.panel__header h2,
.bottom-sheet__header h2,
.sheet-card h3,
.modal__header h2 {
  margin: 0;
}

.hero__copy,
.panel__subtitle,
.sheet-card p,
.terrain-card__copy {
  color: var(--muted);
}

.hero__controls {
  min-width: 0;
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.search {
  width: min(360px, 100%);
}

.search input,
.field input,
.field textarea {
  width: 100%;
  border-radius: 999px;
  border: 1px solid rgba(173, 205, 255, 0.22);
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
  outline: none;
}

.search input {
  height: 42px;
  padding: 0 14px;
}

.search input::placeholder,
.field input::placeholder,
.field textarea::placeholder {
  color: rgba(218, 232, 255, 0.52);
}

.hero__modes,
.hero__actions,
.metric-grid,
.field-grid,
.modal__actions,
.context-menu__actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.hero-mode,
.chip-btn,
.panel__close,
.mobile-nav__action,
.dock__action,
.context-action {
  min-height: 38px;
  border-radius: 999px;
  border: 1px solid rgba(163, 194, 246, 0.18);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  padding: 0 12px;
}

.basemap-switch,
.bottom-sheet__actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.hero-mode.is-active,
.dock__action.is-active,
.mobile-nav__action.is-active,
.chip-btn.is-active,
.chip-btn--primary {
  background: linear-gradient(180deg, rgba(58, 147, 255, 0.92), rgba(21, 86, 189, 0.94));
  border-color: rgba(103, 179, 255, 0.5);
}

.dock {
  top: 138px;
  left: 18px;
  width: 96px;
  border-radius: 32px;
  padding: 12px;
  display: grid;
  gap: 10px;
}

.dock__action {
  min-height: 84px;
  border-radius: 24px;
  padding: 10px 8px;
  display: grid;
  place-items: center;
  gap: 6px;
  text-align: center;
}

.dock__icon {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.12);
  color: var(--cyan);
  font-weight: 700;
}

.floating-summary {
  top: 138px;
  right: 18px;
  border-radius: 30px;
  padding: 12px;
  display: grid;
  gap: 10px;
  min-width: 228px;
}

.summary-card,
.sheet-card,
.detail-row,
.toggle-row,
.metric-card {
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(168, 196, 240, 0.12);
}

.summary-card {
  padding: 12px 14px;
}

.summary-card span,
.detail-row span,
.toggle-row span,
.metric-card span {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
}

.summary-card strong,
.detail-row strong,
.metric-card strong {
  display: block;
  margin-top: 4px;
  font-size: 1.05rem;
}

.panel {
  width: min(360px, calc(100vw - 32px));
  border-radius: var(--radius-xl);
  overflow: hidden;
}

.panel--left {
  top: 138px;
  left: 128px;
}

.panel--right {
  top: 276px;
  right: 18px;
}

.panel__header,
.bottom-sheet__header,
.modal__header {
  padding: 18px 18px 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.panel__body,
.modal__body {
  padding: 18px;
}

.panel__body--spaced {
  display: grid;
  gap: 10px;
}

.toggle-row,
.detail-row {
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.toggle-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--cyan);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  border-radius: 999px;
  padding: 0 12px;
  font-size: 0.74rem;
  font-weight: 700;
  border: 1px solid transparent;
}

.status-pill.neutral {
  background: rgba(131, 165, 217, 0.16);
  color: #d7e8ff;
}

.status-pill.good {
  background: rgba(32, 214, 123, 0.16);
  color: #84f8b8;
}

.status-pill.warning {
  background: rgba(255, 181, 77, 0.16);
  color: #ffd58a;
}

.status-pill.bad {
  background: rgba(255, 95, 95, 0.18);
  color: #ffb3b3;
}

.bottom-sheet {
  left: 128px;
  right: 18px;
  bottom: 18px;
  border-radius: 34px;
  padding-bottom: 14px;
}

.bottom-sheet__grid {
  padding: 18px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.sheet-card {
  padding: 16px;
}

.mobile-nav {
  display: none;
}

.context-menu {
  width: min(320px, calc(100vw - 24px));
  border-radius: 28px;
  padding: 16px;
}

.context-action {
  width: 100%;
  justify-content: center;
}

.context-action--ghost {
  background: rgba(255, 255, 255, 0.03);
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  z-index: 40;
  background: rgba(3, 10, 17, 0.34);
  backdrop-filter: blur(10px);
}

.modal {
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  width: min(760px, calc(100vw - 32px));
  border-radius: 34px;
  z-index: 50;
}

.modal__form {
  padding: 18px;
  display: grid;
  gap: 16px;
}

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

.field {
  display: grid;
  gap: 8px;
}

.field span {
  color: var(--muted);
  font-size: 0.82rem;
}

.field input,
.field textarea {
  padding: 14px 16px;
  border-radius: 18px;
}

.field textarea {
  border-radius: 20px;
  resize: vertical;
}

.metric-grid {
  padding: 18px 18px 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.metric-card {
  padding: 14px;
}

.terrain-card {
  padding: 18px;
}

.terrain-card__header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.terrain-visual {
  margin-top: 18px;
  position: relative;
  height: 150px;
  border-radius: 22px;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(58, 147, 255, 0.18), rgba(4, 14, 28, 0.42)),
    radial-gradient(circle at top, rgba(0, 216, 255, 0.18), transparent 35%);
  border: 1px solid rgba(164, 198, 246, 0.14);
}

.terrain-line,
.terrain-fresnel,
.terrain-obstacle {
  position: absolute;
}

.terrain-line {
  left: 8%;
  right: 8%;
  top: 52%;
  height: 3px;
  background: linear-gradient(90deg, var(--cyan), var(--green));
  transform: rotate(-4deg);
  transform-origin: left center;
}

.terrain-fresnel {
  left: 18%;
  right: 18%;
  top: 28%;
  bottom: 28%;
  border: 2px dashed rgba(0, 216, 255, 0.6);
  border-radius: 999px;
}

.terrain-obstacle {
  width: 22%;
  height: 34%;
  left: 43%;
  bottom: 0;
  background: linear-gradient(180deg, rgba(255, 181, 77, 0.34), rgba(255, 95, 95, 0.62));
  clip-path: polygon(18% 100%, 50% 12%, 82% 100%);
}

.terrain-card__copy {
  margin: 14px 0 0;
}

.leaflet-container {
  background: #07111d;
  font: inherit;
}

.leaflet-popup-content-wrapper {
  background: rgba(10, 21, 39, 0.92);
  color: var(--text);
  border: 1px solid rgba(159, 194, 246, 0.2);
  border-radius: 18px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
}

.leaflet-popup-tip {
  background: rgba(10, 21, 39, 0.92);
}

.map-popup {
  min-width: 220px;
}

.map-popup h4,
.map-popup p {
  margin: 0 0 8px;
}

.map-popup p {
  color: var(--muted);
  font-size: 0.86rem;
}

.popup-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.popup-tag {
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(58, 147, 255, 0.15);
  color: #dff0ff;
  font-size: 0.72rem;
  font-weight: 700;
}

@media (max-width: 1180px) {
  .hero {
    border-radius: 30px;
    min-height: auto;
    align-items: flex-start;
    flex-direction: column;
    padding: 10px 12px;
  }

  .hero__controls {
    width: 100%;
    justify-content: flex-start;
    gap: 8px;
  }

  .dock {
    top: 166px;
    width: 74px;
  }

  .dock__action span:last-child {
    display: none;
  }

  .panel--left {
    left: 102px;
  }

  .floating-summary,
  .panel--right {
    right: 14px;
  }

  .bottom-sheet {
    left: 102px;
  }
}

@media (max-width: 980px) {
  .hero {
    top: 12px;
    left: 12px;
    right: 12px;
    padding: 10px;
  }

  .search {
    width: 100%;
  }

  .hero__controls {
    display: grid;
  }

  .dock,
  .floating-summary,
  .panel--left {
    display: none;
  }

  .panel--right {
    top: auto;
    right: 12px;
    left: 12px;
    bottom: 142px;
    width: auto;
    max-height: 24vh;
    overflow: auto;
  }

  .bottom-sheet {
    left: 12px;
    right: 12px;
    bottom: 72px;
    padding-bottom: 10px;
  }

  .bottom-sheet__grid {
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .mobile-nav {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    left: 12px;
    right: 12px;
    bottom: 12px;
    border-radius: 999px;
    padding: 8px;
    gap: 8px;
  }

  .mobile-nav__action {
    min-height: 46px;
    padding: 0 10px;
  }
}

@media (max-width: 767px) {
  :root {
    --hero-height: auto;
  }

  .hero {
    gap: 8px;
  }

  .hero__modes {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .hero__actions {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr;
  }

  .hero__copy {
    display: none;
  }

  .hero__brand h1 {
    font-size: 1rem;
  }

  .hero__brand .eyebrow {
    font-size: 0.64rem;
  }

  .search input,
  .hero-mode,
  .chip-btn {
    min-height: 36px;
    height: 36px;
  }

  .panel--right {
    max-height: 20vh;
    bottom: 196px;
  }

  .bottom-sheet {
    border-radius: 28px;
    bottom: 64px;
  }

  .bottom-sheet__header {
    padding: 12px 12px 0;
  }

  .sheet-card {
    padding: 12px;
  }

  .metric-grid,
  .field-grid {
    grid-template-columns: 1fr;
  }

  .modal {
    width: calc(100vw - 18px);
    max-height: calc(100vh - 24px);
    overflow: auto;
  }
}
