* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif; font-size: 14px; color: #2c2c2a; background: #f7f7f5; }
.hidden { display: none !important; }
a { color: inherit; text-decoration: none; }

/* ---------- 登录 ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: #f1efe8; }
.login-card { background: #fff; border: 1px solid #e3e1d8; border-radius: 16px; padding: 40px 44px; width: 380px; text-align: center; }
.login-card h1 { font-size: 20px; font-weight: 600; margin-bottom: 6px; }
.login-sub { color: #888780; font-size: 13px; margin-bottom: 28px; }
.login-form input { width: 100%; padding: 10px 14px; border: 1px solid #d3d1c7; border-radius: 8px; margin-bottom: 14px; font-size: 14px; }
.login-form input:focus { outline: none; border-color: #534ab7; }
.login-err { color: #a32d2d; font-size: 13px; min-height: 18px; }
.login-tip { color: #b4b2a9; font-size: 12px; margin-top: 6px; }

/* ---------- 布局 ---------- */
.app { display: flex; height: 100vh; }
.sidebar { width: 220px; background: #fff; border-right: 1px solid #e6e4dc; display: flex; flex-direction: column; flex-shrink: 0; }
.brand { font-size: 16px; font-weight: 600; padding: 22px 20px 18px; border-bottom: 1px solid #f0eee6; }
#nav { flex: 1; padding: 12px 10px; }
#nav { flex: 1; overflow-y: auto; }
#nav a { display: block; padding: 10px 14px; border-radius: 8px; margin-bottom: 2px; color: #5f5e5a; font-size: 14px; }
#nav a:hover { background: #f1efe8; }
#nav a.active { background: #eeedfe; color: #534ab7; font-weight: 500; }
.sidebar-foot { padding: 14px; border-top: 1px solid #f0eee6; }
.user-box { margin-bottom: 10px; }
.user-box .uname { font-weight: 500; }
.user-box .urole { font-size: 12px; color: #888780; }
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }
#main { flex: 1; overflow-y: auto; padding: 24px 28px; }
/* ---------- 内嵌子应用（iframe 常驻，切换不重载） ---------- */
.embed-area { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.embed-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; background: #fff; border-bottom: 1px solid #e6e4dc; flex-shrink: 0; }
.embed-head .etitle { font-size: 15px; font-weight: 600; color: #2c2c2a; display: flex; align-items: center; gap: 8px; }
.embed-head .esub { font-size: 12px; color: #888780; font-weight: 400; }
.embed-body { flex: 1; position: relative; min-height: 0; background: #f9fafb; }
.embed-pane { position: absolute; inset: 0; display: none; }
.embed-pane.active { display: block; }
.embed-pane iframe { width: 100%; height: 100%; border: 0; display: block; background: #fff; }
.embed-actions { display: flex; align-items: center; gap: 8px; }
.page-title { font-size: 18px; font-weight: 600; margin-bottom: 18px; display: flex; align-items: center; justify-content: space-between; }

/* ---------- 通用组件 ---------- */
.btn { padding: 7px 16px; border: 1px solid #d3d1c7; border-radius: 8px; background: #fff; cursor: pointer; font-size: 13px; color: #444; }
.btn:hover { border-color: #b4b2a9; background: #f7f7f5; }
.btn-primary { background: #534ab7; border-color: #534ab7; color: #fff; }
.btn-primary:hover { background: #463da1; border-color: #463da1; }
.btn-sm { padding: 3px 10px; font-size: 12px; }
.btn-danger { color: #a32d2d; }
.btn-block { width: 100%; }
input, select, textarea { font-family: inherit; font-size: 13px; padding: 7px 10px; border: 1px solid #d3d1c7; border-radius: 6px; background: #fff; }
input:focus, select:focus, textarea:focus { outline: none; border-color: #7f77dd; }
table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid #e6e4dc; border-radius: 10px; overflow: hidden; }
th { text-align: left; font-size: 12px; color: #888780; font-weight: 500; background: #faf9f4; padding: 10px 12px; border-bottom: 1px solid #e6e4dc; white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid #f0eee6; font-size: 13px; }
tr:hover td { background: #faf9f4; }
tr:last-child td { border-bottom: none; }
.toolbar { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; align-items: center; }

/* ---------- 指标卡 ---------- */
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 20px; }
.metric { background: #fff; border: 1px solid #e6e4dc; border-radius: 10px; padding: 14px 16px; }
.metric .mlabel { font-size: 12px; color: #888780; margin-bottom: 6px; }
.metric .mval { font-size: 24px; font-weight: 600; }
.metric .msub { font-size: 12px; color: #888780; margin-top: 4px; }

.card { background: #fff; border: 1px solid #e6e4dc; border-radius: 10px; padding: 16px 18px; margin-bottom: 16px; }
.card h3 { font-size: 14px; font-weight: 600; margin-bottom: 12px; color: #444; }

/* 阶段分布条 */
.stage-bar { display: flex; height: 26px; border-radius: 7px; overflow: hidden; margin: 10px 0 8px; }
.stage-bar .seg { min-width: 0; }
.stage-legend { display: flex; flex-wrap: wrap; gap: 10px 18px; font-size: 12px; color: #5f5e5a; }
.stage-legend .dot { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }

/* 销量趋势 CSS 柱状图 */
.chart { display: flex; align-items: flex-end; gap: 2px; height: 120px; margin-top: 10px; }
.chart .bar { flex: 1; background: #afa9ec; border-radius: 2px 2px 0 0; min-height: 1px; }
.chart .bar:hover { background: #534ab7; }

/* ---------- 状态徽章 ---------- */
.tag { display: inline-block; font-size: 12px; padding: 2px 10px; border-radius: 10px; white-space: nowrap; }
.tag-research { background: #e6f1fb; color: #0c447c; }
.tag-review { background: #e6f1fb; color: #0c447c; }
.tag-sampling { background: #faeeda; color: #633806; }
.tag-listing { background: #faeeda; color: #633806; }
.tag-growth { background: #e1f5ee; color: #085041; }
.tag-mature { background: #e1f5ee; color: #085041; }
.tag-clearance { background: #faece7; color: #712b13; }
.tag-archived { background: #f1efe8; color: #888780; }
.tag-todo { background: #f1efe8; color: #5f5e5a; }
.tag-doing { background: #faeeda; color: #633806; }
.tag-done { background: #e1f5ee; color: #085041; }
.tag-high { background: #fcebeb; color: #791f1f; }
.tag-mid { background: #faeeda; color: #633806; }
.tag-low { background: #e6f1fb; color: #0c447c; }
.overdue { color: #a32d2d; font-weight: 500; }

/* ---------- 看板 ---------- */
.kanban { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; align-items: start; }
.kanban-col { background: #f4f2ec; border-radius: 10px; padding: 10px; min-height: 300px; }
.kanban-col h4 { font-size: 13px; color: #5f5e5a; margin: 4px 6px 10px; display: flex; justify-content: space-between; }
.task-card { background: #fff; border: 1px solid #e6e4dc; border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; }
.task-card .tt { font-weight: 500; margin-bottom: 6px; line-height: 1.5; }
.task-card .tmeta { font-size: 12px; color: #888780; display: flex; flex-wrap: wrap; gap: 4px 12px; margin-bottom: 8px; }
.task-card .tops { display: flex; justify-content: space-between; align-items: center; }

/* ---------- 抽屉详情 ---------- */
.drawer-mask { position: fixed; inset: 0; background: rgba(44,44,42,0.25); z-index: 50; }
.drawer { position: fixed; top: 0; right: -640px; width: 620px; max-width: 92vw; height: 100vh; background: #fff; z-index: 51; overflow-y: auto; padding: 24px 26px; transition: right 0.25s ease; box-shadow: -4px 0 24px rgba(0,0,0,0.08); }
.drawer.open { right: 0; }
.drawer h2 { font-size: 17px; margin-bottom: 4px; padding-right: 30px; }
.drawer .dsub { color: #888780; font-size: 12px; margin-bottom: 18px; }
.drawer-close { position: absolute; top: 18px; right: 20px; border: none; background: none; font-size: 20px; cursor: pointer; color: #888780; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; margin-bottom: 18px; }
.field-grid label { display: block; font-size: 12px; color: #888780; margin-bottom: 4px; }
.field-grid input, .field-grid select, .field-grid textarea { width: 100%; }
.field-grid .full { grid-column: 1 / -1; }
.log-item { padding: 8px 0; border-bottom: 1px dashed #e6e4dc; font-size: 12px; color: #5f5e5a; }
.move-bar { display: flex; gap: 10px; margin: 14px 0 20px; }

.empty { color: #b4b2a9; text-align: center; padding: 30px; font-size: 13px; }
.muted { color: #888780; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.form-row .full { grid-column: 1 / -1; display: flex; gap: 8px; }
code { background: #f1efe8; padding: 1px 6px; border-radius: 4px; font-size: 12px; }

/* ── 库存链路 ERP 外链入口 ── */
.nav-sep { height: 1px; background: rgba(148,163,184,.25); margin: 10px 8px; }
.nav-ext { color: #b6c6e0; font-size: 13px; }
.nav-ext:hover { color: #fff; }

/* ── 1688 询价视图 ── */
.inq-search { display: flex; gap: 10px; }
.inq-search select { min-width: 130px; }
.inq-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; font-size: 13px; }
.link { color: var(--primary, #378add); text-decoration: none; }
.link:hover { text-decoration: underline; }

/* ── 产品调研视图 ── */
.res-input { display: flex; gap: 10px; flex-wrap: wrap; }
.res-input input { min-width: 160px; }

/* ── 岗位与权限 ── */
.nav-ro-tag { font-size: 10px; color: #a8a6a0; border: 1px solid #e0ded6; border-radius: 4px; padding: 0 4px; margin-left: 4px; font-weight: 400; }
.nav-empty { padding: 18px 12px; font-size: 12px; color: #888780; line-height: 1.9; text-align: center; }
.ro-note { font-size: 12px; color: #888780; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid #e6e4dc; margin-bottom: 16px; }
.tab { background: none; border: 0; border-bottom: 2px solid transparent; padding: 8px 14px; cursor: pointer; font-size: 14px; color: #5f5e5a; }
.tab:hover { color: #2c2c2a; }
.tab.active { color: #534ab7; border-bottom-color: #534ab7; font-weight: 500; }
.tab-cnt { font-size: 11px; color: #a8a6a0; margin-left: 5px; }

.pos-select { padding: 3px 6px; font-size: 12px; border: 1px solid #d3d1c7; border-radius: 6px; background: #fff; color: #444; }

.perm-toolbar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }
#permMatrix { overflow-x: auto; padding-bottom: 4px; }
.perm-matrix th, .perm-matrix td { text-align: center; vertical-align: middle; }
.perm-matrix .pm-mod { text-align: left; width: 168px; min-width: 168px; }
.perm-matrix th:not(.pm-mod), .perm-matrix td:not(.pm-mod) { min-width: 104px; }
.pm-modname { font-size: 13px; color: #2c2c2a; }
.pm-modgroup { font-size: 11px; color: #a8a6a0; }
.pm-posname { font-size: 13px; font-weight: 500; }
.pm-posmeta { font-size: 11px; color: #a8a6a0; font-weight: 400; }
.pm-posops { font-size: 11px; font-weight: 400; margin-top: 3px; }
.pm-posops a { color: #534ab7; margin: 0 3px; text-decoration: none; }
.pm-posops a:hover { text-decoration: underline; }
.pm-posops a.danger { color: #a32d2d; }

.plv { width: 100%; padding: 5px 0; border-radius: 6px; border: 1px solid #e6e4dc; font-size: 12px; cursor: pointer; background: #faf9f6; color: #888780; }
.plv:hover { border-color: #b4b2a9; }
.plv:disabled { cursor: default; opacity: .7; }
.plv-none { background: #faf9f6; color: #b4b2a9; }
.plv-read { background: #e8f0fb; color: #2c6cb0; border-color: #c5daf5; }
.plv-write { background: #e6f5ee; color: #1d7a5c; border-color: #bfe6d5; }

.perm-savebar { position: sticky; bottom: 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 14px; padding: 10px 14px; background: #fff8e6; border: 1px solid #f0dcae; border-radius: 10px; font-size: 13px; color: #7a5c14; }
.mk-llm-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px dashed #e8e6e0; flex-wrap: wrap; }
.mk-llm-row:last-child { border-bottom: none; }
.mk-badge-ai { font-size: 12px; font-weight: 600; color: #0a7d33; background: #e6f7ec; border: 1px solid #b7e2c6; border-radius: 6px; padding: 2px 8px; }
.mk-badge-mock { font-size: 12px; font-weight: 600; color: #7a5c14; background: #fff8e6; border: 1px solid #f0dcae; border-radius: 6px; padding: 2px 8px; }

.ro-badge { font-size: 11px; font-weight: 400; color: #7a5c14; background: #fff8e6; border: 1px solid #f0dcae; border-radius: 5px; padding: 1px 6px; margin-left: 4px; }

/* ── 市场调研报告视图 ── */
.mk-form .mk-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.mk-form .mk-row input, .mk-form .mk-row select { min-width: 0; }
.mk-head h2 { font-size: 19px; }
.mk-score { text-align: center; background: #f7f7f5; border-radius: 12px; padding: 12px 20px; flex-shrink: 0; }
.mk-score-v { font-size: 34px; font-weight: 700; line-height: 1.1; }
.mk-score-l { font-size: 11px; color: #888780; }
.mk-go { color: #1d7a5c; }
.mk-mid { color: #b07c14; }
.mk-no { color: #a32d2d; }
.mk-rec { display: inline-block; margin-top: 10px; padding: 5px 14px; border-radius: 8px; font-size: 13px; font-weight: 500; }
.mk-rec-go { background: #e6f5ee; color: #1d7a5c; }
.mk-rec-mid { background: #faeeda; color: #633806; }
.mk-rec-no { background: #fcebeb; color: #791f1f; }
.mk-comp { margin-top: 10px; padding: 8px 12px; background: #f7f7f5; border-radius: 8px; font-size: 12px; color: #5f5e5a; }
.mk-kw { display: inline-block; margin: 0 6px 6px 0; padding: 4px 12px; border-radius: 14px; background: #eef0fb; border: 1px solid #c9cef0; color: #4538a8; font-size: 13px; font-weight: 500; text-decoration: none; font-family: Consolas, Menlo, monospace; }
.mk-kw:hover { background: #e2e6fa; border-color: #534ab7; }
.mk-fin { margin-top: 10px; padding: 9px 14px; background: #f3f6fb; border-radius: 8px; font-size: 13px; }
.mk-sec-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; gap: 10px; flex-wrap: wrap; }
.mk-textarea { width: 100%; font-family: Consolas, "Courier New", monospace; font-size: 12.5px; line-height: 1.7; }

/* 报告内 markdown 渲染 */
.md-body { font-size: 13.5px; line-height: 1.85; color: #3a3a37; }
.md-body .md-h { margin: 14px 0 8px; font-weight: 600; color: #2c2c2a; }
.md-body h3.md-h { font-size: 15px; }
.md-body h4.md-h, .md-body h5.md-h, .md-body h6.md-h { font-size: 13.5px; }
.md-body .md-p { margin: 6px 0; }
.md-body .md-list { margin: 6px 0 6px 22px; }
.md-body .md-quote { margin: 8px 0; padding: 6px 12px; border-left: 3px solid #afa9ec; background: #f7f6fd; border-radius: 0 6px 6px 0; color: #5f5e5a; font-size: 12.5px; }
.md-body .md-table { width: 100%; border-collapse: collapse; margin: 10px 0; font-size: 12.5px; }
.md-body .md-table td { border: 1px solid #e6e4dc; padding: 7px 10px; }
.md-body .md-table tr:first-child td { background: #faf9f4; font-weight: 500; }
.md-body .md-table tr:hover td { background: #faf9f4; }

/* 打印：只打报告，隐藏侧栏与按钮 */
@media print {
  .sidebar, .page-title .btn, .mk-sec-head .btn, .mk-comp, .mk-sec-head, .mk-head .tag { display: none !important; }
  .app { height: auto; }
  #main { overflow: visible; padding: 0; }
  .card { border: none; box-shadow: none; page-break-inside: avoid; }
}
