:root {
  --bg: #0f151d;
  --panel: #161f2b;
  --line: rgba(255, 255, 255, 0.08);
  --txt: #dbe4ee;
  --sub: #8ea0b5;
  --accent: #4da3ff;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", sans-serif;
  background: var(--bg); color: var(--txt);
  display: flex; flex-direction: column; overflow: hidden;
}

/* ---- 顶栏 ---- */
header {
  height: 52px; flex: 0 0 auto;
  display: flex; align-items: center; gap: 16px;
  padding: 0 16px; background: var(--panel);
  border-bottom: 1px solid var(--line); z-index: 1200;
}
.brand { font-size: 16px; font-weight: 600; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.brand small { color: var(--sub); font-weight: 400; font-size: 12px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #2f9e44; box-shadow: 0 0 8px #2f9e44; }
.status { color: var(--sub); font-size: 12.5px; flex: 1; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status.warn { color: #f0a35e; }
.toggle { font-size: 13px; color: var(--sub); display: flex; align-items: center; gap: 5px; cursor: pointer; white-space: nowrap; }
.btn {
  background: var(--accent); color: #fff; border: 0; border-radius: 6px;
  padding: 7px 14px; font-size: 13px; cursor: pointer; white-space: nowrap;
}
.btn:hover { filter: brightness(1.1); }
.visit-mini { font-size: 12px; color: var(--sub); white-space: nowrap; }

/* ---- 地图 ---- */
#map { flex: 1; background: var(--bg); z-index: 1; }
.leaflet-container { background: var(--bg); font: inherit; }
.leaflet-bar a { background: var(--panel) !important; color: var(--txt) !important; border-color: var(--line) !important; }
.leaflet-bar a:hover { background: #1d2938 !important; }
.leaflet-control-attribution { background: rgba(15, 21, 29, 0.75) !important; color: #5b6b7d !important; font-size: 10px !important; }
.leaflet-control-attribution a { color: #5b6b7d !important; }
.leaflet-tooltip {
  background: rgba(22, 31, 43, 0.95); border: 1px solid var(--line); color: var(--txt);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45); border-radius: 8px; padding: 8px 10px; font-size: 12.5px; line-height: 1.55;
}
.leaflet-tooltip-top::before { border-top-color: rgba(22, 31, 43, 0.95); }

/* ---- 覆盖层 ---- */
.overlay { position: absolute; z-index: 1000; }
#breadcrumb {
  top: 64px; left: 52px; max-width: 55%;
  display: flex; align-items: center; flex-wrap: wrap; gap: 2px;
  background: rgba(22, 31, 43, 0.88); border: 1px solid var(--line);
  border-radius: 8px; padding: 6px 12px; font-size: 13px; backdrop-filter: blur(4px);
}
#breadcrumb .crumb { cursor: pointer; color: var(--accent); padding: 1px 3px; border-radius: 4px; }
#breadcrumb .crumb:hover { background: rgba(77, 163, 255, 0.15); }
#breadcrumb .crumb.current { color: var(--txt); cursor: default; }
#breadcrumb .sep { color: #4a5a6c; margin: 0 4px; }

#legend {
  left: 12px; bottom: 26px;
  background: rgba(22, 31, 43, 0.92); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 14px; font-size: 12px; backdrop-filter: blur(4px);
}
.lg-title { font-weight: 600; margin-bottom: 6px; font-size: 12.5px; }
.lg-row { display: flex; align-items: center; gap: 7px; color: var(--sub); line-height: 1.7; }
.lg-row i { width: 22px; height: 11px; border-radius: 3px; flex: 0 0 auto; }

.banner {
  position: absolute; top: 64px; left: 50%; transform: translateX(-50%);
  z-index: 1100; max-width: 78%;
  background: rgba(150, 74, 32, 0.92); border: 1px solid rgba(255, 160, 90, 0.5);
  border-radius: 10px; padding: 10px 16px; font-size: 13px; line-height: 1.6;
  backdrop-filter: blur(4px);
}

/* ---- 历史面板 ---- */
#panel {
  position: absolute; top: 64px; right: 12px; bottom: 26px; width: 380px; max-width: calc(100vw - 24px);
  z-index: 1050; overflow-y: auto;
  background: rgba(22, 31, 43, 0.96); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px 16px; backdrop-filter: blur(6px); box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}
#panel.hidden { display: none; }
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
#pName { font-size: 17px; font-weight: 700; }
.icon-btn {
  background: transparent; border: 1px solid var(--line); color: var(--sub);
  border-radius: 6px; width: 26px; height: 26px; cursor: pointer; font-size: 13px;
}
.icon-btn:hover { color: var(--txt); }
.meta { color: var(--sub); font-size: 12px; margin-top: 3px; }
#pCurrent { margin: 12px 0 4px; }
#pCurrent .big { font-size: 38px; font-weight: 700; line-height: 1; }
#pCurrent .unit { font-size: 13px; color: var(--sub); margin-left: 6px; }
#pCurrent .chip {
  display: inline-block; margin-left: 10px; padding: 2px 9px; border-radius: 999px;
  font-size: 12px; vertical-align: 6px;
}
#pMsg { margin: 8px 0; }
.chart-wrap { position: relative; height: 190px; margin: 6px 0 10px; }
.tbl-wrap { max-height: 240px; overflow-y: auto; border-top: 1px solid var(--line); }
#pTable { width: 100%; border-collapse: collapse; font-size: 12.5px; }
#pTable th {
  position: sticky; top: 0; background: var(--panel); text-align: left;
  padding: 6px 8px; color: var(--sub); font-weight: 500; border-bottom: 1px solid var(--line);
}
#pTable td { padding: 6px 8px; border-bottom: 1px solid var(--line); }
#panel .foot { margin-top: 10px; line-height: 1.6; }

/* ---- 提示 ---- */
.toast {
  position: absolute; top: 64px; left: 50%; transform: translateX(-50%);
  z-index: 1150; background: rgba(22, 31, 43, 0.95); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 16px; font-size: 13px; backdrop-filter: blur(4px);
}
.toast.err { border-color: rgba(226, 73, 59, 0.6); color: #ff9b90; }

/* ---- 触屏详情卡片 ---- */
.sheet {
  position: absolute; left: 12px; right: 12px; bottom: 12px;
  z-index: 1160; max-width: 420px; margin: 0 auto;
  background: rgba(22, 31, 43, 0.97); border: 1px solid var(--line); border-radius: 14px;
  padding: 14px 16px; backdrop-filter: blur(6px); box-shadow: 0 -6px 30px rgba(0, 0, 0, 0.5);
  animation: sheetUp 0.18s ease-out;
}
.sheet.hidden { display: none; }
.sheet-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
#sName { font-size: 16px; font-weight: 700; }
#sBody { margin: 10px 0 12px; }
#sBody .big { font-size: 30px; font-weight: 700; line-height: 1; }
#sBody .unit { font-size: 12px; color: var(--sub); margin-left: 5px; }
#sBody .chip { display: inline-block; margin-left: 8px; padding: 2px 8px; border-radius: 999px; font-size: 11px; vertical-align: 5px; }
.sheet-actions { display: flex; gap: 10px; }
.sheet-actions .btn { flex: 1; padding: 11px; font-size: 14px; }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--txt); }
.btn.ghost:hover { border-color: var(--accent); }
@keyframes sheetUp { from { transform: translateY(14px); opacity: 0; } to { transform: none; opacity: 1; } }

#breadcrumb .crumb.back {
  color: var(--txt); font-weight: 600;
  background: rgba(77, 163, 255, 0.16); border-radius: 6px;
}
#breadcrumb .crumb.back:hover { background: rgba(77, 163, 255, 0.3); }

/* ---- 拟合标注 ---- */
.chip.fit { border: 1px dashed rgba(124, 192, 255, 0.65); color: #7cc0ff; background: rgba(124, 192, 255, 0.08); margin-left: 6px; }
.lg-note { margin-top: 7px; color: #8ea0b5; font-size: 10.5px; max-width: 185px; line-height: 1.55; border-top: 1px solid var(--line); padding-top: 6px; }

/* ---- 真实数据等待遮罩 ---- */
.gate { position: fixed; inset: 0; z-index: 2000; background: rgba(9, 14, 21, 0.9); display: flex; align-items: center; justify-content: center; }
.gate.hidden { display: none; }
.gate-box { text-align: center; color: var(--txt); }
.gate-spin { width: 42px; height: 42px; margin: 0 auto 14px; border: 3px solid rgba(77, 163, 255, 0.25); border-top-color: var(--accent); border-radius: 50%; animation: gspin 1s linear infinite; }
@keyframes gspin { to { transform: rotate(360deg); } }

/* ---- 时光回放 ---- */
.rp-row { display: flex; gap: 8px; margin: 10px 0; align-items: center; flex-wrap: wrap; color: var(--sub); font-size: 12px; }
.rp-row label { display: flex; gap: 4px; align-items: center; }
.rp-row input[type="date"], .rp-row select {
  background: var(--panel); color: var(--txt); border: 1px solid var(--line);
  border-radius: 6px; padding: 4px 6px; font-size: 12px;
}
#rpSlider { width: 100%; accent-color: var(--accent); }
.rp-hour { font-size: 20px; font-weight: 700; text-align: center; margin: 6px 0; color: var(--accent); font-variant-numeric: tabular-nums; }
.rp-note { line-height: 1.6; }
.loading {
  position: absolute; top: 64px; left: 50%; transform: translateX(-50%);
  z-index: 1140; background: rgba(22, 31, 43, 0.9); border: 1px solid var(--line);
  border-radius: 999px; padding: 6px 18px; font-size: 12.5px; color: var(--sub);
}
.hidden { display: none; }

@media (max-width: 720px) {
  .brand small, .toggle, .visit-mini { display: none; }
  #panel { left: 12px; right: 12px; top: auto; bottom: 12px; width: auto; max-height: 68vh; }
  .icon-btn { width: 36px; height: 36px; font-size: 15px; }
  #breadcrumb { left: 52px; right: 12px; max-width: none; font-size: 13.5px; padding: 8px 10px; }
  #breadcrumb .crumb { padding: 6px 8px; }
  #breadcrumb .crumb.back { padding: 6px 10px; }
  #legend { transform: scale(0.9); transform-origin: left bottom; }
}

/* ---- 微信防拦截指引遮罩 ---- */
.wx-guide {
  position: fixed; inset: 0; z-index: 3000;
  background: rgba(10, 15, 23, 0.88); backdrop-filter: blur(8px);
  display: flex; flex-direction: column; align-items: flex-end;
  padding: 16px 20px;
}
.wx-guide.hidden { display: none; }
.wx-arrow {
  font-size: 38px; color: var(--accent); font-weight: bold;
  margin-right: 8px; margin-bottom: 4px;
  animation: wxBounce 1s infinite alternate ease-in-out;
}
@keyframes wxBounce {
  from { transform: translateY(0); }
  to { transform: translateY(-8px); }
}
.wx-box {
  background: var(--panel); border: 1px solid rgba(77, 163, 255, 0.35);
  border-radius: 14px; padding: 18px 20px; max-width: 320px; width: 100%;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6); margin-top: 4px;
}
.wx-title {
  font-size: 16px; font-weight: 700; color: #fff; margin-bottom: 8px;
}
.wx-desc {
  font-size: 13px; color: var(--sub); line-height: 1.6; margin-bottom: 16px;
}
.wx-btn {
  width: 100%; padding: 10px; border-radius: 8px; border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06); color: var(--sub); font-size: 13px; cursor: pointer;
}
.wx-btn:hover { color: var(--txt); background: rgba(255, 255, 255, 0.12); }
