:root {
  color-scheme: light;
  --ink: #17201d;
  --muted: #607069;
  --line: #d7ded7;
  --panel: #fbfcf8;
  --paper: #ffffff;
  --green: #2f8f6b;
  --teal: #2c7f91;
  --yellow: #d5a11e;
  --red: #c95f47;
  --blue: #3f6fa8;
  --violet: #6d5f9b;
  --shadow: 0 14px 40px rgba(26, 45, 38, 0.12);
}

* {
  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: #e9eee8;
}

button,
input {
  font: inherit;
}

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

.topbar {
  height: 84px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 14px 18px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

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

.brand-mark {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #16372f;
  color: #fff;
  font-weight: 800;
  font-size: 22px;
}

h1,
h2,
p {
  margin: 0;
}

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

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

.search-panel {
  width: min(480px, 42vw);
}

.search-label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  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);
  border-radius: 8px;
  background: #f7faf7;
  color: var(--ink);
}

.icon-button {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
}

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

.suggestions {
  position: absolute;
  z-index: 20;
  left: 0;
  right: 96px;
  top: 46px;
  max-height: 310px;
  overflow: auto;
  display: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: var(--shadow);
}

.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: #edf5ef;
}

.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 {
  min-height: calc(100vh - 84px);
  display: grid;
  grid-template-columns: 286px minmax(420px, 1fr) 360px;
  gap: 12px;
  padding: 12px;
}

.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: 14px;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  font-size: 14px;
  font-weight: 720;
}

.section-title strong {
  color: var(--green);
  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;
}

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

.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: #edf3ed;
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

.segment.active,
.tool.active {
  background: #17382f;
  color: #fff;
}

.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 #c6d2ca;
  border-radius: 8px;
  background: #dce5dd;
  box-shadow: var(--shadow);
  cursor: grab;
}

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

.tile-pane {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: #dce5dd;
}

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

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

.map-tools {
  position: absolute;
  z-index: 3;
  left: 14px;
  top: 14px;
  display: flex;
  gap: 6px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
}

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

.zoom-button {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--ink);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 8px 22px rgba(26, 45, 38, 0.1);
}

.tool {
  min-width: 76px;
  padding: 0 10px;
  font-size: 13px;
}

.legend {
  position: absolute;
  z-index: 3;
  left: 14px;
  bottom: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  max-width: calc(100% - 28px);
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--muted);
  font-size: 12px;
}

.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(47, 143, 107, 0.35);
}

.risk-mid {
  background: rgba(213, 161, 30, 0.42);
}

.risk-high {
  background: rgba(201, 95, 71, 0.48);
}

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

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

.legend-line.road {
  background: #63736d;
}

.legend-line.river {
  background: #3f8fb9;
}

.legend-chip.building {
  background: rgba(47, 69, 58, 0.22);
  border: 1px solid rgba(47, 69, 58, 0.4);
}

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

.summary-hero {
  background: #16372f;
  color: #fff;
}

.eyebrow {
  color: #bfe0d0;
  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: #d8e7df;
  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);
}

.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;
}

.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: #e7eee8;
}

.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;
  }
}
