/* ==========================================================================
   外贸综合服务平台 · v0.3 出口企业项目执行（0起步外贸 WBS）
   --------------------------------------------------------------------------
   与 app.css 共用 --bg / --text / --accent 等主题变量，因此暗 / 亮主题自动跟随
   #app[data-theme]。本文件只负责项目视图自身的布局与组件，不改地图样式。
   ========================================================================== */

/* 默认不参与布局；只有 #app[data-view="pm"] 时替换掉地图工作区 */
.pm-view { display:none; flex:1 1 auto; min-height:0; flex-direction:column; background:var(--bg-0); }
.app[data-view="pm"] .workspace { display:none; }
.app[data-view="pm"] .mobile-list { display:none !important; }
.app[data-view="pm"] .pm-view { display:flex; }

/* ---------------- 顶部工具栏 ---------------- */
.pm-toolbar {
  flex:0 0 auto; display:flex; align-items:center; justify-content:space-between;
  gap:14px; padding:10px 16px; background:var(--bg-1); border-bottom:1px solid var(--line);
}
.pm-tb-left { display:flex; align-items:center; gap:12px; min-width:0; }
.pm-back { padding:7px 10px; font-size:11.5px; }
.pm-tb-title { min-width:0; }
.pm-tb-title h2 { margin:0; font-size:15px; font-weight:650; color:var(--text); display:flex; align-items:center; gap:8px; }
.pm-tb-title p { margin:3px 0 0; font-size:10.5px; color:var(--text-3); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.pm-tb-actions { display:flex; gap:7px; flex:0 0 auto; }
.pm-tb-actions .btn { padding:7px 11px; font-size:11.5px; }

/* ---------------- 主布局 ---------------- */
.pm-layout { flex:1 1 auto; min-height:0; display:grid; grid-template-columns:294px minmax(0,1fr); }
.pm-side { display:flex; flex-direction:column; min-height:0; background:var(--bg-1); border-right:1px solid var(--line); }
.pm-side-head { padding:11px 12px 9px; border-bottom:1px solid var(--line); }
.pm-search-box { display:flex; align-items:center; gap:7px; background:var(--bg-2); border:1px solid var(--line-strong); border-radius:8px; padding:0 9px; color:var(--text-3); }
.pm-search-box input { flex:1; min-width:0; border:0; outline:0; background:transparent; color:var(--text); font-size:11.5px; padding:8px 0; }
.pm-search-box input::placeholder { color:var(--text-3); }
.pm-kpi { display:grid; grid-template-columns:repeat(3,1fr); gap:6px; margin-top:9px; }
.pm-kpi-cell { background:var(--bg-2); border:1px solid var(--line); border-radius:8px; padding:7px 8px; text-align:center; }
.pm-kpi-cell b { display:block; font-size:15px; color:var(--text); line-height:1.2; }
.pm-kpi-cell span { font-size:9.5px; color:var(--text-3); }
.pm-list-head { display:flex; align-items:center; justify-content:space-between; padding:9px 12px 6px; font-size:11px; font-weight:650; color:var(--text-2); }
.pm-list-hint { display:none; font-size:9px; font-weight:400; color:var(--text-3); margin-left:6px; }
.pm-project-list { flex:1 1 auto; min-height:0; overflow-y:auto; padding:0 8px 12px; -webkit-overflow-scrolling:touch; }
.pm-proj {
  display:block; width:100%; text-align:left; border:1px solid transparent; background:transparent;
  border-radius:9px; padding:9px 10px; margin-bottom:3px; color:var(--text); cursor:pointer;
}
.pm-proj:hover { background:var(--bg-2); }
.pm-proj.active { background:var(--accent-soft); border-color:var(--accent); }
.pm-proj-top { display:flex; align-items:center; gap:7px; }
.pm-proj-name { flex:1; min-width:0; font-size:11.5px; font-weight:600; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.pm-proj-pct { font-size:11px; font-weight:700; color:var(--accent); font-variant-numeric:tabular-nums; }
.pm-proj-sub { margin-top:3px; font-size:9.5px; color:var(--text-3); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.pm-proj-bar { height:4px; border-radius:4px; background:var(--bg-3); overflow:hidden; margin-top:6px; }
.pm-proj-bar i { display:block; height:100%; background:var(--accent); border-radius:4px; transition:width .2s; }

/* ---------------- 右侧内容 ---------------- */
.pm-main { min-width:0; overflow-y:auto; padding:16px 18px 28px; -webkit-overflow-scrolling:touch; }
.pm-sec { margin-bottom:18px; }
.pm-sec-head { display:flex; align-items:center; justify-content:space-between; gap:10px; margin-bottom:9px; }
.pm-sec-head h3 { margin:0; font-size:13px; font-weight:650; color:var(--text); }
.pm-sec-head p { margin:0; font-size:10.5px; color:var(--text-3); }

.pm-hero {
  background:linear-gradient(120deg,var(--bg-2),var(--bg-1));
  border:1px solid var(--line-strong); border-radius:12px; padding:16px 18px;
}
.pm-hero h3 { margin:0 0 5px; font-size:17px; color:var(--text); }
.pm-hero .pm-hero-sub { font-size:11px; color:var(--text-3); line-height:1.65; }
.pm-hero-grid { display:grid; grid-template-columns:repeat(5,1fr); gap:9px; margin-top:14px; }
.pm-hero-cell { background:var(--bg-1); border:1px solid var(--line); border-radius:9px; padding:9px 10px; }
.pm-hero-cell b { display:block; font-size:19px; color:var(--text); line-height:1.25; font-variant-numeric:tabular-nums; }
.pm-hero-cell span { font-size:10px; color:var(--text-3); }
.pm-big-bar { height:9px; border-radius:9px; background:var(--bg-3); overflow:hidden; margin-top:14px; }
.pm-big-bar i { display:block; height:100%; background:linear-gradient(90deg,var(--accent),var(--ok)); border-radius:9px; }
.pm-bar-legend { display:flex; justify-content:space-between; margin-top:6px; font-size:10px; color:var(--text-3); }

/* 阶段卡片 / 进度条 */
.pm-stage-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:9px; }
.pm-stage-card { background:var(--bg-2); border:1px solid var(--line); border-radius:9px; padding:10px 11px; cursor:pointer; transition:.16s; }
.pm-stage-card:hover { border-color:var(--accent); }
.pm-stage-card.on { border-color:var(--accent); background:var(--accent-soft); }
.pm-stage-top { display:flex; justify-content:space-between; align-items:baseline; gap:6px; }
.pm-stage-top b { font-size:11px; color:var(--text); }
.pm-stage-top span { font-size:11px; font-weight:700; color:var(--accent); font-variant-numeric:tabular-nums; }
.pm-stage-name { font-size:10px; color:var(--text-3); margin-top:3px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.pm-stage-bar { height:5px; border-radius:5px; background:var(--bg-3); overflow:hidden; margin-top:8px; }
.pm-stage-bar i { display:block; height:100%; background:var(--accent); border-radius:5px; }
.pm-stage-meta { margin-top:6px; font-size:9.5px; color:var(--text-3); }

/* 过滤器 */
.pm-filters { display:flex; flex-wrap:wrap; gap:8px; align-items:center; background:var(--bg-2); border:1px solid var(--line); border-radius:9px; padding:10px; }
.pm-filters select, .pm-filters input[type=search] {
  background:var(--bg-1); border:1px solid var(--line-strong); border-radius:7px;
  color:var(--text); font-size:11px; padding:7px 9px; outline:0; min-width:0;
}
.pm-filters input[type=search] { flex:1 1 160px; }
.pm-filters select { flex:0 0 auto; max-width:190px; }
.pm-check { display:inline-flex; align-items:center; gap:5px; font-size:10.5px; color:var(--text-2); white-space:nowrap; cursor:pointer; }
.pm-filters .pm-count { margin-left:auto; font-size:10.5px; color:var(--text-3); }

/* 任务表 */
.pm-table { width:100%; border-collapse:collapse; font-size:11px; }
.pm-table th {
  text-align:left; font-size:10px; font-weight:600; color:var(--text-3);
  padding:8px 9px; border-bottom:1px solid var(--line-strong); white-space:nowrap;
  background:var(--bg-1); position:sticky; top:0; z-index:1;
}
.pm-table td { padding:8px 9px; border-bottom:1px solid var(--line); color:var(--text-2); vertical-align:middle; }
.pm-table tr:hover td { background:var(--bg-2); }
.pm-table .pm-wbs { font-variant-numeric:tabular-nums; color:var(--text-3); white-space:nowrap; font-size:10px; }
.pm-table .pm-tname { color:var(--text); min-width:230px; line-height:1.5; }
.pm-table .pm-l1 td { background:var(--bg-2); font-weight:650; color:var(--text); }
.pm-table .pm-l2 td { color:var(--text-2); font-weight:600; }
.pm-table .pm-l3 .pm-tname { padding-left:14px; }
.pm-table .pm-l4 .pm-tname { padding-left:28px; }
.pm-table .pm-num { font-variant-numeric:tabular-nums; text-align:right; }
.pm-tags { display:inline-flex; gap:4px; margin-left:5px; vertical-align:middle; }
.pm-tag { font-size:9px; padding:1px 5px; border-radius:4px; border:1px solid var(--line-strong); color:var(--text-3); white-space:nowrap; }
.pm-tag.risk { color:var(--danger); border-color:rgba(242,112,122,.4); background:rgba(242,112,122,.1); }
.pm-tag.riskitem { color:var(--warn); border-color:rgba(245,185,66,.4); background:rgba(245,185,66,.1); }
.pm-tag.url { color:var(--accent); border-color:rgba(61,139,255,.4); background:rgba(61,139,255,.1); }
.pm-tag.mile { color:var(--ok); border-color:rgba(49,196,141,.4); background:rgba(49,196,141,.1); }
.pm-url { color:var(--accent); text-decoration:none; }
.pm-url:hover { text-decoration:underline; }
.pm-badge { display:inline-block; font-size:9.5px; padding:2px 7px; border-radius:20px; border:1px solid var(--line-strong); color:var(--text-3); white-space:nowrap; }
.pm-badge.st-doing { color:var(--accent); border-color:var(--accent); background:var(--accent-soft); }
.pm-badge.st-done { color:var(--ok); border-color:rgba(49,196,141,.5); background:rgba(49,196,141,.1); }
.pm-badge.st-late { color:var(--danger); border-color:rgba(242,112,122,.5); background:rgba(242,112,122,.1); }
.pm-badge.st-pause { color:var(--warn); border-color:rgba(245,185,66,.5); background:rgba(245,185,66,.1); }
.pm-badge.st-na { color:var(--text-3); }
.pm-mini-bar { width:64px; height:5px; border-radius:5px; background:var(--bg-3); overflow:hidden; display:inline-block; vertical-align:middle; margin-right:6px; }
.pm-mini-bar i { display:block; height:100%; background:var(--accent); }
.pm-row-btn { border:1px solid var(--line-strong); background:var(--bg-2); color:var(--text-2); border-radius:6px; padding:4px 8px; font-size:10px; cursor:pointer; white-space:nowrap; }
.pm-row-btn:hover { color:var(--text); border-color:var(--accent); }
.pm-row-btn:disabled { opacity:.4; cursor:not-allowed; }
.pm-empty { padding:26px 14px; text-align:center; color:var(--text-3); font-size:11px; }

/* 里程碑 / 风险 / 日志 */
.pm-cards { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:8px; }
.pm-card { background:var(--bg-2); border:1px solid var(--line); border-radius:9px; padding:10px 11px; }
.pm-card b { display:block; font-size:11px; color:var(--text); }
.pm-card p { margin:5px 0 0; font-size:10px; color:var(--text-3); line-height:1.6; }
.pm-card-foot { display:flex; align-items:center; justify-content:space-between; margin-top:8px; }
.pm-list { background:var(--bg-2); border:1px solid var(--line); border-radius:9px; overflow:hidden; }
.pm-list-row { display:flex; gap:10px; align-items:center; padding:9px 11px; border-bottom:1px solid var(--line); }
.pm-list-row:last-child { border-bottom:0; }
.pm-list-row .pm-code { flex:0 0 auto; font-size:10px; color:var(--text-3); font-variant-numeric:tabular-nums; }
.pm-list-row .pm-lbody { flex:1; min-width:0; font-size:10.5px; color:var(--text-2); line-height:1.55; }
.pm-list-row .pm-lbody b { color:var(--text); font-weight:600; }
.pm-list-row .pm-lmeta { flex:0 0 auto; text-align:right; font-size:9.5px; color:var(--text-3); }

/* ---------------- 弹窗 ---------------- */
.pm-modal { position:fixed; inset:0; z-index:2100; display:flex; align-items:center; justify-content:center; padding:18px; background:rgba(4,10,20,.6); }
.pm-modal[hidden] { display:none !important; }
.pm-modal-card { width:min(560px,100%); max-height:88dvh; display:flex; flex-direction:column; background:var(--bg-1); border:1px solid var(--line-strong); border-radius:12px; box-shadow:var(--shadow); }
.pm-modal-head { display:flex; justify-content:space-between; align-items:flex-start; gap:12px; padding:14px 16px; border-bottom:1px solid var(--line); }
.pm-modal-head h3 { margin:0; font-size:14px; color:var(--text); }
.pm-modal-head p { margin:4px 0 0; font-size:10.5px; color:var(--text-3); }
.pm-modal-body { padding:14px 16px; overflow-y:auto; flex:1 1 auto; }
.pm-modal-foot { display:flex; justify-content:flex-end; gap:8px; padding:11px 16px; border-top:1px solid var(--line); background:var(--bg-2); }
.pm-field { display:flex; flex-direction:column; gap:5px; margin-bottom:11px; }
.pm-field label { font-size:10.5px; color:var(--text-3); }
.pm-field input, .pm-field select, .pm-field textarea {
  width:100%; box-sizing:border-box; background:var(--bg-2); color:var(--text);
  border:1px solid var(--line-strong); border-radius:7px; padding:8px 9px; font-size:11.5px; outline:0;
  font-family:inherit;
}
.pm-field textarea { resize:vertical; min-height:60px; }
.pm-field input:focus, .pm-field select:focus, .pm-field textarea:focus { border-color:var(--accent); }
.pm-field-2 { display:grid; grid-template-columns:1fr 1fr; gap:10px; }
.pm-note { font-size:10px; color:var(--text-3); line-height:1.65; background:var(--bg-2); border:1px solid var(--line); border-radius:8px; padding:9px 10px; margin-top:4px; }

/* ---------------- 响应式 ---------------- */
@media (max-width:1380px) {
  .pm-layout { grid-template-columns:262px minmax(0,1fr); }
  .pm-hero-grid { grid-template-columns:repeat(3,1fr); }
  .pm-cards { grid-template-columns:repeat(2,minmax(0,1fr)); }
}
@media (max-width:1150px) {
  .pm-layout { grid-template-columns:228px minmax(0,1fr); }
  .pm-stage-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .pm-main { padding:13px 13px 24px; }
}
@media (max-width:820px) {
  .pm-toolbar { padding:8px 10px; gap:8px; }
  .pm-back { display:none; }               /* H5 用底栏切回地图 */
  .pm-tb-title h2 { font-size:13px; }
  .pm-tb-title p { font-size:9.5px; }
  .pm-tb-actions .btn { padding:6px 8px; font-size:10px; }
  .pm-tb-actions #pmRefresh { display:none; }
  .pm-layout { display:flex; flex-direction:column; }
  .pm-side { flex:0 0 auto; max-height:190px; border-right:0; border-bottom:1px solid var(--line); }
  .pm-side-head { padding:8px 10px 6px; }
  .pm-kpi { margin-top:7px; }
  .pm-kpi-cell { padding:5px 6px; }
  .pm-kpi-cell b { font-size:13px; }
  .pm-list-head { padding:6px 10px 3px; }
  .pm-list-hint { display:inline; }
  .pm-project-list { max-height:108px; padding:0 6px 6px; }
  .pm-proj { padding:7px 8px; }
  .pm-main { flex:1 1 auto; padding:11px 10px 22px; }
  .pm-hero { padding:12px; }
  .pm-hero h3 { font-size:14px; }
  .pm-hero-grid { grid-template-columns:repeat(3,1fr); gap:6px; }
  .pm-hero-cell { padding:7px; }
  .pm-hero-cell b { font-size:15px; }
  .pm-stage-grid, .pm-cards { grid-template-columns:1fr; }
  .pm-filters { gap:6px; padding:8px; }
  .pm-filters select { flex:1 1 42%; max-width:none; }
  .pm-filters input[type=search] { flex:1 1 100%; }
  .pm-filters .pm-count { flex:1 1 100%; margin-left:0; }
  /* 任务表在手机上改为卡片：每行按字段折行，用 data-label 生成小标题 */
  .pm-table, .pm-table tbody, .pm-table tr, .pm-table td { display:block; width:100%; box-sizing:border-box; }
  .pm-table thead { display:none; }
  .pm-table tr { border:1px solid var(--line); border-radius:9px; margin-bottom:7px; padding:6px 8px; background:var(--bg-2); }
  .pm-table td { border:0; padding:3px 0; font-size:10.5px; }
  .pm-table td[data-label]:not(.pm-tname)::before {
    content:attr(data-label) "："; color:var(--text-3); font-size:9.5px; margin-right:4px;
  }
  .pm-table .pm-tname { min-width:0; font-size:11.5px; padding:2px 0 5px !important; }
  .pm-table .pm-l1 td, .pm-table .pm-l2 td { background:transparent; }
  .pm-table .pm-l3 .pm-tname, .pm-table .pm-l4 .pm-tname { padding-left:0 !important; }
  .pm-mini-bar { width:80px; }
  .pm-modal { padding:0; align-items:flex-end; }
  .pm-modal-card { width:100%; max-height:90dvh; border-radius:14px 14px 0 0; }
}
