:root {
  --bg: #0a1017;
  --bg-2: #0f1823;
  --panel: #131f2c;
  --panel-2: #182735;
  --line: #223345;
  --line-2: #2c4257;
  --text: #e8f2f8;
  --text-2: #9db2c4;
  --text-3: #647d94;
  --ice: #34d8f5;
  --ice-2: #0fb9dc;
  --frozen: #5b8dff;
  --chilled: #2fd6a8;
  --ambient: #f5b544;
  --warn: #ff9f43;
  --danger: #ff5c6c;
  --ok: #2fd6a8;
  --idle: #34d8f5;
  --busy: #f5b544;
  --offline: #5b6b7d;
  --radius: 12px;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.42);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC',
    'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--ice); text-decoration: none; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #26394d; border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------------- 通用组件 ---------------- */

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.card-head {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: linear-gradient(180deg, rgba(52, 216, 245, 0.07), transparent);
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.3px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title::before {
  content: '';
  width: 3px;
  height: 14px;
  border-radius: 2px;
  background: var(--ice);
}

.card-body { padding: 14px 16px; }

.muted { color: var(--text-2); }
.dim { color: var(--text-3); }
.tiny { font-size: 12px; }
.mono { font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.grow { flex: 1; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.row { display: flex; gap: 10px; align-items: center; }
.row-between { display: flex; gap: 10px; align-items: center; justify-content: space-between; }
.col { display: flex; flex-direction: column; gap: 10px; }
.wrap { flex-wrap: wrap; }

label.field {
  display: block;
  font-size: 12px;
  color: var(--text-2);
  margin-bottom: 6px;
  letter-spacing: 0.2px;
}

input, select, textarea, button {
  font-family: inherit;
  font-size: 14px;
}

input[type='text'], input[type='number'], input[type='tel'], select, textarea {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 9px;
  padding: 9px 11px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--ice-2);
  box-shadow: 0 0 0 3px rgba(52, 216, 245, 0.12);
}

textarea { resize: vertical; min-height: 62px; }

.btn {
  border: 1px solid var(--line-2);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 9px;
  padding: 9px 15px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn:hover { border-color: var(--ice-2); color: #fff; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.42; cursor: not-allowed; transform: none; }

.btn-primary {
  background: linear-gradient(135deg, var(--ice), var(--ice-2));
  border-color: transparent;
  color: #06202b;
  font-weight: 600;
}
.btn-primary:hover { filter: brightness(1.08); color: #06202b; }

.btn-ghost { background: transparent; }
.btn-danger { background: rgba(255, 92, 108, 0.12); border-color: rgba(255, 92, 108, 0.4); color: #ff8f9b; }
.btn-danger:hover { border-color: var(--danger); color: #fff; }
.btn-ok { background: rgba(47, 214, 168, 0.14); border-color: rgba(47, 214, 168, 0.42); color: #6ee7c2; }
.btn-ok:hover { border-color: var(--ok); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 7px; }
.btn-block { width: 100%; display: block; }
.btn-lg { padding: 13px 18px; font-size: 15px; }

.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 12px;
  border: 1px solid var(--line-2);
  color: var(--text-2);
  background: rgba(255, 255, 255, 0.03);
}
.tag-ice { color: var(--ice); border-color: rgba(52, 216, 245, 0.4); background: rgba(52, 216, 245, 0.1); }
.tag-frozen { color: var(--frozen); border-color: rgba(91, 141, 255, 0.42); background: rgba(91, 141, 255, 0.12); }
.tag-chilled { color: var(--chilled); border-color: rgba(47, 214, 168, 0.42); background: rgba(47, 214, 168, 0.12); }
.tag-ambient { color: var(--ambient); border-color: rgba(245, 181, 68, 0.42); background: rgba(245, 181, 68, 0.12); }
.tag-warn { color: var(--warn); border-color: rgba(255, 159, 67, 0.42); background: rgba(255, 159, 67, 0.12); }
.tag-danger { color: var(--danger); border-color: rgba(255, 92, 108, 0.42); background: rgba(255, 92, 108, 0.12); }
.tag-offline { color: var(--offline); }

.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: 0 0 auto; }
.dot-idle { background: var(--idle); box-shadow: 0 0 8px var(--idle); }
.dot-busy { background: var(--busy); box-shadow: 0 0 8px var(--busy); }
.dot-offline { background: var(--offline); }

/* 温度模式选择 */
.mode-group { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.mode-item {
  border: 1px solid var(--line);
  background: var(--bg-2);
  border-radius: 10px;
  padding: 10px 8px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
}
.mode-item:hover { border-color: var(--line-2); }
.mode-item .m-name { font-weight: 600; font-size: 14px; }
.mode-item .m-range { font-size: 11px; color: var(--text-3); margin-top: 2px; }
.mode-item.on { border-color: var(--ice); background: rgba(52, 216, 245, 0.1); }
.mode-item.on .m-name { color: var(--ice); }
.mode-item[data-mode='frozen'].on { border-color: var(--frozen); background: rgba(91, 141, 255, 0.12); }
.mode-item[data-mode='frozen'].on .m-name { color: var(--frozen); }
.mode-item[data-mode='ambient'].on { border-color: var(--ambient); background: rgba(245, 181, 68, 0.12); }
.mode-item[data-mode='ambient'].on .m-name { color: var(--ambient); }

/* 车型卡片 */
.vt-list { display: flex; flex-direction: column; gap: 8px; }
.vt-item {
  border: 1px solid var(--line);
  background: var(--bg-2);
  border-radius: 10px;
  padding: 11px 13px;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  gap: 12px;
}
.vt-item:hover { border-color: var(--line-2); }
.vt-item.on { border-color: var(--ice); background: rgba(52, 216, 245, 0.09); }
.vt-icon {
  width: 44px; height: 30px; flex: 0 0 auto;
  border-radius: 5px;
  background: linear-gradient(160deg, #2a4256, #1b2b3a);
  border: 1px solid #3a5670;
  position: relative;
}
.vt-icon::after {
  content: '';
  position: absolute; left: 5px; top: 7px;
  width: 16px; height: 3px; border-radius: 2px;
  background: rgba(52, 216, 245, 0.55);
  box-shadow: 0 6px 0 rgba(52, 216, 245, 0.28);
}
.vt-item.on .vt-icon { border-color: var(--ice); }
.vt-name { font-weight: 600; }
.vt-spec { font-size: 12px; color: var(--text-2); margin-top: 1px; }

/* 表格 */
table.tb { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tb th {
  text-align: left;
  font-weight: 500;
  color: var(--text-3);
  font-size: 12px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0;
  background: var(--panel);
  z-index: 1;
}
table.tb td { padding: 9px 10px; border-bottom: 1px solid rgba(34, 51, 69, 0.6); }
table.tb tbody tr:hover { background: rgba(52, 216, 245, 0.05); }
table.tb tbody tr.sel { background: rgba(52, 216, 245, 0.1); }

/* 费用明细 */
.fee-line { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px dashed rgba(34, 51, 69, 0.8); font-size: 13px; }
.fee-line:last-child { border-bottom: none; }
.fee-line .fl { color: var(--text-2); }
.fee-total { display: flex; justify-content: space-between; align-items: baseline; padding-top: 10px; margin-top: 4px; border-top: 1px solid var(--line-2); }
.fee-total .amt { font-size: 26px; font-weight: 700; color: var(--ice); font-variant-numeric: tabular-nums; }

/* 状态流 */
.flow { display: flex; align-items: center; gap: 0; flex-wrap: wrap; }
.flow-node { display: flex; align-items: center; gap: 7px; padding: 4px 0; }
.flow-node .fn-dot {
  width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid var(--line-2);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: var(--text-3);
  flex: 0 0 auto;
}
.flow-node .fn-label { font-size: 12px; color: var(--text-3); }
.flow-node.done .fn-dot { border-color: var(--ok); background: rgba(47, 214, 168, 0.18); color: var(--ok); }
.flow-node.done .fn-label { color: var(--text); }
.flow-node.now .fn-dot { border-color: var(--ice); background: var(--ice); color: #06202b; animation: pulse 1.6s infinite; }
.flow-node.now .fn-label { color: var(--ice); font-weight: 600; }
.flow-bar { width: 22px; height: 2px; background: var(--line-2); margin: 0 5px; flex: 0 0 auto; }
.flow-bar.done { background: var(--ok); }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(52, 216, 245, 0.5); }
  50% { box-shadow: 0 0 0 6px rgba(52, 216, 245, 0); }
}

/* 地图 */
.map-wrap { position: relative; width: 100%; background: #071018; overflow: hidden; }
.map-wrap canvas { display: block; width: 100%; height: 100%; cursor: grab; }
.map-wrap canvas:active { cursor: grabbing; }
.map-legend {
  position: absolute; left: 12px; bottom: 12px;
  background: rgba(11, 20, 29, 0.85);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 8px 11px;
  font-size: 12px;
  display: flex; flex-direction: column; gap: 5px;
  backdrop-filter: blur(6px);
}
.map-legend .lg { display: flex; align-items: center; gap: 7px; color: var(--text-2); }
.map-ctl {
  position: absolute; right: 12px; top: 12px;
  display: flex; flex-direction: column; gap: 6px;
}
.map-ctl button {
  width: 32px; height: 32px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(11, 20, 29, 0.85);
  color: var(--text);
  cursor: pointer;
  font-size: 15px;
  backdrop-filter: blur(6px);
}
.map-ctl button:hover { border-color: var(--ice-2); }
.map-coord {
  position: absolute; right: 12px; bottom: 12px;
  font-size: 11px; color: var(--text-3);
  background: rgba(11, 20, 29, 0.8);
  padding: 3px 8px; border-radius: 6px;
}

/* 车辆弹窗 */
.popup {
  position: absolute;
  min-width: 250px;
  max-width: 300px;
  background: rgba(14, 24, 34, 0.97);
  border: 1px solid var(--line-2);
  border-radius: 11px;
  box-shadow: var(--shadow);
  padding: 12px 14px;
  z-index: 20;
  backdrop-filter: blur(10px);
  font-size: 13px;
}
.popup .pu-close {
  position: absolute; right: 8px; top: 6px;
  cursor: pointer; color: var(--text-3);
  font-size: 16px; line-height: 1;
}
.popup .pu-close:hover { color: var(--text); }
.popup h4 { margin: 0 0 8px; font-size: 15px; display: flex; align-items: center; gap: 7px; }
.popup .kv { display: flex; justify-content: space-between; gap: 10px; padding: 3px 0; }
.popup .kv .k { color: var(--text-3); font-size: 12px; }

/* 事件流 */
.feed { display: flex; flex-direction: column; gap: 1px; max-height: 100%; overflow-y: auto; }
.feed-item {
  display: flex; gap: 9px;
  padding: 7px 4px;
  border-bottom: 1px solid rgba(34, 51, 69, 0.5);
  font-size: 12.5px;
}
.feed-item .fi-time { color: var(--text-3); font-size: 11px; flex: 0 0 52px; font-variant-numeric: tabular-nums; }
.feed-item .fi-msg { flex: 1; color: var(--text-2); }
.feed-item.t-dispatch .fi-msg { color: var(--ice); }
.feed-item.t-order .fi-msg { color: var(--text); }
.feed-item.t-driver .fi-msg { color: var(--chilled); }

/* KPI */
.kpi-grid { display: grid; gap: 10px; }
.kpi {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 12px 14px;
  position: relative;
  overflow: hidden;
}
.kpi::after {
  content: ''; position: absolute; right: -18px; top: -18px;
  width: 58px; height: 58px; border-radius: 50%;
  background: radial-gradient(circle, rgba(52, 216, 245, 0.14), transparent 70%);
}
.kpi .kv { font-size: 25px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.15; }
.kpi .kl { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.kpi.k-idle .kv { color: var(--idle); }
.kpi.k-busy .kv { color: var(--busy); }
.kpi.k-offline .kv { color: var(--offline); }
.kpi.k-warn .kv { color: var(--warn); }
.kpi.k-ok .kv { color: var(--ok); }

/* 顶栏 */
.topbar {
  height: 54px;
  border-bottom: 1px solid var(--line);
  background: rgba(15, 24, 35, 0.94);
  display: flex; align-items: center;
  padding: 0 18px; gap: 14px;
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: blur(10px);
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 15px; letter-spacing: 0.3px; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 7px;
  background: linear-gradient(135deg, var(--ice), #1d7fa8);
  display: flex; align-items: center; justify-content: center;
  color: #06202b; font-size: 14px; font-weight: 800;
}
.topbar .sep { width: 1px; height: 22px; background: var(--line); }
.nav-links { display: flex; gap: 4px; }
.nav-links a {
  padding: 6px 12px; border-radius: 8px;
  color: var(--text-2); font-size: 13px;
}
.nav-links a:hover { background: var(--panel-2); color: var(--text); }
.nav-links a.on { background: rgba(52, 216, 245, 0.13); color: var(--ice); }

/* 提示条 */
.alert {
  border-radius: 10px; padding: 10px 13px;
  font-size: 13px; display: flex; gap: 9px; align-items: flex-start;
  border: 1px solid;
}
.alert-warn { background: rgba(255, 159, 67, 0.1); border-color: rgba(255, 159, 67, 0.35); color: #ffc78a; }
.alert-danger { background: rgba(255, 92, 108, 0.1); border-color: rgba(255, 92, 108, 0.35); color: #ffa3ad; }
.alert-ok { background: rgba(47, 214, 168, 0.1); border-color: rgba(47, 214, 168, 0.32); color: #7fe6c6; }
.alert-info { background: rgba(52, 216, 245, 0.08); border-color: rgba(52, 216, 245, 0.3); color: #9de6f6; }

/* Toast */
#toast-host {
  position: fixed; left: 50%; top: 18px;
  transform: translateX(-50%);
  z-index: 999;
  display: flex; flex-direction: column; gap: 8px;
  align-items: center;
  pointer-events: none;
}
.toast {
  background: rgba(18, 30, 42, 0.97);
  border: 1px solid var(--line-2);
  border-radius: 9px;
  padding: 9px 16px;
  box-shadow: var(--shadow);
  font-size: 13px;
  animation: toastIn 0.2s ease-out;
  max-width: 78vw;
}
.toast.ok { border-color: rgba(47, 214, 168, 0.5); color: #8ef0d2; }
.toast.err { border-color: rgba(255, 92, 108, 0.5); color: #ffa3ad; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

.spin {
  width: 14px; height: 14px;
  border: 2px solid rgba(52, 216, 245, 0.25);
  border-top-color: var(--ice);
  border-radius: 50%;
  animation: rot 0.7s linear infinite;
  display: inline-block;
}
@keyframes rot { to { transform: rotate(360deg); } }

.empty { padding: 26px 10px; text-align: center; color: var(--text-3); font-size: 13px; }

/* ---------------- 手机端 / 窄屏响应式 ---------------- */

html { -webkit-text-size-adjust: 100%; }

/* 地图画布交由 JS 手势处理，禁用浏览器自身平移/缩放手势避免冲突 */
.map-wrap canvas { touch-action: none; }

/* 弹窗允许超出地图边界展示，避免小屏被裁切 */
.map-wrap { overflow: visible; }
.popup {
  min-width: 220px;
  max-width: min(300px, calc(100vw - 24px));
}

/* 详情抽屉：手机端占满整屏 */
@media (max-width: 720px) {
  .drawer {
    width: 100%;
    top: 0;
    padding: 14px;
  }
}

/* 顶栏：窄屏折叠为「品牌+选择」一行 + 下方可横滑导航 */
@media (max-width: 720px) {
  .topbar {
    flex-wrap: wrap;
    height: auto;
    min-height: 50px;
    padding: 7px 10px;
    gap: 8px;
  }
  .topbar .brand { font-size: 13px; gap: 6px; }
  .topbar .brand-mark { width: 22px; height: 22px; font-size: 12px; }
  .topbar .sep { display: none; }
  .topbar .grow { display: none; }
  .topbar .nav-links {
    order: 5;
    flex-basis: 100%;
    width: 100%;
    overflow-x: auto;
    gap: 2px;
    padding-bottom: 2px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .topbar .nav-links::-webkit-scrollbar { display: none; }
  .topbar .nav-links a { font-size: 12px; padding: 6px 9px; white-space: nowrap; }
  .topbar select { width: 104px !important; margin-left: auto; }
  .topbar .tag { font-size: 11px; }
  .topbar .tiny.dim { font-size: 11px; }
}

/* 表单控件放大到 16px，防止 iOS 聚焦时整页缩放 */
@media (max-width: 720px) {
  input[type='text'], input[type='number'], input[type='tel'], select, textarea {
    font-size: 16px;
    padding: 11px 12px;
  }
  textarea { min-height: 72px; }
}

/* 触摸目标：按钮点按面积增大 */
@media (max-width: 720px) {
  .btn { padding: 11px 14px; font-size: 14px; }
  .btn-lg { padding: 15px 18px; font-size: 15px; }
  .btn-sm { padding: 8px 11px; }
  .fchip { padding: 5px 12px; }
  .tag { padding: 3px 9px; }
}

/* 通用：窄屏下表格横向滚动（.tb-wrap 已 overflow:auto） */
@media (max-width: 720px) {
  .card-body { padding: 12px 13px; }
  .card-head { padding: 11px 13px; }
  .kpi-grid { gap: 8px; }
  .kpi { padding: 11px 12px; }
  .kpi .kv { font-size: 22px; }
}

/* 超窄屏（≤380px）进一步压缩间距与字号 */
@media (max-width: 380px) {
  .mode-group { gap: 6px; }
  .mode-item { padding: 9px 6px; }
  .vt-icon { width: 38px; height: 26px; }
  .track-grid { gap: 7px; }
  .spec-grid { gap: 6px; }
  .spec .sv { font-size: 14px; }
}
