:root {
  color-scheme: light;
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: #eef2ff;
  --primary-ring: rgba(79, 70, 229, 0.18);

  --bg: #f4f6fb;
  --surface: #ffffff;
  --border: #e6e9f0;
  --border-strong: #d4d9e4;

  --text: #1a2030;
  --text-soft: #5b6678;
  --text-faint: #8b95a7;

  --success: #16a34a;
  --success-soft: #e7f6ec;
  --warning: #d97706;
  --warning-soft: #fdf2e2;
  --danger: #dc2626;
  --danger-soft: #fdecec;
  --info: #0ea5e9;
  --info-soft: #e6f6fe;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow: 0 10px 30px rgba(16, 24, 40, 0.07);
  --shadow-lg: 0 24px 60px rgba(16, 24, 40, 0.16);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
.muted { color: var(--text-soft); font-size: 13px; margin: 4px 0 0; }
.ta-right { text-align: right; }

.icon {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- 按钮 ---------- */
button, input, select, textarea { font: inherit; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: background .16s, border-color .16s, box-shadow .16s, transform .04s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn .icon { width: 16px; height: 16px; }

.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }

.btn-soft { background: var(--surface); border-color: var(--border-strong); color: var(--text-soft); }
.btn-soft:hover { background: #f7f8fc; color: var(--text); }

.btn-ghost { background: transparent; border-color: var(--border-strong); color: var(--text-soft); }
.btn-ghost:hover { background: #f1f3f8; color: var(--text); }

.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }

.btn-ghost-dark { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.16); color: #d9def0; }
.btn-ghost-dark:hover { background: rgba(255,255,255,.16); color: #fff; }

.btn-block { width: 100%; }

.btn-xs {
  min-height: 28px;
  padding: 0 9px;
  font-size: 12px;
  border-radius: 7px;
  font-weight: 500;
  gap: 4px;
}
.btn-xs .icon { width: 14px; height: 14px; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--text-soft);
  cursor: pointer;
}
.icon-btn:hover { background: #f1f3f8; color: var(--text); }

/* ---------- 表单控件 ---------- */
.field { display: grid; gap: 7px; }
.field > span { color: var(--text-soft); font-size: 13px; font-weight: 600; }

input, select, textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  padding: 9px 12px;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-ring);
}
textarea {
  min-height: 100%;
  resize: none;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.6;
}

/* ---------- 登录 ---------- */
.login-view {
  position: relative;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  overflow: hidden;
  background: radial-gradient(1200px 600px at 80% -10%, #6366f1 0%, transparent 55%),
              radial-gradient(900px 500px at -10% 110%, #0ea5e9 0%, transparent 50%),
              #0b1020;
}
.login-decor {
  position: absolute;
  inset: 0;
  background-image: linear-gradient(rgba(255,255,255,.04) 1px, transparent 1px),
                    linear-gradient(90deg, rgba(255,255,255,.04) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(700px 500px at 50% 40%, #000, transparent 80%);
}
.login-panel {
  position: relative;
  width: min(420px, 100%);
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 20px;
  background: rgba(255,255,255,.96);
  padding: 32px;
  box-shadow: var(--shadow-lg);
  display: grid;
  gap: 16px;
  animation: rise .4s ease;
}
.login-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 6px; }
.login-brand h1 { margin: 0; font-size: 21px; }
.login-brand p { margin: 2px 0 0; color: var(--text-faint); font-size: 12px; letter-spacing: .3px; }
.login-logo {
  display: grid;
  place-items: center;
  width: 48px; height: 48px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--primary), #6366f1);
  color: #fff;
  box-shadow: 0 8px 20px var(--primary-ring);
}
.login-logo .icon { width: 26px; height: 26px; fill: currentColor; stroke: none; }
.login-logo.sm { width: 40px; height: 40px; border-radius: 12px; }
.login-logo.sm .icon { width: 22px; height: 22px; }
.error { min-height: 18px; margin: 0; color: var(--danger); font-size: 13px; }

@keyframes rise { from { opacity: 0; transform: translateY(10px); } }

/* ---------- 主布局 ---------- */
.main-view { min-height: 100vh; display: grid; grid-template-columns: 248px 1fr; }

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 20px 14px;
  background: linear-gradient(180deg, #141a2e, #0d1322);
  color: #e6e9f5;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px; }
.sidebar-brand h1 { margin: 0; font-size: 16px; }
.sidebar-brand p { margin: 3px 0 0; color: #8b93ad; font-size: 12px; }
.sidebar nav { display: flex; flex-direction: column; gap: 4px; }
.nav-button {
  display: flex;
  align-items: center;
  gap: 11px;
  height: 42px;
  padding: 0 12px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: #aeb6cf;
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.nav-button .icon { width: 17px; height: 17px; opacity: .85; }
.nav-button:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-button.active { background: var(--primary); color: #fff; font-weight: 600; box-shadow: 0 6px 16px rgba(79,70,229,.4); }
.nav-button.active .icon { opacity: 1; }
#logoutBtn { margin-top: auto; }

.content { min-width: 0; padding: 28px 32px 56px; }
.tab { display: grid; gap: 22px; animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head h2 { margin: 0; font-size: 23px; letter-spacing: -.3px; }
.head-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-faint);
  transition: border-color .15s, box-shadow .15s;
}
.search:focus-within { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-ring); }
.search .icon { width: 16px; height: 16px; }
.search input { border: none; min-height: 38px; padding: 0; width: 220px; }
.search input:focus { box-shadow: none; }

/* ---------- 卡片 ---------- */
.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.card-head { padding: 16px 18px; border-bottom: 1px solid var(--border); }
.card-head h3 { margin: 0; font-size: 15px; }

/* ---------- 统计卡片 ---------- */
.stats-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 14px; }
.stat-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: transform .15s, box-shadow .15s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat-ic { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; flex: none; }
.stat-ic .icon { width: 21px; height: 21px; }
.stat-meta { min-width: 0; }
.stat-meta > span { display: block; color: var(--text-soft); font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-meta strong { display: block; margin-top: 2px; font-size: 24px; letter-spacing: -.5px; }

.tone-indigo { background: var(--primary-soft); color: var(--primary); }
.tone-green { background: var(--success-soft); color: var(--success); }
.tone-amber { background: var(--warning-soft); color: var(--warning); }
.tone-blue { background: var(--info-soft); color: var(--info); }
.tone-red { background: var(--danger-soft); color: var(--danger); }
.tone-slate { background: #eef1f6; color: #475569; }

/* ---------- 图表(横向条) ---------- */
.split { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.chart-block { padding: 16px 18px; display: grid; gap: 14px; min-height: 120px; }
.chart-row { display: grid; gap: 6px; }
.chart-row .chart-label { display: flex; justify-content: space-between; font-size: 13px; }
.chart-row .chart-label b { font-weight: 700; }
.chart-track { height: 8px; border-radius: 999px; background: #eef0f6; overflow: hidden; }
.chart-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--primary), #818cf8); transition: width .5s ease; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; overflow-y: visible; }
table { width: 100%; border-collapse: collapse; min-width: 720px; }
.battery-table { min-width: 940px; }
thead th {
  position: sticky;
  top: 0;
  background: #fafbfd;
  color: var(--text-soft);
  font-weight: 600;
  font-size: 12.5px;
  text-align: left;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td { padding: 11px 16px; border-bottom: 1px solid var(--border); font-size: 13.5px; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: #fafbff; }
.cell-strong { font-weight: 600; }
.cell-actions { display: flex; gap: 5px; justify-content: flex-end; flex-wrap: nowrap; }
.more-menu {
  position: fixed;
  z-index: 20;
  min-width: 108px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-md);
  display: grid;
  gap: 4px;
}
.more-item {
  border: 0;
  background: transparent;
  color: var(--text);
  border-radius: 6px;
  padding: 7px 9px;
  text-align: left;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}
.more-item:hover { background: #f5f7fb; }
.more-item.danger { color: var(--danger); }
.battery-table th,
.battery-table td { text-align: center; }
.battery-table .cell-actions { justify-content: center; }
.battery-table .power,
.battery-table .loc-link { justify-content: center; margin: 0 auto; }
/* 状态/厂家/时间等短列保持单行，避免被挤成竖排 */
.battery-table td .badge,
.battery-table .time-cell { white-space: nowrap; }
.battery-table .time-cell { font-variant-numeric: tabular-nums; color: var(--text-soft); }
.empty { padding: 48px; text-align: center; color: var(--text-faint); font-size: 14px; }

/* ---------- 徽章 ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  line-height: 24px;
  background: var(--primary-soft);
  color: var(--primary);
  white-space: nowrap;     /* 避免短状态文字被挤成竖排 */
  flex: none;
}
.badge.ok { background: var(--success-soft); color: var(--success); }
.badge.warn { background: var(--warning-soft); color: var(--warning); }
.badge.off { background: #eef1f6; color: #64748b; }
.badge.info { background: var(--info-soft); color: var(--info); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* ---------- 电量 ---------- */
.power { display: flex; align-items: center; gap: 9px; min-width: 110px; }
.power-bar { position: relative; flex: 1; height: 7px; border-radius: 999px; background: #eef0f6; overflow: hidden; }
.power-fill { height: 100%; border-radius: 999px; transition: width .4s ease; }
.power-fill.high { background: var(--success); }
.power-fill.mid { background: var(--warning); }
.power-fill.low { background: var(--danger); }
.power-val { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 13px; min-width: 34px; }

.loc-link { color: var(--primary); display: inline-flex; align-items: center; gap: 4px; }
.loc-link .icon { width: 14px; height: 14px; }

/* ---------- 分页 ---------- */
.pager { display: flex; align-items: center; justify-content: flex-end; gap: 14px; flex-wrap: wrap; }
.pager .page-info { color: var(--text-soft); font-size: 13px; margin-right: auto; }
.pager-nav { display: flex; align-items: center; gap: 6px; }
.pager-num, .pager-btn {
  min-width: 34px;
  height: 34px;
  padding: 0 9px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
}
.pager-num:hover:not(.active),
.pager-btn:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.pager-num.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 4px 12px var(--primary-ring);
  cursor: default;
}
.pager-btn:disabled { opacity: .45; cursor: not-allowed; }
.pager-btn svg { width: 16px; height: 16px; }
.pager-gap { min-width: 22px; text-align: center; color: var(--text-faint); user-select: none; }

/* ---------- 调试台 ---------- */
.raw-layout { display: grid; grid-template-columns: minmax(300px, 460px) 1fr; gap: 18px; height: calc(100vh - 200px); min-height: 420px; }
.raw-pane { display: flex; flex-direction: column; overflow: hidden; }
.raw-pane .card-head { flex: none; }
.raw-pane textarea { flex: 1; border: 0; border-radius: 0 0 var(--radius) var(--radius); }
.raw-pane textarea:focus { box-shadow: none; }
.raw-box {
  flex: 1;
  overflow: auto;
  margin: 0;
  padding: 16px 18px;
  color: #334155;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ---------- 抽屉 ---------- */
.scrim {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .42);
  backdrop-filter: blur(2px);
  z-index: 40;
  animation: fade .2s ease;
}
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: min(440px, 100vw);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  z-index: 50;
  display: flex;
  flex-direction: column;
  animation: slideIn .26s cubic-bezier(.2,.8,.2,1);
}
.drawer.wide { width: min(560px, 100vw); }
@keyframes slideIn { from { transform: translateX(100%); } }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.drawer-head h3 { margin: 0; font-size: 17px; }
.drawer-body { padding: 22px; overflow: auto; display: grid; gap: 16px; align-content: start; }
.drawer-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.drawer-actions .btn { flex: 1; }

/* ---------- 电池详情页 ---------- */
.detail-page { display: grid; gap: 28px; animation: fade .25s ease; }
.detail-topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  margin: -22px calc(clamp(18px, 3.2vw, 48px) * -1) 0;
  padding: 0 clamp(18px, 3.2vw, 48px);
  border-bottom: 1px solid #d8dde5;
  background: #f7f9fb;
}
.detail-title { display: flex; align-items: center; gap: 10px; }
.detail-title h2 { margin: 0; font-size: 18px; font-weight: 800; color: #111827; }
.detail-actions { display: flex; align-items: center; gap: 8px; }
.detail-icon-btn {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #111827;
  cursor: pointer;
}
.detail-icon-btn:hover { background: #e9edf3; }
.detail-icon-btn .icon { width: 18px; height: 18px; }
.detail-section-block { display: grid; gap: 14px; }
.detail-section-block h3 { margin: 0; font-size: 18px; font-weight: 800; color: #111827; }
.detail-info-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
  align-items: start;
}
.detail-status-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.detail-status,
.tech-card {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 66px;
  padding: 14px 16px;
  border: 1px solid #cdd3dc;
  border-radius: 4px;
  background: #fff;
}
.detail-status-ic {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: #dbe6ff;
  color: #0b5bd3;
  flex: none;
}
.detail-status.net-good .detail-status-ic { background: #e6f4ea; color: #137333; }
.detail-status.net-normal .detail-status-ic { background: var(--warning-soft); color: var(--warning); }
.detail-status.net-bad .detail-status-ic,
.detail-status.net-unknown .detail-status-ic { background: #eef1f6; color: #64748b; }
.detail-status.power .detail-status-ic { background: #dfe6ff; color: #111827; }
.detail-status.refresh .detail-status-ic { background: #eef2ff; color: #4f46e5; }
.detail-status small { display: block; color: #4b5563; font-size: 12px; font-weight: 700; }
.detail-status strong { display: block; margin-top: 2px; color: #111827; font-size: 18px; line-height: 1.15; }
.tech-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.tech-card { display: block; min-height: 70px; }
.tech-card > span { display: inline-flex; align-items: center; gap: 7px; color: #4b5563; font-size: 12px; font-weight: 700; }
.tech-card .icon { width: 15px; height: 15px; }
.tech-card strong { display: block; margin-top: 6px; color: #111827; font-size: 18px; line-height: 1.2; }
.detail-table-wrap {
  overflow: hidden;
  border: 1px solid #cdd3dc;
  border-radius: 4px;
  background: #fff;
}
.detail-table { width: 100%; min-width: 0; border-collapse: collapse; }
.detail-table th,
.detail-table td {
  padding: 12px 16px;
  border-bottom: 1px solid #d8dde5;
  font-size: 13px;
  text-align: left;
}
.detail-table tr:last-child th,
.detail-table tr:last-child td { border-bottom: 0; }
.detail-table th { width: 34%; color: #374151; background: #f2f4f6; font-weight: 600; }
.detail-table td { color: #111827; word-break: break-word; overflow-wrap: anywhere; }
.detail-table-empty { text-align: center; color: #7c8797; }

/* 原始数据 */
.detail-raw-wrap { padding: 14px 18px; display: grid; gap: 10px; }
.detail-raw-box summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--text-soft); padding: 9px 12px; border-radius: 9px; background: #f5f7fb; list-style: none; transition: background .15s; }
.detail-raw-box summary::-webkit-details-marker { display: none; }
.detail-raw-box summary::before { content: "▸"; display: inline-block; margin-right: 8px; transition: transform .15s; }
.detail-raw-box[open] summary::before { transform: rotate(90deg); }
.detail-raw-box summary:hover { background: #eef1f6; color: var(--text); }
.detail-raw-box[open] summary { margin-bottom: 8px; }
.detail-raw { margin: 0; padding: 14px; border-radius: var(--radius-sm); background: #0f172a; color: #cbd5e1; font-family: var(--mono); font-size: 12px; line-height: 1.6; white-space: pre-wrap; word-break: break-word; max-height: 320px; overflow: auto; }
.detail-empty { grid-column: 1 / -1; padding: 22px 18px; text-align: center; color: var(--text-faint); font-size: 13px; }

/* 详情页全屏：隐藏左侧导航，内容铺满 */
.main-view.detail-mode { grid-template-columns: 1fr; }
.main-view.detail-mode .sidebar { display: none; }
.main-view.detail-mode .content {
  min-height: 100vh;
  padding: 22px clamp(18px, 3.2vw, 48px) 48px;
  background: #f7f9fb;
}
.detail-page { width: 100%; max-width: 1280px; margin: 0 auto; }
.detail-status-card {
  min-height: calc(100vh - 120px);
  display: grid;
  place-items: center;
  align-content: center;
  gap: 12px;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: rgba(255, 255, 255, .82);
  box-shadow: var(--shadow);
}
.detail-status-card h2 { margin: 0; font-size: 24px; }
.detail-status-card p { margin: 0; color: var(--text-soft); font-family: var(--mono); }
.detail-status-card strong { color: var(--danger); }
.detail-status-card.error-card .icon { width: 36px; height: 36px; color: var(--danger); }

/* ---------- 电池轨迹 ---------- */
.track-card {
  overflow: hidden;
  border: 1px solid #cdd3dc;
  border-radius: 4px;
  background: #fff;
}
.track-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid #d8dde5;
}
.track-meta { color: #64748b; font-size: 12px; font-weight: 600; }
.track-amap { color: #4f46e5; font-size: 13px; font-weight: 700; text-decoration: none; white-space: nowrap; }
.track-amap:hover { text-decoration: underline; }
.track-body { position: relative; padding: 0; }

.track-toolbar {
  position: absolute;
  left: 14px;
  right: 14px;
  top: 14px;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.track-range {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border: 1px solid #d8dde5;
  border-radius: 4px;
  background: rgba(255,255,255,.92);
}
.track-range-btn {
  min-height: 28px;
  padding: 0 9px;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: #64748b;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.track-range-btn:hover,
.track-range-btn.active {
  background: #4f46e5;
  color: #fff;
}
.track-legend { margin-left: auto; }
.track-tools { display: inline-flex; align-items: center; gap: 6px; }
.map-ctl {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid #d8dde5;
  border-radius: 3px;
  background: rgba(255,255,255,.92);
  color: #111827;
  font-size: 18px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
}
.map-ctl:hover { background: #eef2ff; border-color: #b9c2ff; color: #4f46e5; }
.track-legend { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-soft); }
.track-legend span:not(.track-count) { display: none; }
.track-count {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid #d8dde5;
  border-radius: 3px;
  background: rgba(255,255,255,.9);
  color: #111827;
  font-size: 12px;
  font-weight: 700;
}
.track-legend .lg { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.lg-start { background: #16a34a; box-shadow: 0 0 0 3px rgba(22, 163, 74, .18); }
.lg-end { background: #dc2626; box-shadow: 0 0 0 3px rgba(220, 38, 38, .18); }

.track-map {
  position: relative;
  height: 420px;
  overflow: hidden;
  background: #dfe7f2;
  cursor: zoom-in;
  touch-action: none;
}
.map-tiles { position: absolute; inset: 0; }
.map-tile { position: absolute; width: 256px; height: 256px; user-select: none; pointer-events: none; }
.track-overlay { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }
.map-watermark {
  position: absolute;
  right: 10px;
  bottom: 8px;
  padding: 3px 7px;
  border-radius: 7px;
  background: rgba(255,255,255,.78);
  color: #64748b;
  font-size: 11px;
}
.track-map::after {
  content: "实时追踪中";
  position: absolute;
  right: 14px;
  top: 56px;
  z-index: 2;
  padding: 7px 10px;
  border: 1px solid #d8dde5;
  border-radius: 2px;
  background: rgba(255,255,255,.92);
  color: #111827;
  font-size: 12px;
  font-weight: 700;
}
.map-chip {
  position: absolute;
  z-index: 2;
  transform: translate(-50%, -50%);
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 2px solid #fff;
  border-radius: 50%;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  box-shadow: 0 6px 16px rgba(15, 23, 42, .22);
  pointer-events: none;
}
.map-chip-start { background: #16a34a; }
.map-chip-end { background: #ef4444; }
.map-chip-mid { background: #2563eb; }
.track-bg-path { fill: none; stroke: rgba(15, 23, 42, .28); stroke-width: 14; stroke-linecap: round; stroke-linejoin: round; }
.track-path {
  fill: none;
  stroke: #155bd5;
  stroke-width: 8;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: url(#trackGlow);
}
.track-path.is-playing { animation: trackPulse 1s ease-in-out infinite; }
.track-arrow {
  fill: none;
  stroke: #0f46b7;
  stroke-width: 5;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 2px 5px rgba(15, 70, 183, .35));
}
.track-start { fill: #16a34a; stroke: #fff; stroke-width: 3; }
.track-end { fill: #dc2626; stroke: #fff; stroke-width: 3; }
.track-marker { filter: drop-shadow(0 3px 6px rgba(79, 70, 229, .55)); }
.track-marker circle { fill: #fff; stroke: #155bd5; stroke-width: 3; }
.track-marker .track-marker-pulse { fill: rgba(21, 91, 213, .22); stroke: none; }
.track-marker.is-playing .track-marker-pulse { animation: markerPulse 1s ease-in-out infinite; }
.track-hint { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); font-size: 12px; color: var(--text-soft); background: rgba(255, 255, 255, .82); padding: 4px 12px; border-radius: 999px; box-shadow: var(--shadow-sm); }

.track-state { display: grid; justify-items: center; align-content: center; gap: 8px; min-height: 220px; color: var(--text-faint); text-align: center; }
.track-state .icon { width: 30px; height: 30px; opacity: .5; }
.track-state p { margin: 0; font-size: 14px; font-weight: 600; color: var(--text-soft); }
.track-state span { font-size: 12.5px; }
.track-state.err p { color: var(--danger); }
.track-spinner { width: 22px; height: 22px; border: 3px solid var(--border-strong); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes markerPulse { 50% { transform: scale(1.35); opacity: .4; } }
@keyframes trackPulse { 50% { stroke-width: 10; } }

/* ---------- 确认弹窗 ---------- */
.modal-scrim { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 20px; background: rgba(15,23,42,.5); backdrop-filter: blur(2px); animation: fade .2s ease; }
.modal { width: min(400px, 100%); background: var(--surface); border-radius: 18px; padding: 26px; text-align: center; box-shadow: var(--shadow-lg); animation: rise .25s ease; }
.modal-icon { display: grid; place-items: center; width: 54px; height: 54px; margin: 0 auto 14px; border-radius: 50%; background: var(--danger-soft); color: var(--danger); }
.modal-icon .icon { width: 26px; height: 26px; }
.modal h3 { margin: 0 0 6px; font-size: 18px; }
.modal p { margin: 0; }
.modal-actions { display: flex; gap: 10px; margin-top: 22px; }
.modal-actions .btn { flex: 1; }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  max-width: min(440px, calc(100vw - 40px));
  border-radius: 12px;
  background: #111827;
  color: #fff;
  padding: 13px 18px;
  box-shadow: var(--shadow-lg);
  font-size: 13.5px;
  font-weight: 500;
  z-index: 70;
  animation: toastIn .3s cubic-bezier(.2,.8,.2,1);
}
.toast.ok { background: #14532d; }
.toast.err { background: #7f1d1d; }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 12px); } }

/* ---------- 响应式 ---------- */
@media (max-width: 1320px) { .stats-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 1024px) {
  .main-view { grid-template-columns: 1fr; }
  .sidebar { position: sticky; top: 0; height: auto; flex-direction: row; align-items: center; gap: 16px; padding: 12px 16px; }
  .sidebar-brand { flex: 1; }
  .sidebar nav { grid-auto-flow: column; grid-template-columns: repeat(4, auto); flex: none; gap: 4px; }
  .nav-button { min-height: 40px; padding: 0 11px; }
  .nav-button span:not(.icon) { display: none; }
  #logoutBtn { padding: 0 12px; }
  #logoutBtn span { display: none; }
  .content { padding: 20px; }
  .split { grid-template-columns: 1fr; }
  .raw-layout { grid-template-columns: 1fr; height: auto; }
  .raw-pane textarea { min-height: 280px; }
  .raw-box { min-height: 280px; }
  .detail-info-row { grid-template-columns: 1fr; }
  .detail-status-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tech-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .search input { width: 100%; }
  .search { flex: 1; }
  .main-view.detail-mode .content { padding: 16px 14px 32px; }
  .detail-topbar { margin: -16px -14px 0; padding: 0 14px; }
  .tech-grid { grid-template-columns: 1fr; }
  .detail-status-grid { grid-template-columns: 1fr; }
  .detail-table th,
  .detail-table td { padding: 10px 12px; }
  .track-map { height: 340px; }
  .track-toolbar {
    left: 10px;
    right: 10px;
    top: 10px;
    justify-content: space-between;
  }
  .track-range { max-width: calc(100vw - 150px); overflow-x: auto; }
  .track-range-btn { flex: none; padding: 0 8px; }
  .track-count { display: none; }
  .track-map::after { top: 50px; right: 10px; }
}
