:root {
  color-scheme: dark;
  --bg: #050608;
  --panel: #0d1117;
  --panel-soft: #111821;
  --ink: #eef6f7;
  --muted: #91a0ad;
  --line: #24303c;
  --line-strong: #3b4a56;
  --teal: #20d6bf;
  --teal-dark: #14a595;
  --gold: #f4c95d;
  --amber: #f59e0b;
  --rose: #fb7185;
  --green: #34d399;
  --blue: #60a5fa;
  --shadow: 0 18px 42px rgba(0, 0, 0, 0.46);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(32, 214, 191, 0.06), transparent 340px),
    var(--bg);
  color: var(--ink);
  font-family: Inter, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 24px;
  padding: 20px clamp(18px, 4vw, 52px);
  background:
    linear-gradient(180deg, rgba(13, 17, 23, 0.98), rgba(8, 11, 15, 0.94)),
    #0d1117;
  border-bottom: 1px solid rgba(32, 214, 191, 0.24);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.35);
}

.title-block {
  min-width: 0;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  color: var(--ink);
  font-size: clamp(23px, 3vw, 32px);
}

h2 {
  color: var(--ink);
  font-size: 18px;
}

.brand-logo {
  position: relative;
  justify-self: center;
  display: grid;
  min-width: 190px;
  padding: 12px 26px 10px;
  overflow: hidden;
  border: 1px solid rgba(244, 201, 93, 0.42);
  border-radius: 10px;
  background:
    linear-gradient(135deg, rgba(244, 201, 93, 0.18), rgba(32, 214, 191, 0.11) 48%, rgba(96, 165, 250, 0.12)),
    rgba(5, 6, 8, 0.88);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.04) inset,
    0 0 28px rgba(32, 214, 191, 0.16),
    0 16px 36px rgba(0, 0, 0, 0.46);
  text-align: center;
}

.brand-logo::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, transparent 0%, rgba(255, 255, 255, 0.14) 44%, transparent 62%);
  transform: translateX(-110%);
  animation: brand-shine 5.6s ease-in-out infinite;
}

.brand-logo::after {
  content: "";
  position: absolute;
  left: 22px;
  right: 22px;
  bottom: 7px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold), var(--teal), transparent);
  opacity: 0.78;
}

.brand-word {
  position: relative;
  z-index: 1;
  background: linear-gradient(90deg, #fff7d1, var(--gold), #d9fffb, var(--teal));
  background-clip: text;
  color: transparent;
  font-family: "Microsoft YaHei UI", "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
  font-size: clamp(28px, 3.2vw, 40px);
  font-weight: 900;
  letter-spacing: 0;
  line-height: 1;
  text-shadow: 0 0 18px rgba(32, 214, 191, 0.22);
  white-space: nowrap;
}

.brand-sub {
  position: relative;
  z-index: 1;
  margin-top: 7px;
  color: rgba(238, 246, 247, 0.74);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0;
  line-height: 1;
  white-space: nowrap;
}

@keyframes brand-shine {
  0%,
  58% {
    transform: translateX(-120%);
  }

  78%,
  100% {
    transform: translateX(120%);
  }
}

.source-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}

.source-strip span,
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 10px;
  border: 1px solid rgba(145, 160, 173, 0.22);
  border-radius: 999px;
  background: rgba(17, 24, 33, 0.84);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(360px, 520px) minmax(320px, 1fr);
  gap: 16px;
  padding: 16px clamp(14px, 4vw, 52px) 32px;
}

.query-panel,
.map-panel,
.result-panel,
.table-panel {
  padding: 16px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent),
    var(--panel);
  border: 1px solid rgba(145, 160, 173, 0.22);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.map-panel {
  min-height: 298px;
}

.result-panel,
.table-panel {
  grid-column: 1 / -1;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.section-head.compact {
  margin-bottom: 12px;
}

.field-label {
  display: block;
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #070a0f;
  color: var(--ink);
  outline: none;
}

select {
  min-height: 42px;
  padding: 0 11px;
}

textarea {
  min-height: 170px;
  resize: vertical;
  padding: 11px;
  line-height: 1.55;
}

select:focus,
textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(32, 214, 191, 0.16);
}

.primary-button,
.secondary-button {
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid var(--line);
  cursor: pointer;
  transition: border-color 0.16s ease, background 0.16s ease, color 0.16s ease, transform 0.16s ease;
}

.primary-button {
  border-color: rgba(32, 214, 191, 0.58);
  background: linear-gradient(135deg, var(--teal-dark), var(--teal));
  color: #041211;
  font-weight: 900;
}

.primary-button:hover {
  transform: translateY(-1px);
  background: linear-gradient(135deg, #1bbcab, #49f0dd);
}

.primary-button:disabled,
.secondary-button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
  transform: none;
}

.secondary-button {
  padding: 0 14px;
  background: #0a0f15;
  color: var(--ink);
  font-weight: 800;
}

.secondary-button:hover:not(:disabled) {
  border-color: rgba(244, 201, 93, 0.55);
  color: var(--gold);
}

.batch-actions {
  display: grid;
  grid-template-columns: 128px 110px 110px;
  gap: 8px;
  margin-top: 10px;
}

.status-line {
  min-height: 22px;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.status-line[data-type="ok"] {
  color: var(--green);
}

.status-line[data-type="warn"] {
  color: var(--amber);
}

.status-line[data-type="error"] {
  color: var(--rose);
}

.map-shell {
  position: relative;
  height: 230px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0a0f15;
}

.leaflet-map {
  width: 100%;
  height: 100%;
}

.map-empty {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  padding: 14px;
  background:
    linear-gradient(135deg, rgba(32, 214, 191, 0.11), rgba(244, 201, 93, 0.08)),
    #070a0f;
  color: var(--muted);
  font-weight: 700;
  text-align: center;
}

.map-empty[hidden] {
  display: none;
}

.leaflet-popup-content {
  margin: 10px 12px;
  font-family: Inter, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  font-size: 12px;
  line-height: 1.5;
}

.badge.good {
  border-color: rgba(52, 211, 153, 0.32);
  background: rgba(16, 185, 129, 0.12);
  color: var(--green);
}

.badge.warn {
  border-color: rgba(245, 158, 11, 0.32);
  background: rgba(245, 158, 11, 0.13);
  color: var(--amber);
}

.badge.bad {
  border-color: rgba(251, 113, 133, 0.34);
  background: rgba(251, 113, 133, 0.12);
  color: var(--rose);
}

.badge.muted {
  background: rgba(17, 24, 33, 0.84);
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.metric {
  min-height: 84px;
  padding: 12px;
  border: 1px solid rgba(145, 160, 173, 0.20);
  border-radius: 8px;
  background: var(--panel-soft);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.metric strong {
  display: block;
  margin-top: 7px;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 16px;
  line-height: 1.35;
}

.empty-state,
.table-empty {
  color: var(--muted);
  text-align: center;
}

.empty-state {
  grid-column: 1 / -1;
  padding: 22px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
}

.source-tables {
  display: grid;
  gap: 14px;
}

.source-group {
  overflow: hidden;
  border: 1px solid rgba(145, 160, 173, 0.20);
  border-radius: 8px;
  background: rgba(17, 24, 33, 0.52);
}

.source-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(90deg, rgba(32, 214, 191, 0.08), transparent),
    #0f151d;
}

.source-group-head h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--ink);
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 0;
}

.table-wrap {
  width: 100%;
  overflow: auto;
  border: 0;
}

table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
  background: #090d13;
}

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #111821;
  color: #c4d0db;
  font-weight: 900;
}

td {
  color: #dbe7ee;
  overflow-wrap: anywhere;
}

tbody tr:hover {
  background: rgba(32, 214, 191, 0.06);
}

.source-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: 6px;
  border-radius: 999px;
  background: var(--teal);
  box-shadow: 0 0 10px rgba(32, 214, 191, 0.45);
}

.source-dot.secondary {
  background: var(--amber);
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.44);
}

.source-dot.tertiary {
  background: var(--blue);
  box-shadow: 0 0 10px rgba(96, 165, 250, 0.44);
}

@media (max-width: 1080px) {
  .workspace {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 680px) {
  .topbar {
    align-items: center;
    grid-template-columns: 1fr;
  }

  .brand-logo {
    order: -1;
    justify-self: center;
    min-width: 166px;
  }

  .brand-word {
    font-size: 30px;
  }

  .source-strip {
    justify-content: flex-start;
  }

  .batch-actions {
    grid-template-columns: 1fr;
  }

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

  .map-shell {
    height: 210px;
  }
}
