:root {
  --ink: #12323a;
  --ink-soft: #466269;
  --paper: #f4f0e7;
  --surface: rgba(255, 255, 255, 0.96);
  --line: rgba(18, 50, 58, 0.13);
  --accent: #de6b37;
  --accent-deep: #b84924;
  --teal: #1b716d;
  --shadow: 0 22px 60px rgba(21, 39, 44, 0.18);
  font-family: "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body, #app { width: 100%; height: 100%; margin: 0; overflow: hidden; }

body { color: var(--ink); background: var(--paper); }

button { font: inherit; }

.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  height: 82px;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 22px;
  padding: 0 28px;
  color: #fff;
  background: linear-gradient(105deg, #0e3038 0%, #153f46 72%, #1a5e5d 100%);
  box-shadow: 0 8px 30px rgba(13, 43, 50, 0.19);
}

.topbar::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), #efb24f 58%, transparent 85%);
}

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

.brand-mark, .loader-mark {
  width: 62px;
  height: 46px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255,255,255,.34);
  border-radius: 13px;
  color: #fff4de;
  font-family: "STKaiti", "KaiTi", serif;
  font-size: 21px;
  letter-spacing: .08em;
  background: rgba(255,255,255,.07);
  flex: none;
}

.brand-copy { line-height: 1; }
.brand-copy h1 { margin: 5px 0 0; font-size: 21px; letter-spacing: .08em; font-weight: 650; }
.eyebrow, .panel-kicker { font-size: 10px; letter-spacing: .24em; opacity: .66; }

.center-wordmark {
  justify-self: center;
  color: #fff4de;
  font-family: "STKaiti", "KaiTi", serif;
  font-size: 29px;
  font-weight: 700;
  letter-spacing: .2em;
  line-height: 1;
  white-space: nowrap;
  text-shadow: 0 2px 14px rgba(0,0,0,.18);
}

.topbar-actions {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 12px;
}

.contact-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 146px;
  padding: 5px 10px 5px 6px;
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 14px;
  color: #fff;
  background: rgba(255,255,255,.075);
  text-decoration: none;
  transition: background .2s ease, border-color .2s ease, transform .2s ease;
}

.contact-card:hover,
.contact-card:focus-visible {
  border-color: rgba(255,255,255,.38);
  background: rgba(255,255,255,.12);
  transform: translateY(-1px);
  outline: none;
}

.contact-qr {
  width: 44px;
  height: 44px;
  flex: none;
  border: 3px solid #fff;
  border-radius: 8px;
  background: #fff;
  object-fit: cover;
}

.contact-copy {
  display: grid;
  gap: 4px;
  line-height: 1;
  white-space: nowrap;
}

.contact-copy strong { font-size: 14px; font-weight: 650; letter-spacing: .08em; }
.contact-copy > span { color: #8de3bd; font-size: 10px; font-weight: 700; letter-spacing: .14em; }

.qr-popover {
  position: absolute;
  top: calc(100% + 12px);
  right: 0;
  width: 226px;
  padding: 15px;
  display: grid;
  justify-items: center;
  gap: 7px;
  border: 1px solid rgba(18,50,58,.12);
  border-radius: 16px;
  color: var(--ink);
  background: rgba(255,255,255,.98);
  box-shadow: 0 18px 48px rgba(18,50,58,.22);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-7px);
  transition: opacity .18s ease, visibility .18s ease, transform .18s ease;
  pointer-events: none;
}

.qr-popover::before {
  content: "";
  position: absolute;
  top: -7px;
  right: 52px;
  width: 13px;
  height: 13px;
  border-left: 1px solid rgba(18,50,58,.12);
  border-top: 1px solid rgba(18,50,58,.12);
  background: #fff;
  transform: rotate(45deg);
}

.qr-popover img { width: 192px; height: 199px; border-radius: 9px; object-fit: contain; background: #fff; }
.qr-popover b { margin-top: 2px; font-size: 14px; letter-spacing: .04em; }
.qr-popover small { color: var(--ink-soft); font-size: 10px; }
.contact-card:hover .qr-popover,
.contact-card:focus .qr-popover,
.contact-card:focus-within .qr-popover { opacity: 1; visibility: visible; transform: translateY(0); }

.data-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 999px;
  font-size: 12px;
  color: rgba(255,255,255,.84);
  background: rgba(255,255,255,.06);
}

.data-badge span { width: 7px; height: 7px; border-radius: 50%; background: #69d3a7; box-shadow: 0 0 0 4px rgba(105,211,167,.12); }

.workspace { position: absolute; inset: 82px 0 0; }
.map-shell, #map { position: absolute; inset: 0; }

.map-shell::after {
  content: "";
  position: absolute;
  pointer-events: none;
  inset: 0;
  background: linear-gradient(90deg, transparent 52%, rgba(17,46,54,.035));
}

.map-hint {
  position: absolute;
  z-index: 5;
  left: 26px;
  top: 24px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 15px;
  border: 1px solid rgba(18,50,58,.12);
  border-radius: 12px;
  color: var(--ink);
  font-size: 13px;
  background: rgba(255,255,255,.93);
  box-shadow: 0 10px 30px rgba(18,50,58,.12);
  backdrop-filter: blur(12px);
  transition: opacity .2s ease, transform .2s ease;
}

.map-hint.is-hidden { opacity: 0; transform: translateY(-7px); pointer-events: none; }
.crosshair { width: 14px; height: 14px; border: 1.8px solid var(--accent); border-radius: 50%; position: relative; }
.crosshair::before, .crosshair::after { content: ""; position: absolute; background: var(--accent); }
.crosshair::before { width: 18px; height: 1px; left: -4px; top: 5px; }
.crosshair::after { width: 1px; height: 18px; left: 5px; top: -4px; }

.locate-button {
  position: absolute;
  z-index: 5;
  left: 26px;
  bottom: 28px;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: var(--ink);
  background: rgba(255,255,255,.95);
  box-shadow: 0 10px 30px rgba(18,50,58,.14);
  cursor: pointer;
}
.locate-button svg { width: 22px; fill: currentColor; }
.locate-button:hover { color: var(--accent); transform: translateY(-1px); }

.result-panel {
  position: absolute;
  z-index: 10;
  top: 22px;
  right: 22px;
  bottom: 22px;
  width: min(430px, calc(100vw - 44px));
  padding: 25px 24px 17px;
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(255,255,255,.78);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  overflow: hidden;
}

.panel-handle { display: none; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.panel-head h2 { margin: 6px 0 0; font-family: "STKaiti", "KaiTi", serif; font-size: 27px; font-weight: 600; letter-spacing: .03em; }
.panel-kicker { color: var(--teal); font-weight: 700; }

.status-chip { flex: none; padding: 7px 10px; border-radius: 999px; color: var(--ink-soft); background: #edf1ef; font-size: 11px; }
.status-chip.ready { color: #11635b; background: #dff1ea; }
.status-chip.outside { color: #925326; background: #faebd9; }

.coordinate-card {
  position: relative;
  margin-top: 19px;
  padding: 15px 104px 15px 16px;
  min-height: 70px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #f7f6f1;
}
.coordinate-label { color: var(--ink-soft); font-size: 11px; }
.coordinate-value { margin-top: 7px; font-family: Consolas, "SFMono-Regular", monospace; font-size: 15px; font-weight: 650; letter-spacing: .015em; }
.copy-button { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); border: 1px solid var(--line); border-radius: 9px; padding: 7px 10px; color: var(--ink); background: #fff; font-size: 11px; cursor: pointer; }
.copy-button:disabled { opacity: .45; cursor: default; }

.empty-state { flex: 1; min-height: 220px; display: grid; align-content: center; justify-items: center; text-align: center; padding: 30px; }
.empty-icon { width: 52px; height: 52px; display: grid; place-items: center; border: 1px dashed rgba(18,50,58,.28); border-radius: 50%; color: var(--accent); font-size: 27px; }
.empty-state p { margin: 16px 0 5px; font-size: 15px; font-weight: 650; }
.empty-state span { max-width: 250px; color: var(--ink-soft); font-size: 12px; line-height: 1.7; }

.results { margin-top: 18px; min-height: 0; overflow: auto; scrollbar-width: thin; }
.table-head, .result-row { display: grid; grid-template-columns: 1.1fr .9fr 1.35fr; align-items: center; gap: 8px; }
.table-head { padding: 0 12px 9px; color: var(--ink-soft); font-size: 10px; letter-spacing: .08em; }
.table-head span:nth-child(2), .table-head span:nth-child(3) { text-align: right; }
.result-row { min-height: 66px; padding: 10px 12px; border-top: 1px solid var(--line); }
.usage-cell { display: flex; align-items: center; gap: 9px; font-size: 13px; font-weight: 650; }
.usage-dot { width: 8px; height: 8px; flex: none; border-radius: 3px; background: var(--usage-color, var(--teal)); }
.grade-cell, .price-cell { text-align: right; }
.grade-code { color: var(--accent-deep); font-family: "STKaiti", "KaiTi", serif; font-size: 17px; font-weight: 700; }
.grade-code.missing { color: #8b999b; font-family: inherit; font-size: 12px; font-weight: 500; }
.price-number { font-size: 17px; font-weight: 750; font-variant-numeric: tabular-nums; }
.price-unit { display: block; margin-top: 2px; color: var(--ink-soft); font-size: 9px; }

.boundary-note { margin-top: 12px; padding: 11px 12px; border-left: 3px solid #d58b37; border-radius: 0 9px 9px 0; background: #fff4df; font-size: 11px; line-height: 1.55; }
.boundary-note strong { display: block; margin-bottom: 2px; color: #8a5220; }

.panel-footer { margin-top: auto; padding-top: 13px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; color: #718185; font-size: 10px; }

.loading-screen { position: fixed; z-index: 100; inset: 0; display: grid; place-content: center; justify-items: center; color: #fff; background: #12323a; transition: opacity .45s ease, visibility .45s ease; }
.loading-screen.done { opacity: 0; visibility: hidden; }
.loader-mark { width: 58px; height: 58px; font-size: 31px; }
.loader-line { width: 180px; height: 2px; margin-top: 24px; overflow: hidden; background: rgba(255,255,255,.14); }
.loader-line span { display: block; width: 42%; height: 100%; background: var(--accent); animation: loading 1.1s ease-in-out infinite; }
.loading-screen p { margin-top: 14px; color: rgba(255,255,255,.7); font-size: 12px; letter-spacing: .08em; }
@keyframes loading { from { transform: translateX(-110%); } to { transform: translateX(340%); } }

.toast { position: fixed; z-index: 110; left: 50%; bottom: 30px; transform: translate(-50%, 15px); padding: 10px 15px; border-radius: 999px; color: #fff; background: rgba(18,50,58,.92); font-size: 12px; opacity: 0; pointer-events: none; transition: .2s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.query-popup { min-width: 280px; color: var(--ink); font-family: "Microsoft YaHei", sans-serif; }
.query-popup .popup-coord { margin-bottom: 8px; color: #567176; font: 11px Consolas, monospace; }
.query-popup .popup-row { display: flex; justify-content: space-between; gap: 18px; padding: 6px 0; border-top: 1px solid rgba(18,50,58,.1); font-size: 12px; }
.query-popup .popup-row strong { color: var(--accent-deep); }

@media (max-width: 760px) {
  .topbar { height: 66px; grid-template-columns: auto 1fr auto; padding: 0 10px; gap: 9px; }
  .brand-cluster { gap: 0; }
  .brand-mark { width: 52px; height: 38px; border-radius: 11px; font-size: 16px; }
  .brand-copy { display: none; }
  .center-wordmark { justify-self: center; font-size: 17px; letter-spacing: .1em; }
  .topbar-actions { gap: 0; }
  .contact-card { min-width: 0; gap: 6px; padding: 3px 7px 3px 4px; border-radius: 11px; }
  .contact-qr { width: 34px; height: 34px; border-width: 2px; border-radius: 7px; }
  .contact-copy { gap: 3px; }
  .contact-copy strong { font-size: 11px; }
  .contact-copy > span { font-size: 8px; }
  .qr-popover { top: calc(100% + 10px); right: -2px; width: 218px; }
  .qr-popover img { width: 184px; height: 190px; }
  .data-badge { display: none; }
  .workspace { top: 66px; }
  .map-hint { left: 12px; top: 12px; }
  .locate-button { left: 12px; bottom: 47vh; }
  .result-panel { top: auto; left: 8px; right: 8px; bottom: 8px; width: auto; height: 45vh; min-height: 330px; padding: 17px 16px 12px; border-radius: 19px; }
  .panel-handle { display: block; width: 42px; height: 4px; margin: -7px auto 10px; border-radius: 99px; background: #d9dfdc; }
  .panel-head h2 { font-size: 22px; }
  .coordinate-card { margin-top: 12px; padding-top: 11px; padding-bottom: 11px; min-height: 60px; }
  .results { margin-top: 12px; }
  .result-row { min-height: 55px; padding-top: 7px; padding-bottom: 7px; }
  .empty-state { min-height: 130px; padding: 15px; }
  .empty-icon { width: 40px; height: 40px; }
  .empty-state p { margin-top: 10px; }
  .panel-footer { display: none; }
}

@media (min-width: 761px) and (max-width: 1120px) {
  .topbar { padding-inline: 18px; gap: 14px; }
  .brand-copy h1 { font-size: 18px; }
  .center-wordmark { font-size: 22px; letter-spacing: .14em; }
  .data-badge { width: 34px; height: 34px; justify-content: center; padding: 0; font-size: 0; }
}

@media (max-height: 700px) and (min-width: 761px) {
  .result-panel { padding-top: 18px; padding-bottom: 12px; }
  .result-row { min-height: 54px; }
  .coordinate-card, .results { margin-top: 12px; }
}
