/* ============ 手机端竖屏适配 · 云上党数字地图 ============ */
:root {
  --bg: #f4fbf7;
  --panel: rgba(255,255,255,.96);
  --line: #d5eadf;
  --text: #173a2c;
  --muted: #668678;
  --green: #1f9d64;
  --green2: #50c878;
  --blue: #3fa7d6;
  --gold: #f3b63f;
  --coral: #f47b64;
  --shadow: 0 4px 16px rgba(41,112,79,.10);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --tab-h: 56px;
  --sheet-peek: 180px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
a { color: inherit; text-decoration: none; }

/* ============ 底部导航栏 ============ */
.tab-bar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  height: calc(var(--tab-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  display: flex; background: #fff;
  border-top: 1px solid var(--line);
  box-shadow: 0 -2px 10px rgba(0,0,0,.06);
}
.tab-bar a {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 2px;
  font-size: 11px; font-weight: 600; color: var(--muted);
  transition: color .2s;
}
.tab-bar a.active { color: var(--green); }
.tab-bar a svg { width: 22px; height: 22px; }

/* ============ 入口页 ============ */
.entry-page {
  height: 100%; overflow-y: auto;
  background:
    radial-gradient(circle at 20% 15%, rgba(31,157,100,.12), transparent 50%),
    radial-gradient(circle at 80% 85%, rgba(63,167,214,.08), transparent 50%),
    var(--bg);
}
.entry-wrap {
  min-height: 100%; padding: 20px 16px calc(var(--tab-h) + var(--safe-bottom) + 20px);
  display: flex; flex-direction: column; gap: 16px;
}
.entry-header {
  text-align: center; padding: 32px 16px 20px;
}
.entry-header h1 {
  font-size: 26px; color: var(--text); line-height: 1.2; margin-bottom: 8px;
}
.entry-header h1 span { color: var(--green); }
.entry-header p { color: var(--muted); font-size: 13px; line-height: 1.5; }
.entry-stats {
  display: flex; justify-content: center; gap: 24px;
  padding: 14px 0; margin-top: 8px;
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
.entry-stats div { text-align: center; }
.entry-stats b { display: block; font-size: 22px; color: var(--green); font-weight: 900; }
.entry-stats span { font-size: 12px; color: var(--muted); }
.entry-cards { display: flex; flex-direction: column; gap: 10px; }
.entry-card {
  display: flex; align-items: center; gap: 14px;
  padding: 16px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 14px;
  cursor: pointer; transition: all .2s;
  box-shadow: var(--shadow);
}
.entry-card:active { transform: scale(.98); background: #f3fff8; }
.entry-card.disabled { opacity: .55; }
.entry-icon {
  width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center; flex-shrink: 0;
  color: #fff; font-size: 18px; font-weight: 900;
  background: var(--green);
  box-shadow: 0 3px 8px rgba(31,157,100,.25);
}
.entry-card-body { flex: 1; min-width: 0; }
.entry-card-body h3 { font-size: 16px; color: var(--text); margin-bottom: 2px; }
.entry-card-body p { font-size: 12px; color: var(--muted); line-height: 1.35; }
.entry-arrow { color: var(--muted); font-size: 20px; flex-shrink: 0; }
.entry-badge {
  display: inline-block; margin-top: 3px; padding: 1px 6px;
  border-radius: 6px; font-size: 10px; font-weight: 700;
}
.entry-badge.real { background: #e8f7ee; color: var(--green); border: 1px solid #b8e6cc; }
.entry-badge.dev { background: #fff3cd; color: #856404; border: 1px solid #ffe07a; }

/* ============ 地图页 ============ */
.map-page { height: 100%; overflow: hidden; background: #e8f6ef; }
.map-shell {
  height: 100%;
  padding-top: var(--safe-top);
  display: flex; flex-direction: column;
}

/* 顶部搜索栏 */
.map-topbar {
  position: relative; z-index: 20;
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  background: rgba(255,255,255,.94);
  border-bottom: 1px solid var(--line);
}
.map-topbar .search-input {
  flex: 1; height: 38px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 19px;
  font-size: 14px; background: #f8fffb; color: var(--text);
  outline: none;
}
.map-topbar .search-input:focus { border-color: var(--green); background: #fff; }
.map-topbar .btn-icon {
  width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--green); color: #fff; border: none;
  font-size: 16px; cursor: pointer; flex-shrink: 0;
}

/* 地图容器 */
.map-container {
  flex: 1; position: relative; min-height: 0;
}
#map { width: 100%; height: 100%; }

/* 地图浮动按钮 */
.map-fab {
  position: absolute; z-index: 15;
  width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center;
  background: #fff; border: 1px solid var(--line);
  box-shadow: 0 3px 12px rgba(0,0,0,.12);
  cursor: pointer; color: var(--green); font-size: 18px;
}
.map-fab:active { background: #f3fff8; }
.fab-center { right: 12px; bottom: calc(var(--tab-h) + var(--safe-bottom) + var(--sheet-peek) + 12px); }
.fab-locate { right: 12px; bottom: calc(var(--tab-h) + var(--safe-bottom) + var(--sheet-peek) + 64px); }

/* 状态提示 */
.map-status {
  position: absolute; left: 10px; top: 10px; z-index: 15;
  max-width: 85%; padding: 7px 10px;
  background: rgba(255,255,255,.92); border: 1px solid var(--line);
  border-radius: 8px; font-size: 12px; color: #315849;
  box-shadow: var(--shadow); line-height: 1.4;
}

/* ============ 底部抽屉 (Bottom Sheet) ============ */
.bottom-sheet {
  position: fixed;
  left: 0; right: 0;
  bottom: calc(var(--tab-h) + var(--safe-bottom));
  z-index: 30;
  background: #fff;
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -4px 20px rgba(0,0,0,.10);
  transition: max-height .3s cubic-bezier(.4,0,.2,1);
  display: flex; flex-direction: column;
  max-height: 26vh;
  overflow: hidden;
}
.bottom-sheet.expanded {
  max-height: 72vh;
}
.sheet-handle {
  display: flex; justify-content: center; padding: 8px 0 2px;
  cursor: grab; flex-shrink: 0;
}
.sheet-handle::after {
  content: ""; width: 36px; height: 4px;
  background: #d0d8d4; border-radius: 2px;
}
.sheet-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 2px 16px 8px;
  border-bottom: 1px solid #eef3f0;
  flex-shrink: 0;
}
.sheet-header h2 { font-size: 15px; color: var(--text); font-weight: 700; }
.sheet-header .count { font-size: 12px; color: var(--muted); }
.sheet-body {
  flex: 1; overflow-y: auto; overscroll-behavior: contain;
  padding: 0;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}

/* 隐藏高德地图水印/版权穿透 */
#map .amap-logo, #map .amap-copyright { display: none !important; }

/* 点位列表项 */
.sheet-item {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 16px;
  border-bottom: 1px solid #f2f6f3;
  cursor: pointer; transition: background .15s;
}
.sheet-item:active { background: #f3fff8; }
.sheet-item.active { background: #edf9f2; border-left: 3px solid var(--green); }
.sheet-item .dot-grade {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
}
.dot-grade.g1 { background: var(--coral); }
.dot-grade.g2 { background: var(--gold); }
.dot-grade.g3 { background: var(--green); }
.sheet-item-info { flex: 1; min-width: 0; }
.sheet-item-info strong {
  display: block; font-size: 14px; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sheet-item-info span {
  display: block; font-size: 12px; color: var(--muted); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sheet-item .age-badge {
  flex-shrink: 0; font-size: 12px; font-weight: 700;
  color: var(--green); white-space: nowrap;
}

/* ============ 详情弹窗（底部抽屉模式） ============ */
.detail-view {
  padding: 0 16px 16px;
  flex: 1; overflow-y: auto; overscroll-behavior: contain;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}
.detail-back {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 14px; color: var(--green); font-weight: 600;
  padding: 10px 0; cursor: pointer; border: none; background: none;
}
.detail-title {
  font-size: 18px; font-weight: 800; color: #0f5b3a;
  line-height: 1.3; margin-bottom: 4px;
}
.detail-subtitle { font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.detail-tags {
  display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px;
}
.detail-tags .tag {
  padding: 3px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 700;
}
.tag-grade-1 { background: #ffe6df; color: #8a3c2c; }
.tag-grade-2 { background: #fff3d6; color: #7a5311; }
.tag-grade-3 { background: #edf8f2; color: #11653f; }
.tag-growth { background: #e8f1f8; color: #1f4e79; }
.tag-env { background: #f0eef9; color: #4a3d8a; }

/* 详情数据网格 */
.detail-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  margin-bottom: 12px;
}
.detail-cell {
  padding: 10px; background: #f8fffb;
  border: 1px solid #e0efe7; border-radius: 8px;
}
.detail-cell.full { grid-column: span 2; }
.detail-cell b {
  display: block; font-size: 11px; color: var(--muted);
  font-weight: 700; margin-bottom: 3px; letter-spacing: .3px;
}
.detail-cell span { font-size: 13px; color: var(--text); line-height: 1.4; word-break: break-word; }

/* 古树故事 */
.detail-story {
  margin: 10px 0; padding: 12px;
  background: #fffaf0; border-left: 3px solid var(--gold);
  border-radius: 0 8px 8px 0;
}
.detail-story b { display: block; font-size: 12px; color: #7a5311; margin-bottom: 4px; }
.detail-story p { font-size: 13px; color: #604817; line-height: 1.6; margin: 0; }

/* 详情操作按钮 */
.detail-actions {
  display: flex; gap: 8px; margin-top: 14px; padding-bottom: calc(var(--tab-h) + var(--safe-bottom));
}
.detail-actions a {
  flex: 1; text-align: center; padding: 12px;
  border-radius: 10px; font-weight: 700; font-size: 14px;
}
.detail-actions .btn-primary { background: var(--green); color: #fff; }
.detail-actions .btn-secondary {
  background: #f2fff7; color: #11653f; border: 1px solid #bfe6d0;
}

/* ============ 数据大屏页 ============ */
.dash-page {
  height: 100%; overflow-y: auto;
  background:
    radial-gradient(circle at 10% 5%, rgba(31,157,100,.08), transparent 40%),
    var(--bg);
  padding-bottom: calc(var(--tab-h) + var(--safe-bottom) + 16px);
}
.dash-topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(var(--safe-top) + 12px) 16px 12px;
  background: rgba(244,251,247,.94);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.dash-topbar h1 { font-size: 17px; color: var(--text); }
.dash-topbar a {
  font-size: 13px; color: var(--green); font-weight: 600;
}
.dash-content { padding: 12px 14px; display: flex; flex-direction: column; gap: 12px; }

/* KPI 卡片 */
.dash-kpis {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
}
.dash-kpi {
  padding: 14px 12px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow);
}
.dash-kpi .kpi-label { font-size: 12px; color: var(--muted); font-weight: 600; }
.dash-kpi .kpi-value {
  margin-top: 6px; font-size: 24px; font-weight: 900;
  color: #147447; line-height: 1;
}
.dash-kpi .kpi-unit { font-size: 12px; color: var(--muted); margin-left: 2px; }

/* 图表卡片 */
.dash-card {
  padding: 14px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow);
}
.dash-card h2 {
  font-size: 15px; color: #144d35; margin-bottom: 12px;
  padding-bottom: 8px; border-bottom: 1px dashed #e2efe8;
}

/* 条形图 */
.m-bar-list { display: flex; flex-direction: column; gap: 10px; }
.m-bar-row {
  display: grid; grid-template-columns: 72px 1fr 36px;
  align-items: center; gap: 8px; font-size: 13px;
}
.m-bar-name {
  color: #315849; font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.m-bar-track {
  height: 10px; background: #eef6f1;
  border: 1px solid #e0efe7; border-radius: 999px; overflow: hidden;
}
.m-bar-fill {
  height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--green2), var(--blue));
}
.m-bar-value { text-align: right; color: #127449; font-weight: 900; font-size: 13px; }

/* 环形图 */
.m-donuts {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
}
.m-donut-card {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 12px 8px;
  background: linear-gradient(180deg, #fff, #f5fbf7);
  border: 1px solid #e0efe7; border-radius: 8px;
}
.m-donut {
  width: 80px; height: 80px; border-radius: 50%;
  position: relative;
}
.m-donut::after {
  content: ""; position: absolute; inset: 18px;
  background: #fff; border-radius: 50%;
  box-shadow: inset 0 0 0 1px #e2efe8;
}
.m-legend { width: 100%; font-size: 12px; color: #517565; }
.m-legend-row {
  display: flex; justify-content: space-between; padding: 2px 0;
}
.m-legend-row strong { color: #164f37; }

/* 详情卡（大屏页） */
.dash-detail {
  background: linear-gradient(120deg, #fffaf0, #fff);
  border-color: #f1dca7;
}
.dash-detail h2 { color: #7a5311; border-bottom-color: #f1dca7; }
.dash-detail-title {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 10px;
}
.dash-detail-title strong { font-size: 18px; color: #7a5311; }
.dash-detail-title span { font-size: 28px; font-weight: 900; color: #c78008; }
.dash-detail-title small { font-size: 13px; color: var(--muted); }
.dash-facts {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 8px;
}
.dash-fact {
  padding: 8px; background: rgba(255,255,255,.72);
  border: 1px solid rgba(241,220,167,.8); border-radius: 6px;
}
.dash-fact.full { grid-column: span 2; }
.dash-fact b { display: block; font-size: 11px; color: #80601f; margin-bottom: 2px; }
.dash-fact span { font-size: 12.5px; color: #3b3322; line-height: 1.35; }
.dash-story {
  margin-top: 8px; font-size: 13px; color: #675632; line-height: 1.6;
}

/* 点位分布迷你地图 */
.mini-map {
  position: relative; height: 200px;
  border: 1px solid #cce9da; border-radius: 8px;
  background:
    linear-gradient(115deg, rgba(80,200,120,.10), transparent 48%),
    linear-gradient(0deg, rgba(31,157,100,.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(31,157,100,.05) 1px, transparent 1px),
    #fbfffd;
  background-size: auto, 28px 28px, 28px 28px;
  overflow: hidden;
}
.mini-map::before {
  content: ""; position: absolute; inset: 10% 12% 11% 10%;
  border: 2px solid rgba(31,157,100,.2);
  border-radius: 48% 52% 44% 56%; transform: rotate(-12deg);
  background: rgba(223,247,234,.3);
}
.mini-dot {
  position: absolute; width: 9px; height: 9px;
  border-radius: 50%; background: var(--gold);
  border: 2px solid #fff;
  box-shadow: 0 0 0 3px rgba(243,182,63,.15), 0 2px 6px rgba(0,0,0,.15);
  cursor: pointer; z-index: 2;
  transform: translate(-50%, -50%);
}
.mini-dot.g1 { background: var(--coral); }
.mini-dot.g3 { background: var(--green); }
.mini-dot.active {
  width: 14px; height: 14px; z-index: 5;
  box-shadow: 0 0 0 4px rgba(243,182,63,.25), 0 4px 10px rgba(0,0,0,.2);
}

/* 页脚 */
.dash-footer {
  display: flex; justify-content: space-between;
  padding: 12px 16px; font-size: 11px; color: var(--muted);
}

/* ============ 高德地图 Marker 样式 ============ */
.tree-marker {
  position: relative; width: 26px; height: 26px;
  border: 2px solid #fff; border-radius: 50% 50% 50% 6px;
  transform: rotate(-45deg);
  color: #fff; background: var(--green);
  box-shadow: 0 6px 16px rgba(24,72,50,.3);
  cursor: pointer;
}
.tree-marker.grade-1 { background: var(--coral); }
.tree-marker.grade-2 { background: var(--gold); }
.tree-marker.grade-3 { background: var(--green); }
.tree-marker.is-active {
  width: 34px; height: 34px; z-index: 5;
  box-shadow: 0 0 0 6px rgba(244,123,100,.2), 0 10px 20px rgba(24,72,50,.35);
}
.tree-marker span {
  position: absolute; inset: 4px;
  display: grid; place-items: center;
  transform: rotate(45deg);
  font-size: 11px; font-weight: 900;
}

/* ============ Fallback 点位图 ============ */
.fallback-map {
  position: absolute; inset: 0;
  display: none;
  background:
    linear-gradient(115deg, rgba(80,200,120,.10), transparent 48%),
    linear-gradient(0deg, rgba(31,157,100,.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(31,157,100,.05) 1px, transparent 1px),
    #fbfffd;
  background-size: auto, 32px 32px, 32px 32px;
}
.fallback-map.visible { display: block; }
.fallback-region {
  position: absolute; inset: 13% 16% 14% 12%;
  border: 2px solid rgba(31,157,100,.2);
  border-radius: 48% 52% 44% 56%; transform: rotate(-12deg);
  background: rgba(223,247,234,.35);
}
.fallback-dot {
  position: absolute; width: 10px; height: 10px;
  border-radius: 50%; background: var(--gold);
  border: 2px solid #fff;
  box-shadow: 0 0 0 4px rgba(243,182,63,.15), 0 4px 8px rgba(0,0,0,.15);
  cursor: pointer; z-index: 2;
  transform: translate(-50%, -50%);
}
.fallback-dot.g1 { background: var(--coral); }
.fallback-dot.g3 { background: var(--green); }
.fallback-dot.active {
  width: 16px; height: 16px; z-index: 5;
  box-shadow: 0 0 0 5px rgba(243,182,63,.25), 0 6px 12px rgba(0,0,0,.2);
}
