:root {
  color-scheme: light;
  --ink: #18201f;
  --ink-strong: #0c1211;
  --muted: #6b7774;
  --line: #dde2de;
  --line-strong: #c8d0ca;
  --panel: #fbfaf6;
  --paper: #ffffff;
  --wash: #f0f1ec;
  --charcoal: #1d2524;
  --teal: #1c7479;
  --cyan: #2797a8;
  --gold: #dca43b;
  --coral: #cf4d5f;
  --indigo: #6275b7;
  --violet: #a75aa8;
  --shadow: 0 18px 48px rgba(29, 37, 36, 0.13);
  --soft-shadow: 0 10px 26px rgba(29, 37, 36, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(29, 37, 36, 0.04), rgba(29, 37, 36, 0)),
    var(--wash);
}

button,
input {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  position: relative;
  z-index: 30;
  height: 88px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 16px 22px;
  background: rgba(251, 250, 246, 0.96);
  border-bottom: 1px solid rgba(200, 208, 202, 0.85);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.85) inset;
  backdrop-filter: blur(18px);
}

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

.brand-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background:
    radial-gradient(circle at 28% 18%, rgba(255, 255, 255, 0.22), transparent 36%),
    linear-gradient(135deg, #1c7479, #18201f 72%);
  color: #fff;
  font-weight: 800;
  font-size: 22px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 21px;
  line-height: 1.2;
  font-weight: 760;
}

.brand p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

.search-panel {
  width: min(480px, 42vw);
  position: relative;
  z-index: 60;
}

.search-label {
  display: block;
  margin-bottom: 6px;
  color: #586460;
  font-size: 12px;
}

.search-row {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 40px 40px;
  gap: 8px;
}

.search-row input {
  min-width: 0;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fffdf8;
  color: var(--ink);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.9) inset;
}

.search-row input:focus {
  outline: 2px solid rgba(28, 116, 121, 0.24);
  border-color: rgba(28, 116, 121, 0.72);
}

.icon-button {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fffdf8;
  color: var(--ink);
  cursor: pointer;
  transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease;
}

.icon-button:hover {
  transform: translateY(-1px);
  border-color: rgba(28, 116, 121, 0.54);
  background: #f5fbfa;
}

.icon-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.suggestions {
  position: fixed;
  z-index: 1000;
  left: 0;
  right: auto;
  top: 72px;
  width: min(520px, calc(100vw - 32px));
  max-height: min(430px, calc(100vh - 112px));
  overflow: auto;
  display: none;
  border: 1px solid rgba(29, 37, 36, 0.16);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.985);
  box-shadow: 0 24px 70px rgba(12, 18, 17, 0.24);
  backdrop-filter: blur(18px);
}

.suggestions.open {
  display: block;
}

.suggestion-item {
  width: 100%;
  display: block;
  padding: 10px 12px;
  border: 0;
  border-bottom: 1px solid #eef2ee;
  background: transparent;
  text-align: left;
  color: var(--ink);
  cursor: pointer;
}

.suggestion-item:hover,
.suggestion-item.active {
  background: #edf7f6;
}

.suggestion-item strong,
.suggestion-item span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.suggestion-item strong {
  font-size: 13px;
}

.suggestion-item span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.workspace {
  position: relative;
  z-index: 1;
  min-height: calc(100vh - 88px);
  display: grid;
  grid-template-columns: 286px minmax(420px, 1fr) 360px;
  gap: 14px;
  padding: 14px;
}

.left-panel,
.right-panel {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.panel-section,
.summary-hero,
.insight-panel,
.chart-panel,
.research-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 15px;
  box-shadow: var(--soft-shadow);
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  color: var(--ink-strong);
  font-size: 13px;
  font-weight: 720;
  letter-spacing: 0.01em;
}

.section-title strong {
  color: var(--teal);
  font-size: 13px;
}

.toggle-list {
  display: grid;
  gap: 8px;
}

.layer-toggle {
  display: grid;
  grid-template-columns: 18px 1fr auto;
  align-items: center;
  gap: 9px;
  min-height: 30px;
  color: var(--ink);
  font-size: 13px;
  border-radius: 6px;
}

.layer-toggle input {
  width: 16px;
  height: 16px;
  accent-color: var(--teal);
}

.layer-swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.layer-count {
  color: var(--muted);
  font-size: 12px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 4px;
  background: #ecefeb;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
}

.segment,
.tool {
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
}

.segment.active,
.tool.active {
  background: var(--teal);
  color: #fff;
  box-shadow: 0 8px 18px rgba(28, 116, 121, 0.2);
}

.scale-note,
.audit-list div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
}

.audit-list {
  display: grid;
  gap: 8px;
  margin: 0;
}

.audit-list dt,
.audit-list dd {
  margin: 0;
}

.audit-list dd {
  color: var(--ink);
  font-weight: 720;
}

.map-stage {
  position: relative;
  min-height: 0;
  overflow: hidden;
  border: 1px solid rgba(29, 37, 36, 0.18);
  border-radius: 8px;
  background: #d5ddd7;
  box-shadow: var(--shadow);
  cursor: grab;
}

.map-stage.dragging {
  cursor: grabbing;
}

.tile-pane {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: #d5ddd7;
  filter: saturate(0.32) contrast(0.82) brightness(1.08) opacity(0.48);
}

.tile-pane::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: rgba(248, 247, 239, 0.34);
  mix-blend-mode: screen;
  z-index: 1;
}

.tile-pane.zoom-mid {
  filter: saturate(0.42) contrast(0.88) brightness(1.02) opacity(0.62);
}

.tile-pane.zoom-mid::after {
  background: rgba(248, 247, 239, 0.24);
}

.tile-pane.zoom-detail {
  filter: saturate(0.52) contrast(0.94) brightness(0.96) opacity(0.76);
}

.tile-pane.zoom-detail::after {
  background: rgba(248, 247, 239, 0.14);
}

.tile-pane img {
  position: absolute;
  z-index: 0;
  width: 256px;
  height: 256px;
  user-select: none;
  -webkit-user-drag: none;
}

#mapCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 2;
}

.map-tools {
  position: absolute;
  z-index: 3;
  left: 14px;
  top: 14px;
  display: flex;
  gap: 5px;
  padding: 5px;
  border: 1px solid rgba(255, 255, 255, 0.26);
  border-radius: 8px;
  background: rgba(24, 32, 31, 0.82);
  box-shadow: 0 12px 30px rgba(12, 18, 17, 0.22);
  backdrop-filter: blur(16px);
}

.zoom-controls {
  position: absolute;
  z-index: 3;
  right: 14px;
  top: 14px;
  display: grid;
  gap: 6px;
}

.zoom-button {
  width: 38px;
  height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  background: rgba(24, 32, 31, 0.84);
  color: #fff;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 12px 28px rgba(12, 18, 17, 0.22);
  transition: background 0.16s ease, transform 0.16s ease;
}

.zoom-button:hover {
  transform: translateY(-1px);
  background: rgba(28, 116, 121, 0.9);
}

.tool {
  min-width: 76px;
  padding: 0 10px;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.72);
}

.tool:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.legend {
  position: absolute;
  z-index: 3;
  left: 14px;
  bottom: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 9px 12px;
  max-width: calc(100% - 28px);
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 8px;
  background: rgba(24, 32, 31, 0.82);
  color: rgba(255, 255, 255, 0.76);
  font-size: 12px;
  box-shadow: 0 12px 30px rgba(12, 18, 17, 0.2);
  backdrop-filter: blur(16px);
}

.legend div {
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend-chip,
.legend-dot,
.legend-line {
  width: 16px;
  height: 10px;
  border-radius: 5px;
}

.risk-low {
  background: rgba(39, 151, 168, 0.52);
}

.risk-mid {
  background: rgba(220, 164, 59, 0.68);
}

.risk-high {
  background: rgba(207, 77, 95, 0.72);
}

.legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--indigo);
}

.legend-line {
  height: 3px;
  border-radius: 2px;
}

.legend-line.road {
  background: #9ca7a1;
}

.legend-line.river {
  background: #6fb7df;
}

.legend-chip.building {
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.38);
}

.tooltip {
  position: absolute;
  z-index: 5;
  max-width: 260px;
  padding: 10px 12px;
  border: 1px solid rgba(29, 37, 36, 0.16);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.97);
  box-shadow: var(--shadow);
  pointer-events: none;
  font-size: 12px;
  color: var(--ink);
}

.summary-hero {
  background:
    radial-gradient(circle at 88% 12%, rgba(220, 164, 59, 0.2), transparent 34%),
    linear-gradient(135deg, #1d2524 0%, #1c7479 100%);
  color: #fff;
  border-color: rgba(29, 37, 36, 0.12);
}

.eyebrow {
  color: #bfe8e7;
  font-size: 12px;
  font-weight: 760;
}

.summary-hero h2 {
  margin-top: 8px;
  font-size: 23px;
  line-height: 1.22;
}

.summary-hero p {
  margin-top: 10px;
  color: rgba(255, 255, 255, 0.78);
  font-size: 13px;
  line-height: 1.55;
}

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

.metrics-grid article {
  min-height: 94px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: var(--soft-shadow);
}

.metrics-grid span,
.metrics-grid small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.metrics-grid strong {
  display: block;
  margin: 8px 0 4px;
  font-size: 24px;
  line-height: 1;
  color: var(--ink-strong);
}

.insight-panel p,
.research-panel p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.research-panel p + p {
  margin-top: 8px;
}

.bar-chart {
  display: grid;
  gap: 9px;
}

.bar-row {
  display: grid;
  grid-template-columns: 92px 1fr 40px;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}

.bar-track {
  height: 12px;
  overflow: hidden;
  border-radius: 6px;
  background: #e8ebe6;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
}

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

  .right-panel {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

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

  .search-panel {
    width: 100%;
  }

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

  .map-stage {
    min-height: 580px;
  }

  .right-panel {
    grid-template-columns: 1fr;
  }
}
