/* ============================================================
   投资拓展区块
   与应付/应收账款区块共用同一套设计 token，前缀 iv-
   ============================================================ */

.iv-block {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: relative;
}

/* ---------- 头部 ---------- */

.iv-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.iv-head h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .3px;
}

.iv-head-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.iv-hint { font-size: 11.5px; color: var(--text-tertiary); }

/* ---------- 两个大段 ---------- */

.iv-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px dashed var(--border-soft);
}

.iv-section:first-of-type { border-top: none; padding-top: 0; }

.iv-section-title {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
  padding-left: 9px;
  border-left: 3px solid var(--blue);
}

.iv-section-hint {
  font-size: 11.5px;
  font-weight: 400;
  color: var(--text-tertiary);
}

.iv-sub-title {
  margin-top: 4px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.iv-sub-hint { font-size: 11.5px; font-weight: 400; color: var(--text-tertiary); }
.iv-sub-hint b { color: var(--text-primary); font-weight: 600; }

/* ---------- 四张卡 ---------- */

.iv-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.iv-card {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--bg-card-2);
  border: 1px solid var(--border-soft);
  border-left: 3px solid var(--blue);
}

.iv-card-label { font-size: 11.5px; color: var(--text-secondary); }

.iv-card-value {
  margin-top: 6px;
  font-size: 22px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: .2px;
  line-height: 1.15;
}

.iv-card-unit {
  margin-left: 4px;
  font-size: 11px;
  font-weight: 400;
  color: var(--text-secondary);
}

.iv-card-sub {
  margin-top: 5px;
  font-size: 11px;
  color: var(--text-tertiary);
  min-height: 14px;
}

.iv-card.tone-blue  { border-left-color: #4D8DFF; }
.iv-card.tone-green { border-left-color: #00E5A0; }
.iv-card.tone-teal  { border-left-color: #00D4FF; }
.iv-card.tone-amber { border-left-color: #EF9F27; }
.iv-card.tone-red   { border-left-color: #FF4D6D; }

.iv-card.tone-blue  .iv-card-value { color: #4D8DFF; }
.iv-card.tone-green .iv-card-value { color: #00E5A0; }
.iv-card.tone-teal  .iv-card-value { color: #00D4FF; }
.iv-card.tone-amber .iv-card-value { color: #EF9F27; }
.iv-card.tone-red   .iv-card-value { color: #FF7790; }
.iv-card.tone-purple .iv-card-value { color: #9B5DE5; }
.iv-card.tone-indigo .iv-card-value { color: #5E60CE; }

.iv-card.tone-purple { border-left-color: #9B5DE5; }
.iv-card.tone-indigo { border-left-color: #5E60CE; }

/* 商机段 6 张卡：桌面一行 6 列；minmax(0,1fr) 防止内容把网格撑溢出 */
.iv-opp-cards { grid-template-columns: repeat(6, minmax(0, 1fr)); }

/* 落地卡可点：hover 上浮 + 聚焦描边，提示「可钻探」 */
.iv-card.clickable { cursor: pointer; transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease; }
.iv-card.clickable:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0, 0, 0, .28); border-color: var(--blue); }
.iv-card.clickable:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

/* ---------- 表格 ---------- */

.iv-table-wrap { overflow-x: auto; }

.iv-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.iv-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  text-align: left;
  padding: 8px 10px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.iv-table th.sortable { cursor: pointer; user-select: none; }
.iv-table th.sortable:hover { color: var(--text-primary); }
.iv-table th .sk { font-style: normal; margin-left: 4px; color: var(--blue); font-size: 10px; }
.iv-table th.on { color: var(--text-primary); }

.iv-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
}

.iv-table tbody tr:hover { background: rgba(255, 255, 255, .03); }

.iv-name { color: var(--text-primary); font-weight: 500; white-space: nowrap; }

/* 商机名 → 飞书原记录 */
.iv-link {
  color: var(--text-primary);
  text-decoration: none;
  border-bottom: 1px dashed rgba(0, 212, 255, .5);
}

.iv-link:hover { color: var(--blue); border-bottom-style: solid; }
.iv-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.iv-num.iv-strong { font-weight: 600; }
/* 注意：这里叫 iv-muted 而不是 iv-dim —— iv-dim 是下方「维度分布」容器的类名，
   表格单元格若也叫 iv-dim 会误吃到容器的背景与边框（已踩过） */
.iv-num.iv-muted { color: var(--text-secondary); }
.iv-num.neg { color: #FF7790; }
.iv-num.pos { color: #00E5A0; }
.iv-mid { color: var(--text-secondary); white-space: nowrap; }
.iv-note {
  color: var(--text-tertiary);
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 完成率条（表内） */
.iv-bar-wrap {
  display: block;
  position: relative;
  min-width: 92px;
  height: 18px;
  border-radius: 4px;
  background: rgba(255, 255, 255, .05);
  overflow: hidden;
}

.iv-bar-wrap .iv-bar {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: 4px;
  opacity: .55;
}

.iv-bar-wrap .iv-bar.tone-good { background: #00E5A0; }
.iv-bar-wrap .iv-bar.tone-mid  { background: #EF9F27; }
.iv-bar-wrap .iv-bar.tone-low  { background: #FF4D6D; }

.iv-bar-wrap .iv-bar-txt {
  position: relative;
  z-index: 1;
  display: block;
  text-align: right;
  padding-right: 7px;
  line-height: 18px;
  font-size: 11.5px;
  font-weight: 600;
}

/* ---------- 季度进度 ---------- */

.iv-quarters {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.iv-q {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-card-2);
  border: 1px solid var(--border-soft);
}

.iv-q.pending { opacity: .55; }

.iv-q-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
}

.iv-q-name { font-size: 12.5px; font-weight: 600; }

.iv-q-rate { font-size: 11.5px; font-weight: 600; }
.iv-q-rate.tone-good { color: #00E5A0; }
.iv-q-rate.tone-mid  { color: #EF9F27; }
.iv-q-rate.tone-low  { color: #FF7790; }
.iv-q-rate.tone-idle { color: var(--text-tertiary); font-weight: 400; }

.iv-q-bar {
  margin: 7px 0 6px;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, .06);
  overflow: hidden;
}

.iv-q-bar > i { display: block; height: 100%; border-radius: 3px; }
.iv-q-bar > i.tone-good { background: #00E5A0; }
.iv-q-bar > i.tone-mid  { background: #EF9F27; }
.iv-q-bar > i.tone-low  { background: #FF4D6D; }
.iv-q-bar > i.tone-idle { background: var(--text-tertiary); }

.iv-q-foot {
  display: flex;
  align-items: baseline;
  gap: 5px;
  font-size: 11.5px;
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
}

.iv-q-actual { color: var(--text-primary); font-weight: 600; }

/* ---------- 漏斗 ---------- */

.iv-funnel {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.iv-funnel-row {
  display: grid;
  grid-template-columns: 96px 1fr 46px 62px 82px;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--bg-card-2);
  color: inherit;
  font: inherit;
  font-size: 12.5px;
  text-align: left;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}

.iv-funnel-row:hover { background: rgba(255, 255, 255, .05); }
.iv-funnel-row.on { border-color: var(--blue); background: rgba(0, 212, 255, .08); }
/* 该环节暂时为空：保留位置（让人知道流程里有这一步），但弱化 */
.iv-funnel-row.dim { opacity: .5; }

.iv-funnel-label { color: var(--text-primary); }

.iv-funnel-bar {
  height: 8px;
  border-radius: 4px;
  background: rgba(255, 255, 255, .06);
  overflow: hidden;
}

.iv-funnel-bar > i { display: block; height: 100%; border-radius: 4px; }

.iv-funnel-bar > i.tone-gray  { background: #8B95B7; }
.iv-funnel-bar > i.tone-blue  { background: #4D8DFF; }
.iv-funnel-bar > i.tone-amber { background: #EF9F27; }
.iv-funnel-bar > i.tone-teal  { background: #00D4FF; }
.iv-funnel-bar > i.tone-green { background: #00E5A0; }
.iv-funnel-bar > i.tone-red   { background: #FF4D6D; }
.iv-funnel-bar > i.tone-purple { background: #B967DB; }

.iv-funnel-n {
  text-align: right;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.iv-funnel-pct { text-align: right; color: var(--text-tertiary); font-variant-numeric: tabular-nums; }
.iv-funnel-qty { text-align: right; color: var(--text-secondary); font-variant-numeric: tabular-nums; }

/* ---------- 维度分布 ---------- */

.iv-dims {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.iv-dim {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-card-2);
  border: 1px solid var(--border-soft);
}

.iv-dim-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
  display: flex;
  align-items: baseline;
}

.iv-dim-row {
  display: grid;
  grid-template-columns: 76px 1fr 40px 62px;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  font-size: 12px;
}

.iv-dim-row.unknown { opacity: .6; }

/* 可切片的维度行：点一下 = 只看这一项 */
.iv-dim-row.clickable {
  cursor: pointer;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 4px 6px;
  margin: 0 -6px;
  font: inherit;
  font-size: 12px;
  text-align: left;
  color: inherit;
  background: none;
  width: calc(100% + 12px);
  transition: background .15s ease, border-color .15s ease;
}

.iv-dim-row.clickable:hover { background: rgba(255, 255, 255, .05); }
.iv-dim-row.clickable:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }

.iv-dim-tip {
  margin-left: 8px;
  font-size: 10.5px;
  font-weight: 400;
  color: var(--text-tertiary);
}

.iv-dim-key {
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.iv-dim-bar {
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, .06);
  overflow: hidden;
}

.iv-dim-bar > i { display: block; height: 100%; border-radius: 3px; }
.iv-dim-bar > i.tone-blue   { background: #4D8DFF; }
.iv-dim-bar > i.tone-teal   { background: #00D4FF; }
.iv-dim-bar > i.tone-purple { background: #B967DB; }

.iv-dim-n { text-align: right; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.iv-dim-v { text-align: right; color: var(--text-tertiary); font-variant-numeric: tabular-nums; }

.iv-dim-foot {
  margin-top: 7px;
  padding-top: 6px;
  border-top: 1px solid var(--border-soft);
  font-size: 10.5px;
  color: var(--text-tertiary);
  text-align: right;
}

/* ---------- 切片筛选条（状态 / 类别） ---------- */

/* 无筛选 / 无数据时整块隐藏，避免留下一条空白的间距 */
.iv-filters-wrap:empty,
.iv-fsummary-wrap:empty { display: none; }

.iv-filters {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  background: var(--bg-card-2);
  border: 1px solid var(--border-soft);
  position: relative;
}

.iv-filter-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.iv-filter-label {
  flex: 0 0 34px;
  font-size: 11.5px;
  color: var(--text-tertiary);
}

.iv-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-size: 12px;
  line-height: 1.5;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease, color .15s ease;
}

.iv-chip:hover:not(:disabled) {
  border-color: var(--border);
  color: var(--text-primary);
  background: rgba(255, 255, 255, .05);
}

.iv-chip:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }

.iv-chip:disabled { cursor: default; }

.iv-chip.zero { opacity: .4; }

.iv-chip-n {
  min-width: 15px;
  padding: 0 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .08);
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
  text-align: center;
  color: inherit;
}

/* 选中态：用 tone 色描边 + 淡底，和漏斗/标签同一套色 */
.iv-chip.on { font-weight: 600; }

.iv-chip.on.tone-gray   { border-color: rgba(139, 149, 183, .6); background: rgba(139, 149, 183, .16); color: #B6BFD8; }
.iv-chip.on.tone-blue   { border-color: rgba(77, 141, 255, .6);  background: rgba(77, 141, 255, .16);  color: #7FB0FF; }
.iv-chip.on.tone-teal   { border-color: rgba(0, 212, 255, .6);   background: rgba(0, 212, 255, .14);   color: #4FD9FF; }
.iv-chip.on.tone-green  { border-color: rgba(0, 229, 160, .6);   background: rgba(0, 229, 160, .14);   color: #34E8B2; }
.iv-chip.on.tone-amber  { border-color: rgba(239, 159, 39, .6);  background: rgba(239, 159, 39, .16);  color: #EFAF55; }
.iv-chip.on.tone-red    { border-color: rgba(255, 77, 109, .6);  background: rgba(255, 77, 109, .16);  color: #FF7790; }
.iv-chip.on.tone-purple { border-color: rgba(185, 103, 219, .6); background: rgba(185, 103, 219, .16); color: #C88BE6; }

.iv-chip.on .iv-chip-n { background: rgba(255, 255, 255, .16); }

.iv-filter-clear {
  position: absolute;
  top: 7px;
  right: 9px;
  padding: 2px 7px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-tertiary);
  font: inherit;
  font-size: 11px;
  cursor: pointer;
}

.iv-filter-clear:hover { color: var(--text-primary); border-color: var(--red, #FF4D6D); }

/* 已生效切片的标签行 */
.iv-fsummary {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 11px;
  color: var(--text-tertiary);
}

.iv-ftag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border: 1px dashed var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, .03);
  color: var(--text-secondary);
  font: inherit;
  font-size: 11px;
  cursor: pointer;
}

.iv-ftag:hover { color: var(--text-primary); border-style: solid; }

.iv-ftag i { font-style: normal; font-size: 9.5px; opacity: .7; }

/* ---------- 状态标签 ---------- */

.iv-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11.5px;
  line-height: 1.5;
  white-space: nowrap;
}

.iv-tag.tone-gray  { background: rgba(139, 149, 183, .18); color: #A7B0CC; }
.iv-tag.tone-blue  { background: rgba(77, 141, 255, .18);  color: #7FB0FF; }
.iv-tag.tone-amber { background: rgba(239, 159, 39, .18);  color: #EFAF55; }
.iv-tag.tone-teal  { background: rgba(0, 212, 255, .16);   color: #4FD9FF; }
.iv-tag.tone-green { background: rgba(0, 229, 160, .16);   color: #34E8B2; }
.iv-tag.tone-red   { background: rgba(255, 77, 109, .18);  color: #FF7790; }
.iv-tag.tone-purple { background: rgba(185, 103, 219, .18); color: #C88BE6; }

/* ---------- 行内编辑 ---------- */

.iv-cell-edit {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 4px;
  margin: -1px -4px;
  border-radius: 4px;
  cursor: pointer;
  transition: background .12s ease, box-shadow .12s ease;
}

.iv-cell-edit:hover {
  background: rgba(0, 212, 255, .1);
  box-shadow: inset 0 0 0 1px rgba(0, 212, 255, .35);
}

.iv-cell-edit:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 1px;
}

.iv-cell-edit .pen {
  font-style: normal;
  font-size: 10px;
  color: var(--blue);
  opacity: 0;
  transition: opacity .12s ease;
}

.iv-cell-edit:hover .pen,
.iv-cell-edit:focus-visible .pen { opacity: 1; }

.iv-cell-input {
  width: 100%;
  min-width: 78px;
  padding: 3px 6px;
  border-radius: 4px;
  border: 1px solid var(--blue);
  background: var(--bg-deep);
  color: var(--text-primary);
  font: inherit;
  font-size: 12.5px;
}

.iv-cell-input:focus { outline: none; box-shadow: 0 0 0 2px rgba(0, 212, 255, .25); }

.iv-cell-saving { font-size: 11.5px; color: var(--text-tertiary); }

/* 跟进说明保持末列，汇报入口放在文字前。 */
.iv-table .iv-report-btn {
  display: inline-flex;
  vertical-align: middle;
  align-items: center;
  justify-content: center;
  gap: 4px;
  white-space: nowrap;
  height: 26px;
  margin-right: 6px;
  padding: 3px 7px;
  border: 1px solid var(--green-border);
  border-radius: 5px;
  color: var(--green);
  background: var(--green-bg);
  cursor: pointer;
}
.iv-table .iv-report-btn:hover { background: rgba(22, 163, 74, .16); }
.iv-table .iv-report-btn:focus-visible { outline: 2px solid #16a34a; outline-offset: 2px; }
.iv-table .iv-report-btn:disabled { opacity: .4; cursor: not-allowed; }
.iv-note-text { vertical-align: middle; white-space: pre-wrap; overflow-wrap: anywhere; }
.sv-modal.sv-modal-wide.iv-stage-modal { width: min(1500px, 96vw); }
.iv-stage-filters .iv-filter-label { flex-basis: 46px; }
.iv-stage-filters .iv-chip { max-width: 100%; overflow-wrap: anywhere; }
.iv-stage-filters .iv-chip.zero.on { opacity: 1; }
.iv-stage-filters .iv-chip-n { flex-shrink: 0; }
.iv-stage-summary { font-weight: 600; color: var(--text-primary); }
.iv-stage-scope { color: var(--text-secondary); font-size: 12px; margin-bottom: 16px; }

/* ---------- 展开按钮 ---------- */

.iv-more-wrap { display: flex; justify-content: center; }

.iv-more {
  padding: 6px 18px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--bg-card-2);
  color: var(--text-secondary);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: color .15s ease, border-color .15s ease;
}

.iv-more:hover { color: var(--text-primary); border-color: var(--blue); }

/* ---------- 提示条 ---------- */

.iv-toast {
  position: absolute;
  right: 18px;
  bottom: 16px;
  max-width: 70%;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  background: rgba(0, 229, 160, .14);
  border: 1px solid rgba(0, 229, 160, .4);
  color: #34E8B2;
  opacity: 0;
  transform: translateY(6px);
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}

.iv-toast.show { opacity: 1; transform: translateY(0); }
.iv-toast.err {
  background: rgba(255, 77, 109, .14);
  border-color: rgba(255, 77, 109, .45);
  color: #FF7790;
}

/* ---------- 空态 ---------- */

.iv-empty,
.iv-empty-inline {
  color: var(--text-tertiary);
  font-size: 12.5px;
  padding: 12px 4px;
  text-align: center;
}

/* 商机明细列多，窄屏下横向滚动而不是挤成一团 */
.iv-opp-table { min-width: 1180px; }

@media (max-width: 1180px) {
  .iv-cards { grid-template-columns: repeat(2, 1fr); }
  /* 商机段 6 卡在窄屏转 3 列（两行），仍不溢出；比目标段的 2 列更密 */
  .iv-opp-cards { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .iv-quarters { grid-template-columns: repeat(2, 1fr); }
  .iv-dims { grid-template-columns: 1fr; }
  .iv-funnel-row { grid-template-columns: 84px 1fr 40px 54px 70px; }
  /* 窄屏下 chip 会换行流到右上角被「清空」按钮压住 → 改为跟随流排布 */
  .iv-filter-clear {
    position: static;
    align-self: flex-end;
    margin-top: 2px;
  }
}

/* 极窄屏（手机）再退到 2 列，保证每张卡不被挤压溢出 */
@media (max-width: 680px) {
  .iv-opp-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
