:root {
  --bg: #f4f6fa;
  --card: #ffffff;
  --ink: #1b2432;
  --ink-2: #5d6b7f;
  --ink-3: #8d99ab;
  --line: #e6eaf1;
  --brand: #2f6bff;
  --brand-soft: #eaf0ff;
  --green: #12a86b;
  --green-soft: #e6f8f0;
  --red: #e2453c;
  --red-soft: #fdeceb;
  --amber: #d98600;
  --amber-soft: #fdf3e0;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 35, 60, .04), 0 8px 24px rgba(20, 35, 60, .06);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

/* ---------- 登录 ---------- */
#login {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1200px 600px at 20% 0%, #e8efff, #f4f6fa 60%);
}
.login-box {
  width: 340px; background: var(--card); border-radius: 20px; padding: 32px 28px;
  box-shadow: var(--shadow); text-align: center;
}
.login-box .logo { width: 52px; height: 52px; margin: 0 auto 14px; border-radius: 16px;
  background: linear-gradient(135deg, #4a86ff, #2f6bff); color: #fff; font-size: 24px;
  display: flex; align-items: center; justify-content: center; }
.login-box h1 { font-size: 18px; margin: 0 0 4px; }
.login-box p { color: var(--ink-3); font-size: 13px; margin: 0 0 22px; }
.login-box input {
  width: 100%; padding: 11px 13px; border: 1px solid var(--line); border-radius: 10px;
  outline: none; margin-bottom: 12px; background: #fbfcfe;
}
.login-box input:focus { border-color: var(--brand); background: #fff; }
.login-box button { width: 100%; padding: 11px; border: 0; border-radius: 10px; background: var(--brand); color: #fff; font-weight: 600; }
.err { color: var(--red); font-size: 12.5px; min-height: 18px; }

/* ---------- 布局 ---------- */
#app { display: flex; min-height: 100vh; }
aside {
  width: 268px; flex: 0 0 268px; background: #fff; border-right: 1px solid var(--line);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { padding: 20px 18px 14px; display: flex; align-items: center; gap: 10px; }
.brand .dot { width: 30px; height: 30px; border-radius: 9px; background: linear-gradient(135deg,#4a86ff,#2f6bff);
  color: #fff; display: flex; align-items: center; justify-content: center; font-size: 15px; }
.brand b { font-size: 15px; letter-spacing: .2px; }
.brand small { display: block; color: var(--ink-3); font-size: 11.5px; font-weight: 400; }
.side-title { padding: 10px 20px 6px; color: var(--ink-3); font-size: 12px; display: flex; justify-content: space-between; align-items: center; }
.side-title a { color: var(--brand); text-decoration: none; font-size: 12px; }
.dev-list { flex: 1; overflow: auto; padding: 0 10px 10px; }
.dev {
  padding: 11px 12px; border-radius: 11px; cursor: pointer; display: flex; gap: 10px; align-items: center;
  margin-bottom: 4px; border: 1px solid transparent;
}
.dev:hover { background: #f7f9fd; }
.dev.active { background: var(--brand-soft); border-color: #d5e2ff; }
.dev .avatar { width: 34px; height: 34px; border-radius: 10px; background: #eef2f9; display: flex;
  align-items: center; justify-content: center; font-size: 16px; flex: 0 0 34px; }
.dev .meta { min-width: 0; flex: 1; }
.dev .meta b { display: block; font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dev .meta span { color: var(--ink-3); font-size: 11.5px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #c4ccd9; display: inline-block; }
.status-dot.on { background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.side-foot { padding: 12px; border-top: 1px solid var(--line); display: flex; gap: 8px; }
.side-foot button { flex: 1; border: 1px solid var(--line); background: #fff; border-radius: 9px; padding: 8px; font-size: 12.5px; color: var(--ink-2); }
.side-foot button:hover { border-color: #cfd8e6; }

main { flex: 1; min-width: 0; padding: 22px 26px 60px; }
.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.topbar h2 { margin: 0; font-size: 20px; letter-spacing: .2px; }
.topbar .sub { color: var(--ink-3); font-size: 12.5px; margin-top: 3px; }
.topbar .actions { display: flex; gap: 8px; flex-wrap: wrap; }

.btn { border: 1px solid var(--line); background: #fff; border-radius: 9px; padding: 8px 13px; font-size: 13px; color: var(--ink-2); }
.btn:hover { border-color: #cfd8e6; background: #fbfcfe; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.btn.primary:hover { background: #245ce0; }
.btn.danger { color: var(--red); border-color: #f3cfcc; background: var(--red-soft); }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.card { background: var(--card); border-radius: var(--radius); padding: 15px 16px; box-shadow: var(--shadow); }
.card .k { color: var(--ink-3); font-size: 12px; margin-bottom: 6px; }
.card .v { font-size: 21px; font-weight: 650; letter-spacing: .3px; }
.card .v small { font-size: 12px; font-weight: 400; color: var(--ink-3); margin-left: 3px; }

.panel { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 16px; overflow: hidden; }
.panel-h { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.panel-h b { font-size: 14px; }
.panel-h .hint { color: var(--ink-3); font-size: 12px; font-weight: 400; }
.panel-b { padding: 16px 18px; }

.tabs { display: flex; gap: 4px; margin-bottom: 14px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.tabs button { border: 0; background: transparent; padding: 9px 14px; color: var(--ink-2); border-bottom: 2px solid transparent; margin-bottom: -1px; border-radius: 0; }
.tabs button.on { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }

/* ---------- 表单 ---------- */
.row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 11px 0; border-bottom: 1px dashed var(--line); }
.row:last-child { border-bottom: 0; }
.row .label b { display: block; font-size: 13.5px; font-weight: 550; }
.row .label span { color: var(--ink-3); font-size: 12px; }
.row .ctrl { flex: 0 0 auto; display: flex; align-items: center; gap: 8px; }
input[type="number"], input[type="time"], input[type="text"], select {
  border: 1px solid var(--line); border-radius: 8px; padding: 6px 9px; background: #fbfcfe; outline: none; width: 92px;
}
input[type="text"].wide { width: 260px; }
input[type="file"] { font-size: 12.5px; color: var(--ink-2); max-width: 250px; }
input[type="file"]::file-selector-button {
  border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 6px 10px;
  margin-right: 8px; font-size: 12.5px; color: var(--ink-2); cursor: pointer;
}
input:focus, select:focus { border-color: var(--brand); background: #fff; }
.switch { position: relative; width: 42px; height: 24px; flex: 0 0 42px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch i { position: absolute; inset: 0; background: #d7dde8; border-radius: 999px; transition: .18s; cursor: pointer; }
.switch i:before { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .18s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch input:checked + i { background: var(--brand); }
.switch input:checked + i:before { transform: translateX(18px); }

.week { display: flex; gap: 6px; }
.week label { width: 28px; height: 28px; border-radius: 8px; background: #f2f5fa; display: flex; align-items: center;
  justify-content: center; font-size: 12px; color: var(--ink-2); cursor: pointer; user-select: none; }
.week input { display: none; }
.week input:checked + span { background: var(--brand); color: #fff; }
.week span { width: 28px; height: 28px; border-radius: 8px; background: #f2f5fa; display: flex; align-items: center; justify-content: center; }

/* ---------- 图表 ---------- */
.bars { display: flex; align-items: flex-end; gap: 10px; height: 150px; padding-top: 8px; }
.bars .bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 6px; height: 100%; }
.bars .bar .fill { width: 100%; max-width: 46px; background: linear-gradient(180deg, #6f9bff, #2f6bff); border-radius: 7px 7px 3px 3px; min-height: 3px; transition: height .3s; }
.bars .bar .num { font-size: 11.5px; color: var(--ink-2); }
.bars .bar .day { font-size: 11px; color: var(--ink-3); }

.rank { display: flex; flex-direction: column; gap: 9px; }
.rank .item { display: grid; grid-template-columns: 22px 1fr 74px; gap: 10px; align-items: center; }
.rank .no { color: var(--ink-3); font-size: 12px; text-align: center; }
.rank .bar-wrap { position: relative; height: 26px; background: #f4f7fc; border-radius: 7px; overflow: hidden; }
.rank .bar-in { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, #e3ecff, #cfe0ff); }
.rank .name { position: relative; padding: 2px 9px; font-size: 12.8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 22px; }
.rank .val { text-align: right; font-size: 12.5px; color: var(--ink-2); font-variant-numeric: tabular-nums; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); }
th { color: var(--ink-3); font-weight: 500; font-size: 12px; }
tr:hover td { background: #fafbfe; }
td.ops { text-align: right; white-space: nowrap; }
td.ops .btn { padding: 4px 9px; font-size: 12px; }
.tag { display: inline-block; padding: 1px 7px; border-radius: 6px; font-size: 11.5px; background: #f1f4f9; color: var(--ink-2); }
.tag.g { background: var(--green-soft); color: var(--green); }
.tag.r { background: var(--red-soft); color: var(--red); }
.tag.a { background: var(--amber-soft); color: var(--amber); }

.map-wrap { background: #f8fafe; border-radius: 12px; border: 1px solid var(--line); padding: 10px; }
svg#track { width: 100%; height: 300px; display: block; }
.loc-list { max-height: 240px; overflow: auto; margin-top: 10px; }
.loc-list .row { padding: 7px 0; font-size: 12.5px; }

.empty { color: var(--ink-3); text-align: center; padding: 30px 10px; font-size: 13px; }
.toast {
  position: fixed; left: 50%; bottom: 32px; transform: translate(-50%, 20px); opacity: 0;
  background: #1b2432; color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 13px;
  transition: .2s; pointer-events: none; z-index: 90; max-width: 70vw;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }

.grid2 { display: grid; grid-template-columns: 1.15fr .85fr; gap: 16px; align-items: start; }
@media (max-width: 1180px) { .cards { grid-template-columns: repeat(2, 1fr); } .grid2 { grid-template-columns: 1fr; } }
@media (max-width: 820px) {
  aside { display: none; }
  main { padding: 16px 14px 50px; }
  .topbar { flex-direction: column; }
}