:root {
  --primary: #1677ff;
  --primary-dark: #0b5ed7;
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #16181d;
  --text2: #6b7280;
  --text3: #9aa0a6;
  --line: #eceff3;
  --radius: 12px;
  --danger: #e5484d;
  --warn: #f79009;
  --success: #12b76d;
  --shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 1px 2px rgba(16, 24, 40, .04);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

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

.qr-tip {
  display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px;
  background: #eaf3ff; border: 1px solid #cfe3ff; color: var(--primary-dark);
  border-radius: var(--radius); padding: 10px 14px; margin-bottom: 12px;
  font-size: 14px; line-height: 1.5;
}
.qr-tip b { font-weight: 600; }
.qr-tip span { color: var(--text2); font-size: 12px; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--primary);
  color: #fff;
  padding: calc(env(safe-area-inset-top) + 12px) 16px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.topbar h1 { font-size: 17px; font-weight: 600; margin: 0; }
.topbar .sub { font-size: 12px; opacity: .85; margin-top: 1px; }
.userchip {
  display: flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,.18);
  border-radius: 999px; padding: 4px 10px; font-size: 12px; white-space: nowrap;
}
.userchip .avatar {
  width: 22px; height: 22px; border-radius: 50%;
  background: rgba(255,255,255,.3); display: grid; place-items: center;
  font-size: 11px; font-weight: 600;
}
.badge-role { background: rgba(255,255,255,.25); border-radius: 4px; padding: 0 5px; font-size: 11px; }

.page { padding: 12px 12px 90px; }
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  display: flex; background: #fff; border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar .tab {
  flex: 1; text-align: center; padding: 7px 0 6px; color: var(--text3);
  font-size: 11px; text-decoration: none; line-height: 1.3;
}
.tabbar .tab.active { color: var(--primary); font-weight: 600; }
.tabbar .ic {
  display: block; width: 22px; height: 22px; margin: 0 auto 2px;
  border-radius: 6px; background: currentColor; opacity: .18;
}
.tabbar .tab.active .ic { opacity: 1; }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; margin-bottom: 12px; }
.card-title { font-size: 14px; font-weight: 600; margin: 0 0 10px; display: flex; align-items: center; justify-content: space-between; }
.req::after { content: '*'; color: var(--danger); margin-left: 2px; }

.grid-cats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.cat {
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 6px; text-align: center;
  background: #fff; transition: .15s;
}
.cat.sel { border-color: var(--primary); background: #f0f6ff; box-shadow: 0 0 0 2px rgba(22,119,255,.12); }
.cat .ci { width: 26px; height: 26px; border-radius: 7px; margin: 0 auto 5px; }
.cat .cn { font-size: 13px; font-weight: 500; }
.cat .cd { font-size: 10px; color: var(--text3); margin-top: 2px; line-height: 1.3; display: none; }
.cat.sel .cd { display: block; }

.field { margin-bottom: 14px; }
.field label.lb { display: block; font-size: 13px; color: var(--text2); margin-bottom: 6px; font-weight: 500; }
input[type=text], input[type=number], textarea, select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 9px; background: #fff; outline: none; transition: .15s; font-size: 15px;
}
input:focus, textarea:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(22,119,255,.1); }
textarea { min-height: 88px; resize: vertical; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.seg { display: flex; gap: 6px; }
.seg .sg {
  flex: 1; text-align: center; padding: 7px 0; border: 1px solid var(--line);
  border-radius: 8px; font-size: 13px; background: #fff;
}
.seg .sg.sel { color: #fff; border-color: transparent; }

.imgs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.imgs .it { position: relative; aspect-ratio: 1; border-radius: 8px; overflow: hidden; background: #f2f4f7; }
.imgs .it img { width: 100%; height: 100%; object-fit: cover; display: block; }
.imgs .it .del {
  position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: rgba(0,0,0,.55); color: #fff; font-size: 13px; line-height: 20px; text-align: center;
}
.imgs .add {
  aspect-ratio: 1; border: 1px dashed #c6cbd4; border-radius: 8px; display: grid;
  place-items: center; color: var(--text3); font-size: 11px; background: #fafbfc;
}
.imgs .add .plus { font-size: 22px; line-height: 1; color: #b6bcc6; }

.btn {
  width: 100%; padding: 12px; border: none; border-radius: 10px;
  background: var(--primary); color: #fff; font-size: 16px; font-weight: 500;
}
.btn:active { background: var(--primary-dark); }
.btn.ghost { background: #fff; color: var(--primary); border: 1px solid #cfe1ff; }
.btn.gray { background: #f2f4f7; color: var(--text2); }
.btn.danger { background: #fef3f2; color: var(--danger); border: 1px solid #fecdca; }
.btn.sm { padding: 8px 14px; font-size: 14px; width: auto; }
.btn[disabled] { opacity: .5; }
.btnrow { display: flex; gap: 8px; }

.filters { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 10px; -webkit-overflow-scrolling: touch; }
.filters::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; padding: 5px 12px; border-radius: 999px; font-size: 13px;
  background: #fff; border: 1px solid var(--line); color: var(--text2);
}
.chip.sel { background: var(--primary); border-color: var(--primary); color: #fff; }

.ticket { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 13px 14px; margin-bottom: 10px; }
.ticket .th { display: flex; align-items: center; gap: 8px; margin-bottom: 7px; }
.ticket .tid { font-size: 11px; color: var(--text3); font-family: ui-monospace, Menlo, Consolas, monospace; }
.ticket .ttl { font-size: 15px; font-weight: 600; line-height: 1.45; margin-bottom: 5px; }
.ticket .meta { font-size: 12px; color: var(--text2); display: flex; flex-wrap: wrap; gap: 4px 10px; }
.ticket .foot { display: flex; align-items: center; justify-content: space-between; margin-top: 9px; padding-top: 9px; border-top: 1px dashed var(--line); font-size: 12px; color: var(--text3); }
.thumbs { display: flex; gap: 5px; margin-top: 8px; }
.thumbs img { width: 52px; height: 52px; border-radius: 6px; object-fit: cover; }

.tag { font-size: 11px; padding: 1px 7px; border-radius: 5px; color: #fff; white-space: nowrap; }
.tag.ghost2 { background: #f2f4f7; color: var(--text2); }

.stats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 12px; }
.kpi { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px; }
.kpi .v { font-size: 22px; font-weight: 600; line-height: 1.2; }
.kpi .k { font-size: 12px; color: var(--text2); margin-top: 2px; }

.bar-row { display: flex; align-items: center; gap: 8px; margin-bottom: 9px; font-size: 13px; }
.bar-row .nm { width: 76px; flex: 0 0 auto; color: var(--text2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row .track { flex: 1; height: 8px; background: #f0f2f5; border-radius: 999px; overflow: hidden; }
.bar-row .fill { height: 100%; border-radius: 999px; }
.bar-row .vl { width: 30px; text-align: right; color: var(--text2); font-size: 12px; }

.empty { text-align: center; padding: 46px 20px; color: var(--text3); font-size: 14px; }
.empty .ec { font-size: 34px; opacity: .35; margin-bottom: 8px; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 14px 18px; border-left: 1px solid var(--line); }
.timeline li:last-child { border-left-color: transparent; padding-bottom: 0; }
.timeline li::before {
  content: ''; position: absolute; left: -4px; top: 6px; width: 7px; height: 7px;
  border-radius: 50%; background: var(--primary);
}
.timeline .a { font-size: 14px; font-weight: 500; }
.timeline .t { font-size: 11px; color: var(--text3); }
.timeline .n { font-size: 13px; color: var(--text2); margin-top: 2px; word-break: break-word; }

.result-box { background: #f7f9fc; border-radius: 10px; padding: 11px; margin-top: 8px; }
.cost-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.cost-row input { flex: 1; }
.cost-row .rmb { width: 100px; flex: 0 0 auto; }
.cost-total { text-align: right; font-size: 15px; font-weight: 600; color: var(--danger); }

.actionbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 55;
  background: #fff; border-top: 1px solid var(--line); padding: 9px 12px calc(env(safe-area-inset-bottom) + 9px);
  display: flex; gap: 8px;
}

.modal-mask { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 100; display: flex; align-items: flex-end; }
.modal { background: #fff; width: 100%; border-radius: 16px 16px 0 0; max-height: 88vh; overflow: auto; }
.modal .mh { position: sticky; top: 0; background: #fff; padding: 14px 16px 10px; border-bottom: 1px solid var(--line); font-weight: 600; display: flex; justify-content: space-between; align-items: center; }
.modal .mb { padding: 14px 16px calc(env(safe-area-inset-bottom) + 14px); }
.modal .x { color: var(--text3); font-size: 20px; line-height: 1; padding: 0 4px; }

.toast {
  position: fixed; left: 50%; top: 42%; transform: translate(-50%, -50%);
  background: rgba(0,0,0,.8); color: #fff; padding: 10px 18px; border-radius: 8px;
  font-size: 14px; z-index: 200; max-width: 78%; text-align: center;
}
.loading { text-align: center; padding: 30px; color: var(--text3); font-size: 14px; }

.stars { font-size: 22px; letter-spacing: 4px; color: #d8dbe0; user-select: none; }
.stars .on { color: #ffb020; }

.mini-list { font-size: 12px; color: var(--text3); }
.mini-list .li { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px dashed var(--line); }
.mini-list .li:last-child { border-bottom: none; }

.handler-tag {
  display: inline-flex; align-items: center; gap: 4px; background: #f0f6ff; color: var(--primary);
  border-radius: 6px; padding: 2px 8px; font-size: 12px; margin: 0 6px 6px 0;
}
.handler-tag .x { font-weight: 600; }
.note { font-size: 12px; color: var(--text3); line-height: 1.5; }
