* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --green: #1D9E75; --green-light: #E1F5EE; --green-dark: #0F6E56;
  --purple: #7F77DD; --purple-light: #EEEDFE;
  --coral: #D85A30; --coral-light: #FAECE7;
  --pink: #D4537E; --pink-light: #FBEAF0;
  --amber: #BA7517; --amber-light: #FAEEDA;
  --blue: #378ADD; --blue-light: #E6F1FB;
  --red: #E24B4A; --red-light: #FCEBEB;
  --gray: #888780; --gray-light: #F1EFE8;
  --text: #2C2C2A; --text-secondary: #5F5E5A; --text-hint: #888780;
  --border: #D3D1C7; --bg: #F5F4F0;
  --radius: 10px; --radius-sm: 6px;
}
body { font-family: -apple-system, 'PingFang SC', 'Helvetica Neue', sans-serif; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
input, select, textarea, button { font-family: inherit; font-size: inherit; }

/* ====== Login ====== */
.login-page { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 100vh; padding: 40px 24px; }
.login-page h1 { font-size: 26px; font-weight: 600; color: var(--green); margin-bottom: 4px; }
.login-page p { color: var(--text-hint); margin-bottom: 32px; font-size: 13px; }
.login-form { width: 100%; max-width: 320px; }
.login-form label { display: block; font-size: 12px; color: var(--text-secondary); margin-bottom: 4px; }
.login-form input { width: 100%; padding: 12px 14px; border: 1.5px solid var(--border); border-radius: var(--radius); margin-bottom: 16px; background: white; outline: none; transition: border .2s; }
.login-form input:focus { border-color: var(--green); }
.login-btn { width: 100%; padding: 13px; background: var(--green); color: white; border: none; border-radius: var(--radius); font-size: 16px; font-weight: 500; cursor: pointer; }
.login-btn:active { opacity: .8; }
.login-error { color: var(--red); font-size: 12px; margin-top: 12px; text-align: center; }

/* ====== Layout ====== */
.app-header { background: white; padding: 12px 16px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.app-header h2 { font-size: 17px; font-weight: 600; color: var(--green); }
.header-user { font-size: 12px; color: var(--text-hint); display: flex; align-items: center; gap: 8px; }
.header-user button { background: none; border: none; color: var(--text-hint); font-size: 12px; padding: 4px; cursor: pointer; }
.page-content { padding: 16px; padding-bottom: calc(80px + env(safe-area-inset-bottom)); }

/* ====== Bottom Nav ====== */
.bottom-nav { position: fixed; bottom: 0; left: 0; right: 0; background: white; border-top: 1px solid var(--border); display: flex; z-index: 10; padding-bottom: env(safe-area-inset-bottom); }
.nav-item { flex: 1; text-align: center; padding: 8px 0 6px; cursor: pointer; color: var(--text-hint); font-size: 11px; }
.nav-item.active { color: var(--green); font-weight: 500; }
.nav-item .icon { font-size: 20px; display: block; margin-bottom: 2px; }

/* ====== Cards ====== */
.card { background: white; border-radius: var(--radius); padding: 14px; margin-bottom: 12px; box-shadow: 0 1px 3px rgba(0,0,0,.04); }
.card-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.card-title { font-weight: 500; font-size: 15px; }
.card-sub { font-size: 12px; color: var(--text-secondary); }

/* ====== Type Badges ====== */
.badge { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 500; }
.badge-purple { background: var(--purple-light); color: var(--purple); }
.badge-green { background: var(--green-light); color: var(--green-dark); }
.badge-coral { background: var(--coral-light); color: var(--coral); }
.badge-pink { background: var(--pink-light); color: var(--pink); }
.badge-amber { background: var(--amber-light); color: var(--amber); }
.badge-blue { background: var(--blue-light); color: var(--blue); }
.badge-red { background: var(--red-light); color: var(--red); }

.type-badge { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 500; }

/* ====== Task Item ====== */
.task-item { display: flex; align-items: flex-start; gap: 12px; padding: 12px 0; border-bottom: 1px solid #f0f0f0; }
.task-item:last-child { border: none; }
.task-cb { width: 16px; height: 16px; accent-color: var(--green); flex-shrink: 0; margin-top: 4px; cursor: pointer; }
.task-check { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--border); background: white; flex-shrink: 0; cursor: pointer; display: flex; align-items: center; justify-content: center; margin-top: 2px; transition: all .2s; }
.task-check.done { background: var(--green); border-color: var(--green); }
.task-check.done::after { content: '✓'; color: white; font-size: 12px; font-weight: bold; }
.task-body { flex: 1; min-width: 0; }
.task-body .name { font-weight: 500; font-size: 14px; }
.task-body .type { font-size: 11px; margin-left: 6px; }
.task-body .note { font-size: 12px; color: var(--text-secondary); margin-top: 4px; line-height: 1.4; }
.task-body .meta { font-size: 11px; color: var(--text-hint); margin-top: 4px; display: flex; gap: 12px; }
.task-body .meta .label { color: var(--text-hint); }

/* ====== Summary Card ====== */
.summary { display: flex; gap: 8px; margin-bottom: 16px; }
.summary-item { flex: 1; background: white; border-radius: var(--radius); padding: 14px; text-align: center; }
.summary-item .num { font-size: 28px; font-weight: 600; color: var(--green); }
.summary-item .label { font-size: 11px; color: var(--text-hint); margin-top: 2px; }

/* ====== Modal ====== */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 100; display: flex; align-items: flex-end; justify-content: center; }
.modal-content { background: white; border-radius: var(--radius) var(--radius) 0 0; width: 100%; max-width: 480px; max-height: 85vh; overflow-y: auto; padding: 20px; }
.modal-content h3 { font-size: 17px; font-weight: 600; margin-bottom: 16px; }
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 12px; color: var(--text-secondary); margin-bottom: 4px; }
.form-group input, .form-group select, .form-group textarea { width: 100%; padding: 10px 12px; border: 1.5px solid var(--border); border-radius: var(--radius-sm); outline: none; background: white; }
.form-group textarea { resize: vertical; min-height: 60px; }
.form-group input:focus, .form-group select:focus { border-color: var(--green); }
.form-actions { display: flex; gap: 10px; margin-top: 20px; }
.btn { padding: 11px 20px; border: none; border-radius: var(--radius-sm); font-weight: 500; cursor: pointer; font-size: 14px; }
.btn:active { opacity: .8; }
.btn-primary { background: var(--green); color: white; flex: 1; }
.btn-secondary { background: var(--gray-light); color: var(--text); flex: 1; }
.btn-danger { background: var(--red); color: white; }
.btn-sm { padding: 6px 14px; font-size: 12px; }

/* ====== Customers ====== */
.customer-search { display: flex; gap: 8px; margin-bottom: 12px; }
.customer-search input { flex: 1; padding: 10px 12px; border: 1.5px solid var(--border); border-radius: var(--radius-sm); background: white; outline: none; }
.customer-search input:focus { border-color: var(--green); }

/* ====== Customer level tabs ====== */
.level-tabs { display: flex; gap: 4px; margin-bottom: 12px; overflow-x: auto; background: white; padding: 6px; border-radius: var(--radius); }
.level-tab { padding: 8px 12px; border-radius: 8px; font-size: 12px; color: var(--text-hint); cursor: pointer; white-space: nowrap; border: 1.5px solid transparent; }
.level-tab span { display: inline-block; min-width: 20px; padding: 0 4px; background: var(--gray-light); border-radius: 10px; font-size: 10px; margin-left: 4px; }
.level-tab.active { color: var(--text); font-weight: 500; background: var(--green-light); border-color: var(--green); }
.level-tab.active-color.active { background: var(--green-light); border-color: var(--green); color: var(--green-dark); }
.level-tab.dormant-color.active { background: var(--amber-light); border-color: var(--amber); color: var(--amber); }
.level-tab.dormant-color.active span { background: var(--amber); color: white; }
.level-tab.deep-color.active { background: var(--red-light); border-color: var(--red); color: var(--red); }
.level-tab.deep-color.active span { background: var(--red); color: white; }

.level-tag { display: inline-block; padding: 1px 6px; border-radius: 4px; font-size: 10px; font-weight: 500; margin-left: 4px; }
.tag-active { background: var(--green-light); color: var(--green-dark); }
.tag-dormant { background: var(--amber-light); color: var(--amber); }
.tag-deep { background: var(--red-light); color: var(--red); }

.customer-item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid #f0f0f0; }
.customer-item:last-child { border: none; }
.customer-info { flex: 1; min-width: 0; }
.customer-info .name { font-weight: 500; }
.customer-info .detail { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.customer-info .times { font-size: 11px; color: var(--text-hint); margin-top: 2px; }
.customer-actions { display: flex; flex-direction: column; gap: 6px; flex-shrink: 0; }
.customer-actions .btn { flex: none; white-space: nowrap; padding: 6px 10px; }

/* ====== Templates ====== */
.template-group { margin-bottom: 16px; }
.template-group h4 { font-size: 13px; color: var(--green-dark); margin-bottom: 8px; padding-left: 4px; border-left: 3px solid var(--green); padding-left: 8px; }
.template-item { background: white; border-radius: var(--radius-sm); padding: 10px 12px; margin-bottom: 6px; font-size: 13px; line-height: 1.5; border: 1px solid var(--border); cursor: pointer; }
.template-item:active { background: var(--green-light); }
.template-item .cond { font-size: 11px; color: var(--text-hint); margin-top: 4px; }

/* ====== FAB ====== */
.fab { position: fixed; bottom: 70px; right: 16px; width: 50px; height: 50px; border-radius: 50%; background: var(--green); color: white; border: none; font-size: 28px; cursor: pointer; box-shadow: 0 2px 8px rgba(29,158,117,.3); z-index: 5; display: flex; align-items: center; justify-content: center; }
.fab:active { transform: scale(.95); }

/* ====== Toast ====== */
.toast { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: white; padding: 10px 20px; border-radius: 20px; font-size: 13px; z-index: 200; opacity: 0; transition: opacity .3s; }
.toast.show { opacity: 1; }

/* ====== Empty ====== */
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-hint); }
.empty-state .icon { font-size: 48px; opacity: .3; }
.empty-state p { margin-top: 8px; font-size: 13px; }

/* ====== History ====== */
.history-item { padding: 10px 0; border-bottom: 1px solid #f0f0f0; display: flex; align-items: center; gap: 10px; }
.history-item:last-child { border: none; }
.history-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.history-dot.done { background: var(--green); }
.history-body { flex: 1; }
.history-body .top { display: flex; gap: 6px; align-items: center; }
.history-body .note { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.history-body .time { font-size: 11px; color: var(--text-hint); margin-top: 2px; }

/* ====== Task group cards ====== */
.task-group-card { margin-bottom: 14px; border-radius: var(--radius); overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,.04); }
.task-group-header { display: flex; align-items: center; gap: 6px; padding: 10px 14px; font-size: 13px; font-weight: 500; border-radius: 0; }
.task-group-count { margin-left: auto; display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: rgba(255,255,255,.3); font-size: 11px; font-weight: 400; }
.group-select-all { font-size: 11px; font-weight: 400; margin-left: 10px; text-decoration: underline; opacity: .85; cursor: pointer; white-space: nowrap; }
.group-select-all:hover { opacity: 1; }

/* ====== 批量完成 ====== */
.batch-bar { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 90; display: flex; align-items: center; gap: 14px; background: #222; color: #fff; padding: 10px 16px; border-radius: 24px; box-shadow: 0 6px 20px rgba(0,0,0,.25); font-size: 13px; max-width: calc(100vw - 32px); }
.batch-bar b { color: #7ED3A5; }
.batch-item { display: flex; flex-direction: column; gap: 6px; padding: 10px 0; border-bottom: 1px solid #f0f0f0; }
.batch-item:last-child { border: none; }
.batch-info { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.task-group-body { background: white; padding: 4px 14px; }
.task-group-body .task-item { padding: 10px 0; }
.task-group-body .task-item:last-child { border-bottom: none; }

/* ====== Tab bar under header ====== */
.tab-bar { display: flex; background: white; border-bottom: 1px solid var(--border); position: sticky; top: 48px; z-index: 9; }
.tab-item { flex: 1; text-align: center; padding: 10px; font-size: 13px; color: var(--text-hint); cursor: pointer; position: relative; }
.tab-item.active { color: var(--green); font-weight: 500; }
.tab-item.active::after { content: ''; position: absolute; bottom: 0; left: 20%; right: 20%; height: 3px; background: var(--green); border-radius: 3px 3px 0 0; }

/* ====== Staff selector chips ====== */
.chip-group { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.chip { padding: 5px 12px; border-radius: 14px; font-size: 12px; border: 1.5px solid var(--border); background: white; cursor: pointer; }
.chip.active { border-color: var(--green); background: var(--green-light); color: var(--green-dark); font-weight: 500; }

/* ====== WeChat button ====== */
.btn-wechat { width: 32px; height: 32px; border-radius: 50%; border: none; background: var(--green-light); cursor: pointer; flex-shrink: 0; display: flex; align-items: center; justify-content: center; margin-top: 2px; }
.btn-wechat:active { background: #c8e8db; }
.btn-wechat-action { background: var(--green-light); color: var(--green-dark); border: 1.5px solid var(--green); padding: 11px 14px; border-radius: var(--radius-sm); font-weight: 500; cursor: pointer; font-size: 13px; }
.btn-wechat-action:active { opacity: .8; }

/* ====== Responsive ====== */
@media (min-width: 640px) {
  .page-content { max-width: 480px; margin: 0 auto; }
  .modal-content { border-radius: var(--radius); margin-bottom: 40px; }
}
