/* 追景地图 WeatherScout —— 浅色主题样式 */
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  display: flex; flex-direction: column; overflow: hidden;
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: #f5f7fa; color: #2c3a47; font-size: 14px;
}
button { font-family: inherit; cursor: pointer; }
.muted { color: #8a929b; font-size: 12px; }

/* ---------- 顶栏 ---------- */
#topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 8px 14px; background: #fff; border-bottom: 1px solid #e3e8ee; flex-shrink: 0;
}
.brand { font-weight: 700; font-size: 17px; white-space: nowrap; }
.brand .sub { font-size: 11px; color: #8a929b; font-weight: 400; }
.date-axis { flex: 1; display: flex; gap: 4px; overflow-x: auto; padding: 2px; }
.date-axis::-webkit-scrollbar { height: 4px; }
.day {
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  min-width: 46px; padding: 4px 6px; border: 1px solid #e3e8ee; border-radius: 8px;
  background: #fff; flex-shrink: 0;
}
.day .dl { font-weight: 600; font-size: 12px; }
.day .dw { font-size: 10px; color: #8a929b; }
.day .dot { width: 6px; height: 6px; border-radius: 50%; }
.day .dd { font-size: 9px; color: #b3bac2; }
.day.on { background: #eaf2fb; border-color: #2b6cb0; }
.day.on .dl { color: #2b6cb0; }
.actions { display: flex; gap: 8px; align-items: center; white-space: nowrap; flex-wrap: wrap; justify-content: flex-end; }
.btn {
  padding: 6px 12px; border: 1px solid #d7dee6; background: #fff; border-radius: 8px;
  position: relative; font-size: 13px;
}
.btn:hover { border-color: #2b6cb0; color: #2b6cb0; }
.btn:disabled { opacity: 0.5; cursor: wait; }
.badge {
  margin-left: 4px; background: #d64550; color: #fff; border-radius: 8px;
  font-size: 10px; padding: 1px 5px;
}
.badge:empty { display: none; }
.origin-label select, select#sortBy {
  padding: 5px 8px; border: 1px solid #d7dee6; border-radius: 8px; background: #fff; font-size: 13px;
}

/* ---------- 筛选条 ---------- */
#filterBar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  padding: 8px 14px; background: #fff; border-bottom: 1px solid #e3e8ee; flex-shrink: 0;
}
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  padding: 6px 12px; border: 1px solid #d7dee6; border-radius: 16px; background: #fff; font-size: 13px;
  transition: all .15s;
}
.chip:hover { border-color: #2b6cb0; }
.chip.on { background: #2b6cb0; border-color: #2b6cb0; color: #fff; }
.chip.sm { padding: 3px 9px; font-size: 12px; }
.chip.primary { background: #2b6cb0; border-color: #2b6cb0; color: #fff; }
.chip.link { text-decoration: none; color: inherit; display: inline-block; }
.chip.link:hover { color: #2b6cb0; }
.filter-more { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.thr-label { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.thr-label input[type=range] { width: 130px; accent-color: #2b6cb0; }
#ringBox summary { font-size: 13px; cursor: pointer; color: #4a5568; }
#ringChecks { display: flex; flex-wrap: wrap; gap: 4px 12px; padding: 6px 0; max-width: 420px; }
.ring-item { font-size: 12px; display: inline-flex; align-items: center; gap: 4px; }

/* ---------- 移动端 tabs ---------- */
#mobileTabs { display: none; }

/* ---------- 主体 ---------- */
#main { flex: 1; display: flex; min-height: 0; }
#mapWrap { flex: 1; position: relative; min-width: 0; }
#map { position: absolute; inset: 0; background: #e8ecef; }
#legend {
  position: absolute; left: 10px; bottom: 14px; z-index: 500;
  background: rgba(255,255,255,.94); border: 1px solid #e3e8ee; border-radius: 10px;
  padding: 8px 10px; font-size: 11px; box-shadow: 0 2px 8px rgba(0,0,0,.08); max-width: 300px;
}
.lg-row { display: flex; gap: 8px; align-items: baseline; }
.lg-row.small { color: #8a929b; }
.lg-bar { flex: 1; height: 8px; border-radius: 4px; background: linear-gradient(90deg,#c9ccd1 30%,#f6c445 50%,#f59e3b 70%,#ef6c2e 85%,#d64550 100%); min-width: 120px; }

#candPanel {
  width: 380px; flex-shrink: 0; background: #fff; border-left: 1px solid #e3e8ee;
  display: flex; flex-direction: column; min-height: 0;
}
.cand-head { padding: 10px 14px; border-bottom: 1px solid #eef1f5; display: flex; gap: 10px; align-items: baseline; flex-shrink: 0; }
#candList { overflow-y: auto; flex: 1; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.card {
  border: 1px solid #e3e8ee; border-radius: 12px; padding: 10px 12px; background: #fff;
  cursor: pointer; transition: box-shadow .15s;
}
.card:hover { box-shadow: 0 3px 12px rgba(43,108,176,.15); border-color: #9dc1e8; }
.card-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.card-name { font-weight: 600; font-size: 14px; }
.card-p { color: #fff; font-weight: 700; border-radius: 8px; padding: 2px 8px; font-size: 13px; }
.card-sub { font-size: 12px; color: #5a6472; margin-top: 3px; }
.card-sub b { color: #2c3a47; }
.mini { font-size: 11px; color: #8a929b; background: #f1f4f8; border-radius: 4px; padding: 1px 5px; margin-right: 4px; }
.card-tags { margin-top: 5px; display: flex; flex-wrap: wrap; gap: 4px; }
.card-tags span { font-size: 10px; background: #eef4fb; color: #2b6cb0; padding: 1px 7px; border-radius: 8px; }
.empty { padding: 24px 16px; text-align: center; color: #5a6472; }
.empty .chip { margin: 4px; }

/* ---------- 页脚 ---------- */
#foot {
  padding: 5px 14px; font-size: 11px; color: #8a929b; background: #fff;
  border-top: 1px solid #e3e8ee; display: flex; justify-content: space-between; gap: 10px; flex-shrink: 0;
}
.linklike { border: none; background: none; color: #2b6cb0; font-size: 11px; padding: 0; text-decoration: underline; }

/* ---------- 详情抽屉 ---------- */
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 600px; max-width: 95vw;
  background: #fff; box-shadow: -6px 0 24px rgba(0,0,0,.15); z-index: 1100;
  transform: translateX(105%); visibility: hidden;
  transition: transform .25s, visibility .25s; overflow-y: auto;
}
.drawer.open { transform: translateX(0); visibility: visible; }
.dr-head { display: flex; justify-content: space-between; gap: 10px; padding: 16px 18px 6px; }
.dr-title { font-size: 18px; font-weight: 700; }
.dr-sub { font-size: 12px; color: #8a929b; margin-top: 4px; }
.icon-btn { border: none; background: none; font-size: 16px; color: #8a929b; padding: 4px 8px; }
.icon-btn:hover { color: #d64550; }
.dr-table { width: calc(100% - 36px); margin: 8px 18px; border-collapse: collapse; font-size: 12.5px; }
.dr-table th, .dr-table td { padding: 6px 8px; border-bottom: 1px solid #eef1f5; text-align: left; }
.dr-table th { color: #8a929b; font-weight: 500; font-size: 11px; }
.dr-table tr[data-key] { cursor: pointer; }
.dr-table tr.on { background: #eaf2fb; }
.pbar { height: 8px; background: #eef1f5; border-radius: 4px; overflow: hidden; }
.pbar i { display: block; height: 100%; border-radius: 4px; }
.dr-note { font-size: 11px; color: #a5adb5; margin: 0 18px; }
.dr-sec { padding: 6px 18px; }
.dr-sec h4 { margin: 10px 0 6px; font-size: 13px; color: #4a5568; }
.dr-actions { padding: 10px 18px 24px; display: flex; flex-wrap: wrap; gap: 8px; }
.hr-legend { font-size: 11px; color: #5a6472; margin-bottom: 4px; }
.hr-legend i { display: inline-block; width: 10px; height: 8px; border-radius: 2px; margin: 0 3px 0 8px; vertical-align: middle; }
.hr-table { border-collapse: collapse; font-size: 10px; margin-top: 4px; min-width: 100%; }
.hr-table th, .hr-table td { border: 1px solid #e8edf3; padding: 2px 5px; text-align: center; white-space: nowrap; }
.hr-table th { background: #f2f6fb; color: #4a5568; font-weight: 600; font-size: 10px; }
.hr-table td { color: #2c3a47; font-variant-numeric: tabular-nums; }

/* ---------- 模态 ---------- */
.modal {
  position: fixed; inset: 0; background: rgba(30,40,52,.45); z-index: 1300;
  display: none; align-items: center; justify-content: center; padding: 20px;
}
.modal.open { display: flex; }
.modal-box {
  background: #fff; border-radius: 14px; padding: 18px 22px; max-width: 560px; width: 100%;
  max-height: 84vh; overflow-y: auto;
}
.modal-box.wide { max-width: 780px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.modal-box h3 { margin: 14px 0 6px; font-size: 15px; }
.modal-box h4 { margin: 14px 0 6px; font-size: 13px; }
.modal-box p, .modal-box li { font-size: 12.5px; line-height: 1.7; color: #4a5568; }
.modal-box ul { padding-left: 18px; }
.about-tbl th, .about-tbl td { font-size: 11.5px; vertical-align: top; }
.sub-item { border: 1px solid #e3e8ee; border-radius: 10px; padding: 8px 12px; margin-bottom: 8px; }
.sub-top { display: flex; justify-content: space-between; font-size: 13px; }
.sub-hit { font-size: 12px; color: #5a6472; margin-top: 4px; }
#subForm label { display: block; font-size: 12px; color: #4a5568; margin: 8px 0 4px; }
#subForm .row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
#subForm input[type=number], #subForm select {
  padding: 4px 8px; border: 1px solid #d7dee6; border-radius: 6px; font-size: 13px; width: 80px;
}
#subForm select { width: auto; }
#subSave { margin-top: 10px; }

/* ---------- Toast ---------- */
#toast {
  position: fixed; bottom: 46px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: #2c3a47; color: #fff; padding: 9px 18px; border-radius: 18px; font-size: 13px;
  opacity: 0; transition: all .3s; z-index: 1500; pointer-events: none; max-width: 80vw;
}
#toast.show { opacity: 0.96; transform: translateX(-50%) translateY(0); }

/* ---------- Leaflet 微调 ---------- */
.leaflet-tooltip { font-size: 12px; }
.leaflet-control-attribution { font-size: 10px; background: rgba(255,255,255,.8); }

/* ---------- 移动端 ---------- */
@media (max-width: 960px) {
  #topbar { flex-wrap: wrap; gap: 8px; }
  .date-axis { order: 3; width: 100%; }
  #main { flex-direction: column; }
  #mapWrap { min-height: 58vh; }
  #candPanel { width: auto; border-left: none; border-top: 1px solid #e3e8ee; }
  body:not([data-view="list"]) #candPanel { display: none; }
  body[data-view="list"] #mapWrap { display: none; }
  #mobileTabs { display: flex; gap: 8px; padding: 8px 14px 0; background: #fff; border-bottom: 1px solid #e3e8ee; flex-shrink: 0; }
  #mobileTabs button { flex: 1; padding: 8px; border: none; background: none; font-size: 14px; color: #8a929b; border-bottom: 2px solid transparent; }
  #mobileTabs button.on { color: #2b6cb0; border-bottom-color: #2b6cb0; font-weight: 600; }
  body { overflow: auto; }
  #main { min-height: 0; }
  #drawer { width: 100vw; }
}

/* ---------- ?mode=h5 强制手机布局（桌面预览用，规则同上） ---------- */
body.force-h5 #topbar { flex-wrap: wrap; gap: 8px; }
body.force-h5 .date-axis { order: 3; width: 100%; }
body.force-h5 #main { flex-direction: column; }
body.force-h5 #mapWrap { min-height: 58vh; }
body.force-h5 #candPanel { width: auto; border-left: none; border-top: 1px solid #e3e8ee; }
body.force-h5:not([data-view="list"]) #candPanel { display: none; }
body.force-h5[data-view="list"] #mapWrap { display: none; }
body.force-h5 #mobileTabs { display: flex; gap: 8px; padding: 8px 14px 0; background: #fff; border-bottom: 1px solid #e3e8ee; flex-shrink: 0; }
body.force-h5 #mobileTabs button { flex: 1; padding: 8px; border: none; background: none; font-size: 14px; color: #8a929b; border-bottom: 2px solid transparent; }
body.force-h5 #mobileTabs button.on { color: #2b6cb0; border-bottom-color: #2b6cb0; font-weight: 600; }
body.force-h5 { overflow: auto; }
body.force-h5 #main { min-height: 0; }
body.force-h5 #drawer { width: 100vw; }
