/* ============================================================
   Keep 校园跑 · 设计系统 v2（深色优先，跟随系统浅色）
   8px 栅格 / 12px 圆角 / 0 1px 3px rgba(0,0,0,.3) 阴影
   零外部依赖：无字体、无图标库、无 CDN
   ============================================================ */

:root {
  color-scheme: dark;

  --bg: #0d1117;
  --bg-deep: #010409;
  --card: #161b22;
  --card-2: #1b222c;
  --card-3: #21262d;
  --border: #30363d;
  --border-soft: #21262d;

  --text: #e6edf3;
  --text-2: #c9d1d9;
  --muted: #8b949e;
  --faint: #6e7681;

  --primary: #58a6ff;
  --primary-2: #1f6feb;
  --primary-soft: rgba(88, 166, 255, .14);
  --primary-line: rgba(88, 166, 255, .4);

  --green: #3fb950;
  --green-soft: rgba(63, 185, 80, .14);
  --red: #f85149;
  --red-soft: rgba(248, 81, 73, .14);
  --orange: #d29922;
  --orange-soft: rgba(210, 153, 34, .14);
  --cyan: #39c5cf;
  --cyan-soft: rgba(57, 197, 207, .14);
  --purple: #bc8cff;
  --purple-soft: rgba(188, 140, 255, .14);

  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --shadow: 0 1px 3px rgba(0, 0, 0, .3);
  --shadow-pop: 0 8px 28px rgba(0, 0, 0, .55);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --sidebar-w: 220px;
  --topbar-h: 56px;
  --tabbar-h: 60px;
}

@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg: #f6f8fa;
    --bg-deep: #eaeef2;
    --card: #ffffff;
    --card-2: #f6f8fa;
    --card-3: #eef1f4;
    --border: #d0d7de;
    --border-soft: #e4e8ec;
    --text: #1f2328;
    --text-2: #32383f;
    --muted: #656d76;
    --faint: #8c959f;
    --primary: #0969da;
    --primary-2: #0550ae;
    --primary-soft: rgba(9, 105, 218, .1);
    --primary-line: rgba(9, 105, 218, .35);
    --green: #1a7f37;
    --green-soft: rgba(26, 127, 55, .1);
    --red: #cf222e;
    --red-soft: rgba(207, 34, 46, .1);
    --orange: #9a6700;
    --orange-soft: rgba(154, 103, 0, .1);
    --cyan: #0e7490;
    --cyan-soft: rgba(14, 116, 144, .1);
    --purple: #8250df;
    --purple-soft: rgba(130, 80, 223, .1);
    --shadow: 0 1px 3px rgba(31, 35, 40, .12);
    --shadow-pop: 0 8px 28px rgba(31, 35, 40, .2);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 650; line-height: 1.3; }
canvas { display: block; }
.hide { display: none !important; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.tiny { font-size: 12px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.center { text-align: center; }

/* ---------------- 布局壳 ---------------- */

.app { min-height: 100vh; }

.sidebar {
  position: fixed;
  z-index: 40;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  background: var(--card);
  border-right: 1px solid var(--border);
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  height: var(--topbar-h);
  padding: 0 16px;
  border-bottom: 1px solid var(--border-soft);
  flex: 0 0 auto;
}
.sidebar-brand .logo {
  width: 28px; height: 28px;
  border-radius: 9px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--primary), #2ea043);
  color: #fff;
  font-weight: 800;
  font-size: 14px;
  flex: 0 0 auto;
}
.sidebar-brand .name { font-size: 14px; font-weight: 700; letter-spacing: .01em; }
.sidebar-brand .tag {
  font-size: 10px;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0 6px;
  margin-left: 2px;
}

.sidebar-nav { flex: 1 1 auto; overflow-y: auto; padding: 10px 8px; }
.nav-group-title {
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--faint);
  padding: 8px 10px 6px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  margin-bottom: 2px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 14px;
  font-weight: 500;
  transition: background .12s, color .12s;
}
.nav-item:hover { background: var(--card-3); text-decoration: none; color: var(--text); }
.nav-item.active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 650;
}
.nav-item .ico { width: 18px; height: 18px; flex: 0 0 auto; opacity: .9; }
.nav-item .ico svg { width: 18px; height: 18px; display: block; }

.sidebar-foot {
  flex: 0 0 auto;
  border-top: 1px solid var(--border-soft);
  padding: 10px 8px;
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
}
.sidebar-user .avatar, .avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--primary-2), var(--purple));
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  flex: 0 0 auto;
}
.sidebar-user .who { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.sidebar-user .who .n {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.25;
}
.sidebar-user .who .money { font-size: 11px; color: var(--muted); font-family: var(--mono); line-height: 1.2; }
.logout-btn svg { width: 16px; height: 16px; flex: 0 0 auto; }
.logout-btn {
  width: 100%;
  margin-top: 6px;
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  text-align: left;
}
.logout-btn:hover { background: var(--red-soft); color: var(--red); }

.main {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 24px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.5) blur(10px);
  border-bottom: 1px solid var(--border);
}
@supports not (background: color-mix(in srgb, red 50%, blue)) {
  .topbar { background: var(--bg); }
}
.topbar h1 { font-size: 16px; font-weight: 650; }
.topbar .crumbs { color: var(--muted); font-size: 12px; }
.topbar-spacer { flex: 1 1 auto; }
.topbar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}
.topbar-user .money {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 650;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--card-2);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.topbar-user .money.low { color: var(--red); border-color: var(--red); background: var(--red-soft); }

.content {
  flex: 1 1 auto;
  width: 100%;
  max-width: 1600px;
  padding: 18px;
  margin: 0 auto;
}

/* ---------------- Tab Bar（移动端） ---------------- */

.tabbar {
  display: none;
  position: fixed;
  z-index: 45;
  left: 0; right: 0; bottom: 0;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--card);
  border-top: 1px solid var(--border);
}
.tab-item {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 550;
}
.tab-item:hover { text-decoration: none; }
.tab-item .ico svg { width: 20px; height: 20px; display: block; }
.tab-item.active { color: var(--primary); }

/* ---------------- 卡片 ---------------- */

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card + .card { margin-top: 10px; }
.card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-soft);
}
.card-head h2 { font-size: 14px; font-weight: 650; }
.card-head .sub { font-size: 12px; color: var(--muted); }
.card-head .spacer { flex: 1 1 auto; }
.card-body { padding: 14px 18px; }
.card-body.tight { padding: 8px 14px; }
.card-foot {
  padding: 12px 16px;
  border-top: 1px solid var(--border-soft);
  background: var(--card-2);
}

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > .grow { flex: 1 1 0; min-width: 0; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.wrap-row { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------------- 统计卡 ---------------- */

.stat {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  position: relative;
  overflow: hidden;
}
.stat .label { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.stat .value {
  font-family: var(--mono);
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -.01em;
  margin-top: 6px;
  line-height: 1.15;
}
.stat .value .unit { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 4px; }
.stat .foot { font-size: 12px; color: var(--muted); margin-top: 6px; }
.stat.accent { border-color: var(--primary-line); background: linear-gradient(160deg, var(--primary-soft), var(--card) 55%); }
.stat.accent .value { color: var(--primary); }

/* ---------------- 表单 ---------------- */

.field { margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
.field label, .field-label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 6px;
}
.field .req { color: var(--red); margin-left: 2px; }
.input, .select, textarea.input {
  width: 100%;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color .14s, box-shadow .14s;
  -webkit-appearance: none;
  appearance: none;
}
.input::placeholder { color: var(--faint); }
.input:focus, .select:focus, textarea.input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.input:disabled, .select:disabled { opacity: .55; cursor: not-allowed; }
.input.invalid, .select.invalid { border-color: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
.select {
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%238b949e' d='M1.4 0 6 4.6 10.6 0 12 1.4 6 7.4 0 1.4z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 34px;
}
textarea.input { min-height: 80px; resize: vertical; }
.hint { font-size: 13px; line-height: 1.5; color: var(--muted); margin-top: 4px; }
.err { font-size: 12px; color: var(--red); margin-top: 5px; min-height: 0; }
.pw-wrap { position: relative; }
.pw-wrap .input { padding-right: 44px; }
.pw-toggle {
  position: absolute;
  right: 4px; top: 50%;
  transform: translateY(-50%);
  width: 36px; height: 32px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
}
.pw-toggle:hover { background: var(--card-3); color: var(--text); }

/* ---------------- 按钮 ---------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--card-3);
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background .14s, border-color .14s, transform .06s, opacity .14s;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { background: var(--card-2); border-color: var(--faint); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[disabled] { opacity: .45; cursor: not-allowed; transform: none; }
.btn-primary {
  background: var(--primary-2);
  border-color: var(--primary-2);
  color: #fff;
}
.btn-primary:hover { background: var(--primary); border-color: var(--primary); }
.btn-success { background: var(--green); border-color: var(--green); color: #04180a; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--card-3); color: var(--text); border-color: transparent; }
.btn-danger { color: var(--red); border-color: rgba(248, 81, 73, .4); background: transparent; }
.btn-danger:hover { background: var(--red-soft); border-color: var(--red); }
.btn-sm { min-height: 30px; padding: 4px 10px; font-size: 12.5px; border-radius: 7px; }
.btn-block { width: 100%; }
.btn-icon {
  width: 32px; height: 32px;
  min-height: 32px;
  padding: 0;
  display: grid; place-items: center;
  border-radius: 7px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  cursor: pointer;
}
.btn-icon:hover { color: var(--text); background: var(--card-3); }

/* ---------------- 徽章 / 标签 ---------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 650;
  line-height: 1.75;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge .dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.badge-gray { color: var(--muted); background: rgba(139, 148, 158, .14); border-color: rgba(139, 148, 158, .3); }
.badge-blue { color: var(--primary); background: var(--primary-soft); border-color: var(--primary-line); }
.badge-green { color: var(--green); background: var(--green-soft); border-color: rgba(63, 185, 80, .35); }
.badge-cyan { color: var(--cyan); background: var(--cyan-soft); border-color: rgba(57, 197, 207, .35); }
.badge-deepgreen { color: #2ea043; background: rgba(46, 160, 67, .16); border-color: rgba(46, 160, 67, .38); }
.badge-red { color: var(--red); background: var(--red-soft); border-color: rgba(248, 81, 73, .35); }
.badge-orange { color: var(--orange); background: var(--orange-soft); border-color: rgba(210, 153, 34, .35); }
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  color: var(--muted);
  background: var(--card-2);
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  padding: 1px 7px;
  font-family: var(--mono);
}

/* ---------------- 表格（斑马纹 + hover） ---------------- */

.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 560px;
}
.table th, .table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
}
.table th {
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--card-2);
  position: sticky;
  top: 0;
  white-space: nowrap;
}
.table tbody tr:nth-child(even) { background: rgba(255, 255, 255, .018); }
@media (prefers-color-scheme: light) {
  .table tbody tr:nth-child(even) { background: rgba(31, 35, 40, .035); }
}
.table tbody tr:hover { background: var(--primary-soft); }
.table td.num { font-family: var(--mono); font-variant-numeric: tabular-nums; text-align: right; }
.table td.mono { font-family: var(--mono); }
.table .delta-pos { color: var(--green); }
.table .delta-neg { color: var(--red); }

/* ---------------- 空态 / 骨架 / loading ---------------- */

.empty {
  text-align: center;
  padding: 44px 16px;
  color: var(--muted);
}
.empty .icon {
  width: 44px; height: 44px;
  margin: 0 auto 12px;
  border-radius: 12px;
  display: grid; place-items: center;
  background: var(--card-2);
  border: 1px solid var(--border);
  color: var(--faint);
}
.empty .icon svg { width: 22px; height: 22px; }
.empty .title { color: var(--text); font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.empty .desc { font-size: 12.5px; margin-bottom: 14px; }

.skeleton {
  height: 76px;
  border-radius: var(--radius);
  background: linear-gradient(100deg, var(--card) 30%, var(--card-3) 50%, var(--card) 70%);
  background-size: 220% 100%;
  animation: sk 1.2s linear infinite;
  border: 1px solid var(--border);
  margin-bottom: 12px;
}
@keyframes sk { 0% { background-position: 180% 0; } 100% { background-position: -60% 0; } }

.spinner {
  display: inline-block;
  width: 13px; height: 13px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: sp .7s linear infinite;
  vertical-align: -2px;
}
@keyframes sp { to { transform: rotate(360deg); } }

/* ---------------- 提示条 ---------------- */

.banner {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  border: 1px solid;
  margin-bottom: 14px;
}
.banner-info { color: var(--primary); background: var(--primary-soft); border-color: var(--primary-line); }
.banner-warn { color: var(--orange); background: var(--orange-soft); border-color: rgba(210, 153, 34, .35); }
.banner-err { color: var(--red); background: var(--red-soft); border-color: rgba(248, 81, 73, .35); }
.banner .x {
  margin-left: auto;
  border: 0; background: transparent; color: inherit;
  cursor: pointer; font-size: 14px; padding: 0 2px; line-height: 1;
}

/* ---------------- 时段行 ---------------- */

.task-list { display: flex; flex-direction: column; gap: 8px; }
.task-item { display: flex; flex-direction: column; gap: 4px; }
.task-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
}
.task-row.invalid { border-color: var(--red); background: var(--red-soft); }
.task-row .idx {
  flex: 0 0 auto;
  width: 22px; height: 22px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--card-3);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  font-family: var(--mono);
}
.task-row .input { min-height: 36px; padding: 5px 9px; font-size: 13.5px; background: var(--card); }
.task-row .task-date { flex: 1.1 1 0; min-width: 0; }
.task-row .task-time { flex: 0 0 94px; }
.task-row .task-err { color: var(--red); font-size: 11.5px; padding-left: 3px; }

/* ---------------- 跑道选择 / 身份卡 ---------------- */

.identity {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid rgba(63, 185, 80, .35);
  background: linear-gradient(120deg, var(--green-soft), transparent 70%);
  margin-bottom: 14px;
}
.identity .avatar {
  width: 38px; height: 38px;
  background: linear-gradient(135deg, var(--green), var(--cyan));
  font-size: 15px;
}
.identity .who { min-width: 0; flex: 1 1 auto; display: flex; flex-direction: column; gap: 1px; }
.identity .who .n { font-size: 14px; font-weight: 650; line-height: 1.3; }
.identity .who .m { font-size: 12px; color: var(--muted); font-family: var(--mono); line-height: 1.3; }
.identity .meta { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

.track-list { display: grid; gap: 8px; }
.track-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  cursor: pointer;
  transition: border-color .14s, background .14s;
}
.track-item:hover { border-color: var(--faint); }
.track-item.active { border-color: var(--primary); background: var(--primary-soft); }
.track-item .radio {
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 2px solid var(--faint);
  flex: 0 0 auto;
  display: grid; place-items: center;
}
.track-item.active .radio { border-color: var(--primary); }
.track-item.active .radio::after {
  content: '';
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--primary);
}
.track-item .info { min-width: 0; flex: 1 1 auto; }
.track-item .t1 { font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.track-item .t2 { font-size: 11.5px; color: var(--muted); font-family: var(--mono); }

/* ---------------- 画布 ---------------- */

.canvas-wrap {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-deep);
  overflow: hidden;
}
.canvas-wrap canvas { width: 100%; height: 100%; }
.canvas-wrap .canvas-hint {
  position: absolute;
  left: 10px; top: 8px;
  font-size: 11px;
  font-family: var(--mono);
  color: var(--muted);
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  padding: 1px 7px;
  pointer-events: none;
}
.canvas-wrap .canvas-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--faint);
  font-size: 12.5px;
  pointer-events: none;
}

/* ---------------- 订单卡 ---------------- */

.order-list { display: grid; gap: 10px; }
.order-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  padding: 12px 14px;
  cursor: pointer;
  transition: border-color .14s, background .14s;
}
.order-card:hover { border-color: var(--primary-line); }
.order-card:active { background: var(--card-2); }
.order-top { display: flex; align-items: center; gap: 8px; }
.order-top .name { font-size: 14px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.order-top .spacer { flex: 1 1 auto; }
.order-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 3px 14px;
  margin-top: 7px;
  font-size: 12.5px;
  color: var(--muted);
}
.order-meta b { color: var(--text-2); font-weight: 600; font-family: var(--mono); }
.order-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 9px;
  padding-top: 8px;
  border-top: 1px dashed var(--border-soft);
  font-size: 11.5px;
  color: var(--faint);
  font-family: var(--mono);
}

/* ---------------- 抽屉 ---------------- */

.drawer-mask {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(1, 4, 9, .6);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}
.drawer-mask.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed;
  z-index: 71;
  top: 0; right: 0; bottom: 0;
  width: min(520px, 100%);
  display: flex;
  flex-direction: column;
  background: var(--card);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-pop);
  transform: translateX(102%);
  transition: transform .24s cubic-bezier(.32, .72, 0, 1);
}
.drawer.open { transform: none; }
.drawer-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-soft);
  flex: 0 0 auto;
}
.drawer-head h2 { font-size: 15px; flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drawer-body { flex: 1 1 auto; overflow-y: auto; padding: 16px; }
.drawer-foot {
  flex: 0 0 auto;
  display: flex;
  gap: 8px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border-soft);
  background: var(--card);
  flex-wrap: wrap;
}
.drawer-foot .btn { flex: 1 1 0; min-width: 92px; }

.kv { display: flex; gap: 10px; padding: 7px 0; border-bottom: 1px dashed var(--border-soft); font-size: 13px; }
.kv:last-child { border-bottom: 0; }
.kv .k { flex: 0 0 82px; color: var(--muted); font-size: 12.5px; }
.kv .v { flex: 1 1 auto; min-width: 0; word-break: break-all; }

.sub-list { display: flex; flex-direction: column; gap: 8px; }
.sub-item {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px 10px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card-2);
  font-size: 12.5px;
}
.sub-item .n { flex: 0 0 auto; min-width: 42px; font-weight: 700; font-size: 11.5px; color: var(--primary); font-family: var(--mono); }
.sub-item .t { flex: 1 1 auto; min-width: 0; font-family: var(--mono); font-size: 12.5px; }
.sub-item .m { flex: 1 1 100%; color: var(--muted); font-size: 11.5px; padding-left: 52px; word-break: break-all; }
.sub-item .m .meta-line {
  font-family: var(--mono);
  opacity: .9;
  display: block;
}

/* ---------------- Toast ---------------- */

.toast-host {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 95;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  width: min(420px, calc(100% - 24px));
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--card-3);
  color: var(--text);
  border: 1px solid var(--border);
  font-size: 13px;
  box-shadow: var(--shadow-pop);
  animation: toastIn .18s ease-out;
  word-break: break-word;
}
.toast.out { animation: toastOut .18s ease-in forwards; }
.toast .ico { flex: 0 0 auto; font-weight: 700; }
.toast-success { border-color: rgba(63, 185, 80, .45); }
.toast-success .ico { color: var(--green); }
.toast-error { border-color: rgba(248, 81, 73, .45); }
.toast-error .ico { color: var(--red); }
.toast-warn { border-color: rgba(210, 153, 34, .45); }
.toast-warn .ico { color: var(--orange); }
.toast-info .ico { color: var(--primary); }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(8px); } }

/* ---------------- 确认弹层 ---------------- */

.modal-mask {
  position: fixed;
  inset: 0;
  z-index: 85;
  background: rgba(1, 4, 9, .65);
  display: grid;
  place-items: center;
  padding: 20px;
}
.modal {
  width: min(380px, 100%);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop);
  padding: 20px;
  animation: popIn .16s cubic-bezier(.2, .9, .3, 1.15);
}
.modal h3 { font-size: 15px; margin-bottom: 8px; }
.modal p { margin: 0; color: var(--muted); font-size: 13px; white-space: pre-wrap; line-height: 1.6; }
.modal .ops { display: flex; gap: 8px; margin-top: 18px; }
.modal .ops .btn { flex: 1 1 0; }
@keyframes popIn { from { opacity: 0; transform: translateY(8px) scale(.97); } }

/* ---------------- 登录页 ---------------- */

.auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background:
    radial-gradient(900px 420px at 50% -10%, var(--primary-soft), transparent 70%),
    var(--bg);
}
.auth-card {
  width: min(400px, 100%);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop);
  padding: 28px 24px;
}
.auth-brand { text-align: center; margin-bottom: 22px; }
.auth-brand .logo {
  width: 52px; height: 52px;
  margin: 0 auto 12px;
  border-radius: 16px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--primary), #2ea043);
  color: #fff;
  font-size: 24px;
  font-weight: 800;
  box-shadow: 0 10px 26px rgba(31, 111, 235, .3);
}
.auth-brand h1 { font-size: 20px; margin-bottom: 5px; }
.auth-brand p { margin: 0; color: var(--muted); font-size: 12.5px; }

.tabs {
  display: flex;
  gap: 4px;
  padding: 3px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 18px;
}
.tabs button {
  flex: 1 1 0;
  min-height: 32px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.tabs button.active { background: var(--card-3); color: var(--text); box-shadow: var(--shadow); }

.auth-foot { text-align: center; font-size: 11.5px; color: var(--faint); margin-top: 18px; line-height: 1.8; }

/* ---------------- 图表容器 ---------------- */

.chart-box {
  position: relative;
  height: 160px;
  padding: 0;
}
.chart-box canvas { width: 100%; height: 100%; }

/* ---------------- 步进器 / 单选 / 复选 ---------------- */

.stepper {
  display: inline-flex;
  align-items: stretch;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--card-2);
}
.stepper button {
  width: 30px;
  border: 0;
  background: var(--card-3);
  color: var(--muted);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}
.stepper button:hover { color: var(--text); background: var(--border); }
.stepper .input {
  border: 0;
  border-radius: 0;
  width: 76px;
  text-align: center;
  min-height: 32px;
  font-family: var(--mono);
  font-size: 13.5px;
  background: transparent;
}
.stepper .input:focus { background: var(--card); outline: none; }

.radio, .chk {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-2);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.radio input, .chk input {
  width: 15px; height: 15px;
  accent-color: var(--primary);
  cursor: pointer;
  margin: 0;
}
.lbl-inline { font-size: 12px; color: var(--muted); white-space: nowrap; }
.hint.hint-warn { color: #d29922; }
.err.warn { color: #d29922; }

/* ---------------- 订单表格 ---------------- */

.table-wrap { overflow-x: auto; }
.order-table { min-width: 1160px; font-size: 12.5px; }
.order-table th { position: sticky; top: 0; z-index: 2; background: var(--card); white-space: nowrap; font-size: 11.5px; padding: 8px 10px; }
.order-table td { height: 40px; padding: 8px 10px; vertical-align: middle; }
.order-table tr[data-id] { cursor: pointer; }
.order-table tr[data-id]:hover { background: var(--primary-soft); }
.order-table .pwd-cell { font-family: var(--mono); letter-spacing: .4px; }

/* 跑步任务子页面 */
.modal-lg { width: min(1120px, 96vw); max-height: 88vh; display: flex; flex-direction: column; }
.modal-head { display: flex; align-items: center; gap: 8px; }
.modal-head h3 { margin: 0; }
.modal-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 0; border-bottom: 1px solid var(--border-soft); }
.modal-body { flex: 1 1 auto; overflow: auto; max-height: 58vh; padding: 6px 0; }
.modal-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding-top: 10px; border-top: 1px solid var(--border-soft); }
.task-table { min-width: 880px; }
.task-table td { height: 38px; }
.task-table .op-cell .btn { min-height: 26px; padding: 2px 9px; font-size: 11.5px; }
.btn-move { color: #d29922; border-color: #d29922; }
.btn-move:hover { background: rgba(210, 153, 34, .12); }
.st-done { color: #3fb950; font-weight: 600; }
.st-pending { color: #58a6ff; font-weight: 600; }
.st-failed { color: #f85149; font-weight: 600; }
.st-running { color: #d29922; font-weight: 600; }

/* 高德静态图 */
#map-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: fill; z-index: 1; }

/* ---------------- 跑区条 ---------------- */

.track-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(120deg, var(--primary-soft), transparent 62%);
  margin-bottom: 12px;
}
.track-bar .ico {
  flex: 0 0 auto;
  width: 40px; height: 40px;
  border-radius: 12px;
  display: grid; place-items: center;
  background: var(--card-3);
  font-size: 20px;
  line-height: 1;
}
.track-bar .main { flex: 1 1 auto; min-width: 0; margin-left: 0; min-height: 0; display: block; }
.track-bar .name {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.35;
}
.track-bar .meta {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 3px;
  font-size: 11.5px;
  color: var(--muted);
  font-family: var(--mono);
}
.track-bar .acts { flex: 0 0 auto; display: flex; align-items: center; gap: 8px; }

/* ---------------- 手绘工具条 ---------------- */

.draw-tools {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
  border: 1px dashed var(--primary-line);
  border-radius: var(--radius-sm);
  background: var(--primary-soft);
  margin-bottom: 10px;
}
.draw-tools .row { gap: 8px; }

/* 跑道列表：名称与坐标必须分两行，不能粘连 */
.track-item .info { display: flex; flex-direction: column; gap: 2px; }
.track-item .t1 { display: block; }
.track-item .t2 { display: block; }
.track-item .del-track {
  flex: 0 0 auto;
  border: 0;
  background: transparent;
  color: var(--faint);
  cursor: pointer;
  font-size: 14px;
  padding: 2px 4px;
  border-radius: 5px;
}
.track-item .del-track:hover { color: var(--red); background: var(--red-soft); }

/* ---------------- 密集表单（W 对接包风格） ---------------- */

.card-body.dense { padding: 10px 18px 12px; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 26px;
}
.form-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 4px 0;
  min-width: 0;
}
.form-row > label {
  flex: 0 0 88px;
  font-size: 12.5px;
  color: var(--muted);
  text-align: right;
  padding: 8px 10px 0 0;
  white-space: nowrap;
}
.form-ctl {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.form-ctl .input,
.form-ctl .select {
  min-height: 34px;
  padding: 5px 10px;
  font-size: 13.5px;
  background: var(--card-2);
}
.form-ctl .input:focus, .form-ctl .select:focus { background: var(--bg); }
.form-ctl .input.narrow { max-width: 130px; }
.stepper .input { min-height: 34px; }
.form-ctl .btn { min-height: 34px; }
.hint-inline { font-size: 11.5px; color: var(--faint); white-space: nowrap; }
.quick-set { display: flex; gap: 4px; }
.quick-set button {
  min-height: 30px;
  padding: 2px 9px;
  font-size: 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--card-2);
  color: var(--muted);
  cursor: pointer;
}
.quick-set button:hover { color: var(--text); border-color: var(--faint); }

.identity-line {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 8px 10px;
  margin-top: 6px;
  border: 1px solid rgba(63, 185, 80, .3);
  background: var(--green-soft);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
}
.identity-line .nick { font-weight: 650; color: var(--text); }
.identity-line .meta { color: var(--muted); font-family: var(--mono); font-size: 11.5px; }

/* ---------------- 分段选择（地图/跑道库/手动） ---------------- */

.seg {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.seg button {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 4px 12px;
  border-radius: 6px;
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.seg button:hover { color: var(--text); }
.seg button.active { background: var(--card-3); color: var(--text); box-shadow: var(--shadow); }

/* ---------------- 地图 ---------------- */

.map-search { display: flex; gap: 8px; margin-bottom: 8px; }
.map-search .input { min-height: 34px; font-size: 13.5px; background: var(--card-2); }
.map-search .btn { min-height: 34px; }

.poi-list {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  max-height: 220px;
  overflow-y: auto;
  margin-bottom: 8px;
}
.poi-item {
  padding: 8px 11px;
  border-bottom: 1px solid var(--border-soft);
  cursor: pointer;
  font-size: 13px;
  display: flex;
  gap: 10px;
  align-items: baseline;
}
.poi-item:last-child { border-bottom: 0; }
.poi-item:hover { background: var(--primary-soft); }
.poi-item .t { font-weight: 600; }
.poi-item .a { color: var(--muted); font-size: 11.5px; }
.poi-empty { padding: 14px 12px; color: var(--muted); font-size: 12.5px; text-align: center; }

.map-box {
  position: relative;
  height: 320px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-deep);
  margin: 6px 0 10px;
}
.map-box #map-el {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 3;
}
.map-box canvas#map-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 2;
  pointer-events: none;
}
.map-box .map-hint {
  position: absolute;
  left: 8px;
  top: 8px;
  z-index: 5;
  font-size: 11.5px;
  color: var(--muted);
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  padding: 2px 8px;
  pointer-events: none;
}
.map-box .map-loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 12.5px;
  background: var(--bg-deep);
  z-index: 4;
}

/* ---------------- 费用条 ---------------- */

.cost-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.cost-left { min-width: 0; }
.cost-total {
  font-family: var(--mono);
  font-size: 26px;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.15;
}
.cost-left .formula { font-size: 12px; color: var(--muted); font-family: var(--mono); }
.cost-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.cost-right .btn { min-height: 40px; padding: 8px 22px; }

/* ---------------- 用户管理 ---------------- */

.table .op-cell { display: flex; gap: 5px; flex-wrap: wrap; }
.table .op-cell .btn { min-height: 26px; padding: 2px 8px; font-size: 11.5px; }
.table td.money { font-family: var(--mono); font-variant-numeric: tabular-nums; text-align: right; }
.key-cell {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  word-break: break-all;
}
.api-key-box {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.api-key-box code {
  flex: 1 1 260px;
  font-family: var(--mono);
  font-size: 12px;
  word-break: break-all;
  color: var(--text-2);
}
.uid-big { font-family: var(--mono); font-size: 34px; font-weight: 700; color: var(--primary); line-height: 1; }

details.doc-fold {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  padding: 10px 12px;
  margin-top: 12px;
}
details.doc-fold summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  list-style: none;
}
details.doc-fold summary::-webkit-details-marker { display: none; }
details.doc-fold summary::before {
  content: '▸ ';
  color: var(--muted);
}
details.doc-fold[open] summary::before { content: '▾ '; }
details.doc-fold pre {
  margin: 10px 0 0;
  padding: 12px;
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.65;
  color: var(--text-2);
}

/* ---------------- 响应式 ---------------- */

@media (max-width: 1080px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  .sidebar { display: none; }
  .main { margin-left: 0; }
  .topbar { padding: 0 16px; }
  .content { padding: 16px 16px calc(var(--tabbar-h) + 24px + env(safe-area-inset-bottom, 0px)); }
  .tabbar { display: flex; }
  .topbar-user .money { font-size: 12px; padding: 3px 8px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); }
  .grid-2.keep-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat .value { font-size: 22px; }
  .drawer { width: 100%; }
  .toast-host { bottom: calc(var(--tabbar-h) + 12px + env(safe-area-inset-bottom, 0px)); }
  .form-grid { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .form-row > label { flex-basis: 88px; padding-top: 9px; }
  .map-box { height: 260px; }
  .cost-bar { gap: 10px; }
  .cost-right { width: 100%; justify-content: space-between; }
  .cost-right .btn { flex: 1 1 auto; }
  .uid-big { font-size: 28px; }
}

@media (min-width: 721px) {
  .content { padding: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* 独立点击层（盖在图片与 canvas 之上） */
.map-box #map-hit {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 4;
  display: none;
  cursor: crosshair;
  background: transparent;
}

/* ============ 交互地图（Leaflet） ============ */
.map-box #map-el { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 3; display: none; background: #eef2f6; }
.map-box #map-el.leaflet-container { font: inherit; }
.leaflet-container { background: #eef2f6; }
.leaflet-control-zoom a { width: 28px !important; height: 28px !important; line-height: 28px !important; font-size: 16px !important; }
.lv-dot span {
  display: flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 50%;
  background: #fff; border: 2px solid #1890ff; color: #1890ff;
  font-size: 11px; font-weight: 700; box-sizing: border-box;
  box-shadow: 0 1px 4px rgba(0,0,0,.25);
}