:root {
  color-scheme: light;
  --bg: #edf3f8;
  --panel: rgba(255, 255, 255, 0.96);
  --line: rgba(15, 23, 42, 0.08);
  --line-strong: rgba(15, 23, 42, 0.14);
  --text: #0f172a;
  --muted: #64748b;
  --accent: #0f766e;
  --accent-soft: rgba(15, 118, 110, 0.08);
  --shadow: 0 14px 36px rgba(15, 23, 42, 0.08);
  --residential: #2563eb;
  --commercial: #d97706;
  --office: #8b5cf6;
  --education: #059669;
  --medical: #ef4444;
  --hotel: #be185d;
  --unknown: #64748b;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--bg);
}

body {
  min-height: 100vh;
  overflow: hidden;
}

h1,
h2,
h3,
p {
  margin: 0;
}

.app-shell {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr) 320px;
  height: 100vh;
  min-height: 100vh;
}

.sidebar {
  background: var(--panel);
  border-color: var(--line);
  border-style: solid;
  min-width: 0;
  position: relative;
  z-index: 20;
  height: 100vh;
  overflow: hidden;
}

.sidebar-left {
  border-width: 0 1px 0 0;
}

.sidebar-right {
  border-width: 0 0 0 1px;
}

.panel-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  padding: 24px 22px;
  overflow: hidden;
}

.eyebrow {
  margin-bottom: 10px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
}

h1 {
  font-size: 28px;
  line-height: 1.08;
  letter-spacing: -0.03em;
}

h2 {
  font-size: 18px;
}

h3 {
  font-size: 22px;
  line-height: 1.15;
}

.intro,
.muted,
.detail-note,
.fact-label,
.field-block > span {
  color: var(--muted);
}

.intro {
  margin-top: 12px;
  font-size: 14px;
  line-height: 1.65;
}

.field-block {
  display: grid;
  gap: 8px;
  margin-top: 20px;
}

.tool-row {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.hidden {
  display: none !important;
}

.draw-hint {
  margin-top: 10px;
  color: var(--accent);
  font-size: 13px;
  line-height: 1.5;
}

.compact-gap {
  margin-top: 14px;
}

input[type="text"],
select,
textarea {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  padding: 12px 14px;
  font: inherit;
  color: var(--text);
  background: #fff;
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

textarea {
  min-height: 92px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(15, 118, 110, 0.42);
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.08);
}

.list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 26px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.count-pill,
.map-chip,
.building-type,
.status-pill,
.edit-toggle,
.radio-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.94);
  font-size: 12px;
  font-weight: 600;
}

.building-list {
  flex: 1 1 auto;
  margin-top: 14px;
  overflow: auto;
  min-height: 0;
  padding-right: 4px;
}

.building-item {
  padding: 14px 14px 14px 12px;
  border-radius: 16px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.building-item + .building-item {
  margin-top: 8px;
}

.building-item:hover {
  background: rgba(15, 118, 110, 0.05);
  transform: translateX(2px);
}

.building-item.active {
  background: rgba(15, 118, 110, 0.08);
  border-color: rgba(15, 118, 110, 0.2);
}

.building-item-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.building-name {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.35;
}

.building-brief {
  margin-top: 8px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--muted);
}

.map-stage {
  position: relative;
  height: 100vh;
  min-height: 100vh;
  background: #dbe8f2;
}

#map {
  position: absolute;
  inset: 0;
}

.leaflet-container {
  background: #dbe8f2;
}

.map-overlay {
  pointer-events: none;
  position: absolute;
  top: 18px;
  left: 18px;
  right: 18px;
  z-index: 500;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.map-chip-group,
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.map-chip,
.legend {
  box-shadow: var(--shadow);
}

.legend {
  pointer-events: auto;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  font-size: 12px;
  font-weight: 600;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  display: inline-block;
}

.legend-dot.residential { background: var(--residential); }
.legend-dot.commercial { background: var(--commercial); }
.legend-dot.office { background: var(--office); }
.legend-dot.education { background: var(--education); }
.legend-dot.medical { background: var(--medical); }
.legend-dot.hotel { background: var(--hotel); }
.legend-dot.unknown { background: var(--unknown); }

.detail-panel-shell {
  gap: 14px;
}

.detail-body {
  flex: 1 1 auto;
  margin-top: 6px;
  overflow: auto;
  min-height: 0;
}

.detail-body.empty {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
}

.detail-card {
  display: grid;
  gap: 18px;
}

.detail-top {
  display: grid;
  gap: 10px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.detail-top-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.detail-note {
  font-size: 13px;
  line-height: 1.6;
}

.status-pill.yes {
  color: #065f46;
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.24);
}

.status-pill.no {
  color: #9a3412;
  background: rgba(249, 115, 22, 0.12);
  border-color: rgba(249, 115, 22, 0.24);
}

.status-pill.unknown {
  color: #475569;
  background: rgba(100, 116, 139, 0.12);
  border-color: rgba(100, 116, 139, 0.22);
}

.quick-facts {
  display: grid;
  gap: 12px;
}

.fact-row {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.7);
}

.fact-label {
  font-size: 12px;
}

.fact-value {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.4;
}

.editor-shell {
  display: grid;
  gap: 12px;
  padding-top: 2px;
}

.edit-toggle {
  width: fit-content;
  cursor: pointer;
  color: var(--accent);
  background: rgba(15, 118, 110, 0.08);
  border-color: rgba(15, 118, 110, 0.18);
}

.save-message {
  font-size: 13px;
}

.save-message.success {
  color: #166534;
}

.save-message.error {
  color: #b91c1c;
}

.editor-form {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.76);
}

.radio-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.radio-chip {
  position: relative;
  cursor: pointer;
}

.radio-chip input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.radio-chip span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
}

.radio-chip input:checked + span {
  color: var(--accent);
}

.button-row {
  display: flex;
  gap: 10px;
}

.button {
  min-height: 42px;
  padding: 0 16px;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.button.primary {
  color: white;
  background: var(--accent);
  border-color: var(--accent);
}

.button.secondary {
  background: rgba(255, 255, 255, 0.94);
}

.region-draft-marker {
  width: 9px;
  height: 9px;
  margin-left: -4px;
  margin-top: -4px;
  border: 2px solid white;
  border-radius: 999px;
  background: #0f766e;
  box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.32);
}

@media (max-width: 1320px) {
  .app-shell {
    grid-template-columns: 300px minmax(0, 1fr) 280px;
  }
}

@media (max-width: 1080px) {
  body {
    overflow: auto;
  }

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

  .sidebar-left,
  .sidebar-right {
    border-width: 0 0 1px 0;
  }

  .sidebar,
  .map-stage {
    height: auto;
  }

  .panel-inner {
    min-height: auto;
    height: auto;
  }

  .map-stage {
    min-height: 70vh;
  }

  .map-overlay {
    flex-direction: column;
  }
}
