/* 佳罗华 pMN 诊疗六步助手・团队版 — 移动端优先样式 */
:root {
    --brand: #2563eb;
    --brand-2: #0d9488;
    --brand-3: #7c3aed;
    --warn: #f59e0b;
    --danger: #dc2626;
    --ok: #16a34a;
    --bg: #f4f7fb;
    --card: #ffffff;
    --text: #1e293b;
    --text-2: #475569;
    --muted: #94a3b8;
    --line: #e6ecf5;
    --radius: 14px;
    --shadow: 0 2px 10px rgba(15, 42, 84, .06);
    --nav-h: 58px;
}

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

body { padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); }

a { color: var(--brand); text-decoration: none; }
img { max-width: 100%; }
ul, ol { margin: 0; padding-left: 1.1em; }

/* ---------- 顶栏 ---------- */
.appbar {
    position: sticky; top: 0; z-index: 50;
    display: flex; align-items: center; gap: 8px;
    height: 50px; padding: 0 12px;
    background: linear-gradient(135deg, var(--brand) 0%, var(--brand-2) 100%);
    color: #fff;
    box-shadow: 0 1px 8px rgba(37, 99, 235, .22);
}
.appbar .title { flex: 1; font-size: 17px; font-weight: 600; letter-spacing: .3px; }
.appbar .title small { display: block; font-size: 11px; font-weight: 400; opacity: .85; }
.appbar .back, .appbar .act {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 34px; height: 34px; border-radius: 10px;
    color: #fff; font-size: 20px; background: rgba(255, 255, 255, .16);
}
.appbar .act { font-size: 13px; padding: 0 10px; }

/* ---------- 容器 ---------- */
.wrap { padding: 12px 12px 20px; }
.section { margin-bottom: 16px; }
.section-title {
    display: flex; align-items: center; justify-content: space-between;
    margin: 0 2px 8px; font-size: 14px; font-weight: 600; color: var(--text-2);
}
.section-title .more { font-size: 12px; color: var(--brand); font-weight: 400; }

/* ---------- 卡片 ---------- */
.card {
    background: var(--card); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 14px; margin-bottom: 12px;
}
.card.tight { padding: 10px 12px; }
.card-h { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.card-h h3 { margin: 0; font-size: 15px; font-weight: 600; }
.card-h .sp { flex: 1; }

/* ---------- 统计格 ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat {
    background: var(--card); border-radius: 12px; box-shadow: var(--shadow);
    padding: 12px 8px; text-align: center;
}
.stat .num { font-size: 22px; font-weight: 700; color: var(--brand); line-height: 1.2; }
.stat .num.red { color: var(--danger); }
.stat .num.teal { color: var(--brand-2); }
.stat .num.amber { color: var(--warn); }
.stat .lbl { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* ---------- 按钮 ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 9px 14px; border: 0; border-radius: 10px;
    background: var(--brand); color: #fff; font-size: 14px; cursor: pointer;
}
.btn:active { opacity: .85; }
.btn.ghost { background: #fff; color: var(--brand); border: 1px solid var(--line); }
.btn.gray { background: #eef2f8; color: var(--text-2); }
.btn.danger { background: var(--danger); }
.btn.warn { background: var(--warn); }
.btn.ok { background: var(--ok); }
.btn.block { display: flex; width: 100%; }
.btn.sm { padding: 5px 10px; font-size: 12px; border-radius: 8px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- 表单 ---------- */
.field { margin-bottom: 12px; }
.field > label {
    display: block; font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 5px;
}
.field .hint { font-size: 11px; color: var(--muted); margin-top: 3px; }
input[type=text], input[type=number], input[type=password], input[type=date], select, textarea {
    width: 100%; padding: 10px 12px; font-size: 15px; font-family: inherit;
    border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--text);
    outline: none; appearance: none;
}
textarea { min-height: 96px; resize: vertical; line-height: 1.6; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(37, 99, 235, .1); }
select { background-image: linear-gradient(45deg, transparent 50%, #94a3b8 50%), linear-gradient(135deg, #94a3b8 50%, transparent 50%); background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }
input[type=file] { padding: 8px; font-size: 13px; }
.check { display: flex; align-items: flex-start; gap: 8px; padding: 7px 0; font-size: 14px; }
.check input { width: 18px; height: 18px; margin: 3px 0 0; accent-color: var(--brand); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }

/* ---------- 标签 ---------- */
.tag {
    display: inline-block; padding: 1px 8px; border-radius: 20px;
    font-size: 11px; background: #eef2f8; color: var(--text-2); margin-right: 4px;
}
.tag.brand { background: rgba(37, 99, 235, .1); color: var(--brand); }
.tag.teal { background: rgba(13, 148, 136, .1); color: var(--brand-2); }
.tag.amber { background: rgba(245, 158, 11, .12); color: #b45309; }
.tag.red { background: rgba(220, 38, 38, .1); color: var(--danger); }
.tag.green { background: rgba(22, 163, 74, .1); color: var(--ok); }
.tag.purple { background: rgba(124, 58, 237, .1); color: var(--brand-3); }
.role-badge {
    display: inline-block; padding: 1px 7px; border-radius: 6px; font-size: 11px; color: #fff; font-weight: 500;
}

/* ---------- 列表 ---------- */
.list { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.list-item {
    display: block; padding: 12px 14px; border-bottom: 1px solid var(--line); color: var(--text);
}
.list-item:last-child { border-bottom: 0; }
.list-item:active { background: #f8fafc; }
.list-item .t { font-size: 15px; font-weight: 600; margin-bottom: 3px; }
.list-item .s { font-size: 12px; color: var(--muted); }
.list-item .meta { font-size: 12px; color: var(--text-2); margin-top: 5px; display: flex; gap: 10px; flex-wrap: wrap; }
.empty { text-align: center; padding: 42px 20px; color: var(--muted); font-size: 14px; }
.empty .ico { font-size: 40px; display: block; margin-bottom: 10px; opacity: .5; }

/* ---------- 六步流程 ---------- */
.path-flow { display: flex; flex-direction: column; gap: 0; }
.step-card {
    position: relative; background: var(--card); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 14px 14px 14px 62px; margin-bottom: 10px; min-height: 76px;
}
.step-card .no {
    position: absolute; left: 12px; top: 14px; width: 36px; height: 36px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff;
    font-size: 17px; font-weight: 700;
}
.step-card .nm { font-size: 16px; font-weight: 600; }
.step-card .sub { font-size: 12px; color: var(--muted); margin: 2px 0 6px; }
.step-card .goal { font-size: 13px; color: var(--text-2); }
.step-card .foot { margin-top: 8px; display: flex; gap: 8px; align-items: center; font-size: 12px; color: var(--brand); }
.connector { width: 2px; height: 10px; background: var(--line); margin: -8px 0 -8px 30px; }

/* 步骤条 */
.stepper { display: flex; gap: 4px; margin-bottom: 12px; overflow-x: auto; padding-bottom: 4px; }
.stepper a {
    flex: 1 0 auto; min-width: 62px; text-align: center; padding: 8px 6px; border-radius: 10px;
    background: #fff; color: var(--text-2); font-size: 12px; box-shadow: var(--shadow);
}
.stepper a.on { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; }
.stepper a .n { display: block; font-size: 16px; font-weight: 700; }

/* 详情块 */
.block { margin-bottom: 14px; }
.block h4 {
    display: flex; align-items: center; gap: 6px; margin: 0 0 7px; font-size: 14px; color: var(--text);
}
.block h4::before { content: ''; width: 3px; height: 14px; background: var(--brand); border-radius: 2px; }
.block ul { padding-left: 18px; margin: 0; }
.block li { margin-bottom: 5px; font-size: 14px; color: var(--text-2); }
.block p { margin: 0 0 6px; font-size: 14px; color: var(--text-2); white-space: pre-wrap; }

/* ---------- 话术 ---------- */
.script-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; margin-bottom: 10px; }
.script-card .hd { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; flex-wrap: wrap; }
.script-card .tt { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.script-card .sc { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.script-card .ct { font-size: 14px; color: var(--text-2); white-space: pre-wrap;
    background: #f8fafc; border-left: 3px solid var(--brand); padding: 10px; border-radius: 0 8px 8px 0; }
.script-card .ft { display: flex; gap: 8px; margin-top: 10px; align-items: center; }
.cat-scroll { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 8px; }
.cat-scroll a {
    flex: 0 0 auto; padding: 7px 14px; border-radius: 20px; background: #fff; color: var(--text-2);
    font-size: 13px; box-shadow: var(--shadow);
}
.cat-scroll a.on { background: var(--brand); color: #fff; }

/* ---------- 筛查 ---------- */
.risk-banner {
    border-radius: var(--radius); padding: 14px; color: #fff; margin-bottom: 12px;
    background: linear-gradient(135deg, var(--brand), var(--brand-2));
}
.risk-banner.r1 { background: linear-gradient(135deg, #34d399, #059669); }
.risk-banner.r2 { background: linear-gradient(135deg, #fbbf24, #d97706); }
.risk-banner.r3 { background: linear-gradient(135deg, #fb923c, #dc2626); }
.risk-banner.r4 { background: linear-gradient(135deg, #ef4444, #7f1d1d); }
.risk-banner .lv { font-size: 20px; font-weight: 700; }
.risk-banner .sc { font-size: 12px; opacity: .9; }
.score-bar { height: 8px; background: #eef2f8; border-radius: 6px; overflow: hidden; margin-top: 8px; }
.score-bar i { display: block; height: 100%; background: #fff; border-radius: 6px; opacity: .95; }

.kv { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.kv:last-child { border-bottom: 0; }
.kv .k { color: var(--text-2); }
.kv .v { font-weight: 600; }

/* 时间轴 */
.timeline { position: relative; padding-left: 22px; }
.timeline::before { content: ''; position: absolute; left: 6px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.tl-item { position: relative; margin-bottom: 12px; }
.tl-item::before {
    content: ''; position: absolute; left: -20px; top: 5px; width: 10px; height: 10px; border-radius: 50%;
    background: var(--brand); box-shadow: 0 0 0 3px rgba(37, 99, 235, .15);
}
.tl-item.done::before { background: var(--ok); box-shadow: 0 0 0 3px rgba(22, 163, 74, .15); }
.tl-item .wk { font-size: 13px; font-weight: 600; }
.tl-item .dt { font-size: 12px; color: var(--muted); }
.tl-item .it { font-size: 13px; color: var(--text-2); margin-top: 3px; }

/* ---------- 论坛 ---------- */
.forum-cat { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.forum-cat a {
    background: var(--card); border-radius: 12px; box-shadow: var(--shadow); padding: 12px 6px; text-align: center;
    color: var(--text);
}
.forum-cat a .ic { font-size: 22px; display: block; }
.forum-cat a .nm { font-size: 12px; margin-top: 3px; }
.topic-item { display: block; padding: 12px 14px; border-bottom: 1px solid var(--line); color: var(--text); }
.topic-item .tt { font-size: 15px; font-weight: 600; line-height: 1.45; }
.topic-item .mt { font-size: 12px; color: var(--muted); margin-top: 5px; display: flex; gap: 10px; flex-wrap: wrap; }
.file-row {
    display: flex; align-items: center; gap: 8px; padding: 10px; background: #f8fafc;
    border-radius: 10px; margin-top: 8px; font-size: 13px;
}
.file-row .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-thumb { display: block; margin-top: 8px; border-radius: 10px; overflow: hidden; background: #f1f5f9; }
.attach-thumb img { display: block; width: 100%; max-height: 320px; object-fit: contain; }
.attach-preview { margin-top: 10px; border-radius: 10px; overflow: hidden; background: #f1f5f9; }
.attach-preview img { display: block; width: 100%; max-height: 220px; object-fit: contain; }
.post { padding: 12px 0; border-bottom: 1px solid var(--line); }
.post .hd { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.post .ct { font-size: 14px; color: var(--text-2); white-space: pre-wrap; }

/* ---------- 积分 ---------- */
.rank-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.rank-row:last-child { border-bottom: 0; }
.rank-no {
    width: 26px; height: 26px; border-radius: 8px; display: flex; align-items: center; justify-content: center;
    background: #eef2f8; color: var(--text-2); font-size: 13px; font-weight: 700;
}
.rank-no.top1 { background: #fbbf24; color: #fff; }
.rank-no.top2 { background: #cbd5e1; color: #fff; }
.rank-no.top3 { background: #d97706; color: #fff; }
.rank-row .nm { flex: 1; font-size: 14px; }
.rank-row .pt { font-weight: 700; color: var(--brand); }

/* ---------- 图表 ---------- */
.chart-box { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px; margin-bottom: 12px; }
.chart { display: block; width: 100%; height: auto; }
.chart-legend { list-style: none; margin: 8px 0 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 4px 10px; }
.chart-legend li { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-2); }
.chart-legend .dot { width: 9px; height: 9px; border-radius: 3px; flex: 0 0 auto; }
.chart-legend .lb { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chart-legend .vl { font-weight: 600; color: var(--text); }
.chart-legend .pct { color: var(--muted); width: 42px; text-align: right; }

/* ---------- 底部导航 ---------- */
.bottomnav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
    display: flex; height: calc(var(--nav-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: rgba(255, 255, 255, .97); border-top: 1px solid var(--line);
    backdrop-filter: blur(8px);
}
.bottomnav a {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    color: var(--muted); font-size: 11px; gap: 2px;
}
.bottomnav a .ic { font-size: 20px; line-height: 1; }
.bottomnav a.on { color: var(--brand); }
.bottomnav a.on .ic { transform: translateY(-1px); }

/* ---------- 浮动按钮 ---------- */
.fab {
    position: fixed; right: 16px; bottom: calc(var(--nav-h) + 18px); z-index: 55;
    width: 50px; height: 50px; border-radius: 25px; border: 0;
    background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff;
    font-size: 26px; line-height: 1; box-shadow: 0 6px 18px rgba(37, 99, 235, .35);
}

/* ---------- 提示 ---------- */
.flash { position: fixed; top: 58px; left: 12px; right: 12px; z-index: 200; }
.flash .item {
    padding: 10px 14px; border-radius: 10px; margin-bottom: 8px; font-size: 14px; color: #fff;
    background: var(--ok); box-shadow: 0 4px 14px rgba(0, 0, 0, .12);
}
.flash .item.error { background: var(--danger); }
.flash .item.info { background: var(--brand); }

.notice {
    background: #fffbeb; border: 1px solid #fde68a; color: #92400e;
    border-radius: 10px; padding: 10px 12px; font-size: 12px; line-height: 1.55; margin-bottom: 12px;
}

/* ---------- 分页 ---------- */
.pager { display: flex; gap: 8px; justify-content: center; align-items: center; padding: 6px 0 4px; font-size: 13px; }
.pager a, .pager span {
    padding: 6px 12px; border-radius: 8px; background: #fff; color: var(--text-2); box-shadow: var(--shadow);
}
.pager a.on { background: var(--brand); color: #fff; }

/* ---------- 搜索栏 ---------- */
.searchbar { display: flex; gap: 8px; margin-bottom: 12px; }
.searchbar input { flex: 1; }
.filterbar { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.filterbar select, .filterbar input { flex: 1; min-width: 110px; }

/* ---------- 登录 ---------- */
.login-page {
    min-height: 100vh; display: flex; flex-direction: column; justify-content: center;
    padding: 28px 22px;
    background: linear-gradient(160deg, #2563eb 0%, #0d9488 55%, #f4f7fb 55%, #f4f7fb 100%);
}
.login-box { background: #fff; border-radius: 18px; padding: 24px 20px; box-shadow: 0 12px 36px rgba(15, 42, 84, .16); }
.login-box .logo { font-size: 30px; text-align: center; }
.login-box h1 { margin: 6px 0 2px; font-size: 19px; text-align: center; }
.login-box .sub { text-align: center; color: var(--muted); font-size: 12px; margin-bottom: 20px; }

/* ---------- 打印 ---------- */
@media print {
    body { background: #fff; padding: 0; }
    .no-print { display: none !important; }
    .card, .chart-box { box-shadow: none; border: 1px solid #ddd; page-break-inside: avoid; }
}
.print-actions { position: fixed; bottom: 20px; left: 12px; right: 12px; display: flex; gap: 10px; }

/* ---------- 角色权限矩阵 ---------- */
.perm-table { width: 100%; border-collapse: collapse; }
.perm-table th, .perm-table td {
    padding: 7px 2px; text-align: center; font-size: 12px;
    border-bottom: 1px solid var(--line); vertical-align: middle;
}
.perm-table thead th {
    color: var(--text-2); font-weight: 500; font-size: 11px;
    border-bottom: 1px solid #d8e2f0; white-space: nowrap;
}
.perm-table td.perm-name, .perm-table th.perm-name { text-align: left; padding-left: 0; }
.perm-table td.perm-name { font-size: 13px; }
.perm-table tbody tr:last-child td { border-bottom: none; }
.perm-table tbody tr.changed td.perm-name { color: var(--brand); }
.perm-ck { width: 17px; height: 17px; margin: 0; vertical-align: middle; }
.perm-ck:disabled { opacity: .45; }
.perm-legend { display: flex; flex-wrap: wrap; gap: 10px 16px; font-size: 12px; color: var(--text-2); }

/* ---------- 大屏适配 ---------- */
@media (min-width: 768px) {
    .app-inner { max-width: 720px; margin: 0 auto; }
    .bottomnav { max-width: 720px; left: 50%; transform: translateX(-50%); border-radius: 16px 16px 0 0; }
    .fab { right: calc(50% - 360px + 16px); }
}
