:root {
  --paper: #f5f8f3;
  --ink: #162119;
  --muted: #6e786f;
  --line: #d6ded3;
  --panel: rgba(255, 255, 255, 0.88);
  --blue: #116bd6;
  --green: #15952e;
  --orange: #f59d08;
  --dash: #646b66;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow: hidden;
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", sans-serif;
  background: radial-gradient(circle at 28% 18%, #ffffff 0, #f1f7ef 34%, #e6efe4 100%);
}

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

.app-shell {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 22px 18px;
  border-right: 1px solid var(--line);
  background: rgba(248, 251, 247, 0.94);
  overflow: auto;
}

.sidebar header {
  padding: 2px 2px 8px;
}

h1 {
  margin: 0 0 8px;
  font-size: 24px;
  line-height: 1.2;
}

h2 {
  margin: 0 0 14px;
  font-size: 16px;
}

p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
  font-size: 14px;
}

.panel {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 10px 28px rgba(48, 66, 44, 0.08);
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.tool-button {
  aspect-ratio: 1;
  border: 1px solid #c9d3c6;
  border-radius: 8px;
  color: #203026;
  background: #fff;
  font-size: 24px;
  cursor: pointer;
}

.tool-button.is-active {
  border-color: var(--blue);
  color: #fff;
  background: var(--blue);
}

.action-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}

button {
  min-height: 38px;
  border: 1px solid #c9d3c6;
  border-radius: 8px;
  color: #1d2b21;
  background: #fff;
  cursor: pointer;
}

button:hover {
  border-color: #8fa18c;
}

button.primary {
  border-color: #0d61c2;
  color: #fff;
  background: var(--blue);
}

#downloadReportBtn {
  grid-column: 1 / -1;
}

label {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
  color: #465048;
  font-size: 13px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #c9d3c6;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

input,
select {
  height: 38px;
  padding: 0 10px;
}

textarea {
  height: 150px;
  padding: 10px;
  resize: vertical;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
}

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
  color: #4f5a52;
  font-size: 13px;
}

.stats span {
  padding: 8px;
  border-radius: 8px;
  background: #eef4ec;
}

.acceptance-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  color: #516153;
  font-size: 13px;
}

.acceptance-card {
  position: relative;
  display: grid;
  align-content: space-between;
  gap: 8px;
  min-height: 72px;
  padding: 11px 11px 10px;
  overflow: hidden;
  border: 1px solid #d8e4d3;
  border-radius: 8px;
  background: linear-gradient(145deg, #ffffff 0%, #f2f8ef 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9), 0 8px 18px rgba(48, 66, 44, 0.07);
}

.acceptance-card::after {
  content: "";
  position: absolute;
  top: 10px;
  right: 10px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #a6b4a4;
  box-shadow: 0 0 0 4px rgba(166, 180, 164, 0.16);
}

.acceptance-card.is-good {
  border-color: #a5d4aa;
  background: linear-gradient(145deg, #ffffff 0%, #eef9ef 100%);
}

.acceptance-card.is-good::after {
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(21, 149, 46, 0.14);
}

.acceptance-card.is-warn {
  border-color: #efd195;
  background: linear-gradient(145deg, #ffffff 0%, #fff7e8 100%);
}

.acceptance-card.is-warn::after {
  background: var(--orange);
  box-shadow: 0 0 0 4px rgba(245, 157, 8, 0.18);
}

.acceptance-grid .wide {
  grid-column: 1 / -1;
}

.acceptance-card strong {
  color: #162119;
  font-size: 20px;
  line-height: 1.2;
}

.workspace {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
  padding: 16px;
}

.stage-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 0 4px 12px;
  color: #536056;
  font-size: 14px;
}

.stage {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border: 2px solid #a9c0a7;
  border-radius: 28px;
  background: #eef5eb;
  box-shadow: inset 0 0 32px rgba(255, 255, 255, 0.86), 0 18px 44px rgba(54, 72, 50, 0.12);
}

#sceneCanvas,
#networkSvg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#networkSvg {
  cursor: crosshair;
  touch-action: none;
}

.greenhouse-frame {
  fill: rgba(231, 236, 228, 0.68);
  stroke: rgba(150, 158, 150, 0.72);
  stroke-width: 3;
}

.bed {
  fill: rgba(107, 157, 91, 0.23);
  stroke: rgba(255, 255, 255, 0.54);
  stroke-width: 2;
}

.road {
  fill: rgba(232, 232, 220, 0.76);
}

.candidate {
  stroke: var(--dash);
  stroke-width: 3;
  stroke-dasharray: 9 9;
  stroke-linecap: round;
  opacity: 0.78;
}

.selected-edge {
  stroke: var(--blue);
  stroke-width: 7;
  stroke-linecap: round;
  paint-order: stroke;
}

.edge-hit {
  stroke: transparent;
  stroke-width: 18;
  cursor: pointer;
}

.node {
  cursor: grab;
}

.node.is-selected circle.main {
  stroke: #fff;
  stroke-width: 7;
  filter: drop-shadow(0 0 8px rgba(17, 107, 214, 0.45));
}

.node circle.main {
  stroke: #fff;
  stroke-width: 5;
  filter: drop-shadow(0 2px 5px rgba(18, 32, 20, 0.28));
}

.node text {
  fill: #fff;
  font-size: 30px;
  font-weight: 800;
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
}

.legend {
  pointer-events: none;
}

.legend-card {
  fill: rgba(255, 255, 255, 0.82);
  stroke: rgba(80, 84, 82, 0.42);
  stroke-width: 2;
}

.legend text {
  fill: #18201b;
  font-size: 24px;
  font-weight: 700;
}

.legend .item {
  font-size: 22px;
  font-weight: 600;
}

.scale text,
.north text {
  fill: #111;
  font-size: 22px;
}

@media (max-width: 980px) {
  body {
    overflow: auto;
  }

  .app-shell {
    grid-template-columns: 1fr;
    height: auto;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .workspace {
    height: 72vh;
  }
}
