:root {
  --bg: #eef1f5;
  --panel: #ffffff;
  --panel-2: #f7f9fb;
  --text: #16202b;
  --sub: #667080;
  --line: #dde3ea;
  --brand: #0f4c81;
  --brand-2: #17679f;
  --brand-soft: #e7f0f8;
  --ok: #0d8a5f;
  --ok-soft: #e3f5ed;
  --warn: #b7791f;
  --warn-soft: #fdf3e0;
  --danger: #c53030;
  --danger-soft: #fdeaea;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 14px rgba(16, 24, 40, .05);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161b;
    --panel: #1b2027;
    --panel-2: #232931;
    --text: #e8ecf1;
    --sub: #98a2b3;
    --line: #2c333c;
    --brand: #4d9fdc;
    --brand-2: #6fb4e8;
    --brand-soft: #1d2b38;
    --ok: #3ecf8e;
    --ok-soft: #16302a;
    --warn: #e0a83e;
    --warn-soft: #302819;
    --danger: #f87171;
    --danger-soft: #331e1e;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
  }
}

* { 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.55;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }

/* ---------- 布局 ---------- */
.app { max-width: 720px; margin: 0 auto; min-height: 100vh; padding-bottom: 74px; }
.header {
  position: sticky; top: 0; z-index: 30;
  background: var(--brand); color: #fff;
  padding: 12px 16px 12px; display: flex; align-items: center; gap: 10px;
  box-shadow: 0 2px 10px rgba(15, 76, 129, .18);
}
.header h1 { margin: 0; font-size: 16px; font-weight: 600; letter-spacing: .5px; }
.header .sub { font-size: 12px; opacity: .8; margin-left: auto; font-variant-numeric: tabular-nums; }

.main { padding: 12px; }
.page { display: none; }
.page.active { display: block; animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------- 卡片 ---------- */
.card {
  background: var(--panel); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px; margin-bottom: 12px;
  border: 1px solid var(--line);
}
.card-title { font-size: 13px; font-weight: 600; color: var(--sub); margin: 0 0 10px; display: flex; align-items: center; gap: 6px; }
.card-title .hint { font-weight: 400; font-size: 12px; margin-left: auto; color: var(--sub); }

/* ---------- 表单 ---------- */
label.lbl { display: block; font-size: 12px; color: var(--sub); margin: 8px 0 4px; font-weight: 500; }
input[type=text], input[type=date], input[type=time], input[type=password], textarea, select {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px;
  background: var(--panel-2); color: var(--text); outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus, select:focus { border-color: var(--brand-2); box-shadow: 0 0 0 3px var(--brand-soft); }
textarea { resize: vertical; min-height: 84px; line-height: 1.6; }
.row { display: flex; gap: 8px; }
.row > * { flex: 1; min-width: 0; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 14px; border-radius: 9px; font-size: 14px; font-weight: 500;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  transition: transform .08s, background .15s;
  user-select: none;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn-ok { background: var(--ok); color: #fff; border-color: var(--ok); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; }

/* ---------- 标签 ---------- */
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 500;
  background: var(--brand-soft); color: var(--brand); white-space: nowrap;
}
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.danger { background: var(--danger-soft); color: var(--danger); }
.tag.grey { background: var(--panel-2); color: var(--sub); border: 1px solid var(--line); }

/* ---------- 人员选择 ---------- */
.people { display: flex; flex-wrap: wrap; gap: 8px; }
.person {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  padding: 8px 12px; border-radius: 10px; border: 1.5px solid var(--line);
  background: var(--panel-2); min-width: 84px; text-align: left;
  transition: all .12s;
}
.person .nm { font-weight: 600; font-size: 14px; }
.person .why { font-size: 10.5px; color: var(--sub); line-height: 1.3; }
.person.on { border-color: var(--brand); background: var(--brand-soft); }
.person.on .nm { color: var(--brand); }
.person.recommend { border-color: var(--ok); }
.person.recommend::after { content: '推荐'; font-size: 9.5px; color: #fff; background: var(--ok); padding: 0 5px; border-radius: 4px; }
.person.busy { opacity: .62; }
.person.busy .why { color: var(--warn); }

/* ---------- 解析结果 ---------- */
.parsed-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; }
.parsed-item .k { font-size: 11px; color: var(--sub); }
.parsed-item .v { font-size: 14px; font-weight: 500; word-break: break-all; }
.parsed-item .v.empty { color: var(--danger); font-weight: 400; font-size: 13px; }
.warn-line { font-size: 12px; color: var(--warn); background: var(--warn-soft); padding: 6px 10px; border-radius: 8px; margin-top: 8px; }

/* ---------- 台账 ---------- */
.mission {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; margin-bottom: 10px; box-shadow: var(--shadow);
  border-left: 3px solid var(--brand);
}
.mission.done { border-left-color: var(--ok); opacity: .82; }
.mission .m-top { display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px; }
.mission .m-time { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--brand); font-size: 14px; }
.mission .m-date { font-size: 12px; color: var(--sub); }
.mission .m-title { font-weight: 600; font-size: 14.5px; margin: 2px 0 4px; }
.mission .m-place { font-size: 12.5px; color: var(--sub); }
.mission .m-people { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.mission .m-acts { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }

.day-group { font-size: 13px; font-weight: 600; color: var(--sub); margin: 16px 4px 8px; display: flex; align-items: center; gap: 8px; }
.day-group::after { content: ''; flex: 1; height: 1px; background: var(--line); }

.empty-state { text-align: center; color: var(--sub); font-size: 13px; padding: 40px 20px; }

/* ---------- 日历 ---------- */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.cal-head .m { font-weight: 600; font-size: 15px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-wd { text-align: center; font-size: 11px; color: var(--sub); padding: 4px 0; }
.cal-cell {
  aspect-ratio: 1 / 1; border-radius: 8px; background: var(--panel-2);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 13px; position: relative; border: 1.5px solid transparent;
}
.cal-cell.out { opacity: .3; }
.cal-cell.today { border-color: var(--brand); font-weight: 700; }
.cal-cell.has { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.cal-cell .dot { width: 4px; height: 4px; border-radius: 50%; background: var(--brand); }
.cal-cell .cnt { font-size: 9px; position: absolute; bottom: 3px; }
.cal-cell.shift { box-shadow: inset 0 -2.5px 0 var(--warn); }

/* ---------- 底部导航 ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex; background: var(--panel); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar button {
  flex: 1; padding: 8px 0 7px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 10.5px; color: var(--sub); transition: color .12s;
}
.tabbar button .ico { font-size: 18px; line-height: 1; }
.tabbar button.on { color: var(--brand); font-weight: 600; }

/* ---------- 提示条 ---------- */
.toast {
  position: fixed; left: 50%; bottom: 88px; transform: translateX(-50%) translateY(20px);
  background: rgba(20, 26, 34, .94); color: #fff; padding: 9px 18px; border-radius: 999px;
  font-size: 13.5px; opacity: 0; pointer-events: none; transition: all .25s; z-index: 100;
  max-width: 86%; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 弹层 ---------- */
.mask { position: fixed; inset: 0; background: rgba(10, 14, 20, .45); z-index: 60; display: none; }
.mask.show { display: block; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 61;
  background: var(--panel); border-radius: 16px 16px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  transform: translateY(100%); transition: transform .25s ease; max-height: 86vh; overflow-y: auto;
}
.sheet.show { transform: none; }
.sheet h3 { margin: 0 0 12px; font-size: 15px; }

/* ---------- 登录 ---------- */
.login-wrap { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; padding: 0 24px; max-width: 420px; margin: 0 auto; }
.login-wrap .brand { font-size: 22px; font-weight: 700; color: var(--brand); letter-spacing: 1px; }
.login-wrap .slogan { font-size: 13px; color: var(--sub); margin: 4px 0 28px; }

/* ---------- 杂项 ---------- */
.divider { height: 1px; background: var(--line); margin: 12px 0; }
.tiny { font-size: 11.5px; color: var(--sub); }
.mono { font-variant-numeric: tabular-nums; }
.flex { display: flex; align-items: center; gap: 8px; }
.between { justify-content: space-between; }
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; }
pre.msgbox {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px; font-size: 13.5px; line-height: 1.75; white-space: pre-wrap; word-break: break-all;
  font-family: inherit; margin: 0;
}
.switch { position: relative; width: 42px; height: 24px; border-radius: 999px; background: var(--line); transition: background .2s; flex: none; }
.switch::after { content: ''; position: absolute; top: 2.5px; left: 2.5px; width: 19px; height: 19px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.switch.on { background: var(--ok); }
.switch.on::after { transform: translateX(18px); }

.list-item { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: none; }
.list-item .nm { font-weight: 600; font-size: 14px; }
.list-item .meta { font-size: 11.5px; color: var(--sub); }
