:root {
  --ink: #17212b;
  --muted: #66727f;
  --line: #d9e0e6;
  --paper: #f5f3ed;
  --surface: #ffffff;
  --surface-strong: #eef4f0;
  --green: #2e7d5b;
  --green-soft: #dcebe3;
  --amber: #c77a1a;
  --amber-soft: #f6e4c7;
  --red: #b84a3a;
  --red-soft: #f3d6d1;
  --blue: #2f6f9f;
  --blue-soft: #d9e9f4;
  --shadow: 0 18px 40px rgba(26, 32, 39, 0.1);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family:
    "Microsoft YaHei",
    "PingFang SC",
    "Segoe UI",
    Arial,
    sans-serif;
}

body {
  min-height: 100%;
  margin: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1180px, calc(100% - 24px));
  margin: 0 auto;
  padding: 18px 0 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0 18px;
}

.topbar h1,
.section-head h2,
.result-summary h3,
.tag-section h3 {
  margin: 0;
  letter-spacing: 0;
}

.topbar h1 {
  font-size: 28px;
  line-height: 1.15;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--green);
  font-size: 13px;
  font-weight: 700;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 0.95fr) minmax(360px, 1.1fr);
  gap: 16px;
  align-items: start;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 18px;
}

.capture-panel,
.map-panel {
  position: sticky;
  top: 12px;
}

.map-panel,
.batch-panel {
  grid-column: 1 / -1;
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.section-head h2 {
  font-size: 20px;
  line-height: 1.25;
}

.status-pill,
.priority-badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 5px 9px;
  border-radius: 8px;
  background: var(--green-soft);
  color: var(--green);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.priority-badge {
  background: var(--blue-soft);
  color: var(--blue);
}

.priority-badge.high {
  background: var(--red-soft);
  color: var(--red);
}

.priority-badge.medium-high {
  background: var(--amber-soft);
  color: var(--amber);
}

.priority-badge.medium {
  background: var(--blue-soft);
  color: var(--blue);
}

.priority-badge.low {
  background: var(--green-soft);
  color: var(--green);
}

.upload-zone {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 290px;
  overflow: hidden;
  border: 1px dashed #9eb2bd;
  border-radius: 8px;
  background: #f7f9f8;
}

.upload-zone input {
  position: absolute;
  inset: 0;
  z-index: 2;
  opacity: 0;
}

.upload-empty {
  display: grid;
  place-items: center;
  gap: 8px;
  color: var(--muted);
  text-align: center;
}

.upload-empty svg {
  width: 42px;
  height: 42px;
  color: var(--green);
}

.upload-empty strong {
  color: var(--ink);
  font-size: 17px;
}

#previewImage {
  display: none;
  width: 100%;
  height: 100%;
  max-height: 390px;
  object-fit: cover;
}

.upload-zone.has-image {
  border-style: solid;
  background: #111;
}

.upload-zone.has-image #previewImage {
  display: block;
}

.upload-zone.has-image .upload-empty {
  display: none;
}

.control-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-top: 14px;
}

.field {
  display: grid;
  gap: 6px;
}

.field span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.field select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 0 12px;
}

.primary-button,
.secondary-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-weight: 700;
}

.primary-button svg,
.secondary-button svg,
.icon-button svg {
  width: 18px;
  height: 18px;
}

.primary-button {
  width: 100%;
  min-height: 48px;
  margin-top: 14px;
  background: var(--green);
  color: white;
}

.primary-button:disabled {
  cursor: not-allowed;
  background: #b4c4bd;
}

.secondary-button,
.icon-button {
  min-height: 44px;
  border-color: var(--line);
  background: var(--surface);
  color: var(--ink);
  padding: 0 13px;
}

.icon-button {
  min-height: 38px;
}

.location-box {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--muted);
  font-size: 13px;
}

.dot {
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  border-radius: 50%;
  background: var(--amber);
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 300px;
  color: var(--muted);
  text-align: center;
}

.empty-state svg {
  width: 48px;
  height: 48px;
  margin-bottom: 8px;
  color: var(--blue);
}

.result-content {
  display: grid;
  gap: 18px;
}

.score-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 16px;
  align-items: center;
}

.score-ring {
  --score: 0;
  width: 112px;
  height: 112px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, #fff 57%, transparent 58%),
    conic-gradient(var(--green) calc(var(--score) * 1%), #e2e6e9 0);
}

.score-ring strong {
  display: block;
  font-size: 30px;
  line-height: 1;
}

.score-ring span {
  margin-top: -34px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.result-summary h3 {
  font-size: 20px;
  margin-bottom: 8px;
}

.result-summary p {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}

.sync-status {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--muted);
  background: #f2f5f3;
  font-size: 13px;
  line-height: 1.45;
}

.sync-status svg {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
  margin-top: 1px;
}

.sync-status.success {
  color: var(--green);
  background: var(--green-soft);
}

.sync-status.warning {
  color: var(--amber);
  background: var(--amber-soft);
}

.sync-status.error {
  color: var(--red);
  background: var(--red-soft);
}

.metric-list {
  display: grid;
  gap: 10px;
}

.metric {
  display: grid;
  grid-template-columns: 86px 1fr 40px;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.bar {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e6ecea;
}

.bar span {
  display: block;
  height: 100%;
  width: var(--value);
  background: var(--green);
}

.tag-section h3,
.suggestion-card h3 {
  font-size: 16px;
  margin-bottom: 10px;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 8px;
  background: var(--amber-soft);
  color: #78480f;
  padding: 5px 9px;
  font-size: 13px;
  font-weight: 700;
}

.tag-list.soft .tag {
  background: var(--blue-soft);
  color: var(--blue);
}

.suggestion-list {
  display: grid;
  gap: 10px;
}

.suggestion-card {
  border-left: 4px solid var(--green);
  border-radius: 8px;
  background: #f7faf8;
  padding: 12px;
}

.suggestion-card:nth-child(2) {
  border-left-color: var(--amber);
}

.suggestion-card:nth-child(3) {
  border-left-color: var(--blue);
}

.suggestion-card ul {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.6;
}

.intent-section {
  display: grid;
  gap: 12px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.intent-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.intent-head h3 {
  margin: 0 0 5px;
  font-size: 16px;
}

.intent-head p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.intent-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.intent-actions .secondary-button {
  min-height: 38px;
}

.intent-actions .secondary-button:disabled {
  cursor: not-allowed;
  color: #9aa5ad;
  background: #f2f4f3;
}

.intent-canvas-wrap {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #edf2ef;
  aspect-ratio: 3 / 2;
}

#intentCanvas {
  display: none;
  width: 100%;
  height: 100%;
}

.intent-canvas-wrap.has-intent #intentCanvas {
  display: block;
}

.intent-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  gap: 8px;
  color: var(--muted);
  padding: 18px;
  text-align: center;
}

.intent-empty svg {
  width: 38px;
  height: 38px;
  color: var(--green);
}

.intent-canvas-wrap.has-intent .intent-empty {
  display: none;
}

#map {
  height: 360px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #e7ece8;
}

.leaflet-container {
  background: #e7ece8;
}

.fallback-map {
  position: relative;
  height: 100%;
  background:
    linear-gradient(90deg, rgba(23, 33, 43, 0.08) 1px, transparent 1px),
    linear-gradient(rgba(23, 33, 43, 0.08) 1px, transparent 1px),
    #e7ece8;
  background-size: 48px 48px;
}

.fallback-point {
  position: absolute;
  width: 18px;
  height: 18px;
  border: 3px solid white;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.25);
}

.site-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.site-item {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  padding: 8px;
}

.site-item img {
  width: 56px;
  height: 56px;
  border-radius: 6px;
  object-fit: cover;
  background: #d9e0e6;
}

.site-item strong {
  display: block;
  margin-bottom: 3px;
  font-size: 13px;
}

.site-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

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

.pipeline div {
  min-height: 110px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  padding: 14px;
}

.pipeline strong,
.pipeline span {
  display: block;
}

.pipeline strong {
  margin-bottom: 10px;
  font-size: 16px;
}

.pipeline span {
  color: var(--muted);
  line-height: 1.55;
}

.leaflet-popup-content {
  margin: 10px 12px;
}

.popup-title {
  margin: 0 0 4px;
  font-weight: 700;
}

.popup-meta {
  margin: 0;
  color: #66727f;
  font-size: 12px;
}

@media (max-width: 860px) {
  .app-shell {
    width: min(100% - 18px, 560px);
    padding-top: 10px;
  }

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

  .capture-panel,
  .map-panel {
    position: static;
  }

  .topbar h1 {
    font-size: 24px;
  }

  .panel {
    padding: 14px;
  }

  .upload-zone {
    min-height: 240px;
  }

  .score-row {
    grid-template-columns: 1fr;
  }

  .score-ring {
    width: 104px;
    height: 104px;
  }

  .site-list,
  .pipeline {
    grid-template-columns: 1fr;
  }

  .intent-head {
    display: grid;
  }

  .intent-actions {
    justify-content: stretch;
  }

  .intent-actions .secondary-button {
    flex: 1 1 130px;
  }

  #map {
    height: 320px;
  }
}

@media (max-width: 420px) {
  .control-grid {
    grid-template-columns: 1fr;
  }

  .secondary-button {
    width: 100%;
  }

  .metric {
    grid-template-columns: 76px 1fr 34px;
  }
}
