:root {
  color-scheme: light;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f3f4f1;
  color: #202326;
  font-size: 15px;
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #f3f4f1;
}

body.auth-pending .app-shell,
body.login-required .app-shell {
  visibility: hidden;
}

body.authenticated .login-overlay,
.login-overlay[hidden] {
  display: none;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  height: 100vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.topbar {
  min-height: 76px;
  display: grid;
  grid-template-columns: minmax(190px, 1fr) max-content minmax(170px, 240px);
  gap: 14px;
  align-items: center;
  padding: 12px 18px;
  border-bottom: 1px solid #d9dcd4;
  background: #fbfbf7;
  overflow: hidden;
}

.brand h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.15;
  font-weight: 680;
  letter-spacing: 0;
}

.brand span,
.eyebrow {
  display: block;
  margin-top: 5px;
  color: #69706b;
  font-size: 12px;
  line-height: 1.2;
  text-transform: uppercase;
  letter-spacing: 0;
}

.controls {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(6, max-content);
  justify-content: end;
  gap: 8px;
  align-items: center;
}

.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 18px;
  background: #f3f4f1;
}

.login-panel {
  width: min(340px, 100%);
  display: grid;
  gap: 12px;
  padding: 20px;
  border: 1px solid #c6cbc4;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 18px 44px rgba(31, 40, 36, 0.18);
}

.login-panel h2 {
  margin: 0 0 4px;
  font-size: 18px;
  line-height: 1.2;
}

.login-panel input {
  width: 100%;
  height: 40px;
  border: 1px solid #c6cbc4;
  border-radius: 6px;
  padding: 8px 10px;
}

.tool-button.login-button {
  width: 100%;
  height: 40px;
  background: #27332d;
  color: #ffffff;
}

.login-error {
  min-height: 17px;
  color: #a13326;
  font-size: 12px;
  line-height: 1.35;
}

.segmented {
  min-width: 0;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  border: 1px solid #c6cbc4;
  border-radius: 6px;
  overflow: hidden;
  background: #ffffff;
}

.segmented button,
.tool-button {
  min-width: 0;
  height: 36px;
  border: 0;
  border-left: 1px solid #d9dcd4;
  background: #ffffff;
  color: #36403a;
  padding: 0 9px;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
  white-space: nowrap;
}

.segmented button:first-child {
  border-left: 0;
}

.segmented button.active {
  background: #27332d;
  color: #ffffff;
}

.tool-button {
  border: 1px solid #c6cbc4;
  border-radius: 6px;
}

.mode-select {
  min-width: 0;
  width: auto;
  height: 36px;
  border: 1px solid #c6cbc4;
  border-radius: 6px;
  background: #ffffff;
  color: #36403a;
  padding: 0 8px;
  font-size: 12px;
}

#sizeModeSelect {
  max-width: 150px;
}

#colorModeSelect {
  max-width: 190px;
}

#embeddingModeSelect {
  max-width: 250px;
}

.segmented button:focus-visible,
.tool-button:focus-visible,
.mode-select:focus-visible,
.settings-field input:focus-visible,
.search input:focus-visible {
  outline: 2px solid #2d6cdf;
  outline-offset: 2px;
}

.search {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px;
  color: #59615b;
}

.search span {
  font-size: 12px;
  text-transform: uppercase;
}

.search input {
  width: 100%;
  min-width: 0;
  height: 38px;
  border: 1px solid #c6cbc4;
  border-radius: 6px;
  background: #ffffff;
  padding: 8px 10px;
  color: #202326;
  text-transform: uppercase;
}

.workspace {
  min-height: 0;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
}

.plot-surface {
  position: relative;
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  background: #ffffff;
}

#scatterCanvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
}

.selection-ring {
  position: absolute;
  z-index: 4;
  width: 22px;
  height: 22px;
  margin-left: -11px;
  margin-top: -11px;
  border: 2px solid #111418;
  border-radius: 999px;
  pointer-events: none;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.72);
}

.selection-bounds {
  position: absolute;
  z-index: 4;
  border: 2px solid rgba(17, 20, 24, 0.78);
  background: rgba(17, 20, 24, 0.035);
  pointer-events: none;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.62);
}

.selection-box {
  position: absolute;
  z-index: 6;
  border: 1px solid #27332d;
  background: rgba(39, 51, 45, 0.09);
  pointer-events: none;
}

.plot-loading {
  position: absolute;
  inset: 0;
  z-index: 7;
  display: grid;
  place-items: center;
  background: #ffffff;
  color: #69706b;
  font-size: 16px;
  pointer-events: none;
}

.plot-loading[hidden] {
  display: none;
}

.tooltip {
  position: absolute;
  z-index: 5;
  pointer-events: none;
  min-width: 108px;
  max-width: 220px;
  padding: 7px 9px;
  border: 1px solid #bec5bd;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.96);
  color: #202326;
  box-shadow: 0 8px 20px rgba(35, 42, 38, 0.12);
  font-size: 12px;
}

.tooltip strong,
.tooltip span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tooltip span {
  margin-top: 3px;
  color: #69706b;
}

.detail-panel {
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  border-left: 1px solid #d9dcd4;
  background: #fbfbf7;
}

.detail-heading {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 18px;
  border-bottom: 1px solid #d9dcd4;
  background: #fbfbf7;
}

.detail-back-button {
  height: 30px;
  margin-bottom: 10px;
  padding: 0 10px;
}

.event-map {
  width: 100%;
  aspect-ratio: 3 / 2;
  margin-bottom: 14px;
  border: 1px solid #d9dcd4;
  border-radius: 6px;
  overflow: hidden;
  background: #ffffff;
}

.event-map.empty {
  background:
    linear-gradient(#ffffff, #ffffff),
    repeating-linear-gradient(45deg, transparent 0 8px, rgba(39, 51, 45, 0.04) 8px 16px);
}

.event-map .maplibregl-ctrl-attrib {
  font-size: 9px;
  line-height: 1.2;
}

.event-map-popup .maplibregl-popup-content {
  padding: 6px 8px;
  border: 1px solid #bec5bd;
  border-radius: 6px;
  box-shadow: 0 8px 20px rgba(35, 42, 38, 0.12);
  color: #202326;
  font-size: 12px;
  line-height: 1.25;
}

.detail-heading h2 {
  margin: 4px 0 0;
  font-size: 28px;
  line-height: 1.05;
  letter-spacing: 0;
}

.detail-content {
  padding: 16px 18px 24px;
}

.empty-state {
  color: #69706b;
}

.section {
  padding: 16px 0;
  border-bottom: 1px solid #e1e4de;
}

.section:first-child {
  padding-top: 0;
}

.section h3 {
  margin: 0 0 10px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0;
  color: #59615b;
}

.fact-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.fact {
  min-width: 0;
}

.fact span,
.event-meta,
.airport-type {
  display: block;
  color: #69706b;
  font-size: 12px;
  line-height: 1.25;
}

.fact strong,
.airport-row strong,
.event-row strong {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
  color: #202326;
  line-height: 1.25;
}

.airport-link {
  display: block;
  min-width: 0;
  padding: 0;
  border: 0;
  appearance: none;
  background: transparent;
  cursor: pointer;
  font: inherit;
  text-align: left;
}

.airport-link:hover strong,
.airport-link:focus-visible strong {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.airport-link:focus-visible {
  outline: 1px solid #bfc7bf;
  outline-offset: 2px;
  border-radius: 3px;
}

.airport-list,
.event-list,
.result-list,
.result-group-list {
  display: grid;
  gap: 8px;
}

.result-group {
  display: grid;
  gap: 6px;
  padding-top: 12px;
  border-top: 1px solid #d4d8d1;
}

.result-group:first-child {
  border-top: 0;
  padding-top: 0;
}

.single-registrant-group {
  gap: 4px;
}

.result-single-count {
  color: #69706b;
  font-size: 12px;
}

.result-group-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) max-content;
  gap: 10px;
  align-items: baseline;
  padding: 0;
  border: 0;
  appearance: none;
  background: transparent;
  cursor: pointer;
  font: inherit;
  line-height: inherit;
  text-align: left;
}

.result-group-heading strong {
  min-width: 0;
  overflow-wrap: anywhere;
  color: #202326;
  font-size: 13px;
}

.result-group-heading span {
  color: #69706b;
  font-size: 12px;
  white-space: nowrap;
}

.result-group-heading:hover strong,
.result-group-heading:focus-visible strong {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.result-group-heading:focus-visible {
  outline: 1px solid #bfc7bf;
  outline-offset: 2px;
  border-radius: 3px;
}

.result-aircraft-list {
  display: flex;
  flex-wrap: wrap;
  column-gap: 9px;
  row-gap: 0;
  align-items: baseline;
  color: #202326;
  font-size: 12px;
  line-height: 1.6;
}

.result-aircraft-item {
  display: inline;
  min-width: 0;
  padding: 0;
  border: 0;
  appearance: none;
  background: transparent;
  color: #202326;
  cursor: pointer;
  font: inherit;
  line-height: inherit;
  text-align: left;
}

.result-aircraft-item:hover strong,
.result-aircraft-item:focus-visible strong {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.result-aircraft-item:focus-visible {
  outline: 1px solid #bfc7bf;
  outline-offset: 2px;
  border-radius: 3px;
}

.result-aircraft-item strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: inherit;
  font-weight: 600;
}

.result-aircraft-count {
  margin-left: 3px;
  color: #8e9690;
  font-size: 11px;
  font-weight: 400;
  white-space: nowrap;
}

.result-aircraft-more,
.result-registrant-more {
  color: #8e9690;
  font-size: 12px;
  font-weight: 400;
}

.settings-dialog {
  width: min(420px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid #c6cbc4;
  border-radius: 8px;
  background: #fbfbf7;
  color: #202326;
  box-shadow: 0 18px 60px rgba(35, 42, 38, 0.22);
}

.settings-dialog::backdrop {
  background: rgba(32, 35, 38, 0.28);
}

.settings-form {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.settings-heading,
.settings-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.settings-heading h2 {
  margin: 0;
  font-size: 17px;
  letter-spacing: 0;
}

.settings-field {
  display: grid;
  gap: 6px;
  color: #59615b;
  font-size: 12px;
}

.settings-field input {
  width: 100%;
  height: 36px;
  border: 1px solid #c6cbc4;
  border-radius: 6px;
  background: #ffffff;
  padding: 7px 9px;
  color: #202326;
}

.settings-actions {
  justify-content: flex-end;
}

.result-registrant-more {
  padding-top: 2px;
}

.airport-row,
.event-row,
.result-row {
  display: grid;
  gap: 3px;
  padding: 10px 0;
  border-top: 1px solid #e1e4de;
}

.airport-row:first-child,
.event-row:first-child,
.result-row:first-child {
  border-top: 0;
  padding-top: 0;
}

.event-row {
  grid-template-columns: minmax(72px, 88px) minmax(0, 1fr);
  column-gap: 12px;
}

.event-kind {
  display: inline-flex;
  width: fit-content;
  max-width: 88px;
  height: 24px;
  align-items: center;
  justify-content: center;
  padding: 0 8px;
  border: 1px solid #c6cbc4;
  border-radius: 6px;
  background: #ffffff;
  color: #202326;
  font-size: 12px;
  text-transform: capitalize;
}

.event-kind.takeoff {
  border-color: #87b2a0;
  color: #17684d;
}

.event-kind.landing {
  border-color: #d1aa83;
  color: #8a4f14;
}

.result-row {
  width: 100%;
  border-right: 0;
  border-left: 0;
  border-bottom: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  text-align: left;
  padding-left: 0;
  padding-right: 0;
}

.result-row:hover,
.result-row:focus-visible {
  background: #f0f2ed;
}

.result-row strong,
.result-row span {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
}

.result-row span {
  color: #69706b;
  font-size: 12px;
  line-height: 1.25;
}

@media (max-width: 900px) {
  .topbar {
    grid-template-columns: 1fr;
    gap: 10px;
    overflow: visible;
  }

  .controls {
    grid-template-columns: 1fr;
  }

  .mode-select {
    width: 100%;
    max-width: none;
  }

  .workspace {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(360px, 1fr) minmax(220px, 42vh);
  }

  .plot-surface,
  .detail-panel {
    min-height: 0;
  }

  .detail-panel {
    border-left: 0;
    border-top: 1px solid #d9dcd4;
  }
}
