:root {
  --pv-ink: #17333b;
  --pv-green: #18794e;
  --pv-mint: #e5f3eb;
  --pv-line: #dfe7e2;
  --pv-paper: #f5f8f6;
  --panel-bg: #f4f7f5;
  --surface: #fff;
  --ink: #16352e;
  --muted: #5f726c;
  --line: #d9e3de;
  --green: #14734a;
  --green-hover: #0e603d;
  --green-soft: #e8f3ed;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  color: #20302d;
  background: var(--pv-paper);
  font-family: "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
}

header {
  position: relative;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 54px;
  padding: 0 20px;
  color: #fff;
  background: var(--pv-ink);
  user-select: none;
}
header strong { font-size: 17px; font-weight: 650; letter-spacing: 0; }

.wrap { display: flex; height: calc(100vh - 54px); }
.panel {
  flex-shrink: 0;
  width: 408px;
  padding: 0 18px 28px;
  overflow-x: hidden;
  overflow-y: auto;
  border-right: 1px solid var(--pv-line);
  background: var(--panel-bg);
  box-shadow: 8px 0 24px rgba(22, 53, 46, .05);
}
.map-workspace { position: relative; display: flex; flex: 1; flex-direction: column; min-width: 0; }
#map { z-index: 1; flex: 1; background: #e8eaed; }

.workflow-section { padding: 18px 0; border-bottom: 1px solid var(--line); }
.workflow-section h2 {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0 0 13px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0;
}
.workflow-section h2 > span {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 4px;
  color: #fff;
  background: var(--ink);
  font: 700 12px Consolas, monospace;
}
.project-locator { position: relative; margin: 0; background: transparent; }

.field { margin-bottom: 10px; }
.field label,
.height-input label {
  display: block;
  height: 17px;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}
.field input,
.field select,
.field textarea,
.workflow-section input,
.workflow-section select {
  width: 100%;
  height: 38px;
  min-height: 38px;
  padding: 7px 10px;
  border: 1px solid #ccd9d3;
  border-radius: 4px;
  outline: none;
  color: #222;
  background: var(--surface);
  font-size: 13px;
  font-family: inherit;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.field input:hover,
.field select:hover { border-color: #aebfb7; }
.field input:focus,
.field select:focus,
.field textarea:focus { border-color: var(--pv-green); box-shadow: 0 0 0 3px rgba(24, 121, 78, .12); }
.workflow-section input:disabled {
  border-color: #d9e1dd;
  color: #8b9993;
  background: #e9eeeb;
  box-shadow: none;
  cursor: not-allowed;
}
.row2,
.paired-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.paired-fields .field { min-width: 0; }

.btn {
  width: 100%;
  height: 40px;
  margin-top: 0;
  padding: 0 12px;
  border: 0;
  border-radius: 4px;
  color: #fff;
  background: var(--pv-green);
  box-shadow: none;
  font-size: 13px;
  font-family: inherit;
  font-weight: 650;
  letter-spacing: 0;
  cursor: pointer;
  transition: background-color .15s ease, opacity .15s ease, transform .08s ease;
}
.btn:hover { opacity: .92; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible,
.segment-control button:focus-visible { outline: 3px solid rgba(20, 115, 74, .2); outline-offset: 2px; }
.btn.sec { border: 1px solid #d5dfd9; color: #30453f; background: #f8faf9; }
.btn.sec:hover { background: var(--pv-mint); }
.btn.sm { padding: 0 6px; font-size: 12px; }
.btn.ok { background: var(--green); }
.btn.ok:hover { background: var(--green-hover); }
.btn.rerun { border: 1px solid #98b7a7; color: var(--green); background: #fff; }
.btn.rerun:hover { background: var(--green-soft); }

.area-actions,
.generate-actions,
.inline-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.area-actions { margin-bottom: 9px; }
.generate-actions { margin-bottom: 12px; }
.area-actions .btn,
.generate-actions .btn,
.inline-actions .btn { margin: 0; }
.area-actions .btn { padding: 0 8px; text-align: center; }
.action-row,
.output-section .btn { padding-left: 13px; text-align: left; }

.obstacle-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; min-height: 40px; margin-bottom: 9px; align-items: stretch; }
.obstacle-row .action-row { height: 40px; margin: 0; }
.obstacle-row .action-row,
.kml-picker { padding-right: 8px; padding-left: 8px; text-align: center; }
.height-input {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 40px;
  padding: 0 10px;
  border: 1px solid #ccd9d3;
  border-radius: 4px;
  background: #fff;
}
.height-input label { flex: 0 0 auto; height: auto; margin: 0; white-space: nowrap; }
.height-input input {
  flex: 1;
  min-width: 0;
  height: 30px;
  min-height: 30px;
  padding: 3px 7px;
  border: 0;
  border-bottom: 1px solid #cbd8d1;
  border-radius: 0;
  background: transparent;
}
.segment-control {
  display: grid;
  grid-template-columns: 1fr 1fr;
  overflow: hidden;
  border: 1px solid #b8cbc1;
  border-radius: 4px;
  background: #fff;
}
.segment-control button {
  min-width: 0;
  padding: 0 4px;
  border: 0;
  border-left: 1px solid var(--line);
  color: #536861;
  background: #fff;
  font: 600 12px "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
  cursor: pointer;
}
.segment-control button:first-child { border-left: 0; }
.segment-control button.active { color: var(--green); background: var(--green-soft); }
.obstacle-mode-control { width: 100%; height: 38px; margin: 0 0 9px; }
.inline-actions { min-height: 40px; margin-bottom: 9px; }
.kml-picker { height: 40px; margin-bottom: 0; }
.visually-hidden-file {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  min-height: 0 !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}
.draw-status { margin-top: 8px; padding: 8px 9px; border-left: 3px solid var(--pv-green); color: #30453f; background: #e8f3ed; font-size: 12px; line-height: 1.55; }

.adjust-layout { margin: 0 0 12px; border: 1px solid #8aaea0; color: var(--green); background: #fff; }
.adjust-layout:hover,
.adjust-layout.active { border-color: var(--green); color: var(--green-hover); background: var(--green-soft); }
.building-select { margin-top: 0 !important; }
.output-section { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; }
.output-section h2 { grid-column: 1 / -1; }
.output-section .btn { margin: 0; }
.output-section .btn:last-child { grid-column: 1 / -1; }
.internal-controls { display: none !important; }

.stats {
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  min-height: 54px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--pv-line);
  background: #fff;
  font-size: 13px;
}
.stat { line-height: 1.2; }
.stat b { color: var(--pv-green); font-size: 16px; }
.stat span { display: block; margin-top: 2px; color: #888; font-size: 11px; }
#log {
  position: absolute;
  z-index: 900;
  left: 18px;
  bottom: 18px;
  max-width: min(520px, calc(100% - 36px));
  min-height: 0;
  margin: 0;
  padding: 9px 12px;
  border: 1px solid rgba(22, 53, 46, .14);
  border-radius: 4px;
  color: #314c44;
  background: rgba(255, 255, 255, .94);
  box-shadow: 0 5px 18px rgba(22, 53, 46, .13);
  font-size: 12px;
  line-height: 1.45;
  pointer-events: none;
  opacity: 0;
  transform: translateY(5px);
  transition: opacity .18s ease, transform .18s ease;
}
#log:not(:empty) { opacity: 1; transform: translateY(0); }

.company-search { position: relative; }
.company-options {
  position: absolute;
  z-index: 1200;
  top: 58px;
  right: 0;
  left: 0;
  max-height: 240px;
  overflow: auto;
  border: 1px solid #cfdad4;
  border-radius: 4px;
  background: #fff;
  box-shadow: 0 10px 24px rgba(23, 51, 59, .14);
}
.company-option { display: block; width: 100%; padding: 9px 10px; border: 0; border-bottom: 1px solid #edf1ef; color: #20302d; background: #fff; text-align: left; font-family: inherit; cursor: pointer; }
.company-option:last-child { border-bottom: 0; }
.company-option:hover,
.company-option:focus { outline: none; background: var(--pv-mint); }
.company-option strong,
.company-option small { display: block; letter-spacing: 0; }
.company-option strong { font-size: 12px; }
.company-option small { margin-top: 3px; overflow: hidden; color: #74817d; font-size: 10px; white-space: nowrap; text-overflow: ellipsis; }
.pv-basemap-control { display: flex !important; overflow: hidden; border: 1px solid rgba(23, 51, 59, .25) !important; border-radius: 5px !important; box-shadow: 0 2px 8px rgba(23, 51, 59, .16) !important; }
.pv-basemap-control button { height: 34px; padding: 0 10px; border: 0; border-right: 1px solid #d9e2dd; color: #30453f; background: #fff; font: 12px "Microsoft YaHei", sans-serif; letter-spacing: 0; cursor: pointer; }
.pv-basemap-control button:last-child { border-right: 0; }
.pv-basemap-control button:hover { background: #edf6f1; }
.pv-basemap-control button.active { color: #fff; background: var(--pv-green); }

.bld-label-icon { border: 0; background: none; }
.bld-label-icon span { display: block; color: #e61919; font-size: 15px; font-weight: bold; text-shadow: 0 0 3px #fff, 0 0 5px #fff, 1px 1px 0 #fff, -1px -1px 0 #fff; white-space: nowrap; pointer-events: none; transform: translate(-50%, -50%); }
.leaflet-container { font-family: inherit; font-size: 12px; }
.leaflet-control-zoom a { border-radius: 4px !important; }
.leaflet-popup-content { margin: 10px 14px; font-size: 12px; line-height: 1.5; }
.map-adjusting .leaflet-container { cursor: crosshair; }
.module-selected { filter: drop-shadow(0 0 3px rgba(255, 196, 0, .9)); }
.delete-selection-menu { min-width: 142px; padding: 2px; }
.delete-selection-menu button { width: 100%; height: 34px; border: 0; border-radius: 3px; color: #fff; background: #b53b34; font: 600 12px "Microsoft YaHei", sans-serif; cursor: pointer; }
::selection { color: #1a1a1a; background: rgba(24, 121, 78, .2); }

@media (max-width: 850px) {
  .wrap { display: block; height: auto; }
  .panel { width: 100%; max-height: none; padding: 0 14px 20px; }
  .map-workspace { height: 68vh; }
  .workflow-section { padding: 15px 0; }
}
