:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --border: #e5e8ed;
  --border-strong: #d5dae2;
  --text: #1e2330;
  --text-2: #4a5261;
  --muted: #7b8493;
  --primary: #4f46e5;
  --primary-dark: #3f38c9;
  --primary-soft: #eef0ff;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --warn: #d97706;
  --warn-soft: #fffbeb;
  --ok: #059669;
  --ok-soft: #ecfdf5;
  --info: #0284c7;
  --info-soft: #f0f9ff;
  --shadow: 0 1px 2px rgba(20, 28, 45, .04), 0 8px 24px rgba(20, 28, 45, .05);
  --radius: 12px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--primary); text-decoration: none; }
.hidden { display: none !important; }

/* ---------- 通用组件 ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 20px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2);
  border-radius: 8px; padding: 8px 14px; font-weight: 500; white-space: nowrap;
  transition: .16s ease;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }
.btn-danger { color: var(--danger); border-color: #f3c9c9; }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; border-radius: 7px; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--primary-soft); }
.btn-block { width: 100%; }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge-muted { background: #f1f3f6; color: var(--muted); }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-primary { background: var(--primary-soft); color: var(--primary); }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field > label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.field .hint { font-size: 12px; color: var(--muted); }
.input, .textarea, .select {
  width: 100%; border: 1px solid var(--border-strong); border-radius: 8px;
  padding: 9px 11px; background: #fff; outline: none; transition: .15s;
}
.input:focus, .textarea:focus, .select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.textarea { resize: vertical; min-height: 96px; line-height: 1.65; }
.input[type=file] { padding: 7px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }

.sec-title { font-size: 15px; font-weight: 700; margin: 0 0 4px; }
.sec-desc { font-size: 12.5px; color: var(--muted); margin: 0 0 16px; }
.divider { height: 1px; background: var(--border); margin: 18px 0; }
.mono { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.strong { font-weight: 700; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- 登录 ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background: radial-gradient(1200px 600px at 15% -10%, #e8eaff 0%, transparent 60%), var(--bg); }
.login-box { width: 100%; max-width: 880px; display: grid; grid-template-columns: 1.05fr .95fr; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; overflow: hidden; box-shadow: 0 20px 60px rgba(30, 40, 80, .09); }
.login-left { padding: 42px 38px; background: linear-gradient(160deg, #f8f9ff, #f3f5ff); border-right: 1px solid var(--border); }
.login-logo { display: flex; align-items: center; gap: 10px; font-size: 17px; font-weight: 800; margin-bottom: 34px; }
.login-logo .mark { width: 32px; height: 32px; border-radius: 9px; background: var(--primary); color: #fff; display: grid; place-items: center; font-size: 15px; font-weight: 800; }
.login-left h1 { font-size: 26px; line-height: 1.35; margin: 0 0 12px; letter-spacing: -.4px; }
.login-left p { color: var(--text-2); font-size: 13.5px; margin: 0 0 26px; }
.login-feature { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 13px; font-size: 13px; color: var(--text-2); }
.login-feature i { flex: 0 0 auto; width: 19px; height: 19px; border-radius: 6px; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; font-size: 11px; font-weight: 800; font-style: normal; }
.login-right { padding: 42px 38px; }
.login-right h2 { margin: 0 0 6px; font-size: 19px; }
.login-right .sub { color: var(--muted); font-size: 12.5px; margin: 0 0 26px; }
.login-tabs { display: flex; gap: 4px; padding: 4px; margin: -8px 0 20px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.login-tab { flex: 1; padding: 8px 10px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); font-size: 13px; font-weight: 600; }
.login-tab.active { background: var(--surface); color: var(--primary); box-shadow: 0 1px 4px rgba(30, 40, 80, .12); }
.login-note { margin-top: 18px; padding: 12px; border-radius: 9px; background: var(--surface-2); border: 1px solid var(--border); font-size: 12px; color: var(--muted); line-height: 1.7; }
.err-text { color: var(--danger); font-size: 12.5px; min-height: 18px; margin-top: 6px; }

/* ---------- 应用骨架 ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 232px; flex: 0 0 232px; background: #fff; border-right: 1px solid var(--border); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.side-brand { padding: 20px 18px 16px; display: flex; gap: 10px; align-items: center; border-bottom: 1px solid var(--border); }
.side-brand .mark { width: 32px; height: 32px; border-radius: 9px; background: var(--primary); color: #fff; display: grid; place-items: center; font-weight: 800; }
.side-brand b { font-size: 15px; letter-spacing: -.2px; }
.side-brand span { display: block; font-size: 11px; color: var(--muted); font-weight: 500; }
.side-nav { padding: 14px 10px; flex: 1; overflow-y: auto; }
.nav-group { font-size: 11px; color: var(--muted); font-weight: 700; letter-spacing: .5px; padding: 12px 10px 6px; }
.nav-item { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: transparent; padding: 9px 11px; border-radius: 8px; color: var(--text-2); font-size: 13.5px; font-weight: 500; text-align: left; margin-bottom: 2px; }
.nav-item:hover { background: var(--surface-2); }
.nav-item.active { background: var(--primary-soft); color: var(--primary); font-weight: 700; }
.nav-ico { width: 18px; text-align: center; font-size: 14px; opacity: .9; }
.side-foot { padding: 14px; border-top: 1px solid var(--border); }
.user-chip { display: flex; align-items: center; gap: 9px; padding: 8px; border-radius: 9px; background: var(--surface-2); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--primary); color: #fff; display: grid; place-items: center; font-size: 12px; font-weight: 700; flex: 0 0 auto; }
.user-chip .u-name { font-size: 12.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip .u-sub { font-size: 11px; color: var(--muted); }

.main { flex: 1; min-width: 0; }
.topbar { height: 64px; background: rgba(255,255,255,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; padding: 0 28px; position: sticky; top: 0; z-index: 20; }
.topbar h2 { margin: 0; font-size: 17px; font-weight: 700; }
.topbar .crumb { font-size: 12px; color: var(--muted); margin-top: 1px; }
.top-actions { display: flex; gap: 8px; align-items: center; }
.cloud-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); display: inline-block; margin-right: 5px; }
.cloud-dot.off { background: var(--danger); }
.view { padding: 24px 28px 60px; max-width: 1400px; margin: 0 auto; }

/* ---------- 卡片 / 网格 ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.kpi { padding: 18px 20px; }
.kpi .k-label { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.kpi .k-value { font-size: 27px; font-weight: 800; letter-spacing: -.8px; margin-top: 8px; line-height: 1.2; }
.kpi .k-foot { font-size: 11.5px; color: var(--muted); margin-top: 6px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.section-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 14px; }
.stack { display: flex; flex-direction: column; gap: 16px; }

.stat-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px dashed var(--border); font-size: 13px; }
.stat-row:last-child { border-bottom: 0; }
.stat-row .grow { flex: 1; min-width: 0; }
.bar-track { height: 7px; border-radius: 4px; background: #eef0f4; overflow: hidden; flex: 1; }
.bar-fill { height: 100%; border-radius: 4px; background: var(--primary); }

/* ---------- 平台徽标 ---------- */
.pf-logo { width: 34px; height: 34px; border-radius: 9px; color: #fff; display: grid; place-items: center; font-size: 12px; font-weight: 800; flex: 0 0 auto; letter-spacing: -.5px; }
.pf-logo.sm { width: 26px; height: 26px; border-radius: 7px; font-size: 10px; }
.platform-card { display: flex; gap: 12px; align-items: flex-start; padding: 15px; border: 1px solid var(--border); border-radius: 11px; background: var(--surface); transition: .16s; }
.platform-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.platform-card .pf-body { flex: 1; min-width: 0; }
.platform-card .pf-name { font-weight: 700; font-size: 14px; display: flex; gap: 7px; align-items: center; }
.platform-card .pf-meta { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.platform-card .pf-tags { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 9px; }
.platform-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.group-title { font-size: 13px; font-weight: 700; margin: 22px 0 10px; display: flex; align-items: center; gap: 8px; }
.group-title:first-child { margin-top: 0; }
.group-title .g-count { font-size: 11px; color: var(--muted); font-weight: 500; }

/* ---------- 选择器 chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 11px; border: 1px solid var(--border-strong); border-radius: 999px; background: #fff; font-size: 12.5px; color: var(--text-2); user-select: none; }
.chip:hover { border-color: var(--primary); }
.chip.on { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); font-weight: 700; }
.chip .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); }
.chip.on .dot { background: var(--primary); }
.chip.locked { opacity: .55; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th { text-align: left; font-size: 11.5px; color: var(--muted); font-weight: 700; letter-spacing: .3px; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.tbl td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.tbl tr:last-child td { border-bottom: 0; }
table.tbl tbody tr:hover { background: var(--surface-2); }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- 诊断 ---------- */
.risk-hero { display: flex; align-items: center; gap: 22px; padding: 22px; }
.risk-ring { width: 88px; height: 88px; flex: 0 0 auto; border-radius: 50%; display: grid; place-items: center; position: relative; }
.risk-ring .num { font-size: 26px; font-weight: 800; z-index: 1; }
.risk-ring .lab { font-size: 10px; z-index: 1; }
.risk-hero .rh-body { flex: 1; min-width: 0; }
.hit-item { display: flex; gap: 11px; padding: 11px 0; border-bottom: 1px dashed var(--border); }
.hit-item:last-child { border-bottom: 0; }
.hit-word { font-weight: 700; padding: 1px 6px; border-radius: 5px; background: #fff1f1; color: var(--danger); font-size: 13px; }
.hit-item.medium .hit-word { background: var(--warn-soft); color: var(--warn); }
.hit-item.low .hit-word { background: var(--info-soft); color: var(--info); }
.hit-detail { flex: 1; min-width: 0; font-size: 12.5px; }
.hit-detail .h-advice { color: var(--muted); margin-top: 3px; }
.matrix-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); gap: 9px; }
.matrix-cell { border: 1px solid var(--border); border-radius: 9px; padding: 10px 11px; font-size: 12px; }
.matrix-cell .mc-top { display: flex; align-items: center; gap: 7px; font-weight: 700; }
.matrix-cell .mc-score { margin-top: 7px; font-size: 18px; font-weight: 800; }
.matrix-cell .mc-hits { color: var(--muted); font-size: 11px; margin-top: 2px; }
.matrix-cell.lv-high { border-color: #f4c7c7; background: #fffafa; }
.matrix-cell.lv-medium { border-color: #f5dfae; background: #fffdf7; }
.matrix-cell.lv-safe { border-color: #c7ebdb; background: #f8fefb; }

/* ---------- 发布工作台 ---------- */
.pub-card { border: 1px solid var(--border); border-radius: 11px; padding: 15px; background: #fff; display: flex; flex-direction: column; gap: 10px; }
.pub-card.lv-high { border-color: #f1caca; }
.pub-head { display: flex; align-items: center; gap: 9px; }
.pub-head .pf-name { font-weight: 700; flex: 1; }
.pub-preview { font-size: 12.5px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 10px; max-height: 148px; overflow: auto; white-space: pre-wrap; word-break: break-word; }
.pub-preview b { display: block; font-size: 13px; margin-bottom: 4px; }
.pub-tags { font-size: 11.5px; color: var(--info); }
.pub-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.pub-spec { font-size: 11px; color: var(--muted); line-height: 1.55; }
.workspace-grid { display: grid; grid-template-columns: 340px 1fr; gap: 16px; align-items: start; }
.sticky-panel { position: sticky; top: 80px; }

/* ---------- 图表 ---------- */
.chart-svg { width: 100%; height: 190px; display: block; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 11.5px; color: var(--muted); margin-top: 8px; }
.legend i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; margin-right: 4px; }

/* ---------- 弹窗 / 提示 ---------- */
.modal-mask { position: fixed; inset: 0; background: rgba(20, 26, 40, .42); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 560px; max-height: 88vh; overflow: auto; box-shadow: 0 24px 70px rgba(15, 20, 40, .22); }
.modal.wide { max-width: 760px; }
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-body { padding: 20px 22px; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; background: var(--surface-2); }
.close-x { border: 0; background: transparent; font-size: 20px; color: var(--muted); line-height: 1; padding: 2px 6px; }
.toast-root { position: fixed; right: 20px; bottom: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.toast { background: #202634; color: #fff; padding: 10px 15px; border-radius: 9px; font-size: 13px; box-shadow: 0 10px 30px rgba(0,0,0,.2); max-width: 420px; }
.toast.err { background: #a72222; }
.toast.ok { background: #147a5a; }
.empty { text-align: center; padding: 42px 20px; color: var(--muted); }
.empty .e-title { font-size: 14px; font-weight: 700; color: var(--text-2); margin-bottom: 5px; }
.notice { padding: 11px 13px; border-radius: 9px; font-size: 12.5px; line-height: 1.65; border: 1px solid var(--border); background: var(--surface-2); color: var(--text-2); }
.notice.warn { background: var(--warn-soft); border-color: #f3dfb6; color: #8a5a08; }
.notice.info { background: var(--info-soft); border-color: #c9e5f6; color: #0b5f8f; }
.notice.danger { background: var(--danger-soft); border-color: #f3caca; color: #9d2222; }
.boot-error { position: fixed; inset: 0; z-index: 999; background: #fff; display: grid; place-items: center; padding: 24px; }
.boot-error .be-box { max-width: 520px; text-align: center; }
.boot-error h2 { font-size: 18px; }
.boot-error p { color: var(--text-2); font-size: 13px; line-height: 1.8; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.tab { border: 0; background: transparent; padding: 9px 14px; font-size: 13px; color: var(--muted); border-bottom: 2px solid transparent; font-weight: 600; }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px dashed var(--border); font-size: 12.5px; }
.kv:last-child { border-bottom: 0; }
.kv span:first-child { color: var(--muted); }
.step-list { margin: 0; padding-left: 18px; font-size: 12.5px; color: var(--text-2); line-height: 1.9; }

@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .platform-grid, .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .workspace-grid { grid-template-columns: 1fr; }
  .sticky-panel { position: static; }
}
@media (max-width: 780px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; height: auto; flex: none; position: static; border-right: 0; border-bottom: 1px solid var(--border); }
  .side-nav { display: flex; overflow-x: auto; padding: 8px; gap: 3px; }
  .nav-group, .side-foot { display: none; }
  .nav-item { width: auto; white-space: nowrap; margin: 0; }
  .topbar { padding: 0 16px; }
  .view { padding: 16px; }
  .grid-2, .form-row, .form-row-3, .login-box { grid-template-columns: 1fr; }
  .login-left { display: none; }
  .platform-grid, .grid-3, .kpi-grid { grid-template-columns: 1fr; }
}

/* ---- 扫码绑定 · 电脑端弹窗 ---- */
.bind-grid { display: grid; grid-template-columns: 216px 1fr; gap: 20px; align-items: start; }
.qr-box { width: 216px; height: 216px; padding: 10px; border: 1px solid var(--border); border-radius: 12px; background: #fff; display: grid; place-items: center; }
.qr-box svg { width: 100%; height: 100%; display: block; }
.bind-side { min-width: 0; }
.bind-ticket { margin-top: 8px; padding: 8px 10px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--border); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; color: var(--muted); word-break: break-all; }
.bind-choose-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; max-height: 360px; overflow: auto; }
.bind-choose-btn { display: flex; align-items: center; gap: 8px; text-align: left; padding: 9px 10px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); font-size: 13px; }
.bind-choose-btn:hover { border-color: var(--primary); background: var(--primary-soft); }

/* ---- 扫码绑定 · 手机端确认页 ---- */
.bind-page { min-height: 100vh; display: flex; align-items: flex-start; justify-content: center; padding: 24px 16px; background: radial-gradient(700px 400px at 50% -10%, #e8eaff 0%, transparent 60%), var(--bg); }
.bind-card { width: 100%; max-width: 460px; padding: 26px 24px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: 0 18px 50px rgba(30, 40, 80, .09); }
.bind-brand { display: flex; align-items: center; gap: 10px; font-size: 15px; font-weight: 800; margin-bottom: 24px; }
.bind-brand .mark { width: 28px; height: 28px; border-radius: 8px; background: var(--primary); color: #fff; display: grid; place-items: center; font-size: 13px; }
.bind-stage h2 { font-size: 18px; margin: 0 0 6px; }
.bind-stage .sub { color: var(--muted); font-size: 12.5px; margin: 0 0 20px; line-height: 1.7; }
.bind-foot { margin-top: 22px; padding-top: 14px; border-top: 1px solid var(--border); font-size: 11.5px; color: var(--muted); line-height: 1.7; }
.bind-done-ico { width: 44px; height: 44px; margin-bottom: 14px; border-radius: 12px; background: var(--ok-soft); color: var(--ok); display: grid; place-items: center; font-size: 24px; font-weight: 800; }
@media (max-width: 780px) {
  .bind-grid { grid-template-columns: 1fr; }
  .qr-box { margin: 0 auto; }
  .bind-choose-grid { grid-template-columns: 1fr; }
}
