/* ============================================================
   Flow DS 落地层 v4 · 2026-11-10
   统一页签 / 行操作区 / 列设置入口 / 统计概览带

   背景：全站历史上存在两套页签（页面级 .tabs/.tab 与卡片内 .subtabs/.subtab），
   后者是「灰字 + 2px 细线」，看起来像一排普通文字链接，用户很难意识到
   下方内容是可切换的分页面板；行操作区最多一排放 9 个文字按钮；
   列表默认把 18~33 列一次全铺出来。
   本层统一为：
     1) 分段轨道页签：浅灰槽 + 白色浮起选中项 + 主色左标（呼应侧栏选中态）
        + 计数胶囊 + 常驻「视图 N/M」指示，明确告诉用户这里有多份内容；
     2) 行操作：查看 / 编辑 常驻，其余整合进「更多 ▾」，危险操作置底标红；
     3) 列设置：按钮统一形态并显示「隐藏 N 列」，默认只留核心列（util.js）；
     4) 统计卡：固定在页签之后的第一个视觉块，间距统一、空态不占位。

   ⚠️ 只追加，不改写 app.css / shell.css 的任何一条规则；
      删除 index.html 中 ui-kit.css / ui-kit.js 两行引用即可整层回滚。
   ⚠️ 位置在 app.css、shell.css 之后，同特异性下本层生效。
   ⚠️ 兼容微信 X5：不使用 :has() / :is() / 逻辑属性等新选择器。
   ============================================================ */

/* ------------------------------------------------------------
   1 · 统一页签：分段轨道（Segmented rail）
   ------------------------------------------------------------ */
.tabs,
.subtabs {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  margin: 0 0 16px;
  width: -moz-fit-content;
  width: fit-content;
  max-width: 100%;
  background: #eef2f8;
  border: 1px solid #e3e9f2;
  border-bottom: 1px solid #e3e9f2;
  border-radius: 12px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  scrollbar-color: #c7d0de transparent;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}
.tabs::-webkit-scrollbar,
.subtabs::-webkit-scrollbar { height: 3px; display: block; }
.tabs::-webkit-scrollbar-thumb,
.subtabs::-webkit-scrollbar-thumb { background: #c7d0de; border-radius: 3px; }

/* 卡片内的次标签（审批中心 / 基础资料 / 数据管理 / 系统设置）：
   轨道本身就是边界，不再需要 card-head 的分割线，也不再留外边距 */
.card-head > .tabs,
.card-head > .subtabs { margin: 0; }

.tab,
.subtab {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  padding: 8px 16px;
  border: 0;
  border-bottom: 0;
  margin: 0;
  background: transparent;
  border-radius: 9px;
  color: #5c6779;
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.3;
  white-space: nowrap;
  cursor: pointer;
  transition: background 150ms cubic-bezier(.2,.8,.2,1),
              color 150ms cubic-bezier(.2,.8,.2,1),
              box-shadow 150ms cubic-bezier(.2,.8,.2,1),
              transform 150ms cubic-bezier(.2,.8,.2,1);
}
.tab:hover,
.subtab:hover { background: rgba(255,255,255,.66); color: #111827; }
.tab:active,
.subtab:active { transform: translateY(1px); }

/* 选中项：白底浮起 + 主色左标（与 .nav-item.active 的 inset 3px 一致），
   一眼看出「这一格是当前打开的面板」 */
.tab.active,
.subtab.active {
  background: #ffffff;
  color: #1749cc;
  font-weight: 650;
  border-bottom-color: transparent;
  box-shadow: inset 3px 0 0 #1f5eff, 0 1px 4px rgba(16,24,40,.13);
}
.tab:focus-visible,
.subtab:focus-visible { outline: 2px solid #1f5eff; outline-offset: 1px; }

/* 计数胶囊：有数字才占位，选中态用主色淡底 */
.tab-n {
  display: inline-block;
  min-width: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: #dfe6f0;
  color: #5c6779;
  font-size: 12px;
  font-weight: 600;
  line-height: 18px;
  text-align: center;
  vertical-align: 0;
}
.tab-n:empty { display: none; }
.tab.active .tab-n,
.subtab.active .tab-n { background: #eaf0ff; color: #1749cc; }

/* 常驻视图指示：明确「这里共有几个可切换的内容面板、当前在第几个」。
   sticky 到轨道右端，窄屏横滑时也不会被滑走。 */
.tabs-meta {
  flex: 0 0 auto;
  margin-left: auto;
  position: sticky;
  right: 0;
  padding: 0 6px 0 14px;
  background: linear-gradient(90deg, rgba(238,242,248,0), #eef2f8 26%);
  color: #64748b;
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  pointer-events: none;
}
.tabs-meta i { font-style: normal; opacity: .65; margin-right: 4px; }
.tabs-meta b { color: #1749cc; font-weight: 700; }

/* 页签与下方内容之间留一条极淡的引导线，强化「轨道下面挂着面板」 */
.tabs + .stats,
.subtabs + .stats { margin-top: 0; }

/* ------------------------------------------------------------
   2 · 行操作区：查看 / 编辑 常驻，其余进「更多」
   ------------------------------------------------------------ */
.ui-ops { display: inline-flex; align-items: center; white-space: nowrap; }
.ui-ops > .btn-link { margin-left: 0; margin-right: 8px; }
.ui-ops > .btn-link:last-of-type { margin-right: 0; }
.ui-ops > .icon-btn { margin-right: 6px; }

.ui-more {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  min-height: 28px;
  padding: 3px 9px;
  border: 1px solid #dfe6f0;
  border-radius: 8px;
  background: #ffffff;
  color: #5c6779;
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1.2;
  cursor: pointer;
  white-space: nowrap;
  transition: background 150ms, border-color 150ms, color 150ms;
}
.ui-more::after { content: "▾"; font-size: 9px; opacity: .7; }
.ui-more:hover { background: #f3f6fc; color: #1749cc; border-color: #cddcff; }
.ui-more.on { background: #eaf0ff; color: #1749cc; border-color: #cddcff; }
.ui-more:focus-visible { outline: 2px solid #1f5eff; outline-offset: 2px; }
.ui-more-n {
  display: inline-block;
  min-width: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: #eef2f8;
  color: #64748b;
  font-size: 11px;
  line-height: 16px;
  text-align: center;
}

.ui-ops-pop {
  position: fixed;
  z-index: 9000;
  display: none;
  min-width: 158px;
  max-width: 280px;
  max-height: 60vh;
  overflow-y: auto;
  padding: 6px;
  background: #ffffff;
  border: 1px solid #e3e9f2;
  border-radius: 11px;
  box-shadow: 0 16px 40px rgba(16,24,40,.2);
}
.ui-ops-pop.on { display: block; }
.ui-ops-pop .btn-link,
.ui-ops-pop a.btn-link {
  display: block;
  width: 100%;
  box-sizing: border-box;
  text-align: left;
  margin: 0 !important;
  padding: 9px 10px;
  border-radius: 7px;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ui-ops-pop .btn-link:hover { background: #f3f6fc; }
/* 少数页面用 .btn-xs（结算单的「采购发票」）做行操作，进下拉后同样要铺满整行 */
.ui-ops-pop .btn-xs {
  display: block;
  width: 100%;
  box-sizing: border-box;
  text-align: left;
  margin: 0 !important;
  padding: 9px 10px;
  border-radius: 7px;
  font-size: 13px;
  white-space: nowrap;
}
.ui-ops-pop .btn-xs:hover { background: #f3f6fc; }
.ui-ops-pop .btn-link.danger,
.ui-ops-pop .btn-link[data-uiops-danger],
.ui-ops-pop .btn-xs.danger,
.ui-ops-pop .btn-xs[data-uiops-danger] { color: #b91c1c; }
.ui-ops-pop .btn-link.danger:hover,
.ui-ops-pop .btn-link[data-uiops-danger]:hover { background: #fef2f2; }
.ui-ops-sep { height: 1px; margin: 5px 4px; background: #eef1f6; }
.ui-ops-label {
  padding: 5px 10px 3px;
  color: #94a3b8;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .5px;
}
table.grid td.ops.ui-ops-open { z-index: 150; }
.appr-row .appr-oper.ui-ops-open { position: relative; z-index: 150; }

/* ------------------------------------------------------------
   3 · 列设置：统一入口形态 + 隐藏列数提示
   ------------------------------------------------------------ */
.colset-btn,
#f-cols,
#s-cols {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid #dfe6f0;
  border-radius: 9px;
  background: #ffffff;
  color: #5c6779;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
}
.colset-btn:hover,
#f-cols:hover,
#s-cols:hover { background: #f3f6fc; color: #1749cc; border-color: #cddcff; }
.colset-ico { font-size: 13px; opacity: .7; line-height: 1; }
.colset-n {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 999px;
  background: #eaf0ff;
  color: #1749cc;
  font-size: 11px;
  font-weight: 600;
  line-height: 16px;
}
.colset-tip { color: #5c6779; font-size: 12.5px; line-height: 1.75; margin-bottom: 10px; }
.colset-tools { gap: 16px; }
.colset-grid { max-height: 48vh; }

/* 工具条：无论按钮挂在 page-head 还是 card-head，间距与对齐一致 */
/* :not(:first-child) 保证只命中「标题 + 操作区」两栏结构的右侧容器；
   单栏页头（基础资料 / 数据管理 / 系统设置）里唯一的 div 不能被改成右对齐 flex */
.page-head > div:last-child:not(:first-child),
.card-head > .filters,
.list-tools,
.fin-acts {
  gap: 8px;
  align-items: center;
}
.page-head > div:last-child:not(:first-child) { display: flex; flex-wrap: wrap; justify-content: flex-end; }

/* ------------------------------------------------------------
   4 · 统计概览带：页签之后的第一个视觉块
   ------------------------------------------------------------ */
.stats { margin: 0 0 16px !important; }
.stats:empty { display: none !important; }
.stats + .card,
.stats + .notice { margin-top: 0; }
/* 统计卡整行最多 6 张，避免 settings 的 7 张卡挤成两行高低不齐。
   注意：auto-fit 只在宽屏用。≤820px 必须固定 2 列——auto-fit 遇到窄于
   2×168+gap 的容器（系统字体放大 / 网页缩放会把布局宽度压到 320 左右）
   会退化成 1 列 4 行，把表格挤出首屏。 */
@media (min-width: 821px) {
  .stats { grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); }
}

/* ------------------------------------------------------------
   5 · 窄屏（≤820px）
   ------------------------------------------------------------ */
@media (max-width: 820px) {
  .tabs, .subtabs { padding: 3px; margin-bottom: 12px; border-radius: 10px; }
  .tab, .subtab { min-height: 36px; padding: 7px 12px; font-size: 13px; }
  .tabs-meta { font-size: 11px; padding-left: 10px; }
  .stats { gap: 9px; margin-bottom: 12px !important; }
  /* 固定 2 列：320~335px 窄视口也不掉成单列（用户真机反馈的 1 列 4 行问题） */
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .ui-ops > .btn-link { margin-right: 6px; }
  .ui-more { min-height: 30px; padding: 3px 8px; }
  .colset-btn, #f-cols, #s-cols { min-height: 34px; padding: 0 10px; font-size: 12.5px; }
}
@media (max-width: 400px) {
  .tabs-meta { padding-left: 6px; }
  .tabs-meta i { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .tab, .subtab, .ui-more { transition: none; }
}

/* ============================================================
   6 · 侧边栏扁平线性图标（2026-11-10）
   ------------------------------------------------------------
   替换 NAV 里的彩色 emoji。图标由 nav-icons.js 提供，全部是
   20×20 网格 / 1.7 描边 / currentColor，颜色与透明度跟随导航项状态。
   这里不硬编码图标颜色：SVG 继承 .nav-item 的 color，
   因此浅色方案 A 与旧深色侧栏都能自动适配（回滚任一层都不会白底白线）。
   ============================================================ */
.nav-item .ni, .nav-sub .ni {
  width: 18px; height: 18px; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; text-align: center; opacity: .72;
  transition: opacity .15s;
}
.nav-item .ni svg, .nav-sub .ni svg {
  width: 18px; height: 18px; display: block; flex: 0 0 auto;
}
.nav-item:hover .ni, .nav-sub:hover .ni,
.nav-item.active .ni, .nav-sub.active .ni,
.nav-parent.on > .ni { opacity: 1; }
/* 选中态描边略加重，让「当前所在模块」在密集导航里更跳得出来 */
.nav-item.active .ni svg, .nav-sub.active .ni svg { stroke-width: 1.9; }

/* 品牌块与头像：去掉渐变 / 投影 / 深色实心块，统一成纯色扁平 */
.side-logo { background: #1f5eff; box-shadow: none; }
.avatar { background: #eaf0ff; color: #1749cc; }

/* 顶栏图标（☰ / ⟳ 已换成同套线性 SVG） */
.icon-btn { display: inline-flex; align-items: center; justify-content: center; }
.icon-btn svg, .nav-toggle svg {
  width: 18px; height: 18px; display: block; flex: 0 0 auto;
}
.shell-search-btn .ss-ico svg, .cmd-head .ch-ico svg { stroke-width: 1.7; }

/* 命令面板：与侧栏同一套图标，避免删掉脚本时留下空格 */
.cmd-item .ci-ico { background: #f1f5fd; }
/* 选中 / 悬停时图标方块白底浮起，呼应页签与侧栏的选中态，避免和浅蓝行背景融在一起 */
.cmd-item:hover .ci-ico, .cmd-item.on .ci-ico { background: #fff; }
.cmd-item .ci-ico svg { width: 18px; height: 18px; color: #1f5eff; }
.cmd-empty .ce-ico svg {
  width: 26px; height: 26px; color: #94a3b8; display: inline-block; vertical-align: middle;
}

@media (max-width: 820px) {
  /* 抽屉侧栏里图标略放大，触控下更易扫读；仍保持 18px 光学尺寸附近 */
  .nav-toggle { display: inline-flex; align-items: center; justify-content: center; }
  .nav-toggle svg { width: 19px; height: 19px; }
}
@media (prefers-reduced-motion: reduce) {
  .nav-item .ni, .nav-sub .ni { transition: none; }
}

/* ================= 7 · 窄屏表格按内容排版（2026-11-10） =================
   问题：各页列表表都写了内联 min-width（960 / 1080 / 1280px 等，为桌面端保证列宽）。
   窄屏（如 390px）时容器只有约 356px，浏览器为了满足 min-width 会把**每一列
   按比例拉宽**——于是出现「字段宽得离谱、操作列被撑到 290px」的观感。
   做法：窄屏取消内联最小宽度，让表格回到内容宽度（超宽由容器横滑承担），
   同时数据行强制单行（th 本来就 nowrap），避免取消宽度后长文本把行高顶到 160px。
   仅作用于页面列表容器，弹窗里的详情表不受影响。 */
@media (max-width: 820px) {
  #content .table-wrap table.grid[style*="min-width"],
  #content .tbl-wrap table.grid[style*="min-width"] { min-width: 0 !important; }
  #content .table-wrap table.grid tbody td,
  #content .tbl-wrap table.grid tbody td { white-space: nowrap; }
  /* 操作列不再吸收表格剩余宽度，收到内容宽度（查看 + 更多 ≈ 90px） */
  #content table.grid th.ops,
  #content table.grid td.ops { width: 1%; }
  /* 表格能完整放下时不吸附（ui-kit.js 会打 .ops-static），避免压住最后一列。
     采购页还有一套自研 .sticky-col，需一并取消，否则仍会盖住表头末尾。 */
  #content table.grid.ops-static th.ops,
  #content table.grid.ops-static td.ops,
  #content table.grid.ops-static th.sticky-col,
  #content table.grid.ops-static td.sticky-col { position: static; box-shadow: none; z-index: auto; }
  /* v3 给卡片内的滚动容器留了 14px 右内边距：宽表横滑时，这 14px 里会漏出
     吸附列背后那一列的一小条（看起来像「操作」右边粘了半个字）。
     窄屏把右内边距交给单元格自己（末列 18px），吸附列就能严丝合缝贴住右缘。 */
  #content .card > .table-wrap,
  #content .card > div:not(.card-body):not(.modal-body) > .table-wrap,
  #content .card > .tbl-wrap,
  #content .card > div:not(.card-body):not(.modal-body) > .tbl-wrap { padding-right: 0; }
  /* 单元格左右内边距 14px → 6px：手机上一屏能多放一列，且列内文字不会被挤断 */
  #content table.grid th,
  #content table.grid td { padding-left: 6px; padding-right: 6px; }
  /* 操作区紧凑化：窄屏不显示「更多」的动作数量徽标（点开即见），
     省出约 16px 让最后一列数据完整可见，而不是被吸附的操作列压住一角 */
  #content td.ops .ui-more-n { display: none; }
  #content td.ops .ui-more { padding: 3px 6px; }
  #content td.ops .ui-ops > .btn-link { margin-right: 6px; }
}

/* ------------------------------------------------------------
   8 · 窄屏顶部信息折叠（说明 / 提示条 / 「更多功能」抽屉）
   规则全部限定在 ≤820px：桌面端一个字节都不隐藏。
   统计卡（.stats）不在本段处理范围内，保持原样。
   ------------------------------------------------------------ */
/* 桌面隐藏折叠开关（标记仍在，但什么都不会折） */
.ui-note-btn, .ui-tools { display: none; }

/* ------------------------------------------------------------
   8.1 「更多功能」抽屉（2026-11-10 用户要求）
   窄屏时筛选、关键词、搜索、说明、重置、列设置、导出、统计图例
   全部收进这一个按钮；桌面端面板根本不会被构建。
   ------------------------------------------------------------ */
@media (max-width: 820px) {
  .ui-tools { display: block; margin: 0 0 12px; }
  /* 卡片头带页签的页面（基础资料 / 数据管理）：按钮排在页签下面、卡片内部，
     左右留出与卡片头一致的内缩 */
  .card > .ui-tools { margin: 12px 15px; }

  .ui-tools-btn {
    width: 100%;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    color: var(--ink-2);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  .ui-tools-btn:active { background: #f6f8fc; }
  .ui-tools-btn .ui-tools-ic { color: var(--ink-3); flex: 0 0 auto; }
  .ui-tools-btn .ui-tools-ar {
    width: 0; height: 0; margin-left: 1px;
    border-left: 4.5px solid transparent;
    border-right: 4.5px solid transparent;
    border-top: 5px solid currentColor;
    opacity: .5;
    transition: transform .18s ease;
  }
  .ui-tools.open .ui-tools-btn {
    border-color: #bcd0ff;
    background: #f4f8ff;
    color: #1f5eff;
  }
  .ui-tools.open .ui-tools-btn .ui-tools-ic { color: #1f5eff; }
  .ui-tools.open .ui-tools-btn .ui-tools-ar { transform: rotate(180deg); }
  /* 「已筛选 N」：抽屉收起时提示列表正带着条件，避免看到空列表以为没数据 */
  .ui-tools-btn .ui-tools-n {
    display: none;
    font-style: normal;
    font-size: 11px;
    line-height: 1;
    padding: 3px 7px;
    border-radius: 99px;
    background: #eef3ff;
    color: #1f5eff;
    font-weight: 600;
  }
  .ui-tools-btn .ui-tools-n[data-on="1"] { display: inline-block; }
  .ui-tools.open .ui-tools-btn .ui-tools-n { display: none; }

  .ui-tools-body {
    display: none;
    margin-top: 8px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fbfcfe;
  }
  .ui-tools.open .ui-tools-body { display: block; }

  /* 收纳进来的每一块之间留白，但最后一块不留尾巴 */
  .ui-tools-body > * { margin-top: 0; margin-bottom: 0; }
  .ui-tools-body > * + * { margin-top: 12px; }
  .ui-tools-body .filters,
  .ui-tools-body .list-tools { width: 100%; margin: 0; }
  .ui-tools-body .trk-filter { margin-bottom: 0; }
  .ui-tools-body .trk-stats { margin-bottom: 0; }
  .ui-tools-body .trk-stats + .trk-stats { margin-top: 8px; }
  /* 字段在抽屉里一行两个；单列的搜索框不再撑满整行 */
  .ui-tools-body .field,
  .ui-tools-body label { min-width: 0; }
  .ui-tools-body input,
  .ui-tools-body select { max-width: 100%; }
  .ui-tools-body .card-head { padding: 0; border: 0; background: none; }
  /* 抽屉里的自由输入框（基础资料/数据管理的搜索）独占一行，不挤成 200px 小方块 */
  .ui-tools-body .list-tools input:not([type="date"]):not([type="number"]) {
    flex: 1 1 100%;
    width: 100% !important;
  }
}


@media (max-width: 820px) {
  /* —— 页头说明：折叠为一行，尾部「▾」提示可展开 —— */
  #content .page-head .desc.uidesc {
    position: relative;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 1;
    overflow: hidden;
    cursor: pointer;
    padding-right: 20px;
    -webkit-tap-highlight-color: transparent;
  }
  #content .page-head .desc.uidesc::after {
    content: '▾';
    position: absolute;
    right: 2px;
    top: 0;
    font-size: 11px;
    line-height: inherit;
    color: #1f5eff;
    font-style: normal;
  }
  #content .page-head .desc.uidesc.uidesc-open {
    -webkit-line-clamp: 99;
    padding-bottom: 2px;
  }
  #content .page-head .desc.uidesc.uidesc-open::after { content: '▴'; }

  /* —— 提示条：按整行裁切到 2 行（省略号提示还有内容），无残影 —— */
  #content .hint.uinote .ui-note-in,
  #content .notice.uinote .nc {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
  }
  #content .hint.uinote.uinote-open .ui-note-in,
  #content .notice.uinote.uinote-open .nc {
    -webkit-line-clamp: 99;
  }

  /* 按钮在提示条外部（紧随其后）：不遮挡正文，也不被裁切区吃掉 */
  .ui-note-btn {
    display: block;
    margin: -8px 0 12px auto;
    background: none;
    border: 0;
    padding: 2px 0 2px 8px;
    font-size: 12px;
    font-weight: 500;
    color: #1f5eff;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  .ui-note-btn.on { color: #64748b; }
}

@media (prefers-reduced-motion: reduce) {
  .uidesc, .uinote { transition: none; }
}
