/* ============================================================
   驾驶舱视觉基线 v1 — 2026-11-04

   一个文件管三件事，纯样式覆盖，不改组件逻辑与 bundle。
   回滚：删掉 index.html 里引用本文件的那一行 <link> 即可。

   第一块 · 表格统一      第 1-7 条
   第二块 · 色彩语义收敛  第 8-14 条
   第三块 · 字号与筛选条  第 15-26 条

   ★ 本文件是追加式的：后写的规则覆盖先写的（同特定度时后出现者生效）。
     改之前先 grep 选择器 —— 同一个选择器可能出现在多处，
     例如 .aph-collection-target 先在红色块里出现、后被灰色块覆盖。

   ★ 两条踩过的坑，改本文件前必读：
   1) 特定度要写到 (0,3,2)。既有规则如
      body.aph2-theme main .text-primary 带 !important 且为 (0,2,2)，
      特定度低了压不住，改了也不生效。
   2) 文字是拿 -webkit-text-fill-color 上的色，不是 color。
      只改 color 时 computed color 变了、肉眼还是旧色。
      所以凡是改色都要同时写 fill（这里统一给 currentColor）。
   ============================================================ */

/* ============================================================
   第一块 · 表格统一
   覆盖三类容器（实测 DOM，非猜测）：
     .aph-project-table-wrap     项目管理
     .aph-service-center-scroll  回款额执行 / 当期收缴率 / 每日回款
     .sprint-screen              百日冲刺（含数据核对）
   不触碰五书表 .fb-form-table。
   ============================================================ */

/* ---- 1. 表头：深底白字 / 38px / 细竖分隔 ---- */
body.aph2-theme main .aph-project-table-wrap thead th,
body.aph2-theme main .aph-service-center-scroll thead th,
body .sprint-screen thead th {
  box-sizing: border-box !important;
  background: #16212e !important;
  color: #e8edf3 !important;
  -webkit-text-fill-color: #e8edf3 !important;
  height: 38px !important;
  padding: 0 10px !important;
  font-size: 11px !important;
  font-weight: 500 !important;
  letter-spacing: .2px !important;
  border-right: 1px solid rgba(255, 255, 255, .09) !important;
  border-bottom: 1px solid rgba(255, 255, 255, .16) !important;
  box-shadow: none !important;
  white-space: nowrap;
  vertical-align: middle;
}

/* ---- 2. 表头容器：清掉残留浅底与投影 ---- */
body.aph2-theme main .aph-project-table-wrap thead,
body.aph2-theme main .aph-service-center-scroll thead,
body .sprint-screen thead {
  background: transparent !important;
  box-shadow: none !important;
}
body.aph2-theme main .aph-project-table-wrap thead tr,
body.aph2-theme main .aph-service-center-scroll thead tr,
body .sprint-screen thead tr {
  box-shadow: none !important;
}

/* ---- 3. 排序图标：变浅、留出间距、不压字 ---- */
body.aph2-theme main .aph-project-table-wrap thead th svg,
body.aph2-theme main .aph-service-center-scroll thead th svg,
body .sprint-screen thead th svg {
  color: #c9d3de !important;
  fill: currentColor !important;
  opacity: .85;
}
body.aph2-theme main .aph-project-table-wrap thead th button,
body.aph2-theme main .aph-service-center-scroll thead th button,
body .sprint-screen thead th button {
  gap: 4px !important;
  white-space: nowrap !important;
}

/* ---- 4. 表头对齐：这两页数据全为左对齐，表头跟随 ---- */
body.aph2-theme main .aph-project-table-wrap thead th {
  text-align: left !important;
}
body.aph2-theme main .aph-project-table-wrap thead th button,
body.aph2-theme main .aph-project-table-wrap thead th .r6-sort-button,
body .sprint-screen thead th button,
body .sprint-screen thead th .r6-sort-button {
  justify-content: flex-start !important;
  text-align: left !important;
}

/* ---- 5. 数据核对表首列原只有 40px，「核对通过」会跨出格线 ---- */
body .sprint-screen thead th:nth-child(1) {
  min-width: 76px !important;
}

/* ---- 6. 表体：内边距与行分割统一 ---- */
body.aph2-theme main .aph-project-table-wrap tbody td,
body.aph2-theme main .aph-service-center-scroll tbody td,
body .sprint-screen tbody td,
body .sprint-screen tbody th {
  padding: 9px 10px !important;
  line-height: 1.45 !important;
  vertical-align: middle;
}
body.aph2-theme main .aph-project-table-wrap tbody td,
body.aph2-theme main .aph-service-center-scroll tbody td,
body .sprint-screen tbody td {
  border-bottom: 1px solid #eef0f2 !important;
}

/* ---- 7. 数字等宽：金额与百分比按位对齐 ---- */
body.aph2-theme main .aph-project-table-wrap table,
body.aph2-theme main .aph-service-center-scroll table,
body .sprint-screen table {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

/* ============================================================
   第二块 · 色彩语义收敛

   实测五个页面：共出现 7 种红、7 种绿，却只表达两种意思。
     红 = 负值 / 缺口 / 不利
     绿 = 正值 / 达成 / 已完成
   色阶过多才是「看着乱」的主因。收敛为各 1 个主色，
   并把纯装饰性的用色（片区名、关联状态、合计金额）降为中性。

   改后分工：
     红   #c00020  负值、缺口、异常
     绿   #0f7a49  正值、达成
     琥珀 #975919  未达标（需注意，但不等同于错）
     中性 #41464c / #4b5563  纯标识与合计
   ============================================================ */

/* ---- 8. 红色收敛：原 6 种 -> 1 种 ---- */
body .sprint-bad,
body .r228-negative,
body .aph-collection-target {
  color: #c00020 !important;
  -webkit-text-fill-color: currentColor !important;
}

/* ---- 9. 绿色收敛：原 7 种 -> 1 种 ---- */
body .r228-positive,
body .r228-target.success,
body .north-ai-status,
body .is-ready {
  color: #0f7a49 !important;
  -webkit-text-fill-color: currentColor !important;
}
/* 表格里的增减列也归到同一个绿 */
body.aph2-theme main table [class*="var(--success)"] {
  color: #0f7a49 !important;
  -webkit-text-fill-color: currentColor !important;
}

/* ---- 10. 琥珀统一（未达标） ---- */
body .r228-target.warning,
body .north-ai-status.warning {
  color: #975919 !important;
  -webkit-text-fill-color: currentColor !important;
}

/* ---- 11. 片区名：原来是红底红字的圆角药丸，每行一个 -
   它只是标识，不构成告警。改为中性方角小标签，
   红色从此只留给真正的负值和缺口。 ---- */
body.aph2-theme main .rounded-full.text-primary {
  background: #f1f3f5 !important;
  color: #4b5563 !important;
  -webkit-text-fill-color: currentColor !important;
  border-radius: 4px !important;
  font-weight: 500 !important;
}

/* ---- 12. 「已关联」：项目管理页 123 处全绿，相当于整列高亮 -
   降为低饱和绿，仍可与「未匹配」的灰区分，但不再抢视线。 ---- */
body .aph-project-link-linked {
  color: #567b68 !important;
  -webkit-text-fill-color: currentColor !important;
}

/* ---- 13. 合计金额去色 ----
   41.74 万、11,663.42 万这类「合计」是对账基数，
   不是达成判断，标绿会让人误以为在说「已达标」。
   带箭头的环比（如「较上一发布周 0.76pp」）属于增减判断，
   不在此列，仍保留绿。---- */
body.aph2-theme main .kpi-grid [class*="var(--success)"]:not([class*="inline-flex"]) {
  color: #41464c !important;
  -webkit-text-fill-color: currentColor !important;
}
body.aph2-theme main .kpi-grid [class*="var(--success)"][class*="inline-flex"] {
  color: #0f7a49 !important;
  -webkit-text-fill-color: currentColor !important;
}
body.aph2-theme main .r228-collection-body dl .r228-positive {
  color: #41464c !important;
  -webkit-text-fill-color: currentColor !important;
}

/* ---- 14. 修一处「隐形文字」 ----
   每日回款页「数据状态」卡里的值（暂无数据）没有自己的颜色类，
   继承了 .card-soft 的 #f1f5f9（近白），而卡片是白底，
   实测对比度只有 1.1:1，等于看不见。
   这里给该卡片一个正常的正文色，子元素自己声明过颜色的不受影响。
   （全站对比度审计只查出这一处低于 3:1）---- */
body.aph2-theme main .r228-source-card {
  color: #41464c !important;
}

/* ============================================================
   第三块 · 字号层级收敛（2026-11-04）

   实测五页字号分布，发现两处「同一层级多种字号」：
     区块标题 h2：15px / 17px / 18.848px  —— 18.848 是 pt 换算残留
     表格小字：  10px / 10.4px / 11px / 12px
   收敛为六级，此后不再出现非整数字号：
     20px  页面标题
     17px  区块标题
     15px  卡片标题
     13px  正文
     12px  表格正文
     11px  辅助说明 / 表头 / 表格内标签
   ============================================================ */

/* ---- 15. 区块标题统一 17px（原 15 / 17 / 18.848 三种） ---- */
body.aph2-theme main h2 {
  font-size: 17px !important;
}

/* ---- 16. 卡片标题统一 15px（原 15 / 16 两种） ---- */
body.aph2-theme main h3 {
  font-size: 15px !important;
}

/* ---- 17. 表格内辅助小字统一 11px（原 10 / 10.4 / 12 三种）
   涉及：项目管理「已关联/未匹配」标签、服务中心地址行、
        百日冲刺表格 .sprint-muted。都是表格里的第二层信息，
         11px 已是可读下限，再小就伤眼。 ---- */
body.aph2-theme main table small,
body.aph2-theme main .aph-project-link,
body.aph2-theme main .sprint-muted {
  font-size: 11px !important;
}

/* ---- 18. 指标区下边距统一 20px（原 mb-5 / mb-4 混用） ---- */
body.aph2-theme main .kpi-grid {
  margin-bottom: 20px !important;
}

/* ---- 19. 清掉最后 5 处非整数字号 ----
   项目管理筛选表单的字段标签（片区/业态/搜索）原 10px，
   脚注与每日回款告警面板的 small 原 10.4px。
   10px 在现代屏上已超出可读下限，统一到 11px。 ---- */
body.aph2-theme main .aph-project-toolbar label span,
body.aph2-theme main .aph-project-footnote,
body.aph2-theme main .r228-panel small {
  font-size: 11px !important;
}

/* ---- 20. 每日回款筛选条：把「可用日期」与胶囊并回一行 ----
   原结构是「可用日期：」一个文本节点 + 一个 display:flex 的 span，
   span 是块级 flex 所以必然换行，整条 toolbar 被撑成三行 93px。
   改成 inline-flex 后与文字同行，toolbar 回到两行。 ---- */
body.aph2-theme main .page-toolbar .toolbar-group > div.text-sm {
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
  flex-wrap: nowrap !important;
}
body.aph2-theme main .page-toolbar .toolbar-group > div.text-sm > span {
  display: inline-flex !important;
  flex-wrap: nowrap !important;
  margin-top: 0 !important;
  gap: 4px !important;
  min-width: 0;
  overflow-x: auto;
}

/* ---- 21. 整条筛选条压成一行（仅桌面宽度） ----
   三个控件区（日期输入 / 可用日期胶囊 / 片区筛选+导出）
   原本各占一行共 93px。桌面宽度下横向排布可容纳，
   胶囊区吃掉剩余空间并在不够时横向滚动，不换行。
   窄屏保持原来的自动换行，避免溢出。 ---- */
@media (min-width: 1340px) {
  body.aph2-theme main .page-toolbar .toolbar-group {
    flex-wrap: nowrap !important;
  }
  body.aph2-theme main .page-toolbar .toolbar-group > div.text-sm {
    flex: 1 1 auto !important;
    min-width: 0 !important;
  }
  body.aph2-theme main .page-toolbar .toolbar-group.ml-auto {
    flex-direction: row !important;
    align-items: center !important;
    gap: 10px !important;
    flex: 0 0 auto !important;
  }
}

/* ---- 22. 修正压缩导致的断行 ----
   压成一行后，「可用日期：」这个文本节点与首个胶囊都是 flex item，
   默认 flex-shrink:1 会被压缩，「可用日」「11-」「04」被迫折行。
   给文字禁止折行、给胶囊禁止收缩。 ---- */
body.aph2-theme main .page-toolbar .toolbar-group > div.text-sm {
  white-space: nowrap !important;
}
body.aph2-theme main .page-toolbar .toolbar-group > div.text-sm > span > * {
  flex: 0 0 auto !important;
  white-space: nowrap !important;
}

/* ---- 23. 胶囊降为 11px ----
   14 个日期胶囊按 12px 排共 764px，一行放不下会横向滚动、
   末 3 个日期看不见。降到 11px 后缩到约 658px，整条正好放下。
   11px 也符合「辅助信息」这一档，与表头同字号。 ---- */
body.aph2-theme main .page-toolbar .toolbar-group > div.text-sm > span > * {
  font-size: 11px !important;
  padding: 3px 7px !important;
}

/* ---- 24. 再收紧 47px，让 14 个胶囊完整落在一行 ---- */
body.aph2-theme main .page-toolbar .toolbar-group > div.text-sm {
  gap: 6px !important;
}
body.aph2-theme main .page-toolbar .toolbar-group > div.text-sm > span {
  gap: 2px !important;
}
body.aph2-theme main .page-toolbar .toolbar-group > div.text-sm > span > * {
  padding: 3px 6px !important;
}
body.aph2-theme main .page-toolbar input[type="date"] {
  width: 134px !important;
  padding-left: 8px !important;
  padding-right: 6px !important;
}

/* ---- 25. 考核指标说明降为中性 ----
   「华北地区2026年度考核指标 88.39%」是口径说明，不是告警。
   它在上一轮被归入红色收敛，结果同一张卡里出现两条红色信息
   （「未达标 · 目标 88.39%」才是告警），反而看不出哪条要紧。
   改为中性灰底灰字，红色只留给第一条。 ---- */
body.aph2-theme main .aph-collection-target {
  color: #4b5563 !important;
  -webkit-text-fill-color: currentColor !important;
  background: #f3f4f6 !important;
  border-color: #e2e5e9 !important;
}

/* ---- 26. 两处对比度压线（WCAG AA 要求小字 4.5:1） ----
   第三批把小字统一到 11px 后，这两处从「勉强 4.3」变成硬性不达标：
     已关联  #567b68 → 4.37
     未配置目标 #6b7280 → 4.28
   各加深一档到 5.0 左右，观感不变但达标。 ---- */
body .aph-project-link-linked {
  color: #4c7060 !important;
  -webkit-text-fill-color: currentColor !important;
}
body.aph2-theme main .r228-target.muted {
  color: #5f6773 !important;
  -webkit-text-fill-color: currentColor !important;
}
