:root {
  --bg: #f4f7f6;
  --card: #ffffff;
  --ink: #162421;
  --muted: #60726d;
  --line: #dce5e2;
  --brand: #0f766e;
  --brand-d: #0b5d56;
  --brand-soft: #e6f4f2;
  --ok: #15803d;
  --warn: #b45309;
  --danger: #b91c1c;
  --radius: 12px;
  --shadow: 0 2px 10px rgba(15, 45, 40, .05);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap { max-width: 680px; margin: 0 auto; padding: 16px; }
.wrap-wide { max-width: 1600px; margin: 0 auto; padding: 16px; }

.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: 12px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 30;
}
.topbar-title { font-size: 16px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.topbar-sub { font-size: 12px; color: var(--muted); }
.topbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.card h2 {
  margin: 0 0 12px;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.card h3 { margin: 0 0 10px; font-size: 14px; }

.muted { color: var(--muted); font-size: 12.5px; }
.notice {
  background: var(--brand-soft);
  border: 1px solid #c2e3df;
  color: #115e59;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 12.5px;
}

label { display: block; font-size: 12.5px; color: var(--muted); margin: 8px 0 4px; }
input, select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  font: inherit;
  color: var(--ink);
  background: #fff;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); }

button {
  background: var(--brand);
  color: #fff;
  border: 1px solid var(--brand);
  border-radius: 9px;
  padding: 9px 14px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: .15s;
}
button:hover { background: var(--brand-d); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.line { background: #fff; color: var(--brand); }
button.line:hover { background: var(--brand-soft); }
button.danger { background: #fff; color: var(--danger); border-color: #f3c4c4; }
button.danger:hover { background: #fef2f2; }
button.sm { padding: 5px 10px; font-size: 12.5px; border-radius: 7px; }

.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1 1 160px; min-width: 0; }

.kpi {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}
.kpi-item {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 13px 14px;
}
.kpi-val { font-size: 22px; font-weight: 700; color: var(--brand); line-height: 1.25; }
.kpi-lbl { font-size: 12px; color: var(--muted); margin-top: 4px; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 11.5px;
  font-weight: 600;
  background: #eef2f1;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}
.badge.ok { background: #dcfce7; color: var(--ok); }
.badge.warn { background: #fef3c7; color: var(--warn); }
.badge.danger { background: #fee2e2; color: var(--danger); }
.badge.brand { background: var(--brand-soft); color: var(--brand); }

.seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  background: #f1f6f5;
  padding: 4px;
  border-radius: 10px;
  border: 1px solid var(--line);
}
.seg button {
  background: transparent;
  color: var(--muted);
  border: none;
  padding: 7px 10px;
  border-radius: 7px;
  font-weight: 600;
}
.seg button:hover { background: rgba(15, 118, 110, .08); color: var(--ink); }
.seg button.active {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 1px 4px rgba(15, 118, 110, .2);
}

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip {
  background: #f4f8f7;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 99px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
}
.chip:hover { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); }
.chip.active { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); font-weight: 600; }

.proposal-box {
  background: #fffbeb;
  border: 1px solid #fcd34d;
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 14px;
}
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(15, 36, 32, .45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 200;
}
.modal-box {
  background: #fff;
  border-radius: 14px;
  max-width: 480px;
  width: 100%;
  padding: 18px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, .2);
}
.modal-box h3 { margin: 0 0 8px; font-size: 16px; }

/* 多轮协商聊天窗口 */
.chat-modal {
  max-width: 520px;
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 86vh;
}
.chat-head {
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  background: #f9fbfa;
}
.chat-body {
  padding: 14px;
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 180px;
  max-height: 44vh;
  background: #f4f7f6;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.chat-msg { display: flex; flex-direction: column; max-width: 86%; }
.chat-msg.left { align-self: flex-start; }
.chat-msg.right { align-self: flex-end; align-items: flex-end; }
.chat-sender { font-size: 11px; color: var(--muted); margin: 0 4px 3px; }
.chat-bubble {
  padding: 9px 12px;
  border-radius: 12px;
  font-size: 13.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}
.chat-msg.left .chat-bubble {
  background: #fff;
  border: 1px solid var(--line);
  border-top-left-radius: 4px;
  color: var(--ink);
}
.chat-msg.left.is-admin .chat-bubble {
  background: #fffbeb;
  border-color: #fcd34d;
}
.chat-msg.right .chat-bubble {
  background: var(--brand);
  color: #fff;
  border-top-right-radius: 4px;
}
.chat-opts {
  padding: 10px 14px;
  border-top: 1px solid var(--line);
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.chat-opts-title { font-size: 11.5px; color: var(--muted); }
.chat-opt-btn {
  width: 100%;
  text-align: left;
  padding: 8px 11px;
  font-size: 13px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.chat-foot {
  padding: 10px 14px 12px;
  border-top: 1px solid var(--line);
  background: #f9fbfa;
}
.chat-input-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.chat-input-row input { flex: 1 1 auto; }
.chat-input-row button { flex: 0 0 auto; white-space: nowrap; }
.chat-typing {
  font-size: 12px;
  color: var(--brand);
  padding: 4px 2px 0;
}

/* 新订单强提醒排队弹窗（不点击确认不关闭） */
.alert-modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 22, .62);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 320;
}
.alert-modal-box {
  background: #fff;
  border-radius: 16px;
  max-width: 490px;
  width: 100%;
  overflow: hidden;
  box-shadow: 0 24px 56px rgba(0, 0, 0, .32);
  border: 2px solid #f59e0b;
}
.alert-modal-head {
  background: linear-gradient(135deg, #d97706, #b45309);
  color: #fff;
  padding: 14px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.alert-modal-head .badge {
  background: rgba(255, 255, 255, .22);
  color: #fff;
}
.alert-modal-body {
  padding: 16px 18px;
}
.alert-kv {
  display: grid;
  grid-template-columns: 78px 1fr;
  gap: 6px 10px;
  font-size: 13.5px;
  margin-bottom: 12px;
}
.alert-kv .k { color: var(--muted); }
.alert-kv .v { color: var(--ink); font-weight: 600; word-break: break-word; }
.alert-queue-strip {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 12.5px;
  color: #92400e;
  margin-bottom: 14px;
}
.alert-modal-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
@keyframes alertPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, .45); }
  50% { box-shadow: 0 0 0 10px rgba(245, 158, 11, 0); }
}
.alert-modal-box.ringing {
  animation: alertPulse 1.4s ease-in-out infinite;
}

/* 傻瓜式可视化路线站点编辑器 */
.stop-builder-box {
  margin-top: 10px;
  padding: 12px 14px;
  background: #f9fbfa;
  border: 1px solid var(--line);
  border-radius: 12px;
}
.stop-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.stop-seq {
  width: 24px;
  height: 24px;
  border-radius: 99px;
  background: var(--brand);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}
.stop-row input[type="text"] { flex: 1 1 180px; padding: 6px 9px; }
.stop-row input[type="time"] { width: 112px; flex: 0 0 auto; padding: 6px 8px; }
.map-pick-modal {
  max-width: 760px;
  padding: 0;
  overflow: hidden;
}
#pickMapCanvas {
  width: 100%;
  height: 390px;
  background: #eaf1ef;
}

.list { list-style: none; margin: 0; padding: 0; }
.list li {
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.list li:last-child { border-bottom: none; }

.scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td {
  text-align: left;
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
th { color: var(--muted); font-weight: 600; background: #f9fbfa; }

.empty { text-align: center; padding: 24px 12px; color: var(--muted); font-size: 13px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: #142824;
  color: #fff;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 13px;
  z-index: 999;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .2);
  max-width: 90vw;
}

/* 运营后台桌面左侧边栏 + 窄屏顶部菜单 */
.admin-shell {
  max-width: 1600px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  gap: 16px;
  padding: 16px;
  align-items: start;
}
.admin-nav {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  position: sticky;
  top: 72px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.admin-nav button {
  text-align: left;
  background: transparent;
  color: var(--ink);
  border: none;
  padding: 10px 12px;
  border-radius: 9px;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.admin-nav button:hover { background: #f1f6f5; }
.admin-nav button.active { background: var(--brand); color: #fff; }
.admin-nav button.active .badge { background: rgba(255,255,255,.22); color: #fff; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }

@media (max-width: 960px) {
  .admin-shell { grid-template-columns: 1fr; padding: 12px; }
  .admin-nav {
    position: static;
    flex-direction: row;
    overflow-x: auto;
    gap: 6px;
  }
  .admin-nav button { flex: 0 0 auto; white-space: nowrap; }
  .grid-2 { grid-template-columns: 1fr; }
}
