:root {
  --blue: #12aed2;
  --blue-dark: #078aad;
  --navy: #203b52;
  --ink: #26364a;
  --muted: #748398;
  --line: #e3e9f1;
  --paper: #fff;
  --panel: rgba(255, 255, 255, 0.97);
  --danger: #b44848;
  --shadow: 0 8px 26px rgba(27, 44, 66, 0.17);
}

* { box-sizing: border-box; }
html, body, .app {
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
}
body {
  color: var(--ink);
  background: #dde6ec;
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
}
button, input, textarea, select { font: inherit; }
button {
  cursor: pointer;
  padding: 9px 14px;
  border: 1px solid #dde5ee;
  border-radius: 5px;
  color: #516176;
  background: #fff;
}
button:hover:not(:disabled) { border-color: var(--blue); color: var(--blue-dark); }
button:disabled { cursor: not-allowed; opacity: .48; }
button.primary, .action-primary {
  border-color: var(--blue);
  color: #fff;
  background: var(--blue);
}
button.primary:hover:not(:disabled), .action-primary:hover:not(:disabled) {
  color: #fff;
  background: var(--blue-dark);
}
.danger { color: var(--danger); }
.hidden { display: none !important; }
input, textarea, select {
  width: 100%;
  padding: 10px 11px;
  border: 1px solid #e0e6ef;
  border-radius: 4px;
  color: var(--ink);
  background: #f7f9fc;
}
input:focus, textarea:focus, select:focus {
  outline: 2px solid rgba(18, 174, 210, .18);
  border-color: var(--blue);
}
textarea { min-height: 64px; resize: vertical; }
.field-label {
  display: block;
  margin: 12px 0 6px;
  color: var(--muted);
  font-size: 12px;
}
.text-button {
  padding: 4px 7px;
  border: 0;
  color: var(--muted);
  background: transparent;
}
.full { width: 100%; margin-top: 12px; }

.appbar {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  z-index: 20;
  height: 66px;
  display: flex;
  align-items: center;
  gap: 25px;
  padding: 0 22px;
  background: rgba(255,255,255,.98);
  box-shadow: 0 1px 4px rgba(30,45,62,.12);
}
.brand-compact {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 195px;
}
h1 { margin: 0; color: var(--navy); font-size: 22px; }
.version {
  margin: 0;
  padding: 3px 7px;
  border-radius: 12px;
  color: var(--blue-dark);
  background: #e8f8fc;
  font-size: 11px;
}
.primary-actions { display: flex; gap: 10px; }
.save-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
}
.map-stage {
  position: relative;
  height: 100%;
  padding-top: 66px;
}
#map {
  position: relative !important;
  z-index: 0 !important;
  width: 100%;
  height: 100%;
  background: #dfe8db;
  touch-action: none;
  overscroll-behavior: none;
}
#map *,
#map .tdt-map-pane,
#map .tdt-tile-pane,
#map .tdt-overlay-pane,
#map .tdt-marker-pane {
  touch-action: none;
}
.app.drawing-active #map, .app.drawing-active #map * { cursor: crosshair !important; }

.land-browser {
  position: absolute;
  z-index: 12;
  top: 82px;
  left: 18px;
  width: 326px;
  max-height: calc(100% - 145px);
  overflow: hidden;
  border-radius: 10px;
  background: var(--panel);
  box-shadow: var(--shadow);
}
.browser-tabs {
  display: flex;
  padding: 10px;
  border-bottom: 1px solid var(--line);
}
.browser-tabs .tab {
  flex: 1;
  border: 0;
  padding: 8px 6px;
  color: var(--muted);
  background: transparent;
  font-weight: 700;
}
.browser-tabs .tab.active { color: var(--blue-dark); background: #e8f8fc; }
.badge {
  display: inline-block;
  min-width: 22px;
  margin-left: 4px;
  padding: 2px 6px;
  border-radius: 12px;
  color: #fff;
  background: #f45a63;
  font-size: 11px;
}
.fold-button { margin-left: 8px; border: 0; color: var(--blue); }
.browser-content {
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: calc(100vh - 160px);
  padding: 10px;
}
.filter-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}
.filter-row select { flex: 1; font-size: 12px; }
.toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}
.toggle input { width: 15px; height: 15px; margin: 0; accent-color: var(--blue); }
.compact { flex-shrink: 0; }
.batch-category {
  flex-shrink: 0;
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f8fbfe;
}
.batch-category-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.batch-category-title span {
  color: var(--blue-dark);
  font-weight: 800;
}
.batch-category-body {
  padding: 0 8px 8px;
}
.batch-category-hint {
  margin: 0 0 6px;
  color: #7d8999;
  font-size: 11px;
  line-height: 1.35;
}
.batch-category-tools {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 6px;
}
.batch-category-row {
  display: flex;
  gap: 6px;
}
.batch-category-row input:first-child { width: 82px; flex-shrink: 0; }
.batch-category-row input:last-child { flex: 1; min-width: 0; }
.batch-category button {
  width: 100%;
  margin-top: 6px;
  padding: 7px 10px;
  color: #fff;
  background: var(--blue);
}
.batch-category-tools button {
  margin-top: 0;
  color: var(--blue-dark);
  background: #e8f8fc;
}
.land-browser.collapsed .browser-content { display: none; }
.land-card-list {
  flex: 1;
  min-height: 120px;
  max-height: none;
  overflow-y: auto;
  margin: 10px 0 0;
  padding: 0 0 72px;
  list-style: none;
}
.land-card-list.empty::before, .result-list.empty::before {
  content: attr(data-empty);
  display: block;
  padding: 20px 8px;
  color: #a0abba;
  font-size: 12px;
  text-align: center;
}
.land-card {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 8px;
  padding: 8px;
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 1px 5px rgba(36, 54, 75, .06);
}
.land-card.selected { background: #ecf9fc; outline: 1px solid rgba(18,174,210,.35); }
.batch-check {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  flex-shrink: 0;
}
.batch-check input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--blue);
}
.land-thumb {
  width: 72px;
  height: 60px;
  flex-shrink: 0;
  border-radius: 4px;
  background: #f1f4f8;
}
.land-card-body { flex: 1; min-width: 0; }
.result-title {
  display: block;
  overflow: hidden;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.result-meta { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; }
.category-pill {
  display: inline-block;
  max-width: 115px;
  overflow: hidden;
  padding: 2px 5px;
  border-radius: 3px;
  color: #037e9d;
  background: #d9f5fb;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card-actions { display: flex; justify-content: flex-end; margin-top: 4px; }
.card-actions button { padding: 2px 5px; border: 0; color: var(--blue-dark); font-size: 11px; }

.detail-drawer {
  position: absolute;
  z-index: 12;
  top: 82px;
  right: 18px;
  width: 302px;
  padding: 14px;
  border-radius: 10px;
  background: var(--panel);
  box-shadow: var(--shadow);
}
.drawer-head { display: flex; justify-content: space-between; align-items: center; }
.drawer-head h2, .area-form h3 { margin: 0; color: var(--navy); font-size: 16px; }
.detail-card { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.detail-name { display: inline-block; margin: 0; font-size: 16px; font-weight: 700; }
.detail-measure { float: right; margin: 0; color: var(--blue-dark); font-weight: 700; }
.detail-category { clear: both; display: inline-block; margin: 14px 0 4px; padding: 3px 7px; border-radius: 3px; color: #037e9d; background: #d9f5fb; font-size: 12px; }
.detail-address { clear: both; margin: 10px 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.detail-actions { display: flex; gap: 9px; margin-top: 16px; }
.detail-actions button { flex: 1; }

.map-controls {
  position: absolute;
  z-index: 13;
  right: 18px;
  bottom: 58px;
}
.map-controls summary {
  padding: 10px 15px;
  border-radius: 6px;
  color: #fff;
  background: rgba(32, 59, 82, .8);
  cursor: pointer;
  list-style: none;
}
.map-controls summary::-webkit-details-marker { display: none; }
.map-controls-panel {
  position: absolute;
  right: 0;
  bottom: 48px;
  width: 310px;
  padding: 14px;
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}
.basemap-tools { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }
.basemap { padding: 8px 3px; font-size: 12px; }
.basemap.active { border-color: var(--blue); color: var(--blue-dark); background: #e8f8fc; }
.file-input { padding: 7px; font-size: 12px; }
.hint { margin: 8px 0 0; color: var(--muted); font-size: 11px; line-height: 1.5; }

.floating-form {
  position: absolute;
  z-index: 14;
  right: 18px;
  top: 82px;
  width: 302px;
  padding: 15px;
  border-radius: 10px;
  background: var(--panel);
  box-shadow: var(--shadow);
}
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.section-head h2 { margin: 0; font-size: 16px; }
.coordinate { margin: 9px 0; color: var(--blue-dark); font-size: 12px; }
.result-list { margin: 10px 0 0; padding: 0; list-style: none; }
.browser-content .result-list { max-height: calc(100vh - 240px); overflow-y: auto; }
.result-item { display: flex; justify-content: space-between; gap: 5px; padding: 7px 0; border-top: 1px dashed var(--line); }
.item-buttons { display: flex; gap: 3px; }
.item-buttons button { padding: 3px 5px; font-size: 11px; }


.editor-screen {
  position: absolute;
  z-index: 15;
  inset: 66px 0 0;
  pointer-events: none;
}
.editor-header {
  position: absolute;
  z-index: 5;
  top: 0;
  right: 0;
  left: 0;
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,.98);
  pointer-events: auto;
}
.editor-header h2 { margin: 0; font-size: 17px; }
.editor-header button { position: absolute; left: 22px; }
.editor-guide {
  position: absolute;
  left: 20px;
  bottom: 56px;
  max-width: 420px;
  padding: 10px 14px;
  border-radius: 5px;
  color: #fff;
  background: rgba(32,59,82,.82);
  font-size: 12px;
  pointer-events: auto;
}
.editor-guide p { margin: 4px 0 0; }
.area-form {
  position: absolute;
  top: 68px;
  right: 18px;
  width: 345px;
  padding: 16px;
  border-radius: 9px;
  background: var(--panel);
  box-shadow: var(--shadow);
  pointer-events: auto;
}
.create-actions, .edit-actions { display: grid; grid-template-columns: repeat(2, 1fr); gap: 7px; margin-top: 12px; }
.mobile-draw-actions {
  position: absolute;
  z-index: 5;
  right: 20px;
  bottom: 56px;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 9px;
  background: rgba(255,255,255,.96);
  box-shadow: var(--shadow);
  pointer-events: auto;
  max-width: calc(100% - 16px);
}
.mobile-draw-actions p { flex: 1; min-width: 0; margin: 0; color: var(--muted); font-size: 12px; line-height: 1.4; overflow-wrap: anywhere; }
.mobile-draw-buttons { display: flex; gap: 8px; flex-shrink: 0; }
.mobile-draw-actions button { min-width: 82px; flex-shrink: 0; }
.mobile-draw-layer {
  position: absolute;
  z-index: 2;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}
.mobile-draw-line,
.mobile-draw-preview,
.mobile-draw-polygon {
  fill: none;
  stroke: #fff;
  stroke-width: 1.25;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 5 6;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,.25));
}
.mobile-draw-polygon { fill: rgba(255,255,255,.05); }
.mobile-draw-preview { opacity: .95; }
.mobile-draw-node {
  fill: #fff;
  stroke: #12aed2;
  stroke-width: 1.5;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,.25));
}
.mobile-center-crosshair {
  position: absolute;
  z-index: 3;
  left: var(--mobile-crosshair-left, 50%);
  top: var(--mobile-crosshair-top, 50%);
  width: 30px;
  height: 30px;
  transform: translate(-50%, -50%);
  pointer-events: none;
  display: none;
}
.app.mobile-crosshair-drawing .mobile-center-crosshair:not(.hidden) { display: block; }
.mobile-center-crosshair::before,
.mobile-center-crosshair::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  background: #12aed2;
  box-shadow: 0 0 0 1px rgba(255,255,255,.88), 0 1px 2px rgba(0,0,0,.2);
  transform: translate(-50%, -50%);
}
.mobile-center-crosshair::before { width: 24px; height: 1px; }
.mobile-center-crosshair::after { width: 1px; height: 24px; }
.mobile-center-crosshair span,
.mobile-center-crosshair::marker { display: none; }
.mobile-center-crosshair {
  border: 0;
  border-radius: 50%;
  box-shadow: none;
}
.app.area-creating .editor-guide strong::after { content: " - 新建"; }
.app.editor-active .appbar, .app.editor-active .land-browser, .app.editor-active .detail-drawer,
.app.editor-active .map-controls, .app.editor-active .marker-form, .app.editor-active .statusbar,
.app.editor-active .map-location { display: none !important; }
.app.editor-active .map-stage { padding-top: 0; }
.app.editor-active .editor-screen { inset: 0; }

.map-placeholder {
  position: absolute;
  inset: 66px 0 0;
  display: grid;
  place-items: center;
  background: #edf3f6;
}
.app.editor-active .map-placeholder { inset: 0; }
.placeholder-card { padding: 30px; border-radius: 12px; background: #fff; text-align: center; box-shadow: var(--shadow); }
.placeholder-card h2 { color: var(--navy); }
.pin { display: inline-block; width: 25px; height: 25px; border-radius: 50% 50% 50% 0; background: var(--blue); transform: rotate(-45deg); }
.statusbar {
  position: absolute;
  z-index: 10;
  right: 18px;
  bottom: 14px;
  left: 365px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 13px;
  border-radius: 6px;
  color: #fff;
  background: rgba(32,59,82,.74);
  font-size: 12px;
  pointer-events: none;
}
.map-location {
  position: absolute;
  z-index: 10;
  left: 365px;
  top: 80px;
  max-width: 300px;
  margin: 0;
  padding: 7px 10px;
  border-radius: 5px;
  color: #fff;
  background: rgba(32,59,82,.72);
  font-size: 11px;
}
.location-detail.warning { color: #fff2c7; }
.area-popup { min-width: 145px; line-height: 1.65; color: #fff; }
.area-popup .popup-edit-button { margin-top: 6px; padding: 3px 4px; border: 0; color: #4de1ff; background: transparent; font-size: 12px; }
.tdt-label { border: 0 !important; background: transparent !important; box-shadow: none !important; color: #fff !important; font-weight: 700 !important; text-shadow: 0 1px 3px #1b3246; }
.map-area-label {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  line-height: 1.18;
  white-space: nowrap;
  pointer-events: none;
}
.map-area-label strong { font-size: 13px; }
.map-area-label span { font-size: 11px; font-weight: 600; }
.map-area-label.isolation-label strong { font-size: 10px; }
.map-area-label.isolation-label span { font-size: 8px; }
.tdt-infowindow, .tdt-infowindow-content-wrapper, .tdt-infowindow-content, .tdt-popup-content {
  border: 0 !important;
  color: #fff !important;
  background: rgba(32,59,82,.82) !important;
}
.tdt-infowindow-tip { opacity: .8; }

@media (max-width: 760px) {
  .appbar {
    height: auto;
    min-height: 96px;
    flex-wrap: wrap;
    gap: 7px;
    padding: 8px 10px;
  }
  .brand-compact { min-width: 0; width: 100%; padding-right: 175px; }
  .brand-compact .version { display: none; }
  h1 { font-size: 19px; }
  .primary-actions { order: 3; width: 100%; display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; }
  .primary-actions button { padding: 9px 3px; font-size: 12px; }
  .save-indicator { position: absolute; top: 13px; right: 10px; max-width: 168px; overflow: hidden; color: var(--muted); font-size: 11px; white-space: nowrap; text-overflow: ellipsis; }
  .save-indicator button { display: none; }
  .map-stage { padding-top: 96px; }
  .map-placeholder { inset: 96px 0 0; }
  .land-browser {
    top: auto;
    right: 8px;
    bottom: 8px;
    left: 8px;
    width: auto;
    max-height: 53vh;
  }
  .land-browser.collapsed { bottom: 60px; }
  .land-card-list { max-height: none; padding-bottom: 82px; }
  .browser-content .result-list { max-height: calc(53vh - 78px); overflow-y: auto; }
  .detail-drawer {
    top: auto;
    right: 8px;
    bottom: 8px;
    left: 8px;
    width: auto;
  }
  .map-controls { right: 9px; bottom: 67px; }
  .land-browser:not(.collapsed) ~ .map-controls { display: none; }
  .land-browser.collapsed ~ .map-controls { bottom: 124px; }
  .map-controls-panel { width: min(320px, calc(100vw - 18px)); }
  .floating-form {
    top: auto;
    right: 8px;
    bottom: 8px;
    left: 8px;
    width: auto;
    max-height: 62vh;
    overflow-y: auto;
  }
}

.app.mobile-device .appbar {
  height: auto;
  min-height: 96px;
  flex-wrap: wrap;
  gap: 7px;
  padding: 8px 10px;
}
.app.mobile-device .brand-compact { min-width: 0; width: 100%; padding-right: 175px; }
.app.mobile-device .brand-compact .version { display: none; }
.app.mobile-device h1 { font-size: 19px; }
.app.mobile-device .primary-actions { order: 3; width: 100%; display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; }
.app.mobile-device .primary-actions button { padding: 9px 3px; font-size: 12px; }
.app.mobile-device .save-indicator { position: absolute; top: 13px; right: 10px; max-width: 168px; overflow: hidden; color: var(--muted); font-size: 11px; white-space: nowrap; text-overflow: ellipsis; }
.app.mobile-device .save-indicator button { display: none; }
.app.mobile-device .map-stage { padding-top: 96px; }
.app.mobile-device .map-placeholder { inset: 96px 0 0; }
.app.mobile-device .land-browser {
  top: auto;
  right: 8px;
  bottom: 8px;
  left: 8px;
  width: auto;
  max-height: 53vh;
}
.app.mobile-device .land-browser.collapsed { bottom: 60px; }
.app.mobile-device .land-card-list { max-height: none; padding-bottom: 82px; }
.app.mobile-device .browser-content .result-list { max-height: calc(53vh - 78px); overflow-y: auto; }
.app.mobile-device .detail-drawer {
  top: auto;
  right: 8px;
  bottom: 8px;
  left: 8px;
  width: auto;
}
.app.mobile-device .map-controls { right: 9px; bottom: 67px; }
.app.mobile-device .land-browser:not(.collapsed) ~ .map-controls { display: none; }
.app.mobile-device .land-browser.collapsed ~ .map-controls { bottom: 124px; }
.app.mobile-device .map-controls-panel { width: min(320px, calc(100vw - 18px)); }
.app.mobile-device .floating-form {
  top: auto;
  right: 8px;
  bottom: 8px;
  left: 8px;
  width: auto;
  max-height: 62vh;
  overflow-y: auto;
}
.app.mobile-device .statusbar { right: 8px; bottom: 4px; left: 8px; font-size: 10px; padding: 5px 8px; }
.app.mobile-device .map-location { top: 104px; left: 8px; font-size: 10px; }
.app.mobile-device.detail-open .land-browser,
.app.mobile-device.detail-open .map-controls,
.app.mobile-device.detail-open .statusbar,
.app.mobile-device.detail-open .map-location { display: none; }
.app.mobile-device .editor-screen { inset: 0; }
.app.mobile-device .editor-header { height: 48px; }
.app.mobile-device .editor-header button { left: 8px; }
.app.mobile-device .area-form {
  top: auto;
  right: 8px;
  bottom: 8px;
  left: 8px;
  width: auto;
  max-height: 47vh;
  overflow-y: auto;
}
.app.mobile-device .editor-guide { left: 8px; right: 8px; bottom: calc(47vh + 20px); max-width: none; }
.app.mobile-device .mobile-draw-actions:not(.hidden) {
  right: 8px;
  bottom: 10px;
  left: 8px;
  display: flex;
  justify-content: space-between;
}
.app.mobile-device .mobile-draw-buttons button { padding: 9px 8px; font-size: 12px; }
.app.mobile-device.mobile-crosshair-drawing .area-form { display: none; }
.app.mobile-device .editor-screen .editor-guide { display: none; }
.app.mobile-device.editor-active .map-stage { padding-top: 0; }
.app.mobile-device.editor-active .map-placeholder { inset: 0; }
.app.mobile-device.boundary-editing .area-form {
  top: auto;
  bottom: 8px;
  max-height: none;
  padding: 8px;
  overflow: visible;
}
.app.mobile-device.boundary-editing .area-form h3,
.app.mobile-device.boundary-editing .area-form .field-label,
.app.mobile-device.boundary-editing .area-form input,
.app.mobile-device.boundary-editing .area-form .coordinate,
.app.mobile-device.boundary-editing #save-area-info,
.app.mobile-device.boundary-editing #edit-vertices,
.app.mobile-device.boundary-editing #focus-area { display: none; }
.app.mobile-device.boundary-editing .edit-actions {
  display: flex;
  flex-wrap: wrap;
  margin-top: 0;
}
.app.mobile-device.boundary-editing .edit-actions button { flex: 1 1 calc(33.33% - 7px); padding: 8px 4px; font-size: 12px; }
