/* 多地点路线规划系统 · 网页版样式 */
:root {
  --bg: #f2f4f8;
  --panel: #ffffff;
  --line: #e2e6ee;
  --text: #1f2430;
  --muted: #6b7280;
  --brand: #1f6feb;
  --brand-dark: #1552b8;
  --start: #16a34a;
  --end: #dc2626;
  --warn: #d97706;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC", "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
a { color: var(--brand); }

/* ---------- 顶栏 ---------- */
.top {
  background: linear-gradient(135deg, #1f2937, #374151);
  color: #fff;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.top h1 { font-size: 17px; margin: 0; font-weight: 600; letter-spacing: .3px; }
.top .sub { font-size: 12px; opacity: .72; }
.top .spacer { flex: 1; }
.top .chip {
  font-size: 12px; background: rgba(255, 255, 255, .14);
  border-radius: 999px; padding: 2px 10px;
}

/* ---------- 布局 ---------- */
.wrap {
  max-width: 1500px;
  margin: 0 auto;
  padding: 16px;
  display: grid;
  grid-template-columns: minmax(360px, 470px) minmax(320px, 1fr);
  gap: 16px;
  align-items: start;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 16px;
}
.panel h2 {
  font-size: 14px; margin: 0 0 10px; font-weight: 600;
  display: flex; align-items: center; gap: 8px;
}
.panel h2 .hint { font-size: 12px; font-weight: 400; color: var(--muted); }

/* ---------- 按钮 ---------- */
button {
  font-family: inherit; font-size: 13px; cursor: pointer;
  border: 1px solid var(--line); background: #fff; color: var(--text);
  border-radius: 8px; padding: 6px 10px; transition: .15s;
}
button:hover:not(:disabled) { border-color: #c3ccdb; background: #f7f9fc; }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary {
  background: var(--brand); border-color: var(--brand); color: #fff;
  font-weight: 600; padding: 12px 14px; font-size: 15px;
}
button.primary:hover:not(:disabled) { background: var(--brand-dark); border-color: var(--brand-dark); }
button.ghost { background: transparent; }
button.danger { color: var(--end); }
button.mini { padding: 3px 8px; font-size: 12px; }
button.icon { padding: 3px 8px; font-size: 13px; line-height: 1.1; }
.toolbar { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }

/* ---------- 地点列表 ---------- */
.places { list-style: none; margin: 0; padding: 0; }
.place-row {
  display: flex; align-items: center; gap: 6px;
  padding: 6px; border: 1px solid transparent; border-radius: 8px;
  position: relative;
}
.place-row:hover { background: #f7f9fc; }
.place-row.sel { background: #eef4ff; border-color: #c6dbff; }
.place-row .idx {
  width: 24px; text-align: right; color: var(--muted);
  font-size: 12px; font-variant-numeric: tabular-nums; flex: 0 0 24px;
}
.place-row .tag {
  flex: 0 0 auto; font-size: 11px; border-radius: 5px; padding: 1px 6px;
  border: 1px solid currentColor;
}
.tag.start { color: var(--start); }
.tag.mid { color: var(--muted); }
.tag.end { color: var(--end); }
.place-row input.name {
  flex: 1 1 auto; min-width: 60px; font-family: inherit; font-size: 13px;
  border: 1px solid transparent; background: transparent; border-radius: 6px;
  padding: 4px 6px; color: inherit;
}
.place-row input.name:hover { border-color: var(--line); }
.place-row input.name:focus { outline: none; border-color: var(--brand); background: #fff; }
.place-row .coord {
  flex: 0 0 auto; font-size: 11px; padding: 1px 6px; border-radius: 5px;
  border: 1px solid var(--line); color: var(--muted); cursor: pointer; white-space: nowrap;
}
.place-row .coord.ok { color: var(--start); border-color: #bfe6cb; background: #f0fdf4; }
.place-row .coord.miss { color: var(--warn); border-color: #f5dcae; background: #fffbeb; }
.empty { color: var(--muted); padding: 12px 6px; font-size: 13px; }

/* 地址输入实时联想下拉（键盘 ↑↓ 选择、Enter 确认、Esc 关闭，鼠标点击也可） */
.sug-box {
  position: absolute; z-index: 45; max-height: 330px; overflow-y: auto;
  background: #fff; border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 8px 22px rgba(17, 22, 31, .14); padding: 4px;
}
.sug-item {
  display: block; width: 100%; text-align: left; font: inherit; cursor: pointer;
  background: transparent; border: 0; border-radius: 6px; padding: 6px 8px;
  line-height: 1.35;
}
.sug-item.on, .sug-item:hover { background: #eef4ff; }
.sug-name { display: block; font-size: 13px; color: var(--text); font-weight: 600; }
.sug-meta {
  display: block; font-size: 11px; color: var(--muted);
  white-space: normal; overflow-wrap: anywhere; word-break: break-word;
}
.save-state { font-size: 12px; color: var(--muted); margin-top: 8px; min-height: 18px; }

/* ---------- 运行区 ---------- */
.status-line {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin: 0 0 10px; font-size: 13px; color: var(--muted);
}
.badge {
  font-size: 12px; border-radius: 999px; padding: 2px 10px;
  border: 1px solid var(--line); background: #f7f9fc;
}
.badge.running { color: #b45309; border-color: #f5dcae; background: #fffbeb; }
.badge.done { color: var(--start); border-color: #bfe6cb; background: #f0fdf4; }
.badge.error { color: var(--end); border-color: #f6c9c9; background: #fef2f2; }
.log {
  background: #11161f; color: #d4e0f0; border-radius: 8px;
  font-family: Consolas, "Courier New", monospace; font-size: 12.5px;
  line-height: 1.65; padding: 10px 12px; height: 240px; overflow: auto;
  white-space: pre-wrap; word-break: break-all; margin: 0;
}
.log:empty::before { content: "提交规划后，这里会实时显示执行进度…"; color: #6b7a90; }

/* ---------- 结果 ---------- */
.result { display: none; }
.result.show { display: block; }
.summary { display: flex; gap: 18px; flex-wrap: wrap; margin: 10px 0 12px; }
.summary .item { font-size: 13px; color: var(--muted); }
.summary .item b { display: block; font-size: 19px; color: var(--text); font-weight: 700; }
.map-preview {
  border: 1px solid var(--line); border-radius: 8px; overflow: hidden;
  background: #f7f9fc; max-height: 520px; display: flex; justify-content: center;
}
.map-preview img { max-width: 100%; max-height: 520px; display: block; cursor: zoom-in; }
table.seg { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 12px; }
table.seg th, table.seg td { border-bottom: 1px solid var(--line); padding: 6px 8px; text-align: left; }
table.seg th { color: var(--muted); font-weight: 500; background: #f7f9fc; }
table.seg td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.downloads { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.downloads a, .downloads button {
  text-decoration: none; border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 12px; font-size: 13px; color: var(--text); background: #fff;
}
.downloads a:hover, .downloads button:hover:not(:disabled) { border-color: #c3ccdb; background: #f7f9fc; }
.res-note { font-size: 12px; color: var(--muted); margin: -4px 0 0; }
.res-note:empty { display: none; }
.warn-box {
  background: #fffbeb; border: 1px solid #f5dcae; color: #92400e;
  border-radius: 8px; padding: 8px 10px; font-size: 13px; margin-top: 10px;
}

/* ---------- 历史任务 ---------- */
.jobs { list-style: none; margin: 0; padding: 0; }
.jobs li {
  display: flex; align-items: center; gap: 10px; padding: 7px 6px;
  border-bottom: 1px solid var(--line); font-size: 13px; cursor: pointer;
}
.jobs li:hover { background: #f7f9fc; }
.jobs li .meta { flex: 1; color: var(--muted); font-size: 12px; }
.jobs li .meta b { color: var(--text); font-weight: 500; }

/* ---------- 弹窗 / 提示 ---------- */
.mask {
  position: fixed; inset: 0; background: rgba(17, 22, 31, .5);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px;
}
.mask.hidden { display: none; }
.dialog {
  background: #fff; border-radius: 12px; padding: 18px; width: 100%; max-width: 520px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .25);
}
.dialog h3 { margin: 0 0 6px; font-size: 15px; }
.dialog p { margin: 0 0 10px; font-size: 13px; color: var(--muted); white-space: pre-line; }
.dialog textarea, .dialog input {
  width: 100%; font-family: inherit; font-size: 13px; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 8px; resize: vertical; color: var(--text);
}
.dialog textarea { min-height: 110px; }
.dialog .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }

/* ---------- 定位面板：候选列表 ---------- */
.dlg-extra { margin-bottom: 12px; }
.loc-box { display: flex; flex-direction: column; gap: 8px; }
.loc-head { font-size: 12px; color: var(--muted); word-break: break-all; }
.loc-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.loc-actions button { font-size: 13px; padding: 7px 10px; }
.loc-cands {
  display: flex; flex-direction: column; gap: 6px;
  max-height: 46vh; overflow-y: auto; -webkit-overflow-scrolling: touch;
}
.loc-tip { font-size: 12px; color: var(--muted); line-height: 1.5; }
.cand {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  width: 100%; text-align: left; font-family: inherit; cursor: pointer;
  background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px;
}
.cand:hover { border-color: var(--brand); background: #f6f9ff; }
.cand-name { font-size: 13px; font-weight: 600; color: var(--text); }
.cand-meta { font-size: 12px; color: var(--muted); }
.cand-coord { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 28px; z-index: 60;
  background: #11161f; color: #fff; border-radius: 8px; padding: 9px 16px; font-size: 13px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .3); max-width: 80vw;
}
.toast.hidden { display: none; }
.toast.error { background: #b91c1c; }
.toast.ok { background: #15803d; }

/* ---------- 响应式：手机 / 窄屏 ---------- */
@media (max-width: 900px) {
  body { padding-bottom: 76px; }              /* 给底部固定按钮留位 */
  .wrap { grid-template-columns: 1fr; padding: 10px; gap: 12px; }
  .top { padding: 12px 14px; gap: 8px; }
  .top h1 { font-size: 16px; }
  .top .sub { display: none; }
  .panel { padding: 12px; margin-bottom: 12px; }

  /* 工具栏：两列大按钮，手指好点 */
  .toolbar { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
  .toolbar button { padding: 10px 6px; font-size: 13px; min-height: 42px; }
  .toolbar button:last-child { grid-column: 1 / -1; }   /* 清空清单：整行，避免误触 */

  /* 地点行：名称独占一行，操作按钮换到下一行 */
  .place-row {
    flex-wrap: wrap; row-gap: 6px; padding: 8px 6px;
    border-color: var(--line); background: #fbfcfe;
  }
  .place-row:hover { background: #fbfcfe; }
  .place-row .idx { order: 1; flex: 0 0 18px; text-align: left; }
  .place-row .tag { order: 2; }
  .place-row .coord {
    order: 3; flex: 0 0 auto; margin-left: auto;
    padding: 5px 8px; font-size: 12px;
  }
  .place-row input.name {
    order: 4; flex: 1 1 100%; min-width: 0; font-size: 16px;
    padding: 8px 10px; border-color: var(--line); background: #fff;
  }
  .place-row button.icon { order: 5; flex: 1 1 0; min-height: 40px; padding: 6px 4px; }
  .place-row button.icon.danger { color: var(--end); }

  /* 主按钮固定在底部，长清单也能随手提交 */
  #btn-run {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    margin: 0; border-radius: 0; padding: 14px 16px; font-size: 16px;
    box-shadow: 0 -6px 18px rgba(17, 22, 31, .12);
    padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  }
  .log { height: 200px; }
  .summary { gap: 14px 18px; }
  .summary .item { flex: 1 1 30%; }
  .summary .item b { font-size: 17px; }
  .map-preview { max-height: 420px; }
  .map-preview img { max-height: 420px; }
  table.seg { font-size: 12.5px; }
  table.seg th, table.seg td { padding: 6px 4px; }
  table.seg th:first-child, table.seg td:first-child { width: 26px; }
  .res-note { font-size: 13px; line-height: 1.65; }

  .jobs li { padding: 10px 6px; }
  .downloads { display: grid; grid-template-columns: 1fr; gap: 8px; }
  .downloads a, .downloads button {
    display: flex; align-items: center; justify-content: center;
    min-height: 44px; padding: 10px 12px; font-size: 14px;
  }

  .mask { padding: 12px; }
  .dialog { padding: 16px; max-height: 88vh; overflow: auto; }
  .dialog textarea, .dialog input { font-size: 16px; }   /* ≥16px 才不会触发 iOS 缩放 */
  .dialog textarea { min-height: 140px; }
  .dialog .actions button { min-height: 44px; padding: 10px 16px; }
  .toast { bottom: 88px; max-width: 88vw; }
}
