:root {
  color-scheme: light;
  --bg: #e9eeed;
  --panel: #f8faf8;
  --panel-strong: #eef3f1;
  --text: #182326;
  --muted: #657579;
  --line: #d4dddc;
  --accent: #b56f26;
  --accent-2: #0d6f80;
  --deployed: #d05f3f;
  --port: #2f8b70;
  --maintenance: #b57a2d;
  --unknown: #737a82;
  --danger: #ba3f35;
  --shadow: 0 18px 50px rgba(39, 55, 57, 0.2);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body,
.app-shell {
  height: 100%;
  margin: 0;
}

html,
body {
  overflow-x: hidden;
}

body {
  background: var(--bg);
  color: var(--text);
}

button,
a {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  width: 100%;
  min-height: 100vh;
  overflow: hidden;
}

.map-panel {
  position: relative;
  overflow: hidden;
  height: 100vh;
  min-height: 100vh;
}

#map {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: #c7ddd9;
}

#map::after {
  position: absolute;
  inset: 0;
  z-index: 450;
  pointer-events: none;
  content: "";
  box-shadow: inset 0 0 110px rgba(23, 45, 50, 0.18);
}

.leaflet-container {
  overflow: hidden;
  font: inherit;
}

.leaflet-pane,
.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow,
.leaflet-tile-container,
.leaflet-pane > svg,
.leaflet-pane > canvas,
.leaflet-zoom-box,
.leaflet-image-layer,
.leaflet-layer {
  position: absolute;
  left: 0;
  top: 0;
}

.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow {
  user-select: none;
  -webkit-user-drag: none;
}

.leaflet-tile {
  border: 0;
  opacity: 1 !important;
}

.leaflet-tile-pane {
  z-index: 200;
}

.leaflet-overlay-pane {
  z-index: 400;
}

.leaflet-shadow-pane {
  z-index: 500;
}

.leaflet-marker-pane {
  z-index: 600;
}

.leaflet-tooltip-pane {
  z-index: 650;
}

.leaflet-popup-pane {
  z-index: 700;
}

.leaflet-control {
  position: relative;
  z-index: 800;
  pointer-events: auto;
}

.leaflet-top,
.leaflet-bottom {
  position: absolute;
  z-index: 800;
  pointer-events: none;
}

.leaflet-top {
  top: 0;
}

.leaflet-bottom {
  bottom: 0;
}

.leaflet-left {
  left: 0;
}

.leaflet-right {
  right: 0;
}

.leaflet-control-zoom {
  margin: 0 0 18px 18px;
}

.leaflet-control-zoom a {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  background: rgba(248, 250, 248, 0.94);
  color: var(--text);
  text-decoration: none;
}

.leaflet-control-zoom a:first-child {
  border-radius: 8px 8px 0 0;
}

.leaflet-control-zoom a:last-child {
  border-top: 0;
  border-radius: 0 0 8px 8px;
}

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

.topbar > * {
  pointer-events: auto;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.45rem, 2.3vw, 2.35rem);
  line-height: 1.05;
  letter-spacing: 0;
  color: #102327;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.7);
}

#updated {
  margin-top: 8px;
  color: #405256;
  font-size: 0.92rem;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.7);
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.chip {
  border: 1px solid rgba(32, 54, 58, 0.18);
  border-radius: 999px;
  background: rgba(248, 250, 248, 0.82);
  color: var(--text);
  min-height: 36px;
  padding: 0 14px;
  cursor: pointer;
  backdrop-filter: blur(10px);
}

.chip:hover,
.chip:focus-visible {
  border-color: var(--accent);
  outline: none;
}

.chip.active {
  background: #183235;
  border-color: #183235;
  color: #f8faf8;
}

.details-panel {
  position: relative;
  z-index: 700;
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--panel);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 24px;
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.eyebrow {
  color: var(--accent-2);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h2 {
  margin-top: 5px;
  font-size: 1.45rem;
  line-height: 1.18;
  letter-spacing: 0;
}

h3 {
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.confidence {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 74px;
  min-height: 28px;
  border-radius: 999px;
  background: rgba(246, 195, 61, 0.14);
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 700;
}

.confidence.muted {
  background: rgba(167, 171, 177, 0.14);
  color: var(--unknown);
}

.ship-summary {
  color: #2c3d41;
  line-height: 1.48;
}

.facts {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin: 0;
}

.facts div {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 12px;
  align-items: baseline;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

dt {
  color: var(--muted);
  font-size: 0.83rem;
}

dd {
  margin: 0;
  color: var(--text);
}

.source-block {
  display: grid;
  gap: 10px;
}

ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

#source-list {
  display: grid;
  gap: 10px;
}

#source-list li {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  padding: 12px;
}

#source-list a {
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
}

#source-list a:hover,
#source-list a:focus-visible {
  color: var(--accent);
  outline: none;
}

.source-meta {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.82rem;
}

.fleet-list {
  display: grid;
  gap: 7px;
}

.fleet-button {
  display: grid;
  width: 100%;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  min-height: 44px;
  padding: 9px 10px;
  text-align: left;
  cursor: pointer;
}

.fleet-button:hover,
.fleet-button:focus-visible,
.fleet-button.active {
  background: var(--panel-strong);
  border-color: var(--line);
  outline: none;
}

.fleet-button strong,
.fleet-button span:first-child {
  min-width: 0;
}

.fleet-location {
  color: var(--muted);
  font-size: 0.78rem;
  white-space: nowrap;
}

.carrier-marker {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 156px;
  min-height: 32px;
  border: 1px solid rgba(24, 35, 38, 0.32);
  border-radius: 999px;
  background: rgba(248, 250, 248, 0.95);
  color: var(--text);
  box-shadow: 0 7px 16px rgba(19, 35, 38, 0.2);
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}

.marker-dot {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  border: 2px solid rgba(255, 255, 255, 0.98);
  border-radius: 50%;
  background: var(--deployed);
  color: white;
  font-size: 0.7rem;
  box-shadow: 0 3px 8px rgba(19, 35, 38, 0.24);
}

.marker-text {
  overflow: hidden;
  padding-right: 10px;
  text-overflow: ellipsis;
}

.carrier-marker.port .marker-dot {
  background: var(--port);
  color: white;
}

.carrier-marker.maintenance .marker-dot {
  background: var(--maintenance);
  color: white;
}

.carrier-marker.unknown .marker-dot {
  background: var(--unknown);
  color: white;
}

.carrier-marker.low {
  border-color: rgba(186, 63, 53, 0.6);
}

.carrier-marker.selected {
  border-color: rgba(13, 111, 128, 0.7);
  box-shadow: 0 8px 22px rgba(13, 111, 128, 0.24);
}

.leaflet-control-attribution {
  background: rgba(248, 250, 248, 0.78) !important;
  color: #4b5c61 !important;
  font-size: 0.72rem;
}

.leaflet-control-attribution a {
  color: #20393e !important;
}

.leaflet-control-zoom a {
  border-color: var(--line) !important;
  background: rgba(248, 250, 248, 0.9) !important;
  color: var(--text) !important;
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(58vh, 1fr) auto;
  }

  .map-panel {
    height: 58vh;
    min-height: 58vh;
  }

  .details-panel {
    min-height: auto;
    max-height: none;
    border-left: 0;
    border-top: 1px solid var(--line);
  }
}

@media (max-width: 640px) {
  .topbar {
    flex-direction: column;
    align-items: stretch;
    top: 12px;
    left: 12px;
    right: 12px;
  }

  .filters {
    justify-content: flex-start;
  }

  .chip {
    min-height: 34px;
    padding-inline: 12px;
  }

  .carrier-marker {
    width: 32px;
    min-height: 32px;
    border-radius: 50%;
    background: transparent;
    border: 0;
    box-shadow: none;
  }

  .carrier-marker.selected {
    border: 0;
    box-shadow: none;
  }

  .marker-text {
    display: none;
  }

  .leaflet-control-attribution {
    max-width: 230px;
    font-size: 0.62rem;
    line-height: 1.15;
  }

  .details-panel {
    padding: 18px;
  }

  .facts div {
    grid-template-columns: 78px minmax(0, 1fr);
  }
}
