:root {
  --bg: #eef3f1;
  --panel: #ffffff;
  --text: #17211d;
  --muted: #66736f;
  --line: #dbe5e1;
  --green: #18a558;
  --green-strong: #0a7d3b;
  --amber: #a66a00;
  --shadow: 0 16px 36px rgba(21, 42, 34, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(340px, 420px) 1fr;
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: 100vh;
  padding: 18px;
  overflow: auto;
  background: #f8fbfa;
  border-right: 1px solid var(--line);
}

.brand,
.panel,
.list-section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(21, 42, 34, 0.06);
}

.brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px;
}

.brand h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.2;
}

.brand p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.count {
  display: grid;
  min-width: 42px;
  height: 42px;
  place-items: center;
  color: #fff;
  background: var(--green);
  border-radius: 50%;
  font-weight: 700;
}

.panel,
.list-section {
  padding: 16px;
}

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

.section-title h2 {
  margin: 0;
  font-size: 16px;
}

.section-title span {
  color: var(--muted);
  font-size: 13px;
}

.section-title button,
.item-main,
.item-actions button,
.admin-bar button,
.danger-btn,
.primary-btn {
  cursor: pointer;
}

.section-title button,
.item-actions button,
.admin-bar button,
.danger-btn,
.primary-btn {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 8px 12px;
}

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

[hidden] {
  display: none !important;
}

.primary-btn {
  width: 100%;
  border-color: var(--green);
  background: var(--green);
  color: #fff;
  font-weight: 700;
}

.danger-btn {
  width: 100%;
  border-color: #d64545;
  background: #fff;
  color: #b42323;
  font-weight: 700;
}

.form-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.field,
.upload-form {
  display: grid;
  gap: 8px;
}

.upload-form,
.panel {
  gap: 12px;
}

.field + .field,
.field-grid + .field,
.field + .primary-btn {
  margin-top: 12px;
}

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

.field input,
.field select {
  min-width: 0;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 10px 11px;
  color: var(--text);
  outline: none;
}

.field select {
  min-height: 42px;
}

.field select[multiple] {
  padding: 7px;
}

.field input:focus,
.field select:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(24, 165, 88, 0.16);
}

#loginMessage {
  color: var(--amber);
}

.form-message {
  min-height: 18px;
  color: var(--amber);
  font-size: 13px;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 120px;
  gap: 10px;
}

.list-section {
  display: flex;
  flex-direction: column;
  min-height: 220px;
  flex: 0 0 auto;
}

.airspace-list {
  display: grid;
  align-content: start;
  gap: 10px;
  padding-right: 2px;
}

.airspace-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.item-main {
  display: grid;
  gap: 4px;
  width: 100%;
  border: 0;
  background: transparent;
  padding: 12px;
  text-align: left;
}

.item-name {
  overflow-wrap: anywhere;
  font-size: 15px;
}

.item-meta {
  color: var(--muted);
  font-size: 12px;
}

.item-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 12px 12px;
}

.item-actions {
  display: flex;
  justify-content: flex-end;
  padding: 0 12px 12px;
}

.item-actions button {
  padding: 6px 10px;
  font-size: 13px;
}

.tag {
  max-width: 100%;
  overflow-wrap: anywhere;
  border-radius: 999px;
  padding: 4px 8px;
  background: #e8f5ee;
  color: var(--green-strong);
  font-size: 12px;
}

.tag.warn {
  background: #fff4db;
  color: var(--amber);
}

.empty {
  padding: 22px 12px;
  color: var(--muted);
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
}

.map-wrap {
  position: relative;
  min-height: 100vh;
}

.admin-bar {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 600;
}

.admin-bar button {
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

#map {
  width: 100%;
  height: 100vh;
  background: #dce8e4;
}

.map-notice {
  position: absolute;
  left: 16px;
  bottom: 16px;
  z-index: 500;
  max-width: min(520px, calc(100% - 32px));
  padding: 10px 12px;
  border: 1px solid rgba(23, 33, 29, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--muted);
  box-shadow: var(--shadow);
  font-size: 13px;
}

.map-legend {
  position: absolute;
  right: 16px;
  bottom: 16px;
  z-index: 500;
  display: grid;
  gap: 7px;
  padding: 10px 12px;
  border: 1px solid rgba(23, 33, 29, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--text);
  box-shadow: var(--shadow);
  font-size: 13px;
}

.map-legend span {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.map-legend i {
  width: 18px;
  height: 12px;
  border-radius: 2px;
  display: inline-block;
}

.legend-pass {
  border: 2px solid #0a9d4b;
  background: rgba(37, 194, 102, 0.28);
}

.legend-candy {
  border: 2px solid #d11f1f;
  background: rgba(239, 68, 68, 0.24);
}

.legend-rect {
  border: 1px solid #8d969e;
  background: rgba(207, 212, 217, 0.36);
}

.leaflet-popup-content {
  min-width: 220px;
}

.popup-title {
  margin: 0 0 8px;
  font-size: 16px;
}

.popup-row {
  display: grid;
  grid-template-columns: 74px 1fr;
  gap: 8px;
  margin: 5px 0;
  color: var(--text);
}

.popup-row span:first-child {
  color: var(--muted);
}

.dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(12, 24, 18, 0.36);
}

.dialog {
  width: min(520px, 100%);
  max-height: calc(100vh - 36px);
  overflow: auto;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    max-height: none;
    overflow: visible;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .map-wrap,
  #map {
    min-height: 58vh;
    height: 58vh;
  }
}

@media (max-width: 460px) {
  .sidebar {
    padding: 12px;
  }

  .field-grid {
    grid-template-columns: 1fr;
  }
}
