* { box-sizing: border-box; }

html, body, #app {
  height: 100%;
  margin: 0;
  font-family: "Microsoft YaHei", -apple-system, "Segoe UI", "PingFang SC", sans-serif;
  color: #1f2430;
  background: #f4f6fa;
}

.layout {
  display: grid;
  grid-template-columns: 380px 1fr;
  height: 100%;
}

/* ---------- 左侧面板 ---------- */
.panel {
  background: #fff;
  border-right: 1px solid #e6e9f0;
  padding: 26px 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
}

.panel header h1 {
  margin: 0 0 6px;
  font-size: 21px;
  letter-spacing: 0.5px;
}

.panel header .sub {
  margin: 0;
  font-size: 12px;
  color: #8b93a7;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  font-size: 13px;
  color: #5b6478;
}

.field input {
  height: 42px;
  padding: 0 12px;
  border: 1px solid #dfe3ec;
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field input:focus {
  border-color: #1552c9;
  box-shadow: 0 0 0 3px rgba(21, 82, 201, 0.12);
}

.actions {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}

button {
  height: 42px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: 0.15s;
  flex: 1;
}

button.primary {
  background: #1552c9;
  color: #fff;
}

button.primary:hover:not(:disabled) { background: #1245aa; }

button.ghost {
  background: #fff;
  color: #1552c9;
  border-color: #c9d6f2;
}

button.ghost:hover:not(:disabled) { background: #f2f6ff; }

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.error {
  margin: 0;
  padding: 9px 12px;
  background: #fff2f2;
  border: 1px solid #ffd6d6;
  color: #c22a2a;
  border-radius: 8px;
  font-size: 13px;
}

/* ---------- 结果 ---------- */
.result {
  border: 1px solid #e6e9f0;
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #fbfcff;
}

.row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 13px;
  color: #5b6478;
}

.row b { color: #1f2430; font-size: 13.5px; }
.row b.good { color: #1a8a4a; }

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 4px 0;
}

.stats div {
  background: #fff;
  border: 1px solid #e9edf6;
  border-radius: 10px;
  padding: 10px 8px;
  text-align: center;
}

.stats b {
  display: block;
  font-size: 19px;
  color: #1552c9;
}

.stats span {
  font-size: 11.5px;
  color: #8b93a7;
}

.link-box { display: flex; flex-direction: column; gap: 6px; }

.link-title { font-size: 12px; color: #8b93a7; }

.link-box textarea {
  width: 100%;
  resize: vertical;
  border: 1px solid #e2e7f1;
  border-radius: 8px;
  padding: 8px;
  font-size: 11.5px;
  line-height: 1.5;
  color: #37405a;
  background: #fff;
  font-family: ui-monospace, Consolas, monospace;
  word-break: break-all;
}

details summary {
  cursor: pointer;
  font-size: 12.5px;
  color: #5b6478;
}

.residual {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  max-height: 190px;
  overflow: auto;
  font-size: 12px;
}

.residual li {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 0;
  border-bottom: 1px dashed #eef1f7;
  color: #37405a;
}

.residual em {
  margin-left: auto;
  color: #98a1b5;
  font-style: normal;
  white-space: nowrap;
}

.residual i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex: none;
}

i.c1 { background: #db3838; }
i.c2 { background: #2e5cdc; }
i.c3 { background: #e88c20; }
i.c4 { background: #9646c8; }
i.c0 { background: #9aa3b5; }

footer {
  margin-top: auto;
  font-size: 11px;
  color: #a4adbf;
  line-height: 1.6;
}

/* ---------- 地图 ---------- */
.map-wrap { position: relative; }

.map { width: 100%; height: 100%; }

.map-fallback {
  position: absolute;
  inset: 0;
  background: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 30px;
  text-align: center;
  font-size: 13px;
  color: #5b6478;
}

.map-fallback img {
  max-width: 92%;
  max-height: 74%;
  border: 1px solid #e6e9f0;
  border-radius: 10px;
}

.map-hint {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(31, 36, 48, 0.82);
  color: #fff;
  font-size: 12px;
  padding: 7px 14px;
  border-radius: 20px;
}

/* ---------- 弹窗 ---------- */
.mask {
  position: fixed;
  inset: 0;
  background: rgba(17, 22, 34, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
}

.dialog {
  width: 380px;
  background: #fff;
  border-radius: 14px;
  padding: 22px 24px 18px;
  box-shadow: 0 18px 50px rgba(15, 25, 50, 0.25);
}

.dialog h3 {
  margin: 0 0 10px;
  font-size: 17px;
}

.dialog p {
  margin: 0 0 18px;
  font-size: 13.5px;
  line-height: 1.7;
  color: #5b6478;
}

.dialog button { width: 100%; }

/* ---------- 轻提示 ---------- */
.toast {
  position: fixed;
  top: 22px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(24, 30, 44, 0.9);
  color: #fff;
  font-size: 13px;
  padding: 9px 18px;
  border-radius: 20px;
  z-index: 1000;
}

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .panel { max-height: 54vh; }
}

/* ---------- 摄像头开关与图例 ---------- */
.switch {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #37405a;
  background: #f7f9fd;
  border: 1px solid #e6e9f0;
  border-radius: 8px;
  padding: 9px 12px;
  cursor: pointer;
}

.switch input { width: 15px; height: 15px; accent-color: #1552c9; cursor: pointer; }

.legend {
  display: grid;
  gap: 6px;
  font-size: 12px;
  color: #5b6478;
}

.legend-item { display: flex; align-items: center; gap: 7px; }
.legend-item b { color: #37405a; font-weight: 600; }
.legend-item span { color: #8b93a7; }

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
  flex: none;
  border: 1px solid #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.12);
}

.legend-item i.c1, .dot.c1 { background: #db3838; }
.legend-item i.c2, .dot.c2 { background: #2e5cdc; }
.legend-item i.c3, .dot.c3 { background: #e88c20; }
.legend-item i.c4, .dot.c4 { background: #9646c8; }
.legend-item i.c0, .dot.c0 { background: #9aa3b5; }

/* ---------- 摄像头弹窗 ---------- */
.cam-pop {
  min-width: 210px;
  max-width: 280px;
  font-family: "Microsoft YaHei", sans-serif;
  padding: 2px 0;
}

.cam-head {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  font-size: 13.5px;
  font-weight: 700;
  color: #1f2430;
  line-height: 1.45;
  margin-bottom: 8px;
}

.cam-head .dot { margin-top: 5px; }

.cam-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 12.5px;
  padding: 3px 0;
  border-bottom: 1px dashed #eef1f7;
}

.cam-row span { color: #8b93a7; flex: none; }
.cam-row b { color: #37405a; font-weight: 600; text-align: right; }

.cam-note {
  margin-top: 8px;
  font-size: 11.5px;
  line-height: 1.55;
  color: #8b93a7;
}

/* Leaflet 弹窗样式微调 */
.leaflet-popup-content { margin: 12px 14px; }
.leaflet-container { font-family: "Microsoft YaHei", sans-serif; }

/* ---------- 风险点位高亮动画 ---------- */
.pulse-marker {
  position: relative;
  width: 0;
  height: 0;
  --c: #db3838;
  pointer-events: none;
}

.pulse-marker .core {
  position: absolute;
  left: -7px;
  top: -7px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--c);
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--c) 40%, transparent),
              0 0 14px var(--c);
  animation: core-throb 1.2s ease-in-out infinite;
  z-index: 2;
}

.pulse-marker .ring {
  position: absolute;
  left: -9px;
  top: -9px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--c);
  opacity: 0;
  animation: pulse-ring 1.8s cubic-bezier(0.2, 0.6, 0.3, 1) infinite;
}

.pulse-marker .r2 { animation-delay: 0.6s; }
.pulse-marker .r3 { animation-delay: 1.2s; }

@keyframes pulse-ring {
  0%   { transform: scale(0.6); opacity: 0.95; }
  70%  { opacity: 0.25; }
  100% { transform: scale(2.6); opacity: 0; }
}

@keyframes core-throb {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.35); }
}

/* Leaflet 的 divIcon 容器不要默认白框 */
.pulse-icon {
  background: none !important;
  border: none !important;
}

/* 风险点位列表的选中态 */
.residual li.active {
  background: #eef4ff;
  border-radius: 6px;
  padding-left: 6px;
  padding-right: 6px;
  color: #1552c9;
  font-weight: 600;
}

.residual li { cursor: pointer; }
.residual li:hover { background: #f6f9ff; border-radius: 6px; }

/* 风险点位：文案与数字标红 */
.stats .stat-risk b,
.stats .stat-risk span {
  color: #d93025;
}
.stats .stat-risk { border-color: #f6d5d1; background: #fff7f6; }

/* ---------- 三个复制按钮 ---------- */
.copy-group {
  display: grid;
  gap: 8px;
}

.copy-title {
  font-size: 12px;
  color: #8b93a7;
  margin-bottom: -2px;
}

.copy-btn {
  height: 38px;
  font-size: 13px;
  flex: none;
}

/* ---------- 安卓手机导航（直接拉起） ---------- */
.launch-btn {
  height: 40px;
  font-size: 13.5px;
  font-weight: 600;
  border-radius: 8px;
  border: 1px solid #1552c9;
  background: linear-gradient(180deg, #eaf1ff 0%, #dfe9ff 100%);
  color: #1552c9;
  cursor: pointer;
  transition: 0.15s;
  flex: none;
}

.launch-btn:hover:not(:disabled) {
  background: linear-gradient(180deg, #dfe9ff 0%, #d3e0ff 100%);
}

.launch-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
