:root {
  --bg-1: #040813;
  --bg-2: #07111f;
  --panel: rgba(8, 15, 31, 0.78);
  --panel-border: rgba(146, 176, 255, 0.18);
  --text: #ebf3ff;
  --muted: #9eb1d8;
  --accent: #6f8cff;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  font-family: "Segoe UI", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 20% 10%, rgba(29, 59, 112, 0.45), transparent 32%),
    radial-gradient(circle at 80% 0%, rgba(13, 102, 126, 0.24), transparent 28%),
    linear-gradient(180deg, #040712 0%, #02050d 55%, #010309 100%);
}

.app-shell {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 24px 8px;
}

.eyebrow {
  margin: 0 0 6px;
  color: #7d90c8;
  letter-spacing: 0.36em;
  font-size: 10px;
}

h1 {
  margin: 0;
  font-size: 20px;
  letter-spacing: 0.04em;
  font-weight: 700;
}

.tool-btn {
  min-width: 92px;
  height: 38px;
  border: 1px solid rgba(161, 188, 255, 0.22);
  border-radius: 12px;
  background: rgba(16, 29, 58, 0.72);
  color: var(--text);
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}

.tool-btn:hover {
  transform: translateY(-1px);
  border-color: rgba(161, 188, 255, 0.46);
  background: rgba(27, 45, 85, 0.86);
}

.tool-btn:disabled {
  cursor: default;
  opacity: 0.74;
  transform: none;
}

.icon-btn {
  min-width: 0;
  width: 30px;
  height: 30px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
}

.tool-icon {
  position: relative;
  display: inline-block;
  width: 14px;
  height: 14px;
}

.tool-icon-refresh::before,
.tool-icon-refresh::after,
.tool-icon-rotate::before,
.tool-icon-rotate::after {
  content: "";
  position: absolute;
}

.tool-icon-refresh::before {
  inset: 1px;
  border: 2px solid rgba(221, 235, 255, 0.92);
  border-right-color: transparent;
  border-radius: 999px;
}

.tool-icon-refresh::after {
  top: 0;
  right: 0;
  width: 0;
  height: 0;
  border-left: 5px solid rgba(221, 235, 255, 0.92);
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  transform: rotate(18deg);
}

.icon-btn.is-loading .tool-icon-refresh {
  animation: refresh-spin 0.85s linear infinite;
}

.tool-icon-rotate::before,
.tool-icon-rotate::after {
  top: 2px;
  bottom: 2px;
  width: 3px;
  border-radius: 999px;
  background: rgba(221, 235, 255, 0.92);
}

.tool-icon-rotate::before {
  left: 4px;
}

.tool-icon-rotate::after {
  right: 4px;
}

.icon-btn.active-rotate .tool-icon-rotate::before {
  left: 6px;
  width: 0;
  height: 0;
  top: 2px;
  bottom: auto;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-left: 9px solid rgba(221, 235, 255, 0.92);
  background: transparent;
}

.icon-btn.active-rotate .tool-icon-rotate::after {
  display: none;
}

@keyframes refresh-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.globe-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  padding: 0 24px 18px;
}

.stage-grid {
  position: absolute;
  inset: 18px 24px 34px;
  display: grid;
  grid-template-columns: minmax(320px, 0.92fr) minmax(520px, 1.48fr);
  gap: 18px;
  min-height: 0;
  align-items: stretch;
}

.scene-panel {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border-radius: 24px;
  border: 1px solid rgba(126, 167, 255, 0.18);
  background:
    linear-gradient(180deg, rgba(6, 15, 34, 0.98) 0%, rgba(3, 10, 25, 0.96) 100%);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.02),
    0 24px 80px rgba(0, 0, 0, 0.34);
}

.scene-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 18% 0%, rgba(44, 97, 198, 0.16), transparent 34%),
    radial-gradient(circle at 100% 100%, rgba(21, 119, 150, 0.12), transparent 28%);
}

.scene-overlay {
  position: absolute;
  z-index: 4;
}

.scene-overlay-top-left {
  top: 16px;
  left: 16px;
}

.scene-overlay-bottom-left {
  bottom: 16px;
  left: 16px;
}

.scene-view {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
}

.globe-container,
.flat-map-container {
  overflow: hidden;
}

.globe-container canvas {
  border-radius: 24px;
}

.flat-map-container {
  background:
    radial-gradient(circle at 50% 42%, rgba(18, 67, 120, 0.18), transparent 36%),
    linear-gradient(180deg, rgba(4, 11, 28, 0.92), rgba(2, 8, 20, 0.98));
}

.flat-map-svg {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
}

.flat-map-svg.is-panning {
  cursor: grabbing;
}

.flat-map-point {
  cursor: pointer;
}

.flat-map-viewport {
  transform-origin: 0 0;
}

.flat-map-land-wash {
  fill: rgba(34, 88, 126, 0.2);
  stroke: none;
}

.flat-map-land {
  stroke: rgba(134, 236, 255, 0.22);
  stroke-width: 0.9;
  filter: drop-shadow(0 0 8px rgba(79, 160, 255, 0.08));
}

.flat-map-point-halo {
  filter: blur(0.6px);
}

.flat-map-point .flat-map-point-halo {
  transform-box: fill-box;
  transform-origin: center;
  animation: flatMapPulseHalo 2.6s ease-in-out infinite;
  animation-delay: var(--pulse-delay);
}

.flat-map-point .flat-map-point-core {
  transform-box: fill-box;
  transform-origin: center;
  animation: flatMapPulseCore 2.6s ease-in-out infinite;
  animation-delay: var(--pulse-delay);
}

.flat-map-point-core {
  stroke: rgba(255, 228, 242, 0.35);
  stroke-width: 0.9;
}

.flat-map-point.is-active .flat-map-point-halo {
  filter: blur(1px);
}

@keyframes flatMapPulseHalo {
  0%, 100% { opacity: 0.10; transform: scale(0.92); }
  50% { opacity: 0.24; transform: scale(1.26); }
}

@keyframes flatMapPulseCore {
  0%, 100% { opacity: 0.88; transform: scale(0.96); }
  50% { opacity: 1; transform: scale(1.08); }
}

.flat-map-tooltip {
  position: absolute;
  z-index: 7;
  left: 12px;
  top: 12px;
  max-width: 340px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 120ms ease;
}

.flat-map-tooltip.is-visible {
  opacity: 1;
  visibility: visible;
}

.flat-map-grid {
  opacity: 0.18;
}

.scene-panel-globe,
.scene-panel-flat {
  height: 100%;
  min-height: 100%;
}

.flat-map-credit {
  position: absolute;
  left: 22px;
  right: 22px;
  top: 14px;
  z-index: 3;
  color: rgba(145, 154, 172, 0.82);
  font-size: 11px;
  line-height: 1.35;
  letter-spacing: 0.01em;
  text-align: center;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.22);
  pointer-events: none;
  user-select: none;
}

.overlay-panel {
  position: absolute;
  z-index: 9;
}

.overlay-top-left {
  top: 24px;
  left: 32px;
  width: calc(((100% - 66px) * 0.3833333333) - 16px);
  max-width: calc(((100% - 66px) * 0.3833333333) - 16px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 11;
}

.overlay-bottom-left {
  left: 42px;
  bottom: 40px;
  width: calc(((100% - 66px) * 0.3833333333) - 36px);
  max-width: calc(((100% - 66px) * 0.3833333333) - 36px);
}

.panel-card {
  backdrop-filter: blur(12px);
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 14px 16px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.36);
}

.legend-item {
  font-size: 10px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 7px;
}

.legend-card {
  display: flex;
  width: 100%;
  max-width: 100%;
  padding: 8px 18px;
  overflow: hidden;
  border-radius: 16px;
  background: rgba(6, 15, 30, 0.72);
  border-color: rgba(116, 158, 255, 0.24);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.24);
}

.legend-container {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 16px;
  width: 100%;
  min-height: 22px;
}

.legend-hint {
  margin-left: auto;
  color: #8ea4d6;
  min-width: 0;
}

.legend-hint-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: right;
}

.legend-app {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: #d9e4ff;
  white-space: nowrap;
}

.legend-app-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  display: inline-block;
  flex: 0 0 auto;
  box-shadow: 0 0 10px currentColor;
}

.legend-app-name {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.legend-app-count {
  color: #ffffff;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.flatmap-stats-group {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.total-box {
  border-radius: 11px;
  width: 80px;
  min-height: 64px;
  padding: 5px 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  display: grid;
  grid-template-rows: auto auto;
  place-items: center;
  align-content: center;
  gap: 4px;
  text-align: center;
}

.flatmap-stat-box {
  width: 64px;
  min-width: 64px;
  min-height: 60px;
  height: 60px;
  padding: 5px 4px 6px;
  border-radius: 12px;
  background: rgba(13, 24, 48, 0.78);
  border-color: rgba(158, 186, 255, 0.14);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.02),
    0 10px 24px rgba(0, 0, 0, 0.16);
}

.total-label {
  width: 100%;
  font-size: 9px;
  font-weight: 500;
  color: var(--muted);
  line-height: 1.1;
  white-space: nowrap;
  text-align: center;
  justify-self: center;
  align-self: center;
}

.total-value {
  margin-top: 0;
  width: 100%;
  font-size: 20px;
  font-weight: 800;
  line-height: 1;
  color: #86ecff;
  text-align: center;
  justify-self: center;
  align-self: center;
}

.status-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-width: 400px;
  max-width: 100%;
  padding: 6px 12px;
  border-radius: 12px;
  font-size: 12px;
  backdrop-filter: blur(10px);
  background: rgba(12, 25, 53, 0.84);
  border: 1px solid rgba(167, 192, 255, 0.2);
  color: #d9e4ff;
}

.status-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.status-divider {
  width: 1px;
  align-self: stretch;
  background: rgba(167, 192, 255, 0.2);
}

.status-text {
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-badge.loading {
  color: #f7d28c;
}

.status-badge.ok {
  color: #95f0b8;
}

.status-badge.error {
  color: #ffb2c0;
}

.globe-tooltip {
  min-width: 200px;
  max-width: 300px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(6, 12, 24, 0.92);
  border: 1px solid rgba(161, 188, 255, 0.22);
  color: #edf3ff;
  font-size: 12px;
  line-height: 1.65;
}

.globe-tooltip .tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  font-weight: 700;
}

.globe-tooltip .tag::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: currentColor;
  box-shadow: 0 0 10px currentColor;
}

@media (max-width: 820px) {
  .topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .globe-stage {
    padding: 0 14px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow: auto;
  }

  .stage-grid {
    position: static;
    inset: auto;
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .scene-panel-globe,
  .scene-panel-flat {
    min-height: 42vh;
  }

  .scene-overlay {
    position: static;
    margin: 10px;
  }

  .overlay-top-left,
  .overlay-bottom-left {
    position: static;
    transform: none;
    width: auto;
    max-width: none;
    margin: 0 0 10px;
  }

  .status-badge {
    max-width: none;
  }
}
