/* 爱阳光服务队 PWA - 移动端优先卡片式 UI */
:root {
  --primary: #1a6b4f;
  --primary-light: #2e8b6a;
  --primary-bg: #e8f4ef;
  --danger: #d64545;
  --warn: #e8a13c;
  --text: #1f2937;
  --text-2: #6b7280;
  --bg: #f4f6f8;
  --card-bg: #ffffff;
  --border: #e5e7eb;
  --radius: 14px;
  --shadow: 0 2px 8px rgba(0,0,0,.06);
  --tabbar-h: 56px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; }
body { font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif; background: var(--bg); color: var(--text); font-size: 15px; }

#app { max-width: 640px; margin: 0 auto; min-height: 100vh; position: relative; }
.page { display: none; padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); }
.page.active { display: block; }

/* 登录页 */
#page-auth { padding: 20px; background: linear-gradient(160deg, var(--primary) 0%, #145c44 60%, #0e4533 100%); min-height: 100vh; padding-bottom: 40px; }
.auth-hero { text-align: center; color: #fff; padding: 36px 0 24px; }
.auth-logo { width: 84px; height: 84px; border-radius: 22px; background: #fff; padding: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
.auth-hero h1 { margin: 14px 0 4px; font-size: 24px; letter-spacing: 2px; }
.auth-hero p { margin: 0; font-size: 13px; opacity: .85; }
.auth-card { border-radius: 18px; padding: 20px; }
.tabs { display: flex; margin-bottom: 16px; background: var(--bg); border-radius: 10px; padding: 3px; }
.tab-btn { flex: 1; border: none; background: transparent; padding: 9px; border-radius: 8px; font-size: 15px; color: var(--text-2); cursor: pointer; }
.tab-btn.active { background: #fff; color: var(--primary); font-weight: 600; box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* 通用控件 */
.input { width: 100%; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; font-size: 15px; margin-bottom: 12px; outline: none; background: #fff; }
.input:focus { border-color: var(--primary-light); }
textarea.input { min-height: 90px; resize: vertical; }
select.input { appearance: none; }
.btn { border: none; border-radius: 10px; padding: 12px 18px; font-size: 15px; cursor: pointer; }
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:active { background: var(--primary-light); }
.btn.ghost { background: var(--primary-bg); color: var(--primary); }
.btn.danger { background: #fdeaea; color: var(--danger); }
.btn.small { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.btn.block { display: block; width: 100%; }
.btn:disabled { opacity: .5; }
.tip { text-align: center; color: var(--text-2); font-size: 12px; margin-top: 10px; }
.hidden { display: none !important; }
.row { display: flex; gap: 10px; align-items: center; }
.row .grow { flex: 1; }
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; }

/* 顶栏 */
.topbar { position: sticky; top: 0; z-index: 100; background: var(--primary); color: #fff; padding: calc(env(safe-area-inset-top) + 12px) 16px 12px; display: flex; justify-content: space-between; align-items: center; }
.topbar-title { font-size: 17px; font-weight: 600; }
.badge-dot { width: 10px; height: 10px; border-radius: 50%; background: #ffd166; display: inline-block; box-shadow: 0 0 0 3px rgba(255,209,102,.3); }

/* 内容区 */
.content { padding: 12px; }

/* 卡片 */
.card { background: var(--card-bg); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; margin-bottom: 12px; }
.card-title { font-size: 15px; font-weight: 600; margin-bottom: 10px; display: flex; justify-content: space-between; align-items: center; }
.card-title small { color: var(--text-2); font-weight: 400; font-size: 12px; }

/* 工作台 */
.grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.grid-item { background: var(--card-bg); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 6px; text-align: center; cursor: pointer; }
.grid-item:active { transform: scale(.96); }
.grid-item .gi-ic { font-size: 24px; display: block; margin-bottom: 6px; }
.grid-item .gi-name { font-size: 12px; color: var(--text); }
.stat-row { display: flex; gap: 8px; margin-bottom: 12px; }
.stat-card { flex: 1; background: var(--card-bg); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px; text-align: center; }
.stat-card .sc-num { font-size: 22px; font-weight: 700; color: var(--primary); }
.stat-card .sc-label { font-size: 12px; color: var(--text-2); margin-top: 2px; }

/* 列表 */
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); cursor: pointer; }
.list-item:last-child { border-bottom: none; }
.list-item .li-avatar { width: 42px; height: 42px; border-radius: 50%; background: var(--primary-bg); color: var(--primary); display: flex; align-items: center; justify-content: center; font-weight: 600; flex-shrink: 0; }
.list-item .li-main { flex: 1; min-width: 0; }
.list-item .li-title { font-weight: 500; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item .li-sub { font-size: 12px; color: var(--text-2); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item .li-right { text-align: right; flex-shrink: 0; }
.list-item .li-time { font-size: 11px; color: var(--text-2); }
.tag { display: inline-block; font-size: 11px; padding: 2px 7px; border-radius: 6px; background: var(--primary-bg); color: var(--primary); margin-left: 6px; }
.tag.orange { background: #fdf0e0; color: var(--warn); }
.tag.red { background: #fdeaea; color: var(--danger); }
.tag.gray { background: #f1f3f5; color: var(--text-2); }

/* 徽章 */
.nav-badge { position: absolute; top: 4px; right: calc(50% - 22px); background: var(--danger); color: #fff; border-radius: 10px; font-size: 10px; min-width: 16px; height: 16px; line-height: 16px; text-align: center; padding: 0 4px; font-style: normal; display: none; }
.nav-badge.show { display: block; }

/* 底部导航 */
.tabbar { position: fixed; bottom: 0; left: 0; right: 0; z-index: 100; max-width: 640px; margin: 0 auto; background: #fff; border-top: 1px solid var(--border); display: flex; padding-bottom: env(safe-area-inset-bottom); height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); }
.nav-btn { flex: 1; border: none; background: transparent; color: var(--text-2); font-size: 11px; padding: 8px 0 4px; cursor: pointer; position: relative; }
.nav-btn.active { color: var(--primary); font-weight: 600; }
.nav-btn .nav-ic { display: block; font-size: 20px; margin-bottom: 2px; }

/* 聊天 */
.chat-list-empty, .empty { text-align: center; color: var(--text-2); padding: 40px 0; font-size: 13px; }
.chat-window { display: flex; flex-direction: column; height: calc(100vh - var(--tabbar-h) - env(safe-area-inset-bottom)); }
.chat-msgs { flex: 1; overflow-y: auto; padding: 12px; }
.msg { display: flex; gap: 8px; margin-bottom: 14px; }
.msg.me { flex-direction: row-reverse; }
.msg .m-avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--primary-bg); color: var(--primary); display: flex; align-items: center; justify-content: center; font-size: 12px; flex-shrink: 0; }
.msg .m-body { max-width: 72%; }
.msg .m-name { font-size: 11px; color: var(--text-2); margin-bottom: 3px; padding: 0 2px; }
.msg.me .m-name { text-align: right; }
.msg .m-bubble { padding: 10px 12px; border-radius: 12px; background: #fff; box-shadow: var(--shadow); font-size: 14px; line-height: 1.5; word-break: break-word; }
.msg.me .m-bubble { background: var(--primary); color: #fff; border-top-right-radius: 4px; }
.msg .m-bubble.system { background: #f1f3f5; color: var(--text-2); text-align: center; font-size: 12px; }
.msg .m-meta { font-size: 10px; color: var(--text-2); margin-top: 3px; padding: 0 2px; }
.msg.me .m-meta { text-align: right; }
.msg .m-img { max-width: 200px; border-radius: 10px; display: block; }
.msg .m-mention { color: var(--danger); font-style: normal; }
.msg.me .m-mention { color: #ffe0e0; }
.chat-input-bar { border-top: 1px solid var(--border); background: #fff; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); display: flex; gap: 8px; align-items: flex-end; }
.chat-input-bar textarea { flex: 1; border: 1px solid var(--border); border-radius: 10px; padding: 9px 12px; font-size: 14px; resize: none; height: 40px; max-height: 100px; outline: none; font-family: inherit; }
.chat-tools { display: flex; gap: 12px; padding: 6px 12px 2px; background: #fff; border-top: 1px solid var(--border); font-size: 12px; color: var(--text-2); }
.chat-tools button { border: none; background: none; color: var(--primary); font-size: 13px; cursor: pointer; padding: 4px 0; }

/* 详情页头部 */
.detail-header { display: flex; align-items: center; gap: 10px; padding: 4px 0 10px; }
.back-btn { border: none; background: transparent; font-size: 16px; color: var(--primary); cursor: pointer; padding: 4px 8px; }
.detail-header h2 { margin: 0; font-size: 17px; flex: 1; }

/* 审批流 */
.flow-steps { display: flex; align-items: center; gap: 4px; overflow-x: auto; padding: 4px 0; }
.flow-step { flex-shrink: 0; font-size: 12px; background: var(--bg); border-radius: 8px; padding: 6px 10px; color: var(--text-2); white-space: nowrap; }
.flow-step.done { background: var(--primary-bg); color: var(--primary); }
.flow-step.active { background: var(--primary); color: #fff; }

/* 模态框 */
.modal-mask { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 200; display: flex; align-items: center; justify-content: center; padding: 24px; }
.modal { width: 100%; max-width: 400px; }
.modal-title { font-weight: 600; font-size: 16px; margin-bottom: 10px; }
.modal-body { font-size: 14px; color: var(--text); line-height: 1.6; max-height: 55vh; overflow-y: auto; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }

/* Toast */
.toast { position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%); background: rgba(0,0,0,.78); color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 14px; z-index: 300; max-width: 80%; text-align: center; }

/* 荣誉徽章 */
.badge-grid { display: flex; gap: 10px; flex-wrap: wrap; }
.badge-item { background: var(--primary-bg); border-radius: 12px; padding: 10px 14px; text-align: center; }
.badge-item.unearned { opacity: .45; filter: grayscale(1); }
.badge-item .b-ic { font-size: 22px; display: block; }
.badge-item .b-name { font-size: 12px; margin-top: 4px; }

/* 底部滚动加载 */
.section-title { font-size: 14px; font-weight: 600; color: var(--text-2); margin: 14px 0 8px; display: flex; justify-content: space-between; align-items: center; }

/* 进度条 */
.progress { height: 6px; background: var(--bg); border-radius: 4px; overflow: hidden; margin-top: 6px; }
.progress i { display: block; height: 100%; background: var(--primary); border-radius: 4px; }
