/* ==========================================================================
   Plan System · Shared Styles
   放在 /app_files/assessment_plan/css/plan_system.css
   所有新增工作/方案/批次/报告页面共用
   ========================================================================== */

:root {
  --ps-primary: #1ab394;
  --ps-primary-dark: #18a689;
  --ps-primary-soft: #e6f5f1;
  --ps-ink: #2f3840;
  --ps-ink-2: #545b61;
  --ps-ink-3: #889096;
  --ps-ink-4: #b6bbbf;
  --ps-bg: #f3f3f4;
  --ps-bg-2: #f8f9fa;
  --ps-line: #e7eaec;
  --ps-line-2: #f1f3f4;

  --ps-amber: #f39c12;
  --ps-amber-soft: #fef3e0;
  --ps-coral: #e74c3c;
  --ps-coral-soft: #fbe5e2;
  --ps-sage: #6b8e6b;
  --ps-sage-soft: #e8efe2;
  --ps-gold: #a78a3c;

  --ps-radius: 4px;
}

/* 全站 wrapper-content 边距压缩一点 */
.ps-wrap { padding: 20px 24px 40px !important; }

/* ==========================================================================
   Page Header
   ========================================================================== */
.ps-page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--ps-line);
  margin-bottom: 22px;
}
.ps-page-title {
  font-size: 22px;
  font-weight: 600;
  color: var(--ps-ink);
  margin: 0;
  line-height: 1.2;
}
.ps-page-title .fa { color: var(--ps-primary); margin-right: 8px; }
.ps-page-sub {
  font-size: 13px;
  color: var(--ps-ink-3);
  margin: 4px 0 0;
}
.ps-page-actions { display: flex; gap: 8px; }

.ps-breadcrumb {
  font-size: 12.5px;
  color: var(--ps-ink-3);
  margin-bottom: 4px;
}
.ps-breadcrumb a { color: var(--ps-ink-3); }
.ps-breadcrumb a:hover { color: var(--ps-primary); }
.ps-breadcrumb .sep { margin: 0 6px; color: var(--ps-ink-4); }
.ps-breadcrumb .current { color: var(--ps-ink-2); }

/* ==========================================================================
   Buttons
   ========================================================================== */
.ps-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--ps-radius);
  border: 1px solid var(--ps-line);
  background: #fff;
  color: var(--ps-ink-2);
  transition: all .15s;
  cursor: pointer;
  white-space: nowrap;
}
.ps-btn:hover { border-color: var(--ps-ink-4); color: var(--ps-ink); }
.ps-btn-primary {
  background: var(--ps-primary);
  color: #fff;
  border-color: var(--ps-primary);
}
.ps-btn-primary:hover {
  background: var(--ps-primary-dark);
  color: #fff;
  border-color: var(--ps-primary-dark);
}
.ps-btn-dark {
  background: var(--ps-ink);
  color: #fff;
  border-color: var(--ps-ink);
}
.ps-btn-dark:hover { background: #1a2128; color: #fff; border-color: #1a2128; }
.ps-btn-sm { padding: 4px 10px; font-size: 12px; }
.ps-btn-ghost { border: none; background: transparent; padding: 4px 8px; color: var(--ps-ink-3); }
.ps-btn-ghost:hover { color: var(--ps-primary); background: var(--ps-bg-2); }

/* ==========================================================================
   Stat Cards (dashboard 顶部)
   ========================================================================== */
.ps-stat-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 22px;
}
@media (max-width: 992px) { .ps-stat-row { grid-template-columns: repeat(2, 1fr); } }

.ps-stat {
  background: #fff;
  border: 1px solid var(--ps-line);
  border-radius: var(--ps-radius);
  padding: 16px 18px;
  position: relative;
  overflow: hidden;
}
.ps-stat .label {
  font-size: 12px;
  color: var(--ps-ink-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.ps-stat .value {
  font-size: 30px;
  font-weight: 600;
  color: var(--ps-ink);
  margin-top: 4px;
  line-height: 1.1;
}
.ps-stat .value .unit {
  font-size: 13px;
  color: var(--ps-ink-3);
  font-weight: 400;
  margin-left: 4px;
}
.ps-stat .delta {
  font-size: 11.5px;
  color: var(--ps-sage);
  margin-top: 6px;
}
.ps-stat .delta.down { color: var(--ps-coral); }
.ps-stat.highlight {
  background: linear-gradient(135deg, #1ab394 0%, #0d8070 100%);
  border-color: transparent;
}
.ps-stat.highlight .label,
.ps-stat.highlight .delta { color: rgba(255,255,255,0.75); }
.ps-stat.highlight .value { color: #fff; }

/* ==========================================================================
   Panel (通用内容面板)
   ========================================================================== */
.ps-panel {
  background: #fff;
  border: 1px solid var(--ps-line);
  border-radius: var(--ps-radius);
  margin-bottom: 14px;
  overflow: hidden;
}
.ps-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--ps-line);
  background: #fff;
}
.ps-panel-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--ps-ink);
  margin: 0;
}
.ps-panel-title .fa { color: var(--ps-primary); margin-right: 6px; }
.ps-panel-sub {
  font-size: 12px;
  color: var(--ps-ink-3);
  margin-top: 2px;
}
.ps-panel-body { padding: 4px 0; }
.ps-panel-body-padded { padding: 16px 18px; }

/* ==========================================================================
   Risk Pills & Status Pills
   ========================================================================== */
.ps-risk {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 3px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.ps-risk-high { background: var(--ps-coral-soft); color: var(--ps-coral); }
.ps-risk-mid  { background: var(--ps-amber-soft); color: var(--ps-amber); }
.ps-risk-low  { background: var(--ps-sage-soft);  color: var(--ps-sage); }

.ps-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  padding: 2px 8px;
  border-radius: 3px;
  font-weight: 500;
}
.ps-status::before {
  content: "";
  width: 5px; height: 5px;
  border-radius: 50%;
  background: currentColor;
}
.ps-status-active  { background: var(--ps-sage-soft);  color: var(--ps-sage); }
.ps-status-pending { background: var(--ps-amber-soft); color: var(--ps-amber); }
.ps-status-draft   { background: var(--ps-bg);         color: var(--ps-ink-3); border: 1px solid var(--ps-line); }
.ps-status-closed  { background: var(--ps-bg);         color: var(--ps-ink-3); }

/* ==========================================================================
   Alert / Activity List
   ========================================================================== */
.ps-alert-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px 18px;
  border-bottom: 1px solid var(--ps-line-2);
  transition: background .15s;
}
.ps-alert-item:last-child { border-bottom: none; }
.ps-alert-item:hover { background: var(--ps-bg-2); }
.ps-alert-body .name { font-weight: 500; color: var(--ps-ink); font-size: 13px; }
.ps-alert-body .meta { font-size: 11.5px; color: var(--ps-ink-3); margin-top: 2px; }
.ps-alert-body .meta .sep { margin: 0 6px; color: var(--ps-line); }
.ps-alert-time { font-size: 11px; color: var(--ps-ink-4); }

.ps-activity {
  padding: 11px 18px;
  border-bottom: 1px solid var(--ps-line-2);
  display: grid;
  grid-template-columns: 8px 1fr auto;
  gap: 10px;
  align-items: start;
}
.ps-activity:last-child { border-bottom: none; }
.ps-activity .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--ps-ink-4); margin-top: 7px;
}
.ps-activity .dot.primary { background: var(--ps-primary); }
.ps-activity .dot.sage    { background: var(--ps-sage); }
.ps-activity .dot.coral   { background: var(--ps-coral); }
.ps-activity .text { font-size: 13px; color: var(--ps-ink-2); line-height: 1.5; }
.ps-activity .text b { color: var(--ps-ink); font-weight: 500; }
.ps-activity .time { font-size: 11px; color: var(--ps-ink-4); white-space: nowrap; }

/* ==========================================================================
   Filter Chips
   ========================================================================== */
.ps-filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.ps-chip {
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 12.5px;
  background: #fff;
  border: 1px solid var(--ps-line);
  color: var(--ps-ink-2);
  cursor: pointer;
  transition: all .15s;
}
.ps-chip:hover { border-color: var(--ps-primary); color: var(--ps-primary); }
.ps-chip.active {
  background: var(--ps-primary);
  color: #fff;
  border-color: var(--ps-primary);
}
.ps-filter-spacer { flex: 1; }

/* ==========================================================================
   Plan Card Grid
   ========================================================================== */
.ps-plan-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 14px;
}
.ps-plan-card {
  background: #fff;
  border: 1px solid var(--ps-line);
  border-top: 3px solid var(--ps-primary);
  border-radius: var(--ps-radius);
  padding: 20px 20px 16px;
  transition: all .18s;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  min-height: 210px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.ps-plan-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  border-top-color: var(--ps-primary-dark);
}
.ps-plan-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.ps-plan-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--ps-ink);
  line-height: 1.3;
}
.ps-plan-ver {
  font-size: 11px;
  color: var(--ps-ink-3);
  background: var(--ps-bg);
  padding: 2px 7px;
  border-radius: 3px;
  letter-spacing: 0.04em;
  white-space: nowrap;
  font-family: Menlo, monospace;
}
.ps-plan-desc {
  color: var(--ps-ink-3);
  font-size: 12.5px;
  line-height: 1.55;
  margin-bottom: 12px;
  flex: 1;
}
.ps-plan-tags { display: flex; gap: 5px; flex-wrap: wrap; margin-bottom: 12px; }
.ps-plan-tag {
  font-size: 11px;
  padding: 2px 7px;
  background: var(--ps-primary-soft);
  color: var(--ps-primary-dark);
  border-radius: 3px;
  font-weight: 500;
}
.ps-plan-tag.alt { background: #f5eddc; color: var(--ps-gold); }
.ps-plan-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 12px;
  border-top: 1px solid var(--ps-line-2);
  font-size: 11.5px;
  color: var(--ps-ink-3);
}
.ps-plan-stats { display: flex; gap: 14px; }
.ps-plan-stats .num { color: var(--ps-ink); font-weight: 600; }
.ps-plan-card.new {
  background: transparent;
  border: 1.5px dashed var(--ps-line);
  border-top-width: 1.5px;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--ps-ink-3);
}
.ps-plan-card.new:hover {
  border-color: var(--ps-primary);
  color: var(--ps-primary);
  background: #fff;
}
.ps-plan-card.new .plus {
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 1.5px solid currentColor;
  display: grid; place-items: center;
  font-size: 22px;
  margin-bottom: 8px;
}

/* ==========================================================================
   Tabs
   ========================================================================== */
.ps-tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--ps-line);
  margin-bottom: 20px;
}
.ps-tab {
  padding: 9px 16px;
  font-size: 13px;
  color: var(--ps-ink-3);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  font-weight: 500;
  transition: all .15s;
}
.ps-tab:hover { color: var(--ps-ink); }
.ps-tab.active { color: var(--ps-primary); border-bottom-color: var(--ps-primary); }
.ps-tab .badge-num {
  font-size: 10.5px;
  color: var(--ps-ink-4);
  margin-left: 4px;
  font-family: Menlo, monospace;
}

/* ==========================================================================
   Stages (方案阶段)
   ========================================================================== */
.ps-stage {
  background: #fff;
  border: 1px solid var(--ps-line);
  border-radius: var(--ps-radius);
  margin-bottom: 12px;
  overflow: hidden;
}
.ps-stage-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  background: linear-gradient(90deg, #f5faf8 0%, #fff 60%);
  border-bottom: 1px solid var(--ps-line);
}
.ps-stage-title-wrap { display: flex; align-items: center; gap: 14px; }
.ps-stage-num {
  font-size: 26px;
  font-weight: 300;
  color: var(--ps-primary);
  line-height: 1;
  font-family: Menlo, monospace;
}
.ps-stage-name { font-size: 15px; font-weight: 600; color: var(--ps-ink); }
.ps-stage-desc { font-size: 11.5px; color: var(--ps-ink-3); margin-top: 2px; }
.ps-stage-meta { font-size: 11.5px; color: var(--ps-ink-3); font-family: Menlo, monospace; }

.ps-tool-row {
  display: grid;
  grid-template-columns: 36px 1fr auto 30px;
  gap: 12px;
  align-items: center;
  padding: 11px 20px;
  border-bottom: 1px solid var(--ps-line-2);
}
.ps-tool-row:last-child { border-bottom: none; }
.ps-tool-icon {
  width: 34px; height: 34px;
  border-radius: 6px;
  display: grid; place-items: center;
  background: var(--ps-primary-soft);
  color: var(--ps-primary-dark);
  font-size: 14px;
}
.ps-tool-icon.alt  { background: #f5eddc; color: var(--ps-gold); }
.ps-tool-icon.sage { background: var(--ps-sage-soft); color: var(--ps-sage); }
.ps-tool-icon.coral{ background: var(--ps-coral-soft); color: var(--ps-coral); }
.ps-tool-name { font-weight: 500; color: var(--ps-ink); font-size: 13.5px; }
.ps-tool-rationale { font-size: 12px; color: var(--ps-ink-3); margin-top: 2px; }
.ps-tool-dur { font-size: 11.5px; color: var(--ps-ink-3); font-family: Menlo, monospace; }

.ps-branch {
  background: #fef8e8;
  padding: 9px 20px 9px 70px;
  font-size: 12px;
  color: var(--ps-amber);
  border-top: 1px dashed var(--ps-line);
}
.ps-branch code {
  font-family: Menlo, monospace;
  background: #fff;
  padding: 1px 6px;
  border-radius: 3px;
  border: 1px solid var(--ps-line);
  color: var(--ps-ink-2);
  font-size: 11px;
}

/* ==========================================================================
   Data Table
   ========================================================================== */
.ps-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}
.ps-table th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ps-ink-3);
  padding: 11px 18px;
  background: var(--ps-bg-2);
  border-bottom: 1px solid var(--ps-line);
}
.ps-table td {
  padding: 12px 18px;
  border-bottom: 1px solid var(--ps-line-2);
  font-size: 13px;
  color: var(--ps-ink-2);
  vertical-align: middle;
}
.ps-table tr:last-child td { border-bottom: none; }
.ps-table tr:hover td { background: var(--ps-bg-2); }
.ps-table .primary-cell { color: var(--ps-ink); font-weight: 500; }
.ps-table .num { font-family: Menlo, monospace; }

.ps-progress {
  width: 110px;
  height: 6px;
  background: var(--ps-line);
  border-radius: 3px;
  overflow: hidden;
  display: inline-block;
  vertical-align: middle;
}
.ps-progress-fill {
  height: 100%;
  background: var(--ps-primary);
  border-radius: 3px;
  transition: width .6s ease;
}
.ps-progress-label {
  font-family: Menlo, monospace;
  font-size: 11px;
  color: var(--ps-ink-3);
  margin-left: 8px;
}

/* ==========================================================================
   Donut Chart (简易)
   ========================================================================== */
.ps-donut-wrap {
  background: #fff;
  border: 1px solid var(--ps-line);
  border-radius: var(--ps-radius);
  padding: 16px;
  text-align: center;
}
.ps-donut-title {
  font-size: 11.5px;
  color: var(--ps-ink-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 10px;
}
.ps-donut {
  width: 130px; height: 130px;
  margin: 0 auto;
  position: relative;
}
.ps-donut svg { transform: rotate(-90deg); }
.ps-donut .circle-bg { fill: none; stroke: var(--ps-line); stroke-width: 10; }
.ps-donut .circle-fill { fill: none; stroke-width: 10; stroke-linecap: round; transition: stroke-dashoffset .8s; }
.ps-donut-center {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
}
.ps-donut-value {
  font-size: 26px;
  font-weight: 600;
  color: var(--ps-ink);
  line-height: 1;
}
.ps-donut-label { font-size: 11px; color: var(--ps-ink-3); margin-top: 2px; }
.ps-donut-legend {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  text-align: left;
  padding: 0 8px;
}
.ps-legend-row {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--ps-ink-2);
}
.ps-legend-dot { width: 8px; height: 8px; border-radius: 2px; }
.ps-legend-row .n { margin-left: auto; font-family: Menlo, monospace; color: var(--ps-ink-3); }

.ps-mini-stat {
  background: #fff;
  border: 1px solid var(--ps-line);
  border-radius: var(--ps-radius);
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.ps-mini-stat .l { font-size: 12px; color: var(--ps-ink-3); }
.ps-mini-stat .v {
  font-size: 18px;
  font-weight: 600;
  color: var(--ps-ink);
}

.ps-bars-panel {
  background: #fff;
  border: 1px solid var(--ps-line);
  border-radius: var(--ps-radius);
  padding: 16px;
}
.ps-bars-title {
  font-size: 11.5px;
  color: var(--ps-ink-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 12px;
}
.ps-bar-row {
  display: grid;
  grid-template-columns: 70px 1fr 30px;
  gap: 8px;
  align-items: center;
  margin-bottom: 7px;
  font-size: 11.5px;
}
.ps-bar-row .bl { color: var(--ps-ink-2); }
.ps-bar-track { height: 6px; background: var(--ps-line); border-radius: 3px; overflow: hidden; }
.ps-bar-fill { height: 100%; background: var(--ps-primary); border-radius: 3px; }
.ps-bar-fill.amber { background: var(--ps-amber); }
.ps-bar-fill.coral { background: var(--ps-coral); }
.ps-bar-fill.sage  { background: var(--ps-sage); }
.ps-bar-row .bn { font-family: Menlo, monospace; color: var(--ps-ink-3); text-align: right; }

/* ==========================================================================
   Detail Head (方案详情/批次详情)
   ========================================================================== */
.ps-detail-head {
  background: #fff;
  border: 1px solid var(--ps-line);
  border-top: 3px solid var(--ps-primary);
  border-radius: var(--ps-radius);
  padding: 20px 24px;
  margin-bottom: 18px;
}
.ps-detail-title {
  font-size: 22px;
  font-weight: 600;
  color: var(--ps-ink);
  margin: 0;
  line-height: 1.2;
}
.ps-detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  margin-top: 10px;
  color: var(--ps-ink-3);
  font-size: 12.5px;
}
.ps-detail-meta b { color: var(--ps-ink-2); font-weight: 500; }

/* ==========================================================================
   Chat / AI Panel
   ========================================================================== */
.ps-ai-layout {
  display: flex;
  gap: 0;
  height: calc(100vh - 200px);
  min-height: 560px;
  position: relative;
}
@media (max-width: 1100px) { .ps-ai-layout { flex-direction: column; height: auto; } }

.ps-chat-panel, .ps-draft-panel {
  background: #fff;
  border: 1px solid var(--ps-line);
  border-radius: var(--ps-radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── 左侧对话面板：默认 45%，可拖拽可折叠 ── */
.ps-chat-panel {
  flex-shrink: 0;
  width: 45%;
  min-width: 0;
  transition: width 0.22s ease, border-width 0.22s ease, opacity 0.22s ease;
}
.ps-chat-panel.dragging { transition: none; }
.ps-chat-panel.collapsed {
  width: 0 !important;
  border-width: 0;
  opacity: 0;
  pointer-events: none;
}

/* ── 右侧草稿面板：自动占满剩余空间 ── */
.ps-draft-panel {
  flex: 1;
  min-width: 0;
}

/* ── 中间拖拽条 ── */
.ps-resizer {
  flex-shrink: 0;
  width: 14px;
  cursor: col-resize;
  position: relative;
  background: transparent;
  transition: background 0.15s;
  user-select: none;
}
.ps-resizer:hover { background: rgba(26, 179, 148, 0.06); }
.ps-resizer::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 0; bottom: 0;
  width: 1px;
  transform: translateX(-50%);
  background: var(--ps-line);
  transition: background 0.15s, width 0.15s;
}
.ps-resizer:hover::before,
.ps-resizer.dragging::before {
  background: var(--ps-primary);
  width: 2px;
}

/* ── 折叠/展开按钮（嵌在拖拽条中间） ── */
.ps-resizer-toggle {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 22px;
  height: 48px;
  border-radius: 4px;
  background: #fff;
  border: 1px solid var(--ps-line);
  color: var(--ps-ink-3);
  display: grid;
  place-items: center;
  cursor: pointer;
  z-index: 3;
  padding: 0;
  font-size: 11px;
  transition: all 0.15s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}
.ps-resizer-toggle:hover {
  background: var(--ps-primary);
  color: #fff;
  border-color: var(--ps-primary);
}
.ps-resizer-toggle i { line-height: 1; }

/* ── 折叠状态下拖拽条高亮，提醒可点击展开 ── */
.ps-chat-panel.collapsed + .ps-resizer { background: rgba(26, 179, 148, 0.08); }
.ps-chat-panel.collapsed + .ps-resizer::before { background: var(--ps-primary); }

/* ── 拖拽期间禁用 iframe 指针事件，避免吞掉 mousemove ── */
body.ps-dragging {
  cursor: col-resize !important;
  user-select: none;
}
body.ps-dragging iframe { pointer-events: none; }
.ps-chat-head, .ps-draft-head {
  padding: 12px 18px;
  border-bottom: 1px solid var(--ps-line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(90deg, #f5faf8 0%, #fff 60%);
}
.ps-chat-head-left { display: flex; align-items: center; gap: 10px; }
.ps-ai-mark {
  width: 28px; height: 28px;
  border-radius: 6px;
  background: linear-gradient(135deg, #1ab394 0%, #0d8070 100%);
  display: grid; place-items: center;
  color: #fff;
  font-weight: 600;
  font-size: 14px;
}
.ps-chat-title { font-size: 14px; font-weight: 600; color: var(--ps-ink); }
.ps-chat-sub { font-size: 11px; color: var(--ps-ink-3); margin-top: 1px; }

.ps-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.ps-msg { display: flex; gap: 10px; max-width: 92%; }
.ps-msg-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
  color: #fff;
}
.ps-msg-avatar.user { background: linear-gradient(135deg, #c9a676, #8b6f3e); }
.ps-msg-avatar.ai   { background: linear-gradient(135deg, #1ab394 0%, #0d8070 100%); }
.ps-msg-avatar.sys  { background: var(--ps-bg); color: var(--ps-ink-3); border: 1px dashed var(--ps-line); }
.ps-msg-body { flex: 1; min-width: 0; }
.ps-msg-name {
  font-size: 11.5px;
  color: var(--ps-ink-3);
  margin-bottom: 4px;
}
.ps-msg-name b { color: var(--ps-ink-2); font-weight: 500; }
.ps-msg-content {
  background: var(--ps-bg-2);
  border-radius: 2px 8px 8px 8px;
  padding: 9px 13px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--ps-ink);
}
.ps-msg.user { align-self: flex-end; flex-direction: row-reverse; }
.ps-msg.user .ps-msg-body { text-align: right; }
.ps-msg.user .ps-msg-content {
  background: var(--ps-primary-soft);
  border-radius: 8px 2px 8px 8px;
  text-align: left;
  display: inline-block;
}
.ps-msg.sys .ps-msg-content {
  background: transparent;
  border: 1px dashed var(--ps-line);
  color: var(--ps-ink-3);
  font-style: italic;
  font-size: 12px;
}
.ps-msg-changes {
  margin-top: 8px;
  padding: 9px 13px;
  background: var(--ps-primary-soft);
  border-left: 2px solid var(--ps-primary);
  border-radius: 0 6px 6px 0;
  font-size: 12px;
}
.ps-msg-changes .ct {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ps-primary-dark);
  font-weight: 600;
  margin-bottom: 4px;
}
.ps-msg-changes ul { padding-left: 14px; margin: 0; }
.ps-msg-changes li { color: var(--ps-primary-dark); margin: 2px 0; }
.ps-msg-clarify {
  margin-top: 8px;
  padding: 9px 13px;
  background: var(--ps-amber-soft);
  border-left: 2px solid var(--ps-amber);
  border-radius: 0 6px 6px 0;
  font-size: 12px;
  color: var(--ps-amber);
  display: flex;
  gap: 8px;
}

.ps-chat-input-wrap {
  border-top: 1px solid var(--ps-line);
  padding: 10px 14px 12px;
  background: #fff;
}
.ps-chat-input {
  width: 100%;
  min-height: 56px;
  border: 1px solid var(--ps-line);
  border-radius: var(--ps-radius);
  padding: 9px 11px;
  resize: none;
  outline: none;
  font-size: 13px;
  background: var(--ps-bg-2);
  transition: border-color .15s;
  font-family: inherit;
}
.ps-chat-input:focus { border-color: var(--ps-primary); background: #fff; }
.ps-chat-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
}
.ps-chat-hint { font-size: 10.5px; color: var(--ps-ink-4); font-family: Menlo, monospace; }

/* Draft */
.ps-draft-body { flex: 1; overflow-y: auto; padding: 18px 20px 24px; }
.ps-draft-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 24px;
  padding: 14px 16px;
  background: var(--ps-bg-2);
  border-radius: var(--ps-radius);
  margin-bottom: 18px;
  font-size: 12px;
}
.ps-draft-meta .row {
  display: grid;
  grid-template-columns: 70px 1fr;
  align-items: baseline;
  gap: 12px;
  min-width: 0;
  overflow: hidden;
}
.ps-draft-meta .l {
  color: var(--ps-ink-3);
  white-space: nowrap;
}
.ps-draft-meta .v {
  color: var(--ps-ink);
  font-weight: 500;
  word-break: break-word;
  overflow-wrap: anywhere;
  min-width: 0;
  overflow: hidden;
}

.ps-draft-stage {
  margin-bottom: 18px;
  position: relative;
  padding-left: 20px;
}
.ps-draft-stage::before {
  content: "";
  position: absolute;
  left: 4px; top: 8px; bottom: 8px;
  width: 1px;
  background: var(--ps-line);
}
.ps-draft-stage::after {
  content: "";
  position: absolute;
  left: 0; top: 5px;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--ps-primary);
  border: 2px solid #fff;
}
.ps-draft-stage-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--ps-ink);
  margin-bottom: 9px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.ps-draft-stage-title .num {
  font-family: Menlo, monospace;
  font-size: 10px;
  color: var(--ps-ink-3);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 500;
}
.ps-draft-tool {
  background: var(--ps-bg-2);
  border: 1px solid var(--ps-line);
  border-radius: var(--ps-radius);
  padding: 9px 13px;
  margin-bottom: 6px;
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 0;
}
.ps-draft-tool .dt-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  width: 100%;
}
.ps-draft-tool .dt-name { color: var(--ps-ink); font-weight: 500; font-size: 12.5px; }
.ps-draft-tool .dt-why { color: var(--ps-ink-3); font-size: 11px; margin-top: 2px; }
.ps-draft-tool .dt-dur { font-family: Menlo, monospace; font-size: 10.5px; color: var(--ps-ink-3); white-space: nowrap; }
.ps-draft-tool .dt-expand-btn { color: var(--ps-ink-3); }
.ps-draft-tool .dt-expand-btn:hover { color: var(--ps-primary); }
.ps-draft-tool.locked {
  background: #faf5e9;
  border-color: #e8dcc0;
  border-left: 2px solid var(--ps-gold);
}
.ps-draft-tool.changed {
  border-left: 2px solid var(--ps-primary);
  background: var(--ps-primary-soft);
}

.ps-draft-branch {
  margin-left: 14px;
  padding: 6px 10px;
  font-size: 11px;
  color: var(--ps-amber);
  font-family: Menlo, monospace;
  background: var(--ps-amber-soft);
  border-radius: 3px;
  margin-bottom: 6px;
}

.ps-draft-foot {
  padding: 12px 18px;
  border-top: 1px solid var(--ps-line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #fff;
}
.ps-draft-foot-info { font-size: 11px; color: var(--ps-ink-3); }

/* ==========================================================================
   Batch Layout
   ========================================================================== */
.ps-batch-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 16px;
  align-items: start;
}
@media (max-width: 992px) { .ps-batch-layout { grid-template-columns: 1fr; } }
.ps-dashboard-col { display: flex; flex-direction: column; gap: 12px; }

/* ==========================================================================
   Scrollbar (refined)
   ========================================================================== */
.ps-chat-body::-webkit-scrollbar,
.ps-draft-body::-webkit-scrollbar { width: 6px; }
.ps-chat-body::-webkit-scrollbar-thumb,
.ps-draft-body::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.12); border-radius: 3px; }

/* Utilities */
.ps-mt-0 { margin-top: 0 !important; }
.ps-mb-0 { margin-bottom: 0 !important; }
.ps-text-muted { color: var(--ps-ink-3); }
.ps-text-primary { color: var(--ps-primary); }
.ps-text-coral { color: var(--ps-coral); }


/* ==========================================================================
   Mobile Responsive (≤767px)
   ----------------------------------------------------------------------------
   全局针对手机窄屏的优化。覆盖 work / plan 全部页面。
   设计原则：
   1. 缩小整体留白和字号（保持可读性）
   2. 多列布局自动变单列
   3. 表格行变成卡片样式（标签+值堆叠）
   4. 按钮组允许换行
   5. 顶部 hero 紧凑化
   ========================================================================== */
@media (max-width: 767px) {

    /* ── 1. 整体容器：减小内边距 ─────────────────────────────────── */
    .ps-page,
    .wrapper-content {
        padding: 12px 14px !important;
    }

    /* ── 2. 页面标题与 hero 区紧凑化 ──────────────────────────────── */
    .ps-hero,
    .ps-page-header {
        padding: 14px 14px;
        margin-bottom: 14px;
    }
    .ps-hero h1,
    .ps-page-title {
        font-size: 18px !important;
        line-height: 1.35;
        margin-bottom: 4px;
    }
    .ps-page-sub,
    .ps-hero-sub {
        font-size: 12px;
    }

    /* ── 3. 面包屑 / 顶部 meta：可换行 ───────────────────────────── */
    .ps-crumb,
    .ps-page-meta,
    .ps-meta-line {
        flex-wrap: wrap;
        gap: 6px 10px;
        font-size: 12px;
    }

    /* ── 4. 顶部按钮组：允许换行 ─────────────────────────────────── */
    .ps-page-actions,
    .ps-toolbar,
    .ps-btn-row {
        flex-wrap: wrap;
        gap: 6px;
    }
    .ps-btn,
    .ps-btn-sm {
        font-size: 12px;
        padding: 6px 10px;
    }

    /* ── 5. 统计卡片：从 4 列变 2 列 ──────────────────────────────── */
    .ps-stat-row,
    .ps-stat-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px;
    }
    .ps-stat-card {
        padding: 12px;
    }
    .ps-stat-num {
        font-size: 20px !important;
    }
    .ps-stat-label {
        font-size: 11px !important;
    }

    /* ── 6. 双栏布局变单栏（plans / batch / ai_plan） ─────────────── */
    .ps-batch-layout,
    .ps-ai-layout,
    .ps-plan-layout,
    .ps-detail-layout {
        grid-template-columns: 1fr !important;
        gap: 14px;
    }
    /* AI 共建方案双栏切换：两个面板纵向堆叠 */
    .ps-chat-panel,
    .ps-draft-panel {
        max-height: none !important;
        height: auto !important;
    }

    /* ── 7. 表格 → 卡片（手机不适合横向滚动表格） ────────────────── */
    .ps-table-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .ps-table-card-mobile,
    .ps-mobile-card {
        display: block;
    }
    /* 默认所有 .ps-table 在手机上转成"标签+值"堆叠卡片 */
    table.ps-table thead {
        display: none;
    }
    table.ps-table,
    table.ps-table tbody,
    table.ps-table tr,
    table.ps-table td {
        display: block;
        width: 100%;
    }
    table.ps-table tr {
        background: #fff;
        border: 1px solid var(--ps-line);
        border-radius: 8px;
        margin-bottom: 10px;
        padding: 8px 12px;
    }
    table.ps-table td {
        border: none !important;
        padding: 4px 0 !important;
        font-size: 13px;
        text-align: left !important;
    }
    /* 用 data-label 属性显示字段标签（HTML 里加 data-label="状态" 即可生效） */
    table.ps-table td[data-label]::before {
        content: attr(data-label) "：";
        font-weight: 600;
        color: var(--ps-ink-3);
        margin-right: 6px;
    }
    /* 第一列默认作主标题：加粗 */
    table.ps-table td:first-child {
        font-weight: 600;
        font-size: 14px;
        margin-bottom: 4px;
    }

    /* ── 8. 标签 / chip 行：可换行 ──────────────────────────────── */
    .ps-tag-row,
    .ps-chip-row {
        flex-wrap: wrap;
        gap: 6px;
    }
    .ps-tag,
    .ps-chip {
        font-size: 11px;
        padding: 3px 8px;
    }

    /* ── 9. 表单：label 和 input 堆叠 ──────────────────────────────── */
    .ps-form-row,
    .ps-form-grid {
        grid-template-columns: 1fr !important;
        gap: 10px;
    }
    .ps-form-group {
        margin-bottom: 12px;
    }
    .ps-form-group > label {
        font-size: 13px;
        margin-bottom: 4px;
    }
    .ps-form-group input,
    .ps-form-group select,
    .ps-form-group textarea {
        font-size: 14px;          /* iOS 防自动放大：必须 ≥16px 才不放大；这里 14px 接受小放大 */
        padding: 8px 10px;
    }

    /* ── 10. 工具卡片网格：从多列变 1 列或 2 列 ────────────────────── */
    .ps-tool-grid {
        grid-template-columns: 1fr !important;
        gap: 10px;
    }
    .ps-tool-card {
        padding: 12px;
    }

    /* ── 11. 草稿区工具行：紧凑 ────────────────────────────────── */
    .ps-draft-tool {
        padding: 10px 12px;
        gap: 6px;
    }
    .ps-draft-tool .dt-row {
        flex-wrap: wrap;
        gap: 4px 10px;
    }

    /* ── 12. 弹窗 / Modal：占满屏幕 ──────────────────────────────── */
    .ps-modal-content,
    .swal2-popup {
        width: calc(100vw - 24px) !important;
        max-width: calc(100vw - 24px) !important;
        margin: 12px auto;
    }
    .swal2-html-container {
        font-size: 13px !important;
    }

    /* ── 13. 列表项 / 行高紧凑 ──────────────────────────────── */
    .ps-list-item {
        padding: 10px 12px;
        gap: 8px;
    }

    /* ── 14. 避免横向溢出 ──────────────────────────────────────── */
    body, html {
        overflow-x: hidden;
    }
    img, iframe, video {
        max-width: 100%;
        height: auto;
    }

    /* ── 15. INSPINIA 模板的左侧菜单：手机折叠（默认 INSPINIA 会处理）─── */
    /* 一般 INSPINIA 自带 .body-small / .navbar-toggle 处理，这里不强制改 */

    /* ── 16. 卡片间距 ────────────────────────────────────────── */
    .ps-card,
    .ibox {
        margin-bottom: 14px;
    }
    .ps-card-header,
    .ibox-title {
        padding: 12px 14px;
    }
    .ps-card-body,
    .ibox-content {
        padding: 14px;
    }

    /* ── 17. 面包屑省略 ────────────────────────────────────────── */
    .ps-crumb-sep {
        display: none;
    }
    .ps-crumb a:not(:last-child) {
        max-width: 80px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        display: inline-block;
        vertical-align: bottom;
    }
}

/* 进一步针对超小屏（≤380px）—— 单手抓握的小手机 */
@media (max-width: 380px) {
    .ps-page,
    .wrapper-content {
        padding: 10px 10px !important;
    }
    .ps-stat-row,
    .ps-stat-grid {
        grid-template-columns: 1fr !important;
    }
    .ps-hero h1,
    .ps-page-title {
        font-size: 16px !important;
    }
}


/* ==========================================================================
   Mobile Patches v2 —— 实测后修复（≤767px）
   ========================================================================== */
@media (max-width: 767px) {

    /* 1. AI 共建对话气泡：放开宽度（之前每字一行的 bug） */
    .ps-msg,
    .ps-msg-bubble,
    .ps-msg-content,
    .ps-chat-bubble,
    .ps-chat-msg-content {
        max-width: 100% !important;
        width: auto !important;
        word-break: break-word;
    }
    /* 整个 ai_plan 双栏在手机上变单栏后，左侧聊天面板应占满 */
    .ps-ai-chat-panel,
    .ps-ai-draft-panel,
    .ps-chat-panel,
    .ps-draft-panel {
        width: 100% !important;
        max-width: 100% !important;
        min-height: auto !important;
    }
    /* 单条消息容器自适应 */
    .ps-chat-body,
    .ps-msg-list {
        padding: 12px 10px;
    }
    .ps-msg {
        margin-bottom: 12px;
    }
    /* 头像不再占大宽度 */
    .ps-msg-avatar {
        width: 30px;
        height: 30px;
        flex-shrink: 0;
    }

    /* 2. plans.html 列表：长描述限制 2 行省略 */
    .ps-list-item-title,
    .ps-plan-card-title {
        font-size: 14px;
        line-height: 1.4;
        word-break: break-all;
    }
    .ps-plan-card-desc,
    .ps-list-item-desc,
    .ps-list-item-sub {
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
        text-overflow: ellipsis;
        font-size: 12.5px;
        line-height: 1.5;
    }

    /* 3. hero 区右侧按钮组：移到下方独立行 */
    .ps-hero-actions,
    .ps-page-header-actions,
    .ps-hero .ps-btn-group {
        margin-top: 12px;
        width: 100%;
        flex-wrap: wrap;
    }
    /* 整个 hero 让标题/按钮分两行 */
    .ps-hero,
    .ps-page-header {
        flex-direction: column;
        align-items: flex-start;
    }
    .ps-hero-actions .ps-btn,
    .ps-page-header-actions .ps-btn {
        flex: 0 0 auto;
    }

    /* 4. 表格→卡片：进一步美化 */
    table.ps-table tr {
        padding: 12px 14px;
        box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    }
    /* 第一列（主标题）放大字号 */
    table.ps-table td:first-child {
        font-size: 14.5px !important;
        margin-bottom: 6px;
        padding-bottom: 6px !important;
        border-bottom: 1px dashed var(--ps-line) !important;
    }
    /* 数字列右对齐改左对齐 */
    table.ps-table td.num,
    table.ps-table td[align="right"] {
        text-align: left !important;
    }
    /* 操作列（多个按钮）放底部居右 */
    table.ps-table td:last-child {
        margin-top: 6px;
        text-align: right !important;
        white-space: normal !important;
    }
    table.ps-table td:last-child .ps-btn {
        font-size: 11.5px;
        padding: 4px 8px;
    }

    /* 5. 顶部 chip 行（全部/进行中/已结束）超小屏可换行 */
    .ps-chip-row,
    .ps-filter-bar {
        flex-wrap: wrap;
        gap: 6px;
    }
    .ps-chip {
        font-size: 11.5px;
        padding: 4px 10px;
    }

    /* 6. plan_detail 顶部 tab 紧凑 */
    .ps-tabs,
    .ps-tab-bar {
        gap: 14px;
        font-size: 12.5px;
        flex-wrap: wrap;
    }
    .ps-tab {
        padding: 6px 0;
    }

    /* 7. AI 共建 banner（手机端体验提示） */
    .ps-mobile-banner {
        display: block;
        margin: 10px 0 14px;
        padding: 10px 14px;
        background: linear-gradient(135deg, #fef3c7, #fef9e7);
        border: 1px solid #fbbf24;
        border-radius: 8px;
        font-size: 12px;
        color: #92400e;
        line-height: 1.5;
    }
    .ps-mobile-banner i {
        margin-right: 6px;
    }
}

/* 桌面端默认隐藏 mobile banner */
.ps-mobile-banner {
    display: none;
}