:root {
  --color-bg: #eef3f8;
  --color-panel: #ffffff;
  --color-panel-alt: #f8fbff;
  --color-border: rgba(15, 23, 42, 0.08);
  --color-border-strong: rgba(15, 23, 42, 0.14);
  --color-text: #13233a;
  --color-muted: #66758b;
  --color-primary: #1d74f5;
  --color-primary-hover: #145fd1;
  --color-success: #18b26b;
  --color-danger: #e54b4b;
  --color-warning: #ffb648;
  --color-toolbar: linear-gradient(120deg, #0f1728 0%, #152845 55%, #15365f 100%);
  --color-toolbar-text: #f7fbff;
  --color-shadow: 0 16px 40px rgba(10, 37, 64, 0.14);
  --color-shadow-soft: 0 8px 18px rgba(15, 23, 42, 0.08);

  --status-planning: #f59e0b;
  --status-building: #2a7fff;
  --status-running: #19b06d;
  --status-paused: #8b96a7;
  --status-default: #64748b;
  --factory-color: #00b7c3;
  --factory-color-deep: #00a8b5;
  --factory-shadow: rgba(0, 168, 181, 0.22);
  --negotiation-color-start: #ff6b6b;
  --negotiation-color-end: #e53935;
  --negotiation-shadow: rgba(229, 57, 53, 0.28);
  --negotiation-chip-bg: rgba(229, 57, 53, 0.14);
  --negotiation-chip-color: #c62828;
  --legend-project-start: #2a7fff;
  --legend-project-end: #1a56f0;
  --legend-cluster-base: #8fb6f6;
  --legend-cluster-deep: #6f97da;
  --legend-cluster-shadow: rgba(111, 151, 218, 0.24);
  --legend-coverage-bg: rgba(37, 99, 235, 0.12);
  --legend-coverage-border: rgba(94, 176, 255, 0.55);

  --toolbar-height: 64px;
  --toolbar-float-top: 6px;
  --toolbar-float-gap: 18px;
  --sidebar-width: 280px;
  --status-height: 42px;
  --panel-width: 400px;
  --radius-xl: 22px;
  --radius-lg: 16px;
  --radius-md: 12px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  height: 100dvh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei",
    sans-serif;
  color: var(--color-text);
  background:
    radial-gradient(circle at top left, rgba(29, 116, 245, 0.18), transparent 28%),
    linear-gradient(180deg, #f5f8fc 0%, #edf2f7 100%);
}

body {
  overflow: hidden;
}

button,
input,
select {
  font: inherit;
}

#app {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

#toolbar {
  position: absolute;
  top: calc(var(--toolbar-float-top) + env(safe-area-inset-top, 0px));
  left: calc(18px + env(safe-area-inset-left, 0px));
  right: calc(18px + env(safe-area-inset-right, 0px));
  min-height: var(--toolbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 18px;
  background: rgba(255, 255, 255, 0.76);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  color: var(--color-text);
  border: 1px solid rgba(255, 255, 255, 0.56);
  box-shadow:
    0 18px 36px rgba(15, 23, 42, 0.12),
    0 8px 18px rgba(15, 23, 42, 0.06);
  z-index: 1200;
  flex-wrap: wrap;
  border-radius: 22px;
}

.toolbar-left,
.toolbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.toolbar-right {
  margin-left: auto;
}

.toolbar-left {
  min-width: 240px;
}

.toolbar-zoom-controls {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.toolbar-zoom-btn {
  min-width: 40px;
  width: 40px;
  padding: 0;
  font-size: 14px;
}

.toolbar-zoom-icon {
  width: 18px;
  height: 18px;
  display: block;
  flex-shrink: 0;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.toolbar-left .app-title {
  font-size: 18px;
  font-weight: 700;
  white-space: nowrap;
  color: var(--color-text);
}

#toolbar .app-subtitle {
  font-size: 12px;
  color: var(--color-muted);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  text-decoration: none;
  transition:
    transform 0.16s ease,
    background 0.16s ease,
    border-color 0.16s ease,
    box-shadow 0.16s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-primary {
  background: linear-gradient(135deg, #1d74f5, #40a9ff);
  color: #fff;
  box-shadow: 0 12px 20px rgba(29, 116, 245, 0.24);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #1668e4, #329af7);
}

.btn-ghost {
  color: #f7fbff;
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.07);
  backdrop-filter: blur(8px);
}

#toolbar .btn-ghost {
  color: var(--color-text);
  border-color: rgba(15, 23, 42, 0.12);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: none;
  box-shadow: var(--color-shadow-soft);
}

#toolbar .btn-ghost:hover {
  background: #f8fbff;
  border-color: rgba(29, 116, 245, 0.22);
}

#toolbar .btn-danger {
  color: var(--color-danger);
  border-color: rgba(229, 75, 75, 0.28);
  background: rgba(229, 75, 75, 0.06);
}

#toolbar .btn-danger:hover {
  background: rgba(229, 75, 75, 0.1);
}

#toolbar .switch-label {
  color: var(--color-text);
}

#toolbar .toggle-chip {
  background: rgba(15, 23, 42, 0.04);
  border: 1px solid rgba(15, 23, 42, 0.08);
}

#toolbar .control-field {
  background: rgba(15, 23, 42, 0.04);
  border: 1px solid rgba(15, 23, 42, 0.08);
}

#toolbar .control-field select {
  border: 1px solid rgba(15, 23, 42, 0.12);
  background: #fff;
  color: var(--color-text);
}

.btn-danger {
  color: #ffd2d2;
  border-color: rgba(255, 124, 124, 0.3);
  background: rgba(229, 75, 75, 0.08);
}

.btn-danger:hover {
  background: rgba(229, 75, 75, 0.14);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.12);
}

.btn-light {
  background: #fff;
  color: var(--color-text);
  border-color: var(--color-border);
  box-shadow: var(--color-shadow-soft);
}

.btn-light:hover {
  background: #f8fbff;
}

.upload-btn {
  position: relative;
  padding-right: 16px;
}

.upload-meta {
  padding-left: 10px;
  margin-left: 2px;
  border-left: 1px solid rgba(255, 255, 255, 0.28);
  font-size: 12px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.85);
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.08);
}

.status-dot.ready {
  background: var(--color-success);
  box-shadow: 0 0 0 4px rgba(24, 178, 107, 0.18);
}

.switch-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--color-toolbar-text);
  white-space: nowrap;
}

.toggle-chip {
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.toggle-chip input {
  accent-color: #42b883;
}

.control-field {
  padding: 8px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.control-field select {
  min-width: 92px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(17, 25, 40, 0.48);
  color: #fff;
  padding: 6px 10px;
  outline: none;
}

#filter-bar {
  display: none;
}

#main {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: stretch;
  position: relative;
  overflow: hidden;
}

#sidebar-shell {
  position: absolute;
  top: calc(var(--toolbar-height) + var(--toolbar-float-top) + 22px);
  left: 16px;
  bottom: 16px;
  flex: 0 0 var(--sidebar-width);
  width: var(--sidebar-width);
  min-width: 0;
  align-self: auto;
  overflow: visible;
  z-index: 960;
  transition: flex-basis 0.28s ease, width 0.28s ease;
}

#sidebar-shell.collapsed {
  flex: 0 0 0;
  width: 0;
  pointer-events: none;
}

#left-sidebar {
  width: var(--sidebar-width);
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0.9) 14%, rgba(249, 252, 255, 0.96)),
    linear-gradient(135deg, rgba(63, 145, 255, 0.08), transparent 36%);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 26px;
  box-shadow:
    0 24px 50px rgba(10, 37, 64, 0.18),
    0 8px 20px rgba(15, 23, 42, 0.08);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(15, 23, 42, 0.22) transparent;
  z-index: 10;
  transition:
    transform 0.28s ease,
    opacity 0.2s ease,
    box-shadow 0.2s ease;
  box-sizing: border-box;
}

#left-sidebar > * + * {
  margin-top: 12px;
}

#sidebar-shell.collapsed #left-sidebar {
  transform: translateX(calc(-1 * var(--sidebar-width)));
  opacity: 0;
  pointer-events: none;
}

#left-sidebar::-webkit-scrollbar {
  width: 6px;
}

#left-sidebar::-webkit-scrollbar-track {
  background: transparent;
  margin: 8px 0;
}

#left-sidebar::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.16);
  border: 2px solid transparent;
  background-clip: padding-box;
}

#left-sidebar::-webkit-scrollbar-thumb:hover {
  background: rgba(15, 23, 42, 0.28);
  border: 2px solid transparent;
  background-clip: padding-box;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 2px 2px 6px;
}

.sidebar-header-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--color-text);
}

.sidebar-title-icon,
.sidebar-svg-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.sidebar-icon {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  color: #5b6b86;
  opacity: 0.92;
}

.sidebar-icon-btn {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.72);
  background: rgba(255, 255, 255, 0.74);
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
  color: var(--color-muted);
  cursor: pointer;
}

.sidebar-expand-btn {
  display: none;
  place-items: center;
  position: absolute;
  z-index: 850;
  width: 30px;
  height: 52px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.76);
  border-left: none;
  border-radius: 0 14px 14px 0;
  background: rgba(255, 255, 255, 0.9);
  color: var(--color-text);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow:
    4px 0 18px rgba(15, 23, 42, 0.1),
    0 8px 24px rgba(15, 23, 42, 0.08);
  cursor: grab;
  touch-action: none;
  user-select: none;
  transition:
    background 0.16s ease,
    box-shadow 0.16s ease,
    color 0.16s ease;
}

.sidebar-expand-btn:not(.is-positioned) {
  top: 50%;
  left: 0;
  transform: translateY(-50%);
}

.sidebar-expand-btn.is-positioned {
  left: 0;
  transform: translateY(-50%);
}

.sidebar-expand-btn.is-dragging {
  cursor: grabbing;
  background: rgba(255, 255, 255, 0.98);
  color: var(--color-primary);
  box-shadow:
    4px 0 24px rgba(15, 23, 42, 0.16),
    0 12px 30px rgba(15, 23, 42, 0.12);
}

.sidebar-expand-btn:hover {
  background: rgba(255, 255, 255, 0.96);
  color: var(--color-primary);
  box-shadow:
    4px 0 22px rgba(15, 23, 42, 0.14),
    0 10px 28px rgba(15, 23, 42, 0.1);
}

.sidebar-expand-btn .sidebar-expand-icon {
  width: 16px;
  height: 16px;
}

#main.sidebar-collapsed .sidebar-expand-btn {
  display: inline-grid;
}

.sidebar-section {
  padding: 14px;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.76);
  box-shadow:
    0 12px 24px rgba(15, 23, 42, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.46);
}

.sidebar-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  font-size: 13px;
  font-weight: 700;
  color: var(--color-text);
}

.sidebar-section-toggle {
  width: 100%;
  margin-bottom: 12px;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  text-align: left;
  font: inherit;
}

.sidebar-section.is-collapsed .sidebar-section-toggle {
  margin-bottom: 0;
}

.sidebar-section.is-collapsed .sidebar-section-body {
  display: none;
}

.sidebar-section-chevron {
  width: 14px;
  height: 14px;
  margin-left: auto;
  flex-shrink: 0;
  color: var(--color-muted);
  transition: transform 0.2s ease;
}

.sidebar-section:not(.is-collapsed) .sidebar-section-chevron {
  transform: rotate(90deg);
}

.sidebar-filters {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* iOS < 14.5 不支持 flex gap，用 margin 兜底 */
.sidebar-filters > * + * {
  margin-top: 10px;
}

.sidebar-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.sidebar-field > * + * {
  margin-top: 6px;
}

.sidebar-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-muted);
}

.sidebar-field select {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  min-height: 38px;
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: rgba(248, 251, 255, 0.9);
  color: var(--color-text);
  outline: none;
  -webkit-appearance: menulist-button;
  appearance: menulist-button;
  font-size: 14px;
  line-height: 1.3;
}

.sidebar-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin-top: 4px;
}

.sidebar-btn .sidebar-svg-icon {
  color: var(--color-primary);
  display: block;
  overflow: visible;
}

.sidebar-query {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sidebar-query > * + * {
  margin-top: 10px;
}

.sidebar-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 0 12px;
  border-radius: 12px;
  background: rgba(248, 251, 255, 0.88);
  border: 1px solid rgba(15, 23, 42, 0.08);
  font-size: 13px;
  color: var(--color-text);
  cursor: pointer;
  width: 100%;
  box-sizing: border-box;
}

.sidebar-toggle > * + * {
  margin-left: 10px;
}

.sidebar-toggle input {
  accent-color: var(--color-primary);
  flex: 0 0 auto;
  margin: 0;
}

.sidebar-toggle span {
  flex: 1 1 auto;
  min-width: 0;
  line-height: 1.35;
}

.sidebar-data {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-admin-guide {
  margin-top: 6px;
  padding: 12px 12px 10px;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(29, 116, 245, 0.08), rgba(29, 116, 245, 0.03));
  border: 1px solid rgba(29, 116, 245, 0.12);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.38);
}

.sidebar-admin-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 700;
  color: #1a56f0;
}

.sidebar-admin-steps {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  line-height: 1.6;
  color: var(--color-muted);
}

.sidebar-admin-steps code {
  padding: 1px 5px;
  border-radius: 6px;
  background: rgba(15, 23, 42, 0.05);
  color: var(--color-text);
  font-family: Consolas, "Courier New", monospace;
}

.sidebar-upload-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sidebar-upload-btn {
  width: 100%;
  justify-content: flex-start;
  gap: 8px;
  min-height: 42px;
  border-radius: 12px;
  font-size: 13px;
}

.sidebar-upload-meta {
  margin-left: auto;
  padding-left: 8px;
  font-size: 12px;
  font-weight: 500;
  opacity: 0.9;
}

.sidebar-btn-danger {
  color: var(--color-danger);
  border-color: rgba(229, 75, 75, 0.28);
}

.sidebar-btn-danger:hover {
  background: rgba(229, 75, 75, 0.06);
}

#left-sidebar .status-dot {
  background: rgba(255, 255, 255, 0.35);
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.1);
}

#left-sidebar .status-dot.ready {
  background: #fff;
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.25);
}

.filter-summary {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(15, 23, 42, 0.08);
  font-size: 12px;
  color: var(--color-muted);
  line-height: 1.6;
}

.sidebar-legend {
  grid-template-columns: 1fr;
  gap: 10px;
}

.sidebar-legend .legend-item {
  color: var(--color-text);
}

.theme-switcher-block {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid rgba(15, 23, 42, 0.08);
}

.theme-toggle-btn {
  width: 100%;
  min-height: 40px;
  justify-content: center;
}

.legend-pin {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: #fff;
  font-size: 8px;
  border: 1.5px solid rgba(255, 255, 255, 0.92);
  box-shadow: 0 4px 10px rgba(9, 16, 29, 0.16);
}

.legend-pin::before {
  content: "";
  position: absolute;
}

.legend-pin i {
  position: relative;
  z-index: 1;
}

.legend-pin.project-marker {
  border-radius: 50% 50% 50% 0;
  transform: rotate(45deg);
  background: linear-gradient(135deg, var(--legend-project-start), var(--legend-project-end));
}

.legend-pin.project-marker::before {
  inset: 3px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
}

.legend-pin.project-marker i {
  transform: rotate(45deg);
}

.legend-pin.factory-marker {
  border-radius: 3px;
  transform: rotate(45deg);
  background: linear-gradient(135deg, var(--factory-color), var(--factory-color-deep));
}

.legend-pin.factory-marker::before {
  inset: 3px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.16);
}

.legend-pin.factory-marker::after {
  content: none;
}

.legend-coverage {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  border-radius: 4px;
  background: var(--legend-coverage-bg);
  border: 1.5px solid var(--legend-coverage-border);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.45);
}

.legend-city-cluster {
  --cluster-base: var(--legend-cluster-base);
  --cluster-deep: var(--legend-cluster-deep);
  --cluster-shadow: var(--legend-cluster-shadow);
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  background: linear-gradient(135deg, var(--cluster-base), var(--cluster-deep));
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  border: 1.5px solid rgba(255, 255, 255, 0.95);
  box-shadow: 0 8px 16px var(--cluster-shadow);
}

.legend-city-cluster.sm {
  width: 16px;
  height: 16px;
}

.legend-city-cluster::after {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  transform: rotate(45deg);
}

#map-shell {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  align-self: stretch;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(210, 228, 250, 0.9), rgba(244, 248, 255, 0.94) 26%, rgba(244, 248, 255, 0.92));
}

#map {
  position: relative;
  flex: 1 1 auto;
  width: 100%;
  min-height: 240px;
  background: #dceaff;
}

#map .leaflet-container {
  width: 100%;
  height: 100%;
  z-index: 1;
}

#map-startup-hint,
#map-tile-hint {
  position: absolute;
  left: 18px;
  right: 18px;
  z-index: 620;
  padding: 12px 14px;
  border-radius: 14px;
  color: #f7fbff;
  font-size: 13px;
  line-height: 1.6;
  text-align: center;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.2);
  backdrop-filter: blur(10px);
}

#map-startup-hint {
  top: calc(var(--toolbar-height) + var(--toolbar-float-top) + 22px);
  background: rgba(197, 68, 68, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.24);
}

#map-startup-hint code {
  padding: 1px 4px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.14);
  font-family: Consolas, "Courier New", monospace;
}

#map-tile-hint.hidden {
  display: none;
}

#map-tile-hint {
  bottom: 18px;
  background: rgba(197, 115, 33, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.2);
  pointer-events: none;
}

#map-startup-hint.hidden {
  display: none;
}

.map-overlay-group {
  position: absolute;
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 12px;
  pointer-events: none;
}

.map-overlay-group.top-left {
  top: calc(var(--toolbar-height) + var(--toolbar-float-top) + 22px);
  left: 16px;
  width: 260px;
  max-height: calc(100% - var(--toolbar-height) - var(--toolbar-float-top) - 38px);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.35) transparent;
}

.map-overlay-group.top-left::-webkit-scrollbar {
  width: 6px;
}

.map-overlay-group.top-left::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.28);
}

.map-overlay-group > .glass-card {
  flex: 0 0 auto;
  padding: 10px 12px;
  border-radius: 16px;
}

.glass-card {
  width: 260px;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.68);
  background: rgba(13, 28, 52, 0.62);
  color: #f7fbff;
  box-shadow: 0 16px 30px rgba(8, 23, 45, 0.18);
  backdrop-filter: blur(14px);
  pointer-events: auto;
}

/* 地图搜索卡片 */
.search-card {
  padding-top: 8px;
  padding-bottom: 8px;
}

.map-search-row {
  display: block;
}

.map-search-actions-col {
  display: none;
}

.search-input-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.12);
  transition: background 0.16s;
}

.search-input-wrap:focus-within {
  background: rgba(255, 255, 255, 0.18);
  outline: 2px solid rgba(255, 255, 255, 0.25);
}

.search-input-wrap i {
  font-size: 12px;
  opacity: 0.6;
}

.search-input-wrap input {
  flex: 1;
  border: none;
  background: transparent;
  color: #f7fbff;
  font-size: 12px;
  outline: none;
  min-width: 0;
  padding: 4px 0;
}

.search-input-wrap input::placeholder {
  color: rgba(247, 251, 255, 0.5);
}

/* 项目选址卡片 */
.negotiation-card {
  padding-bottom: 12px;
}

.negotiation-card-header {
  justify-content: space-between;
  margin-bottom: 10px;
}

.negotiation-card-heading {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.negotiation-icon-btn,
.negotiation-expand-btn {
  display: none;
}

.negotiation-result-float.hidden {
  display: none;
}

#detail-panel.negotiation-panel #detail-close {
  display: none;
}

#negotiation-shell {
  flex: 0 0 auto;
}

.negotiation-field {
  display: block;
  margin-bottom: 8px;
}

.negotiation-region-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-bottom: 8px;
}

.negotiation-region-row > * + * {
  margin-top: 8px;
}

.negotiation-region-item {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  width: 100%;
  min-width: 0;
}

.negotiation-region-tag {
  font-size: 11px;
  color: rgba(247, 251, 255, 0.72);
  text-align: center;
  padding: 4px 0;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
}

.negotiation-select:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.negotiation-detail-wrap {
  margin-top: 0;
}

.negotiation-label {
  display: block;
  margin-bottom: 6px;
  font-size: 11px;
  color: rgba(247, 251, 255, 0.78);
}

.negotiation-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

.negotiation-btn {
  position: relative;
  width: 100%;
  margin-top: 0;
  justify-content: center;
  text-align: center;
  min-height: 36px;
  padding: 0 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.25;
}

.negotiation-card .negotiation-btn.btn-primary {
  background: linear-gradient(180deg, rgba(56, 141, 255, 0.96), rgba(29, 116, 245, 0.92));
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow:
    0 6px 14px rgba(29, 116, 245, 0.24),
    inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.negotiation-card .negotiation-btn.btn-primary:hover {
  background: linear-gradient(180deg, rgba(72, 152, 255, 0.98), rgba(37, 124, 245, 0.94));
  box-shadow:
    0 8px 16px rgba(29, 116, 245, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.negotiation-card .negotiation-btn.btn-light {
  background: rgba(255, 255, 255, 0.08);
  color: rgba(247, 251, 255, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.negotiation-card .negotiation-btn.btn-light:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.3);
  color: #fff;
}

.negotiation-card .negotiation-btn:hover {
  transform: translateY(-1px);
}

.negotiation-card .negotiation-btn:active {
  transform: translateY(0);
}

.negotiation-btn i {
  font-size: 11px;
  opacity: 0.85;
  pointer-events: none;
}

.negotiation-advanced .negotiation-btn {
  margin-top: 4px;
}

.negotiation-btn.active {
  background: rgba(229, 57, 53, 0.24);
  border-color: rgba(255, 138, 128, 0.52);
  color: #ffeceb;
  box-shadow:
    0 0 0 1px rgba(255, 138, 128, 0.16) inset,
    0 6px 14px rgba(229, 57, 53, 0.18);
}

.negotiation-coord-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}

.negotiation-advanced {
  margin-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 6px;
}

.negotiation-advanced > summary {
  display: flex;
  align-items: center;
  gap: 6px;
  list-style: none;
  cursor: pointer;
  font-size: 11px;
  color: rgba(247, 251, 255, 0.72);
  padding: 4px 0;
  user-select: none;
}

.negotiation-advanced > summary::-webkit-details-marker {
  display: none;
}

.negotiation-advanced > summary::after {
  content: "▾";
  margin-left: auto;
  font-size: 10px;
  opacity: 0.7;
  transition: transform 0.16s ease;
}

.negotiation-advanced[open] > summary::after {
  transform: rotate(180deg);
}

.negotiation-advanced-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 6px;
}

.negotiation-coord-row input,
.negotiation-select {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  border: none;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 14px;
  line-height: 1.3;
  min-height: 40px;
  padding: 8px 10px;
  outline: none;
  -webkit-appearance: menulist-button;
  appearance: menulist-button;
}

.negotiation-coord-row input::placeholder {
  color: #fff;
  opacity: 1;
}

.negotiation-coord-row input:focus,
.negotiation-select:focus {
  background: rgba(255, 255, 255, 0.18);
  outline: 2px solid rgba(255, 255, 255, 0.25);
}

.negotiation-select option {
  color: #0f172a;
}

#map-shell.map-pick-mode,
#map-shell.map-pick-mode #map {
  cursor: crosshair !important;
}

.negotiation-pin {
  position: relative;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  color: #fff;
  font-size: 12px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  border: 2px solid rgba(255, 255, 255, 0.94);
  background: linear-gradient(135deg, var(--negotiation-color-start), var(--negotiation-color-end));
  box-shadow: 0 12px 18px var(--negotiation-shadow);
}

.negotiation-pin > span {
  transform: rotate(45deg);
}

.legend-pin.negotiation-marker {
  background: linear-gradient(135deg, var(--negotiation-color-start), var(--negotiation-color-end));
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  border: 1px solid rgba(255, 255, 255, 0.8);
}

.detail-chip.negotiation-chip {
  background: var(--negotiation-chip-bg);
  color: var(--negotiation-chip-color);
}

.card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  font-size: 13px;
  font-weight: 700;
}

.card-title-compact {
  margin-bottom: 6px;
  font-size: 12px;
}

.legend-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 12px;
  font-size: 12px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  color: rgba(247, 251, 255, 0.86);
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.legend-dot.planning {
  background: var(--status-planning);
}

.legend-dot.building {
  background: var(--status-building);
}

.legend-dot.running {
  background: var(--status-running);
}

.legend-dot.paused {
  background: var(--status-paused);
}

.insight-metrics {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}

.metric-item {
  flex: 1 1 0;
  padding: 10px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.08);
  text-align: center;
}

.metric-label {
  display: block;
  font-size: 11px;
  color: rgba(247, 251, 255, 0.72);
  margin-bottom: 6px;
}

.metric-item strong {
  font-size: 20px;
}

#detail-panel {
  position: absolute;
  top: calc(var(--toolbar-height) + var(--toolbar-float-top) + 22px);
  right: 16px;
  bottom: 16px;
  width: var(--panel-width);
  max-width: min(var(--panel-width), 92vw);
  border-radius: 26px;
  background: linear-gradient(180deg, #ffffff 0%, #f7fbff 100%);
  box-shadow: 0 20px 48px rgba(10, 37, 64, 0.18);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(15, 23, 42, 0.18) transparent;
  z-index: 900;
  transform: translateX(100%);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.28s ease, opacity 0.2s ease;
  border: 1px solid rgba(255, 255, 255, 0.8);
}

#detail-panel::-webkit-scrollbar {
  width: 6px;
}

#detail-panel::-webkit-scrollbar-track {
  background: transparent;
  margin: 12px 0;
}

#detail-panel::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.16);
  border: 2px solid transparent;
  background-clip: padding-box;
}

#detail-panel::-webkit-scrollbar-thumb:hover {
  background: rgba(15, 23, 42, 0.28);
  border: 2px solid transparent;
  background-clip: padding-box;
}

#detail-panel::-webkit-scrollbar-button {
  display: none;
  width: 0;
  height: 0;
}

#detail-panel:not(.collapsed) {
  transform: translateX(0);
  opacity: 1;
  pointer-events: auto;
}

#detail-panel.collapsed {
  transform: translateX(100%);
  opacity: 0;
  pointer-events: none;
}

#detail-close {
  position: absolute;
  top: 14px;
  right: 14px;
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.06);
  cursor: pointer;
  color: var(--color-muted);
  z-index: 2;
}

.card-title-icon {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  opacity: 0.9;
}

#detail-close:hover {
  background: rgba(15, 23, 42, 0.11);
}

#detail-content {
  padding: 22px;
}

.detail-empty {
  color: var(--color-muted);
  font-size: 14px;
  text-align: center;
}

.modern-empty {
  display: flex;
  min-height: 100%;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding-top: 56px;
}

.empty-hero {
  width: 78px;
  height: 78px;
  display: grid;
  place-items: center;
  border-radius: 24px;
  background: linear-gradient(135deg, rgba(29, 116, 245, 0.16), rgba(64, 169, 255, 0.1));
  color: var(--color-primary);
  font-size: 30px;
}

.empty-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--color-text);
}

.detail-empty .hint {
  font-size: 12px;
  margin-top: 0;
}

.detail-header {
  margin-bottom: 16px;
}

.detail-back-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  margin-right: 4px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--color-muted);
  cursor: pointer;
  transition: color 0.16s ease, background 0.16s ease;
  vertical-align: middle;
}

.detail-back-icon:hover {
  color: var(--color-primary);
  background: rgba(29, 116, 245, 0.08);
}

.detail-title {
  margin: 0 40px 10px 0;
  font-size: 24px;
  font-weight: 700;
  line-height: 1.3;
}

.detail-meta-top {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
}

.detail-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  min-height: 28px;
  border-radius: 999px;
  background: rgba(29, 116, 245, 0.08);
  color: var(--color-primary);
  font-size: 12px;
  font-weight: 600;
}

.detail-banner {
  position: relative;
  height: 220px;
  margin-bottom: 18px;
  border-radius: 22px;
  overflow: hidden;
  background: linear-gradient(135deg, #10233f, #16457a 60%, #1d74f5);
  box-shadow: 0 12px 26px rgba(10, 37, 64, 0.16);
}

.detail-banner img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.detail-banner.image-error img,
.detail-banner:not(.has-image) img,
.gallery-card.image-error img {
  display: none;
}

.media-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 22px;
  color: #fff;
  background:
    radial-gradient(circle at top right, rgba(255, 255, 255, 0.24), transparent 28%),
    linear-gradient(135deg, rgba(10, 22, 43, 0.92), rgba(29, 116, 245, 0.72));
}

.detail-banner.has-image .media-placeholder {
  display: none;
}

.detail-banner.image-error .media-placeholder,
.detail-banner:not(.has-image) .media-placeholder,
.gallery-card.image-error .media-placeholder,
.gallery-card:not(.has-image) .media-placeholder {
  display: flex;
}

.media-placeholder::before {
  content: "";
  position: absolute;
  inset: 16px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.media-icon {
  width: 60px;
  height: 60px;
  display: grid;
  place-items: center;
  margin-bottom: auto;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.12);
  font-size: 26px;
}

.media-placeholder strong,
.media-placeholder span {
  position: relative;
  z-index: 1;
}

.media-placeholder strong {
  font-size: 18px;
  margin-bottom: 8px;
}

.media-placeholder span {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.78);
  line-height: 1.6;
}

.detail-grid {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.detail-row {
  padding: 14px 16px;
  border-radius: 16px;
  background: #fff;
  border: 1px solid rgba(15, 23, 42, 0.05);
  box-shadow: var(--color-shadow-soft);
  font-size: 13px;
  line-height: 1.7;
}

.detail-row .label {
  display: inline-block;
  min-width: 76px;
  color: var(--color-muted);
  margin-right: 6px;
}

.detail-section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 20px 0 10px;
  font-size: 14px;
  font-weight: 700;
  color: var(--color-text);
}

.detail-note {
  margin-bottom: 14px;
}

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

.gallery-card {
  position: relative;
  min-height: 120px;
  border-radius: 18px;
  overflow: hidden;
  background: linear-gradient(135deg, #cfe4ff, #eef6ff);
  box-shadow: var(--color-shadow-soft);
}

.gallery-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.gallery-card .media-placeholder {
  justify-content: flex-end;
  padding: 18px;
}

.gallery-card .media-icon {
  width: 40px;
  height: 40px;
  font-size: 18px;
  border-radius: 12px;
}

#status-message {
  transition: color 0.2s ease;
}

#status-message.is-success {
  color: #15803d;
  font-weight: 600;
}

#status-message.is-warning {
  color: #b45309;
  font-weight: 600;
}

#status-message.is-error {
  color: #dc2626;
  font-weight: 600;
}

#status-message.is-info {
  color: var(--color-muted);
}

.btn.is-loading {
  opacity: 0.72;
  cursor: wait;
  pointer-events: none;
}

.query-btn {
  display: inline-flex;
  width: 100%;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  margin: 14px 0 10px;
  padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(56, 141, 255, 0.96), rgba(29, 116, 245, 0.92));
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 8px 16px rgba(29, 116, 245, 0.22);
  cursor: pointer;
  transition:
    background 0.16s ease,
    box-shadow 0.16s ease,
    transform 0.16s ease;
}

.query-btn:hover {
  background: linear-gradient(180deg, rgba(72, 152, 255, 0.98), rgba(37, 124, 245, 0.94));
  transform: translateY(-1px);
}

.factory-item {
  padding: 14px 14px 12px;
  border: 1px solid rgba(15, 23, 42, 0.06);
  border-radius: 18px;
  background: linear-gradient(180deg, #ffffff 0%, #f7fbff 100%);
  box-shadow: var(--color-shadow-soft);
  font-size: 13px;
  margin-bottom: 10px;
}

.factory-name {
  font-weight: 700;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.factory-distance {
  color: var(--color-primary);
  font-size: 20px;
  font-weight: 800;
  white-space: nowrap;
}

.factory-meta {
  color: var(--color-muted);
  margin-top: 8px;
  line-height: 1.6;
}

.factory-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(29, 116, 245, 0.08);
  color: var(--color-primary);
  font-size: 12px;
  font-weight: 600;
}

#status-bar {
  height: var(--status-height);
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding:
    0
    calc(18px + env(safe-area-inset-right, 0px))
    env(safe-area-inset-bottom, 0px)
    calc(18px + env(safe-area-inset-left, 0px));
  background: rgba(255, 255, 255, 0.88);
  border-top: 1px solid rgba(15, 23, 42, 0.06);
  box-shadow: 0 -10px 24px rgba(15, 23, 42, 0.04);
  font-size: 12px;
  color: var(--color-muted);
}

.status-left {
  min-width: 240px;
}

.status-center {
  flex: 1 1 auto;
  display: flex;
  justify-content: center;
}

#progress-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: 420px;
}

#progress-bar,
#progress-modal-bar {
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(
    to right,
    var(--color-primary) var(--progress, 0%),
    rgba(15, 23, 42, 0.08) var(--progress, 0%)
  );
}

#progress-bar {
  flex: 1 1 auto;
}

#progress-text {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.status-right {
  display: flex;
  align-items: center;
  gap: 16px;
  white-space: nowrap;
}

.attribution a {
  color: var(--color-primary);
  text-decoration: none;
}

.leaflet-control-attribution {
  white-space: nowrap;
}

.hidden {
  display: none !important;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: grid;
  place-items: center;
  background: rgba(9, 16, 29, 0.48);
  backdrop-filter: blur(10px);
}

.modal-card {
  width: min(92vw, 560px);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.52);
  box-shadow: 0 24px 60px rgba(10, 22, 43, 0.24);
}

.progress-modal-card {
  padding: 26px 28px;
  text-align: center;
}

.modal-icon {
  width: 72px;
  height: 72px;
  display: grid;
  place-items: center;
  margin: 0 auto 18px;
  border-radius: 22px;
  background: linear-gradient(135deg, rgba(29, 116, 245, 0.12), rgba(64, 169, 255, 0.2));
  color: var(--color-primary);
  font-size: 28px;
}

.pulse {
  animation: pulse 1.6s infinite;
}

.modal-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--color-text);
}

.modal-desc {
  margin-top: 10px;
  color: var(--color-muted);
  line-height: 1.7;
}

.modal-progress {
  margin-top: 18px;
  padding: 8px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.05);
}

.modal-hint {
  margin-top: 14px;
  font-size: 12px;
  color: var(--color-muted);
}

.failures-modal-card {
  width: min(92vw, 780px);
  max-height: min(84vh, 820px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.upload-choice-modal-card {
  width: min(92vw, 460px);
  padding: 0 0 22px;
  overflow: hidden;
}

.upload-choice-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 0 24px;
}

.upload-choice-btn {
  width: 100%;
  min-height: 46px;
  border-radius: 14px;
}

.upload-choice-hint {
  margin-top: 16px;
  padding: 0 24px;
  font-size: 12px;
  color: var(--color-muted);
  line-height: 1.6;
}

.import-result-modal-card {
  width: min(92vw, 520px);
  padding: 0 0 22px;
  overflow: hidden;
}

.import-result-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 0 24px;
}

.import-result-stat {
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--color-surface-2, #f8fafc);
  border: 1px solid var(--color-border, #e2e8f0);
}

.import-result-stat strong {
  display: block;
  margin-top: 4px;
  font-size: 24px;
  line-height: 1.2;
}

.import-result-stat.is-success strong {
  color: #15803d;
}

.import-result-stat.is-warning strong {
  color: #c2410c;
}

.import-result-stat.is-muted strong {
  color: var(--color-muted);
}

.import-result-stat span {
  font-size: 13px;
  color: var(--color-muted);
}

.import-result-failures {
  margin: 16px 24px 0;
  padding: 12px 14px;
  border-radius: 12px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  max-height: 180px;
  overflow: auto;
}

.import-result-failures .failure-line {
  font-size: 13px;
  line-height: 1.6;
  color: #9a3412;
}

.import-result-failures .failure-line + .failure-line {
  margin-top: 8px;
}

.import-result-actions {
  padding: 18px 24px 0;
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 24px 14px;
}

.upload-choice-modal-card .modal-header {
  padding-right: 18px;
}

.upload-choice-modal-card .modal-header > div:first-child {
  flex: 1 1 auto;
  min-width: 0;
}

.failure-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 0 24px 14px;
}

.failure-count {
  color: var(--color-muted);
  font-size: 13px;
}

.failure-list {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 0 24px 24px;
}

.failure-list.empty {
  display: grid;
  place-items: center;
  min-height: 220px;
  color: var(--color-muted);
}

.failure-item {
  padding: 14px 16px;
  margin-bottom: 10px;
  border-radius: 18px;
  background: linear-gradient(180deg, #fff 0%, #fbfcff 100%);
  border: 1px solid rgba(15, 23, 42, 0.06);
  box-shadow: var(--color-shadow-soft);
}

.failure-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.failure-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--color-text);
}

.failure-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
}

.failure-badge.failed {
  background: var(--color-danger);
}

.failure-badge.out_of_range {
  background: var(--color-warning);
  color: #3d2a00;
}

.failure-badge.pending {
  background: #94a3b8;
}

.failure-badge.validation_failed {
  background: #ea580c;
}

.failure-meta {
  color: var(--color-muted);
  font-size: 13px;
  line-height: 1.7;
}

.icon-btn {
  width: 38px;
  height: 38px;
  min-width: 38px;
  min-height: 38px;
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  border: none;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.06);
  color: var(--color-muted);
  cursor: pointer;
}

.icon-btn i {
  line-height: 1;
  font-size: 16px;
}

.icon-btn-svg {
  width: 16px;
  height: 16px;
  display: block;
}

.icon-btn:hover {
  background: rgba(15, 23, 42, 0.1);
}

.project-pin {
  position: relative;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  border: 2px solid rgba(255, 255, 255, 0.92);
  box-shadow: 0 12px 18px rgba(9, 16, 29, 0.22);
}

.project-pin > span {
  transform: rotate(45deg);
}

.project-pin {
  width: 24px;
  height: 24px;
}

.project-pin.small {
  width: 18px;
  height: 18px;
  font-size: 10px;
}

.factory-pin {
  position: relative;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  transform: rotate(45deg);
  border: 2px solid rgba(255, 255, 255, 0.94);
  background: linear-gradient(135deg, var(--factory-color, #22d3c5), var(--factory-color-deep, #00a8b5));
  box-shadow: 0 8px 14px var(--factory-shadow, rgba(0, 168, 181, 0.22));
}

.factory-pin::after {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.14);
}

.factory-pin svg {
  position: relative;
  z-index: 1;
  transform: rotate(-45deg);
}

.factory-cluster {
  position: relative;
  display: grid;
  place-items: center;
  border-radius: 4px;
  transform: rotate(45deg);
  border: 2px solid rgba(255, 255, 255, 0.94);
  background: linear-gradient(135deg, var(--factory-color, #22d3c5), var(--factory-color-deep, #00a8b5));
  box-shadow: 0 8px 14px var(--factory-shadow, rgba(0, 168, 181, 0.22));
  color: #fff;
  font-weight: 700;
}

.factory-cluster::after {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.14);
}

.factory-cluster.sm {
  width: 32px;
  height: 32px;
  font-size: 12px;
}

.factory-cluster.md {
  width: 40px;
  height: 40px;
  font-size: 13px;
}

.factory-cluster.lg {
  width: 48px;
  height: 48px;
  font-size: 14px;
}

.factory-cluster-count {
  line-height: 1;
  position: relative;
  z-index: 1;
  transform: rotate(-45deg);
}

.marker-highlight {
  box-shadow:
    0 12px 18px rgba(9, 16, 29, 0.24),
    0 0 0 8px rgba(29, 116, 245, 0.18);
}

.city-cluster {
  --cluster-base: #8fb6f6;
  --cluster-deep: #6f97da;
  --cluster-shadow: rgba(111, 151, 218, 0.24);
  position: relative;
  display: grid;
  place-items: center;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  color: #fff;
  font-weight: 700;
  background: linear-gradient(135deg, var(--cluster-base), var(--cluster-deep));
  border: 2px solid rgba(255, 255, 255, 0.95);
  box-shadow: 0 12px 22px var(--cluster-shadow);
}

.city-cluster::before {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: 50% 50% 50% 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0));
}

.city-cluster.sm {
  width: 32px;
  height: 32px;
  font-size: 11px;
}

.city-cluster.md {
  width: 40px;
  height: 40px;
  font-size: 12px;
}

.city-cluster.lg {
  width: 47px;
  height: 47px;
  font-size: 13px;
}

.city-cluster-count {
  line-height: 1;
  position: relative;
  z-index: 1;
  transform: rotate(45deg);
}

.province-coverage-path {
  transition:
    fill-opacity 0.28s cubic-bezier(0.4, 0, 0.2, 1),
    stroke-opacity 0.28s cubic-bezier(0.4, 0, 0.2, 1),
    stroke-width 0.28s cubic-bezier(0.4, 0, 0.2, 1),
    filter 0.32s cubic-bezier(0.4, 0, 0.2, 1);
}

.province-coverage-path.province-active {
  cursor: pointer;
}

.province-coverage-path.province-noninteractive {
  pointer-events: none;
  cursor: default;
}

.province-coverage-path.province-hover-active {
  filter:
    drop-shadow(0 0 2px var(--province-glow, rgba(37, 99, 235, 0.55)))
    drop-shadow(0 0 6px var(--province-glow-soft, rgba(37, 99, 235, 0.28)))
    drop-shadow(0 0 14px var(--province-glow-soft, rgba(37, 99, 235, 0.18)));
}

.province-coverage-path.province-hover-dimmed {
  filter: none;
}

.province-hover-label {
  padding: 0;
  background: transparent;
  color: #334155;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  transform: translateY(-6px);
  white-space: nowrap;
  border: none;
  box-shadow: none;
  text-shadow:
    0 1px 2px rgba(255, 255, 255, 0.92),
    0 0 8px rgba(255, 255, 255, 0.72);
}

.location-chip {
  background: rgba(37, 99, 235, 0.12);
  color: #1d4ed8;
}

.location-note {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(37, 99, 235, 0.08);
  color: #334155;
  line-height: 1.6;
}

.detail-alert {
  color: var(--color-danger);
}

.detail-muted {
  color: var(--color-muted);
}

.chip-disabled {
  background: rgba(107, 115, 125, 0.14);
  color: var(--color-muted);
}

.chip-enabled {
  background: rgba(0, 183, 195, 0.14);
  color: #00838f;
}

.detail-icon {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
}

.detail-icon-lg {
  width: 28px;
  height: 28px;
  color: var(--color-primary);
}

.city-project-arrow {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  color: var(--color-muted);
  opacity: 0.7;
}

.query-btn-secondary {
  width: 100%;
  margin-top: 12px;
  border-radius: 12px;
}

#failures-modal .btn,
.upload-choice-btn {
  border-radius: 14px;
}

.city-project-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
}

.city-project-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.92);
  cursor: pointer;
  text-align: left;
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}

.city-project-item:hover {
  transform: translateY(-1px);
  border-color: rgba(37, 99, 235, 0.22);
  box-shadow: 0 10px 20px rgba(15, 23, 42, 0.08);
}

.city-project-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  flex: 0 0 12px;
}

.city-project-copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  flex: 1;
}

.city-project-copy strong {
  font-size: 14px;
  color: var(--color-text);
}

.city-project-copy span {
  font-size: 12px;
  color: var(--color-text-muted);
}

.city-project-arrow {
  color: #94a3b8;
  font-size: 12px;
}

.location-modal-card {
  width: min(520px, 92vw);
}

.edit-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 8px;
}

.edit-field,
.edit-field-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.edit-field-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.edit-field span {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
}

.edit-field input {
  width: 100%;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 12px;
  font-size: 14px;
  background: #fff;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 4px;
}

.leaflet-container {
  background: #dceaff;
}

.leaflet-control-zoom {
  border: none !important;
  box-shadow: 0 10px 20px rgba(15, 23, 42, 0.14) !important;
}

.leaflet-control-zoom a {
  width: 36px !important;
  height: 36px !important;
  line-height: 36px !important;
  border: none !important;
  color: var(--color-text) !important;
}

.leaflet-popup-content {
  font-size: 13px;
}

@keyframes pulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.06);
  }
}

@media (max-width: 1280px) {
  :root {
    --panel-width: 360px;
    --sidebar-width: 260px;
  }
}

@media (max-width: 1024px) {
  :root {
    --panel-width: min(100vw, 380px);
    --sidebar-width: min(320px, 86vw);
    --status-height: 0;
    --toolbar-height: 0;
    --toolbar-float-top: 0;
  }

  #app {
    height: 100vh;
    height: 100dvh;
    min-height: 100vh;
    min-height: 100dvh;
  }

  #toolbar {
    display: none;
  }

  .toolbar-left {
    width: 100%;
    min-width: 0;
  }

  .filter-search input {
    min-width: 180px;
  }

  #main {
    flex: 1 1 auto;
    min-height: 0;
  }

  #sidebar-shell {
    top: calc(env(safe-area-inset-top, 0px) + 12px);
    left: calc(12px + env(safe-area-inset-left, 0px));
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    width: var(--sidebar-width);
  }

  #left-sidebar {
    padding: 14px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  .sidebar-expand-btn:not(.is-positioned) {
    top: 50%;
    left: env(safe-area-inset-left, 0px);
    transform: translateY(-50%);
  }

  #detail-panel {
    top: calc(env(safe-area-inset-top, 0px) + 12px);
    right: calc(12px + env(safe-area-inset-right, 0px));
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  }

  #map-startup-hint {
    top: calc(env(safe-area-inset-top, 0px) + 12px);
  }

  .map-overlay-group.top-left {
    top: calc(env(safe-area-inset-top, 0px) + 12px);
    left: calc(12px + env(safe-area-inset-left, 0px));
    right: calc(12px + env(safe-area-inset-right, 0px));
    bottom: auto;
    width: auto;
    max-width: none;
    align-items: stretch;
    max-height: calc(55vh - env(safe-area-inset-top, 0px));
  }

  .map-search-row {
    display: flex;
    align-items: flex-start;
    align-self: stretch;
    gap: 8px;
    width: 100%;
    box-sizing: border-box;
    pointer-events: none;
  }

  .map-search-row > * + * {
    margin-left: 8px;
  }

  .map-search-row .search-card.glass-card {
    flex: 1 1 0;
    min-width: 0;
    width: auto;
    max-width: none;
    align-self: auto;
    pointer-events: auto;
  }

  .map-search-actions-col {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 0 0 auto;
    align-items: stretch;
    pointer-events: auto;
  }

  .map-search-actions {
    display: flex;
    align-items: stretch;
    flex: 0 0 auto;
    pointer-events: auto;
  }

  #main:not(.sidebar-collapsed) .map-overlay-group.top-left {
    left: calc(var(--sidebar-width) + 12px + env(safe-area-inset-left, 0px));
    right: calc(12px + env(safe-area-inset-right, 0px));
  }

  #main:not(.sidebar-collapsed) .search-card {
    width: auto;
  }

  .negotiation-icon-btn,
  .negotiation-expand-btn {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: auto;
    min-width: 44px;
    align-self: stretch;
    min-height: 44px;
    padding: 0 12px;
    border-radius: 16px;
    flex-shrink: 0;
    border: 1px solid rgba(255, 255, 255, 0.68);
    background: rgba(13, 28, 52, 0.62);
    color: #f7fbff;
    box-shadow: 0 16px 30px rgba(8, 23, 45, 0.18);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    cursor: pointer;
    pointer-events: auto;
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
  }

  .negotiation-toggle-label {
    line-height: 1;
  }

  #map-shell.negotiation-collapsed .negotiation-expand-btn {
    display: inline-flex;
  }

  #map-shell:not(.negotiation-collapsed) .negotiation-collapse-btn {
    display: inline-flex;
  }

  #negotiation-shell.collapsed {
    display: none;
  }

  .negotiation-result-float:not(.hidden) {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    position: absolute;
    top: calc(env(safe-area-inset-top, 0px) + 68px);
    right: calc(12px + env(safe-area-inset-right, 0px));
    left: auto;
    width: auto;
    min-width: 120px;
    min-height: 44px;
    padding: 0 12px;
    z-index: 510;
    border: 1px solid rgba(255, 255, 255, 0.68);
    border-radius: 16px;
    background: rgba(13, 28, 52, 0.62);
    color: #f7fbff;
    box-shadow: 0 16px 30px rgba(8, 23, 45, 0.18);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    cursor: pointer;
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
    pointer-events: auto;
  }

  #negotiation-shell,
  #negotiation-shell .negotiation-card {
    width: 100%;
  }

  #main:not(.sidebar-collapsed) #negotiation-shell,
  #main:not(.sidebar-collapsed) #negotiation-shell .negotiation-card {
    width: 100%;
  }

  .glass-card {
    width: auto;
  }

  .insight-card {
    display: none;
  }

  #status-bar {
    display: none;
  }

  .leaflet-control-attribution {
    margin-bottom: env(safe-area-inset-bottom, 0px);
    margin-right: env(safe-area-inset-right, 0px);
    width: max-content;
    max-width: none;
  }

  .btn {
    min-height: 44px;
  }

  .sidebar-icon-btn {
    width: 44px;
    height: 44px;
  }

  .toolbar-zoom-btn {
    min-width: 44px;
    width: 44px;
  }

  .sidebar-toggle {
    min-height: 44px;
  }

  .sidebar-toggle input {
    width: 18px;
    height: 18px;
  }

  .negotiation-select,
  .sidebar-field select {
    min-height: 44px;
  }

  .negotiation-icon-btn,
  .negotiation-expand-btn {
    min-width: 44px;
    min-height: 44px;
  }

  #detail-close {
    width: 44px;
    height: 44px;
  }
}

@media (min-width: 1025px) {
  .negotiation-result-float:not(.hidden) {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    position: absolute;
    top: calc(var(--toolbar-height) + var(--toolbar-float-top) + 22px);
    right: 16px;
    left: auto;
    width: auto;
    min-width: 140px;
    min-height: 40px;
    padding: 0 14px;
    z-index: 901;
    border: 1px solid rgba(255, 255, 255, 0.68);
    border-radius: 16px;
    background: rgba(13, 28, 52, 0.62);
    color: #f7fbff;
    box-shadow: 0 16px 30px rgba(8, 23, 45, 0.18);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    cursor: pointer;
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
    pointer-events: auto;
  }
}

@media (max-width: 640px) {
  #main:not(.sidebar-collapsed) #negotiation-shell,
  #main:not(.sidebar-collapsed) .map-search-actions-col {
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
  }
}

@media (max-width: 480px) {
  :root {
    --panel-width: min(86vw, 300px);
    --sidebar-width: min(86vw, 300px);
  }

  .toolbar-left .app-title {
    font-size: 15px;
    white-space: normal;
    line-height: 1.35;
  }

  .map-overlay-group .glass-card {
    padding: 8px 10px;
    border-radius: 14px;
  }

  .glass-card {
    padding: 10px 12px;
    border-radius: 16px;
  }

  .modal-card {
    width: min(94vw, 560px);
    border-radius: 20px;
  }

  .modal-header {
    padding: 18px 16px 12px;
  }

  .failure-toolbar {
    padding: 0 16px 12px;
  }

  .failure-list {
    padding: 0 16px 18px;
  }

  .upload-choice-actions {
    padding: 0 16px;
  }

  .upload-choice-hint,
  .import-result-summary,
  .import-result-failures {
    padding-left: 16px;
    padding-right: 16px;
  }

  .import-result-actions {
    padding: 16px 16px 0;
  }

  .modal-actions {
    padding-left: 16px;
    padding-right: 16px;
  }
}

@media (max-width: 1024px) and (max-height: 500px) and (orientation: landscape) {
  #sidebar-shell,
  #detail-panel {
    top: calc(env(safe-area-inset-top, 0px) + 8px);
    bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    max-height: calc(100% - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 16px);
  }

  .map-overlay-group.top-left {
    max-height: calc(100% - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 72px);
  }
}

@media (min-width: 1025px) and (max-height: 500px) and (orientation: landscape) {
  :root {
    --toolbar-height: 48px;
  }

  #toolbar .app-subtitle {
    display: none;
  }

  #toolbar {
    padding-top: 8px;
    padding-bottom: 8px;
  }

  #sidebar-shell,
  #detail-panel {
    top: calc(var(--toolbar-height) + env(safe-area-inset-top, 0px) + 16px);
    bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    max-height: calc(100% - var(--toolbar-height) - env(safe-area-inset-top, 0px) - 24px);
  }

  .map-overlay-group.top-left {
    max-height: calc(100% - var(--toolbar-height) - env(safe-area-inset-top, 0px) - 28px);
  }

  #status-bar {
    padding-top: 6px;
    padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px));
  }
}

@media (pointer: coarse) {
  .btn {
    min-height: 44px;
  }

  .sidebar-icon-btn {
    width: 44px;
    height: 44px;
  }

  .toolbar-zoom-btn {
    min-width: 44px;
    width: 44px;
  }

  .sidebar-toggle {
    min-height: 44px;
  }

  .sidebar-toggle input {
    width: 18px;
    height: 18px;
  }

  .negotiation-select,
  .sidebar-field select {
    min-height: 44px;
  }

  #detail-close {
    width: 44px;
    height: 44px;
  }
}
