:root {
  color-scheme: dark;
  --bg: #050b12;
  --panel: #0a1522;
  --panel-2: #0d2031;
  --line: rgba(246, 199, 68, 0.25);
  --text: #eef6ff;
  --muted: #9bb4cf;
  --gold: #f6c744;
  --green: #18ae7e;
}

* {
  box-sizing: border-box;
}

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

.app-shell {
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 18px;
  padding: 20px;
}

.topbar {
  min-height: 106px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 22px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: linear-gradient(135deg, #0a1725 0%, #102b40 100%);
}

.brand {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 18px;
}

.brand-mark {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 12px;
  background: transparent;
  border: 0;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.32);
}

.brand-mark img {
  width: 64px;
  height: 64px;
  display: block;
  object-fit: contain;
}

h1 {
  margin: 0;
  color: var(--gold);
  font-size: 34px;
  line-height: 1.05;
  letter-spacing: 0;
}

.brand p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 15px;
  white-space: normal;
}

.actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.button {
  min-width: 120px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 18px;
  border: 0;
  border-radius: 4px;
  color: #06101a;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  text-decoration: none;
}

.button.primary {
  background: var(--gold);
}

.button.secondary {
  background: var(--green);
  color: white;
}

.button.ghost {
  background: #233447;
  color: #d9e8f9;
}

.button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.workspace {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(620px, 1fr) minmax(420px, 31vw);
  gap: 18px;
}

.map-panel,
.side-panel .box,
.stat {
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.map-panel {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto 1fr;
  padding: 16px;
}

.panel-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin: 0 0 10px;
  color: var(--gold);
  font-size: 19px;
  font-weight: 800;
}

.muted {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#map {
  min-height: 0;
  width: 100%;
  height: 100%;
  background: #06111c;
}

.leaflet-container {
  background: #06111c;
  font-family: "Segoe UI", Arial, sans-serif;
}

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  background: #07111d;
  color: white;
}

.text-marker {
  color: var(--gold);
  font-weight: 800;
  text-shadow: 0 2px 4px #000, 0 0 3px #000;
  white-space: nowrap;
}

.sc23-pin {
  width: 34px;
  height: 42px;
  position: relative;
  transform: translate(-17px, -42px);
  filter: drop-shadow(0 5px 7px rgba(0, 0, 0, 0.65));
}

.sc23-pin-body {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 3px solid var(--gold);
  border-radius: 50% 50% 50% 8px;
  background: linear-gradient(145deg, #06101a 0%, #0d2a3d 58%, #18ae7e 100%);
  transform: rotate(-45deg);
}

.sc23-pin-body::after {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 0 3px rgba(246, 199, 68, 0.18);
}

.sc23-pin-label {
  position: absolute;
  left: 50%;
  top: 35px;
  max-width: 180px;
  transform: translateX(-50%);
  padding: 3px 7px;
  border-radius: 4px;
  background: rgba(3, 9, 15, 0.86);
  color: var(--gold);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.1;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#coordHud {
  position: absolute;
  left: 28px;
  bottom: 28px;
  z-index: 500;
  padding: 10px 14px;
  border-radius: 6px;
  background: rgba(3, 9, 15, 0.82);
  color: var(--gold);
  font-size: 13px;
  font-weight: 700;
  pointer-events: none;
}

.center-target {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 510;
  width: 34px;
  height: 46px;
  display: none;
  transform: translate(-50%, -100%);
  pointer-events: none;
  filter: drop-shadow(0 5px 8px rgba(0, 0, 0, 0.65));
}

.center-target::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 2px;
  width: 28px;
  height: 28px;
  border: 3px solid var(--gold);
  border-radius: 50% 50% 50% 6px;
  background: linear-gradient(145deg, #06101a 0%, #0d2a3d 58%, #18ae7e 100%);
  transform: translateX(-50%) rotate(-45deg);
}

.center-target::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 13px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 0 3px rgba(246, 199, 68, 0.18);
  transform: translateX(-50%);
}

.drop-zone {
  position: absolute;
  inset: 74px 34px 34px;
  z-index: 450;
  display: none;
  place-items: center;
  align-content: center;
  gap: 10px;
  border: 2px dashed rgba(246, 199, 68, 0.65);
  background: rgba(5, 11, 18, 0.76);
  color: white;
  text-align: center;
}

.drop-zone.visible {
  display: grid;
}

.drop-zone span {
  color: var(--muted);
}

.side-panel {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(260px, 1fr) minmax(160px, 0.42fr);
  gap: 12px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.stat {
  min-width: 0;
  padding: 12px 14px;
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 4px;
}

.stat strong {
  display: block;
  color: var(--gold);
  font-size: clamp(24px, 2.2vw, 34px);
  line-height: 1.05;
  overflow: hidden;
  text-overflow: ellipsis;
}

.box {
  min-height: 0;
  padding: 14px;
  display: grid;
  grid-template-rows: auto 1fr;
}

.box h2 {
  margin: 0 0 10px;
  color: var(--gold);
  font-size: 20px;
}

.table-wrap {
  min-height: 0;
  overflow: auto;
  background: #06101a;
  scrollbar-color: #24405b #06101a;
}

table {
  width: 100%;
  min-width: 620px;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  padding: 7px 8px;
  border: 1px solid #1c3146;
  text-align: left;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #152336;
  color: var(--gold);
}

td {
  color: #e8f3ff;
  max-width: 210px;
  overflow: hidden;
  text-overflow: ellipsis;
}

pre {
  min-height: 0;
  margin: 0;
  padding: 12px;
  overflow: auto;
  background: #06101a;
  color: #e8f3ff;
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
  white-space: pre-wrap;
  scrollbar-color: #24405b #06101a;
}

@media (max-width: 1100px) {
  body {
    overflow: auto;
  }

  .app-shell {
    min-height: 100vh;
    height: auto;
  }

  .topbar,
  .workspace {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .workspace {
    display: block;
  }

  .map-panel {
    height: 68vh;
    margin-bottom: 16px;
  }

  .side-panel {
    min-height: 720px;
  }
}

@media (max-width: 640px) {
  .app-shell {
    gap: 12px;
    padding: 10px;
  }

  .topbar {
    min-height: 0;
    gap: 10px;
    padding: 12px;
  }

  .brand {
    gap: 8px;
  }

  .brand-mark {
    width: 48px;
    height: 48px;
  }

  .brand-mark img {
    width: 48px;
    height: 48px;
  }

  h1 {
    font-size: 22px;
  }

  .brand p {
    font-size: 12px;
    margin-top: 4px;
  }

  .actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    width: 100%;
  }

  .button {
    min-width: 0;
    width: 100%;
    height: 38px;
    padding: 0 5px;
    font-size: 12px;
    white-space: nowrap;
  }

  .map-panel {
    height: 64vh;
    padding: 10px;
  }

  .panel-title {
    font-size: 16px;
  }

  .center-target {
    width: 30px;
    height: 42px;
    top: calc(50% + 15px);
    display: block;
  }

  #coordHud {
    left: 6px;
    right: auto;
    bottom: 8px;
    max-width: calc(100% - 132px);
    padding: 6px 7px;
    font-size: 9px;
    line-height: 1.15;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

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