:root {
  --green: #07c160;
  --bg: #ededed;
  --card: #ffffff;
  --text: #1a1a1a;
  --text2: #888888;
  --line: #e5e5e5;
  --red: #fa5151;
  --blue: #10aeff;
  --orange: #ff9f00;
  --grey: #7f8c9b;
}

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

button, .tab, .qchip, .item-check, .q-option, .arrow, .nav-btn {
  touch-action: manipulation;
  -webkit-touch-callout: none;
  user-select: none;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue",
    "Microsoft YaHei", sans-serif;
  height: 100%;
  overscroll-behavior-y: none;
  -webkit-text-size-adjust: 100%;
}

#app {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100%;
  background: var(--bg);
  position: relative;
  display: flex;
  flex-direction: column;
}

/* 主界面：纵向排列（顶栏→日期→标签→列表），列表撑满剩余高度 */
#main-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* ---------- 顶栏 ---------- */
.nav {
  position: sticky;
  top: 0;
  z-index: 20;
  background: #f7f7f7;
  border-bottom: 1px solid var(--line);
  padding: calc(10px + env(safe-area-inset-top)) 12px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.nav .title { font-size: 17px; font-weight: 600; }
.nav .nav-actions { display: flex; gap: 16px; align-items: center; }
.nav .nav-btn {
  background: none;
  border: none;
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  padding: 4px;
}
.nav .nav-btn.green { color: var(--green); }

/* ---------- 日期条 ---------- */
.datebar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 10px;
  background: var(--bg);
}
.datebar .arrow {
  width: 30px; height: 30px; border: none; background: #fff;
  border-radius: 50%; font-size: 16px; color: var(--text); cursor: pointer;
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
}
.datebar .date { font-size: 15px; font-weight: 500; min-width: 110px; text-align: center; cursor: pointer; }
.datebar .date::after { content: " ▾"; font-size: 11px; color: #b0b0b0; }
.datebar .today-btn { font-size: 12px; color: var(--green); cursor: pointer; }

/* ---------- 四象限 tab ---------- */
.tabs {
  display: flex;
  background: #fff;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: calc(45px + env(safe-area-inset-top));
  z-index: 15;
  overflow-x: auto;
}
.tab {
  flex: 1;
  min-width: 60px;
  text-align: center;
  padding: 10px 4px;
  font-size: 13px;
  color: var(--text2);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.tab.active { color: var(--text); border-bottom-color: var(--green); font-weight: 600; }
.tab .count { font-size: 11px; color: #b0b0b0; margin-left: 2px; }

/* ---------- 事项列表 ---------- */
.list { padding: 10px 12px 90px; flex: 1; }
.qgroup-title { font-size: 13px; color: var(--text2); margin: 12px 2px 6px; }

.item-row { position: relative; overflow: hidden; margin-bottom: 8px; border-radius: 10px; }
.item-inner {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--card);
  padding: 14px 12px;
  border-radius: 10px;
  transition: transform .18s ease;
  touch-action: pan-y;
}
.item-row.open .item-inner { transform: translateX(-76px); }
.item-del {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 76px;
  background: var(--red);
  color: #fff;
  border: none;
  font-size: 15px;
  cursor: pointer;
}
.item-check {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid #c8c8c8; flex: 0 0 22px;
  margin-right: 12px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 13px;
  transition: all .15s;
}
.item-check.done { background: var(--green); border-color: var(--green); }
.item-body { flex: 1; min-width: 0; cursor: pointer; }
.item-content { font-size: 15px; line-height: 1.4; word-break: break-all; }
.item-content.done { color: #b0b0b0; text-decoration: line-through; }
.item-meta { display: flex; align-items: center; gap: 6px; margin-top: 6px; }
.qchip {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 4px;
  color: #fff;
  cursor: pointer;
}
.source-tag { font-size: 10px; color: #b0b0b0; }
.hint { color: #b0b0b0; font-size: 11px; }

/* ---------- 底部输入栏 ---------- */
.inputbar {
  position: fixed;
  bottom: 0;
  left: 0; right: 0;
  max-width: 520px;
  margin: 0 auto;
  background: #f7f7f7;
  border-top: 1px solid var(--line);
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  display: flex;
  gap: 8px;
  align-items: center;
  z-index: 25;
}
.inputbar input {
  flex: 1;
  height: 40px;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 0 12px;
  font-size: 16px; /* 16px 防止 iOS 聚焦自动放大 */
  background: #fff;
  outline: none;
}
.inputbar input:focus { border-color: var(--green); }
.icon-btn {
  width: 38px; height: 38px; border-radius: 8px;
  border: 1px solid #e0e0e0; background: #fff;
  cursor: pointer; font-size: 17px; color: var(--text);
  display: flex; align-items: center; justify-content: center;
}
.icon-btn.recording { background: var(--red); color: #fff; border-color: var(--red); animation: pulse 1s infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.6} }
.send-btn {
  height: 38px; padding: 0 16px; border-radius: 8px;
  background: var(--green); color: #fff; border: none;
  font-size: 15px; cursor: pointer;
}
.send-btn:disabled { background: #9be6bd; cursor: default; }

/* 语音「按住说话」 */
.hold-talk {
  flex: 1; height: 40px; border-radius: 8px;
  background: #fff; border: 1px solid #e0e0e0;
  font-size: 15px; color: var(--text); cursor: pointer;
  user-select: none; -webkit-user-select: none;
}
.hold-talk.recording { background: var(--green); color: #fff; border-color: var(--green); }

/* 日历弹窗 */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cal-nav { width: 32px; height: 32px; border: none; background: #f2f2f2; border-radius: 8px; font-size: 18px; cursor: pointer; }
.cal-title { font-size: 16px; font-weight: 600; }
.cal-week { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; margin-bottom: 4px; }
.cal-wd { font-size: 12px; color: #b0b0b0; padding: 4px 0; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-day { height: 38px; display: flex; align-items: center; justify-content: center; border-radius: 50%; font-size: 14px; cursor: pointer; }
.cal-day.empty { cursor: default; }
.cal-day.today { color: var(--green); font-weight: 600; }
.cal-day.selected { background: var(--green); color: #fff; font-weight: 600; }

/* 我的（个人统计） */
.mine-stats { display: flex; gap: 8px; margin-bottom: 6px; }
.mine-stat { flex: 1; background: #fff; border-radius: 10px; padding: 14px 8px; text-align: center; }
.mine-stat .num { font-size: 20px; font-weight: 700; }
.mine-stat .lbl { font-size: 11px; color: var(--text2); margin-top: 3px; }
.mine-section-title { font-size: 14px; font-weight: 600; margin: 18px 2px 10px; }
.mine-q-row { display: flex; align-items: center; gap: 8px; margin-bottom: 9px; }
.mine-q-name { font-size: 13px; flex: 0 0 64px; }
.mine-bar { flex: 1; height: 8px; background: #e9e9e9; border-radius: 4px; overflow: hidden; }
.mine-bar-fill { height: 100%; border-radius: 4px; }
.mine-q-cnt { font-size: 12px; color: var(--text2); flex: 0 0 auto; }
.mine-p-row { margin-bottom: 12px; }
.mine-p-top { display: flex; justify-content: space-between; margin-bottom: 4px; }
.mine-p-name { font-size: 14px; }
.mine-p-cnt { font-size: 12px; color: var(--text2); }
.mine-f-item { font-size: 12px; color: var(--text2); margin-bottom: 3px; }
.mine-f-text { font-size: 14px; }
.mine-logout { display: block; width: 100%; margin: 24px 0 10px; padding: 12px; border: 1px solid #e0e0e0; background: #fff; border-radius: 10px; font-size: 15px; color: var(--red); cursor: pointer; }

/* ---------- 弹层 ---------- */
.mask {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 70;
  display: flex; align-items: flex-end;
  justify-content: center;
}
.sheet {
  width: 100%; max-width: 520px;
  background: #fff;
  border-radius: 14px 14px 0 0;
  padding: 16px 16px 24px;
  animation: slideup .2s ease;
}
@keyframes slideup { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet h4 { margin: 0 0 12px; font-size: 16px; text-align: center; }
.q-option {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 8px; border-bottom: 1px solid #f2f2f2; cursor: pointer;
}
.q-option:last-child { border-bottom: none; }
.q-dot { width: 12px; height: 12px; border-radius: 50%; flex: 0 0 12px; }
.q-option .q-name { font-size: 15px; flex: 1; }
.q-option .q-hint { font-size: 12px; color: var(--text2); }
.sheet-cancel {
  display: block; width: 100%; margin-top: 14px;
  padding: 12px; border: none; background: #f2f2f2;
  border-radius: 10px; font-size: 15px; cursor: pointer; color: var(--text);
}

/* ---------- 登录页 ---------- */
.login-view {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
}
.login-card {
  width: 88%; max-width: 360px;
  background: #fff; border-radius: 12px;
  padding: 28px 24px;
  box-shadow: 0 4px 20px rgba(0,0,0,.06);
}
.login-card h2 { text-align: center; margin: 0 0 6px; }
.login-card .sub { text-align: center; color: var(--text2); font-size: 13px; margin-bottom: 22px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--text2); margin-bottom: 6px; }
.field input {
  width: 100%; height: 42px; border: 1px solid #e0e0e0; border-radius: 8px;
  padding: 0 12px; font-size: 16px; outline: none;
}
.field input:focus { border-color: var(--green); }
.btn-primary {
  width: 100%; height: 44px; border: none; border-radius: 8px;
  background: var(--green); color: #fff; font-size: 16px; cursor: pointer;
}
.btn-plain {
  width: 100%; height: 44px; margin-top: 10px; border: 1px solid var(--green);
  border-radius: 8px; background: #fff; color: var(--green); font-size: 16px; cursor: pointer;
}

/* ---------- 提示 ---------- */
.toast {
  position: fixed; top: 20%; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,.78); color: #fff;
  padding: 10px 18px; border-radius: 8px; font-size: 14px;
  z-index: 100; opacity: 0; transition: opacity .25s; pointer-events: none;
}
.toast.show { opacity: 1; }

.empty { text-align: center; color: #b0b0b0; padding: 60px 20px; font-size: 14px; }

/* ---------- 导出弹窗 ---------- */
.modal {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center;
}
.modal-card {
  width: 90%; max-width: 420px; max-height: 80vh;
  background: #fff; border-radius: 12px; padding: 20px;
  display: flex; flex-direction: column;
}
.modal-card h3 { margin: 0 0 10px; font-size: 16px; }
.modal-card pre {
  flex: 1; overflow: auto; background: #f7f7f7; border-radius: 8px;
  padding: 12px; font-size: 13px; white-space: pre-wrap; word-break: break-all;
  font-family: inherit; margin: 0 0 14px;
}
.seg { display: flex; background: #f2f2f2; border-radius: 8px; padding: 3px; margin-bottom: 12px; }
.seg-btn { flex: 1; border: none; background: transparent; padding: 7px 0; font-size: 14px; color: var(--text2); border-radius: 6px; cursor: pointer; }
.seg-btn.active { background: #fff; color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.08); }

.modal-btns { display: flex; gap: 10px; }
.modal-btns button {
  flex: 1; height: 42px; border-radius: 8px; font-size: 15px; cursor: pointer;
}

/* ---------- 跟进详情页 ---------- */
.detail {
  position: fixed;
  top: 0; bottom: 0; left: 0; right: 0;
  margin: 0 auto;
  max-width: 520px;
  background: var(--bg);
  z-index: 55;
  display: flex;
  flex-direction: column;
  animation: slideup .2s ease;
}
.detail-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f7f7f7;
  border-bottom: 1px solid var(--line);
  padding: calc(10px + env(safe-area-inset-top)) 12px 10px;
}
.detail-header .back { background: none; border: none; font-size: 15px; color: var(--text); cursor: pointer; padding: 4px; }
.detail-header .title { font-size: 16px; font-weight: 600; }
.detail-scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 14px 12px 20px; }
.detail-content {
  background: #fff; border-radius: 10px; padding: 16px 14px;
  font-size: 17px; font-weight: 600; line-height: 1.5; word-break: break-all;
}
.detail-content.done { color: #b0b0b0; text-decoration: line-through; }
.detail-meta { display: flex; align-items: center; gap: 8px; margin: 10px 2px; }
.followup-title { font-size: 13px; color: var(--text2); margin: 16px 2px 8px; }
.followup-item { display: flex; gap: 10px; margin-bottom: 10px; }
.followup-item .time { flex: 0 0 auto; font-size: 11px; color: #b0b0b0; padding-top: 3px; }
.followup-item .bubble { flex: 1; background: #fff; border-radius: 10px; padding: 10px 12px; font-size: 14px; line-height: 1.5; word-break: break-all; }
.followup-empty { color: #b0b0b0; font-size: 13px; text-align: center; padding: 24px 10px; }
.detail-inputbar {
  flex: 0 0 auto;
  display: flex; gap: 8px; align-items: center;
  background: #f7f7f7;
  border-top: 1px solid var(--line);
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
}
.detail-inputbar input {
  flex: 1; height: 40px; border: 1px solid #e0e0e0; border-radius: 8px;
  padding: 0 12px; font-size: 16px; background: #fff; outline: none;
}
.detail-inputbar input:focus { border-color: var(--green); }

/* 详情页到期时间 */
.due-row { display: flex; align-items: center; gap: 8px; margin: 2px 2px; }
.due-label { font-size: 13px; color: var(--text2); flex: 0 0 auto; }
.due-input { flex: 1; height: 36px; border: 1px solid #e0e0e0; border-radius: 8px; padding: 0 10px; font-size: 15px; background: #fff; outline: none; }
.due-clear { background: none; border: none; color: var(--text2); font-size: 13px; cursor: pointer; padding: 6px; }
.due-hint { font-size: 12px; color: #b0b0b0; margin: 2px 2px 10px; }
.escalated-tag { font-size: 10px; color: var(--red); }

/* 判定依据 */
.why-box { background: #f7f7f7; border-radius: 10px; padding: 12px 14px; margin: 4px 0 12px; }
.why-title { font-size: 12px; color: var(--text2); margin-bottom: 6px; font-weight: 600; }
.why-line { font-size: 13px; color: var(--text); line-height: 1.7; word-break: break-all; }

/* 到期状态 */
.due-overdue { font-size: 11px; color: #fff; background: var(--red); padding: 1px 6px; border-radius: 4px; }
.due-soon { font-size: 10px; color: var(--orange); }

/* 下拉刷新 */
.ptr {
  position: fixed; top: 0; left: 0; right: 0;
  max-width: 520px; margin: 0 auto;
  height: 0; overflow: hidden;
  display: flex; align-items: flex-end; justify-content: center;
  background: var(--bg); color: var(--text2);
  font-size: 12px; opacity: 0;
  transition: height .15s ease;
  z-index: 90;
  pointer-events: none;
}

