:root {
  --bg: #f4f6fa; --card: #fff; --text: #1d2433; --muted: #6b7489; --line: #e6e9f0;
  --primary: #1f6feb; --primary-soft: #e8f0fe; --ok: #1a7f37; --ok-soft: #e6f4ea;
  --warn: #b35900; --warn-soft: #fff1e0; --danger: #cf222e; --danger-soft: #fdecec;
  --radius: 12px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  --tabbar: 58px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif; }
a { color: var(--primary); text-decoration: none; }
.boot { padding: 40vh 0; text-align: center; color: var(--muted); }
h1, h2, h3 { margin: 0; font-weight: 600; }

/* ---------- 布局 ---------- */
.layout { min-height: 100vh; }
.topbar { position: sticky; top: 0; z-index: 20; background: var(--card); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 8px; height: 52px; padding: 0 12px; padding-top: env(safe-area-inset-top); }
.topbar h1 { font-size: 17px; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .back { font-size: 22px; padding: 4px 10px 4px 2px; color: var(--text); background: none; border: 0; cursor: pointer; }
.main { padding: 12px 12px calc(var(--tabbar) + 24px + env(safe-area-inset-bottom)); max-width: 960px; margin: 0 auto; }
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabbar a { flex: 1; height: var(--tabbar); display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 11px; color: var(--muted); position: relative; }
.tabbar a .ic { font-size: 20px; line-height: 1.1; }
.tabbar a.on { color: var(--primary); }
.tabbar .dot { position: absolute; top: 6px; left: 54%; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--danger); color: #fff; font-size: 10px; line-height: 16px; text-align: center; }
.side-brand { display: none; }

@media (min-width: 900px) {
  .layout { display: grid; grid-template-columns: 200px 1fr; }
  .tabbar { position: sticky; top: 0; height: 100vh; flex-direction: column; justify-content: flex-start; border-top: 0; border-right: 1px solid var(--line); padding: 12px 10px; gap: 2px; grid-row: 1 / span 2; }
  .tabbar a { flex: none; height: 42px; flex-direction: row; justify-content: flex-start; gap: 10px; padding: 0 12px; border-radius: 8px; font-size: 14px; }
  .tabbar a.on { background: var(--primary-soft); }
  .tabbar .dot { position: static; margin-left: auto; }
  .side-brand { display: block; font-weight: 600; font-size: 16px; padding: 8px 12px 16px; }
  .main { padding: 20px 24px 40px; width: 100%; }
  .fab { display: none !important; }
}

/* ---------- 组件 ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; margin-bottom: 12px; }
.card > h3 { font-size: 15px; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.card > h3 .sp { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.gap { height: 10px; }
.right { margin-left: auto; }
.nowrap { white-space: nowrap; }
.pre { white-space: pre-wrap; word-break: break-word; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 38px; padding: 0 14px; border-radius: 9px; border: 1px solid var(--line); background: var(--card); color: var(--text); font-size: 14px; cursor: pointer; white-space: nowrap; font-family: inherit; }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.danger { color: var(--danger); border-color: #f2c4c6; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--primary); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; border-radius: 7px; }
.btn.block { width: 100%; height: 44px; font-size: 16px; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; }

.chip { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 11px; font-size: 12px; background: #eef0f4; color: var(--muted); white-space: nowrap; }
.chip.blue { background: var(--primary-soft); color: var(--primary); }
.chip.green { background: var(--ok-soft); color: var(--ok); }
.chip.orange { background: var(--warn-soft); color: var(--warn); }
.chip.red { background: var(--danger-soft); color: var(--danger); }

.tabs { display: flex; gap: 6px; overflow-x: auto; margin: 0 -12px 12px; padding: 0 12px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { flex: none; padding: 6px 14px; border-radius: 18px; background: var(--card); color: var(--text); font-size: 14px; box-shadow: var(--shadow); }
.tabs a.on { background: var(--primary); color: #fff; }
.tabs a b { font-weight: 600; margin-left: 4px; }

/* 表单 */
.form .f { margin-bottom: 12px; }
.form label, .lbl { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.form label .req { color: var(--danger); }
input, select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; font: inherit; font-size: 16px; color: var(--text); background: #fff; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
textarea { resize: vertical; min-height: 72px; }
input[type=checkbox] { width: auto; }
.f2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.f3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.inline-btn { display: flex; gap: 6px; }
.inline-btn input { flex: 1; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.loc-ok { color: var(--ok); }

/* 申请列表 */
.day-h { display: flex; align-items: baseline; gap: 8px; margin: 16px 2px 8px; font-weight: 600; }
.day-h:first-child { margin-top: 4px; }
.day-h .chip { font-weight: 400; }
.rq { display: block; color: inherit; padding: 12px 14px; }
.rq .t { font-weight: 600; font-size: 16px; }
.rq .meta { font-size: 13px; color: var(--muted); margin-top: 4px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.rq .as { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--line); font-size: 13px; }
.urgent { border-left: 4px solid var(--warn); }

.fab { position: fixed; right: 18px; bottom: calc(var(--tabbar) + 18px + env(safe-area-inset-bottom)); width: 56px; height: 56px; border-radius: 28px; background: var(--primary); color: #fff; font-size: 30px; display: flex; align-items: center; justify-content: center; box-shadow: 0 6px 16px rgba(31,111,235,.4); z-index: 25; }

/* 详情 */
.kv { display: grid; grid-template-columns: 76px 1fr; gap: 6px 10px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }
.cand { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; }
.cand.best { border-color: var(--primary); background: #f7faff; }
.cand.busy { opacity: .6; }
.cand .nm { font-weight: 600; }
.cand .why { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.cand select { font-size: 14px; padding: 6px 8px; }
.msg { background: #f7f8fa; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; white-space: pre-wrap; font-size: 14.5px; word-break: break-word; }
.done-tag { color: var(--ok); font-size: 13px; }

/* 日程 */
.daystrip { display: flex; gap: 6px; overflow-x: auto; margin: 0 -12px 12px; padding: 2px 12px 4px; scrollbar-width: none; }
.daystrip::-webkit-scrollbar { display: none; }
.daystrip a { flex: none; width: 54px; padding: 6px 0; border-radius: 10px; background: var(--card); text-align: center; color: var(--text); box-shadow: var(--shadow); }
.daystrip a .w { font-size: 11px; color: var(--muted); }
.daystrip a .d { font-size: 17px; font-weight: 600; }
.daystrip a .n { font-size: 10px; color: var(--primary); height: 14px; }
.daystrip a.on { background: var(--primary); color: #fff; }
.daystrip a.on .w, .daystrip a.on .n { color: #fffc; }
.drow { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.drow:last-child { border-bottom: 0; }
.drow .who { width: 64px; flex: none; font-weight: 600; }
.drow .who .small { font-weight: 400; }
.slot { display: block; background: var(--primary-soft); color: var(--text); border-radius: 8px; padding: 6px 9px; font-size: 13px; margin-bottom: 4px; }
.slot.pending { background: var(--warn-soft); }
.free { color: var(--ok); font-size: 13px; padding-top: 6px; }

table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th, .tbl td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); }
.tbl th { color: var(--muted); font-weight: 500; font-size: 13px; }
.bar { height: 6px; background: var(--primary); border-radius: 3px; min-width: 2px; }

.list-item { display: flex; align-items: center; gap: 10px; padding: 12px 14px; color: inherit; }
.list-item + .list-item { border-top: 1px solid var(--line); }
.list-item .arrow { color: #c0c5d0; }
.card.flush { padding: 0; overflow: hidden; }
.avatar { width: 38px; height: 38px; border-radius: 19px; background: var(--primary-soft); color: var(--primary); display: flex; align-items: center; justify-content: center; font-weight: 600; flex: none; }
.off { opacity: .5; }

.empty { text-align: center; color: var(--muted); padding: 40px 0; }

/* 弹窗 */
.mask { position: fixed; inset: 0; background: rgba(15,20,30,.45); z-index: 100; display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
.sheet { background: var(--card); width: 100%; max-width: 520px; max-height: 90vh; overflow: auto; border-radius: 16px 16px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); animation: up .2s; }
.sheet h3 { font-size: 17px; margin-bottom: 14px; }
@media (min-width: 600px) { .mask { align-items: center; } .sheet { border-radius: 16px; } }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(40px); opacity: .5; } }

/* 地图选点 */
.mapbox { position: fixed; inset: 0; z-index: 120; background: var(--card); display: flex; flex-direction: column; }
.mapbox .mtop { display: flex; gap: 8px; padding: 10px; padding-top: calc(10px + env(safe-area-inset-top)); border-bottom: 1px solid var(--line); }
.mapbox #mapc { flex: 1; position: relative; }
.mapbox .center-pin { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -100%); font-size: 34px; z-index: 10; pointer-events: none; filter: drop-shadow(0 2px 2px rgba(0,0,0,.3)); }
.mapbox .mbot { padding: 12px; padding-bottom: calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.mapbox .addr { font-size: 14px; min-height: 42px; margin-bottom: 10px; }
.amap-sug-result { z-index: 200 !important; }

#toast { position: fixed; left: 50%; top: 40%; transform: translateX(-50%); z-index: 300; pointer-events: none; }
#toast div { background: rgba(20,24,32,.88); color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 14px; max-width: 80vw; text-align: center; white-space: pre-wrap; animation: fade .15s; }

.login { max-width: 380px; margin: 0 auto; padding: 14vh 20px 40px; }
.login .logo { width: 56px; height: 56px; margin-bottom: 12px; }
.login h1 { font-size: 22px; margin-bottom: 4px; }
.login .sub { color: var(--muted); margin-bottom: 24px; }
.code-btn { width: 120px; flex: none; }
.tpl-vars { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0; }
.tpl-vars .chip { cursor: pointer; }

/* 地址选择 */
.addr-box { width: 100%; display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; background: #fff; font: inherit; font-size: 15px; color: var(--text); text-align: left; cursor: pointer; }
.addr-box::before { content: '📍'; }
.addr-box .addr-text { flex: 1; min-width: 0; word-break: break-all; }
.addr-box .addr-act { color: var(--primary); font-size: 14px; flex: none; }
.addr-box.empty .addr-text { color: #9aa1b2; }
.addr-box.warn { border-color: var(--warn); }
.addr-res { max-height: 50vh; overflow: auto; margin-bottom: 0; box-shadow: none; border: 1px solid var(--line); }
