:root {
  --bg: #f4f7f4;
  --panel: #ffffff;
  --line: #dfe6dd;
  --text: #16211a;
  --muted: #6a7a6c;
  --accent: #2f7d55;
  --accent-soft: #e6f2e9;
  --warn: #b26a12;
  --shadow: 0 10px 30px rgba(22, 45, 30, 0.07);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: radial-gradient(1200px 600px at 8% -10%, #e9f3ec 0%, var(--bg) 55%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui,
    "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB",
    "Noto Sans CJK SC", "WenQuanYi Zen Hei", sans-serif;
  font-size: 14px;
  line-height: 1.55;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 16px 28px;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 14px; }

.logo {
  width: 42px; height: 42px;
  border-radius: 12px;
  background: linear-gradient(145deg, #2f7d55, #58a87b);
  color: #fff;
  display: grid; place-items: center;
  font-weight: 700; font-size: 15px;
  letter-spacing: 1px;
}

.topbar h1 { margin: 0; font-size: 17px; font-weight: 700; }
.topbar p { margin: 2px 0 0; font-size: 12px; color: var(--muted); }

.status { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.chip {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid #cfe4d5;
  white-space: nowrap;
}
.chip.warn { background: #fdf3e3; color: var(--warn); border-color: #f0dcbd; }

.layout {
  display: grid;
  /* 用 minmax(..., fr) 而非固定列宽，任意分辨率下都不撑破；超宽屏限幅居中 */
  grid-template-columns: minmax(380px, 0.85fr) minmax(480px, 1.15fr);
  gap: 20px;
  padding: 20px 28px 40px;
  align-items: start;
  max-width: 1680px;
  margin: 0 auto;
}

@media (max-width: 1180px) {
  .layout { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 640px) {
  .layout { padding: 12px; }
  .topbar { padding: 12px 16px; }
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 18px 20px 22px;
}

.form-panel { position: sticky; top: 84px; max-height: calc(100vh - 104px); overflow-y: auto; }
@media (max-width: 1180px) { .form-panel { position: static; max-height: none; } }

.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 12px;
}
.panel-head h2 { margin: 0; font-size: 15px; letter-spacing: .5px; }

.badge {
  font-size: 12px; color: var(--muted);
  background: #f3f6f2; border: 1px solid var(--line);
  border-radius: 999px; padding: 3px 10px;
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px 12px; }
@media (max-width: 560px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

.field { display: flex; flex-direction: column; gap: 5px; }
.field > span { font-size: 12px; color: var(--muted); }
.field em { color: #9aa89c; font-style: normal; }

input, select, textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fcfdfc;
  font-size: 13px;
  color: var(--text);
  font-family: inherit;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 125, 85, .12);
  background: #fff;
}
input.sub { background: #f8faf8; font-size: 12px; }

.checkbox-field { justify-content: flex-end; }
.checkbox-field input { width: 18px; height: 18px; accent-color: var(--accent); }

.section-title {
  margin: 18px 0 10px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--accent);
  text-transform: uppercase;
  display: flex; align-items: center; gap: 10px;
}
.section-title::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.section-title .hint { order: 3; font-weight: 400; color: var(--muted); font-size: 11px; letter-spacing: 0; text-transform: none; }

.stops { display: flex; flex-direction: column; gap: 10px; }

.stop-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  background: #fbfdfb;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.stop-card .handle {
  width: 20px; text-align: center; color: #b4c0b6; font-weight: 700; font-size: 13px;
  padding-top: 8px; flex: none;
}
.stop-main { flex: 1; display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.stop-row { display: grid; grid-template-columns: 112px minmax(100px, 1fr) 88px 104px 26px; gap: 7px; }
.stop-row.alt { grid-template-columns: minmax(120px, 1fr) 170px; }
@media (max-width: 700px) {
  .stop-row { grid-template-columns: 1fr 1fr; }
  .stop-row.alt { grid-template-columns: 1fr; }
}
.stop-card input, .stop-card select { padding: 6px 8px; font-size: 12px; }
.stop-card .remove {
  background: none; border: none; color: #b9c3bb; cursor: pointer; font-size: 16px;
  padding: 0; line-height: 1;
}
.stop-card .remove:hover { color: #cf5b4a; background: none; }

.stop-time {
  font-size: 11px; color: #2f7a45; background: #eef7f0; border: 1px solid #d6e9db;
  border-radius: 8px; padding: 3px 8px; align-self: flex-start;
}

.loc-row { display: flex; align-items: center; gap: 6px; margin-top: 4px; flex-wrap: wrap; }
.loc-state { font-size: 11px; color: var(--muted); }
.loc-state.ok { color: #2f7a45; }
button.tiny { padding: 3px 8px; font-size: 11px; border-radius: 8px; }

button {
  font-family: inherit;
  cursor: pointer;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  font-size: 13px;
  padding: 8px 14px;
  transition: all .15s;
}
button:hover { border-color: #c6d5c9; background: #f7faf7; }
button:disabled { opacity: .5; cursor: not-allowed; }

.primary {
  background: linear-gradient(145deg, #2f7d55, #3f9268);
  color: #fff; border-color: transparent;
  font-weight: 600;
  padding: 10px 22px;
  box-shadow: 0 6px 16px rgba(47, 125, 85, .22);
}
.primary:hover { background: linear-gradient(145deg, #276a48, #368058); }
.ghost { background: #f7faf7; }
.ghost.block { width: 100%; margin-top: 10px; border-style: dashed; color: var(--muted); }

.actions { display: flex; gap: 10px; margin-top: 20px; align-items: center; }

.preview-frame {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfdfb;
  min-height: 320px;
  display: grid;
  place-items: center;
  padding: 12px;
  overflow: auto;
}
.preview-frame img { max-width: 100%; border-radius: 6px; box-shadow: 0 4px 14px rgba(0,0,0,.08); }

.placeholder { text-align: center; color: var(--muted); }
.ph-icon { font-size: 36px; margin-bottom: 6px; opacity: .55; }
.placeholder p { margin: 4px 0; font-size: 13px; }
.ph-sub { font-size: 12px; color: #9aa89c; }

.metrics { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.metric {
  background: #f6faf7; border: 1px solid var(--line); border-radius: 10px;
  padding: 7px 12px; font-size: 12px; color: var(--muted);
}
.metric b { color: var(--text); font-size: 13px; margin-left: 4px; }

.timeline-box {
  margin-top: 12px; border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px;
  background: #fbfdfb;
}
.timeline-box summary { cursor: pointer; font-size: 12px; color: var(--accent); font-weight: 600; }
#timeline { margin-top: 8px; max-height: 240px; overflow: auto; }
.tl-row {
  display: grid; grid-template-columns: 104px 62px 1fr; gap: 8px;
  font-size: 12px; padding: 5px 0; border-bottom: 1px dashed #ecf1ec;
}
.tl-row:last-child { border-bottom: none; }
.tl-time { color: var(--muted); font-variant-numeric: tabular-nums; }
.tl-kind { font-size: 11px; color: var(--accent); }
.tl-kind.rest { color: var(--warn); }
.warn-line { color: var(--warn); font-size: 12px; margin-top: 8px; }

.robot-box {
  margin-top: 14px; border: 1px dashed #cddccf; border-radius: 12px; padding: 12px 14px;
  background: linear-gradient(180deg, #f7fbf8, #ffffff);
}
.robot-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.robot-head h3 { margin: 0; font-size: 13px; }
.robot-head span { font-size: 11px; color: var(--muted); }
.robot-box pre {
  margin: 8px 0 10px; padding: 10px; background: #10221a; color: #cfe8d8;
  border-radius: 9px; font-size: 11px; line-height: 1.6; overflow: auto;
  font-family: "JetBrains Mono", Consolas, monospace; white-space: pre-wrap;
}
.robot-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.toast {
  position: fixed; left: 50%; bottom: 32px; transform: translate(-50%, 20px);
  background: #16281f; color: #eaf6ee; padding: 10px 18px; border-radius: 10px;
  font-size: 13px; opacity: 0; pointer-events: none; transition: all .25s; z-index: 50;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: #5c231c; color: #ffe6e1; }

/* 排期算法规则面板 */
.algo-box { padding: 8px 14px 2px; }
.algo-row {
  display: flex; align-items: baseline; gap: 10px; padding: 5px 0;
  border-bottom: 1px dashed #e3e8e3; font-size: 13px;
}
.algo-row:last-child { border-bottom: none; }
.algo-no {
  flex: 0 0 22px; height: 22px; line-height: 22px; text-align: center;
  border-radius: 50%; background: #eaf3ea; color: #3f7d4f; font-weight: 700; font-size: 12px;
}
.algo-label { flex: 1 1 auto; color: #47534a; }
.algo-value { flex: 0 0 auto; font-weight: 700; color: #3f7d4f; }
.algo-foot {
  display: flex; flex-wrap: wrap; gap: 6px 18px; padding: 8px 14px 12px;
  font-size: 12px; color: #7b8679;
}

/* 智能识别录入 */
.intake-box {
  border: 1px dashed #c6d8c9; border-radius: 12px; padding: 10px 12px;
  background: linear-gradient(180deg, #f7fbf8, #ffffff); margin-bottom: 14px;
}
.intake-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.intake-head strong { font-size: 13px; color: #2f7d55; }
.intake-head span { font-size: 11px; color: #7b8679; }
.intake-box textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 9px; padding: 7px 9px;
  font-family: inherit; font-size: 12px; color: var(--text); background: #fcfdfc; resize: vertical;
}
.intake-box textarea:focus { outline: none; border-color: var(--accent); background: #fff; }
.intake-actions { display: flex; align-items: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.intake-actions input[type="file"] { font-size: 11px; color: #6a7a6c; width: auto; border: none; background: none; padding: 0; flex: 1 1 160px; }
.intake-state {
  margin-top: 6px; font-size: 11px; color: #6a7a6c; line-height: 1.5; word-break: break-all;
}

/* ── 定位簿（网页端登记位置，含精确经纬度） ───────────────────── */
.locbook { grid-column: 1 / -1; margin: 2px 0 6px; border: 1px solid var(--line); border-radius: 10px; background: rgba(255,255,255,.62); }
.locbook summary { cursor: pointer; padding: 8px 10px; font-size: 12px; font-weight: 600; color: var(--muted); list-style: none; }
.locbook summary::-webkit-details-marker { display: none; }
.locbook summary::before { content: "\25B8 "; color: var(--accent); }
.locbook[open] summary::before { content: "\25BE "; }
.locbook-body { padding: 0 10px 10px; }
.locbook-row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-bottom: 6px; }
.locbook-row input { flex: 2 1 190px; }
.locbook-row select { flex: 0 1 auto; }
.locbook-row button { flex: 0 0 auto; }
.loc-list { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.loc-item { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.loc-item .loc-kind { flex: none; padding: 1px 6px; border-radius: 6px; background: var(--accent-soft); color: var(--accent); font-size: 11px; }
.loc-item .loc-text { flex: 1 1 auto; min-width: 0; font-size: 12px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.loc-item .acts { flex: none; display: flex; gap: 4px; }
