/* ============================================================
 * 悦点进销存 Web 版 · 全站紧凑化补丁（20261113）
 * ------------------------------------------------------------
 * 必须在 components.css 与全部 css/pages/*.css 之后加载（见 index.html）。
 * 目标：
 *   ① 查询条件行与动作按钮行并排 —— 不再「一行只有一个按钮」；
 *   ② 输入控件宽度按内容自适应 —— 不再一律 width:100% 铺满整列；
 *   ③ 收敛纵向留白与表格行高 —— 一屏能显示更多内容。
 * 原则：只改样式值，不新增/重命名任何类名，不动 DOM 与 JS。
 * 回滚：删除 index.html 里本文件的 <link> 即可（或整段清空本文件）。
 * ============================================================ */

/* ---------- 1. 工具条：按内容收边，并与动作行并排 ----------
   后面紧跟 .bar-acts 的查询行改成行内级 flex + fit-content；
   两个 inline-flex 兄弟会自然落在同一行，宽度不够时整体换行（自适应）。
   :has() 只命中真正有动作行的页面，bb 轮的 .pt-od 两行查询区不受影响。 */
.page-head:has(+ .bar-acts),
.page-tools:has(+ .bar-acts) {
  display: inline-flex;
  vertical-align: top;
  width: fit-content;
  max-width: 100%;
  margin-right: 10px;
}
.bar-acts {
  display: inline-flex;
  vertical-align: top;
  width: fit-content;
  max-width: 100%;
  gap: 8px;
  margin: 0 0 10px;
}
/* 卡片头 / 弹窗内嵌的工具条同样只包住内容 */
.card-head .page-tools, .modal-body .page-tools {
  width: fit-content; max-width: 100%;
}
/* 单据页两行查询区（.pt-od）保持整宽，不能被 fit-content 压扁 */
.page-tools.pt-od {
  display: flex; width: 100%; max-width: 100%; margin-right: 0;
}

/* 主操作按钮不再用 auto 外边距推到行尾 —— 那会在按钮之间留一大片空白；
   左侧竖分隔线仍在，视觉分组不丢 */
.page-tools .btn-add, .bar-acts .btn-add { margin-left: 0; }

/* 工具条自身留白收紧 */
.page-tools { padding: 7px 10px; gap: 8px; }
.card-head .page-tools, .modal-body .page-tools { padding: 0; }

/* ---------- 2. 输入控件：宽度按内容 ----------
   field-sizing:content 让输入框随内容 / placeholder 伸缩（Edge/Chrome 123+）；
   不支持的浏览器忽略该声明，回落到 width:auto，仍比 width:100% 紧凑。
   min-width 保证空框不塌成一条缝，max-width 保证不撑破栅格。 */
.field input[type=text], .field input[type=number], .field input[type=tel],
.field input[type=email], .field input[type=url], .field input[type=search],
.field input[type=password], .field input[type=date],
.field input[type=datetime-local], .field input[type=time],
.field select {
  width: auto;
  min-width: 150px;
  max-width: 100%;
}
.field input[type=text], .field input[type=number], .field input[type=tel],
.field input[type=email], .field input[type=url], .field input[type=search] {
  field-sizing: content;
}
/* 按控件预期内容给不同初始宽度；field-sizing 会在输入后继续按实际内容伸缩。
   金额/数量只装数字 → 最窄；日期固定 yyyy-MM-dd；文本/邮箱要装长内容 → 最宽。 */
.field input[type=number] { min-width: 130px; }
.field input[type=date], .field input[type=datetime-local], .field input[type=time] { min-width: 158px; }
.field input[type=tel], .field input[type=password] { min-width: 168px; }
.field input[type=text], .field input[type=email], .field input[type=url],
.field input[type=search] { min-width: 180px; }
/* select 的 auto 宽度按最长选项，天然贴合内容 */
.field select { min-width: 145px; max-width: 100%; }
/* 多行文本 / 明细表格单元格内的输入仍需要铺满整格 */
.field textarea, .row-input { width: 100%; }
/* 「输入 + 按钮」「下拉 + 快捷新增」这类行内组合交给 flex 分配，保持原行为 */
.prof-inline input, .sel-row select, .form-item-inline input { width: auto; }
/* 个人资料页密码框原本单独写死 100%，这里同步为按内容 */
.prof-card .field input[type=password] {
  width: auto; min-width: 168px; max-width: 100%;
}
/* 登录/注册页密码框由 flex:1 与眼睛按钮配对，不参与按内容伸缩 */
.login-page .field input { field-sizing: auto; }

/* ---------- 3. 收敛留白，提升一屏信息量 ---------- */
.content { padding: 14px 20px 24px; }
.page-head { margin-bottom: 10px; }
.card { margin-bottom: 12px; }
.card-head { padding: 11px 16px; }
.card-body { padding: 13px 16px; }
.stat-row { gap: 12px; margin-bottom: 12px; }
.stat-card { padding: 12px 16px; }
.stat-num { font-size: 22px; margin-top: 4px; }
.tbl th { padding: 8px 14px; }
.tbl td { padding: 9px 14px; }
.tbl .empty { padding: 28px 0; }
.mini-tbl td, .mini-tbl th { padding: 6px 10px; }
.form-grid { gap: 10px 14px; }
.field label { margin-bottom: 4px; }
.modal-head { padding: 13px 18px; }
.modal-body { padding: 14px 18px; }
.modal-foot { padding: 11px 18px; }
.view-row { padding: 7px 0; }
.pager { padding: 9px 2px 2px; }
.tabs { padding: 0 10px; }
.tab { padding: 10px 14px; }
.org-guide { margin-bottom: 12px; padding: 11px 16px; }
.items-detail { padding: 8px 12px; }

/* 20261113e：导出 / 打印留在工具条后，动作行可能被拆空 —— 空的 .bar-acts 不再留一道空白 */
.bar-acts:empty { display: none; }

/* 20261113d：开票 / 对账状态查询条件暂时隐藏（z 轮新增，共 3 套查询区 × 2 = 6 个下拉）。
   DOM 与事件绑定保持原样，控件默认值为空 = 不带过滤条件，查询逻辑不受影响；
   单据编辑器表头的「是否开票 / 是否对账」录入字段仍保留。恢复时删掉本段即可。
   20261116d：组合框化后可见元素变成 select 旁挂的 .sel-combo，原 select 上的
   display:none 管不到它 —— 补 :has() 连带隐藏组合框（buildCombo 生成结构：
   .sel-combo > [input, arrow] + select.sel-combo-native 在 combo 内部）。 */
#odq-invoice, #odq-recon,
#poq-invoice, #poq-recon,
#soq-invoice, #soq-recon { display: none !important; }
.sel-combo:has(> .sel-combo-native#odq-invoice), .sel-combo:has(> .sel-combo-native#odq-recon),
.sel-combo:has(> .sel-combo-native#poq-invoice), .sel-combo:has(> .sel-combo-native#poq-recon),
.sel-combo:has(> .sel-combo-native#soq-invoice), .sel-combo:has(> .sel-combo-native#soq-recon) { display: none !important; }

/* ---------- 4. 弹窗显示修复（20261113g） ----------
   问题：第 2 节给 .field 输入框设了 width:auto / min-width:180px / field-sizing:content，
         查询条受益，但弹窗里的 .form-grid 是 1fr 1fr —— 列被 min-content 撑到 180px，
         380px 弹窗的内容区只有 344px（180+14+180=374），于是 .modal-body 冒出横向
         滚动条，第二列输入框被右边界裁掉一半（「快捷新增供应商 / 客户」等）。
   原则：弹窗表单回到「按列铺满」口径，页面查询条仍保持按内容伸缩；
         行内 style 写死的宽度（如 style="width:110px"）优先级更高，原样保留。 */

/* 列可收缩，长内容不再撑破栅格；跨列统一用 1/-1，单列时不会生成隐式列 */
.modal .form-grid, .modal .view-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.modal .form-grid > *, .modal .view-grid > * { min-width: 0; }
.modal .form-grid .span2, .modal .form-grid .trace-line,
.modal .view-grid .span2 { grid-column: 1 / -1; }

/* 窄弹窗（≤430px，ui.js 挂 .modal-sm）：一行一个字段，输入框拿到完整宽度 */
.modal-sm .form-grid, .modal-sm .view-grid { grid-template-columns: minmax(0, 1fr); }

/* 弹窗里的输入框恢复铺满所在列；组合控件（.sel-row / .bp-input-wrap 内的子输入）
   只清掉 min-width / field-sizing，宽度仍由各自的 flex 规则决定 */
.modal .field input[type=text], .modal .field input[type=number], .modal .field input[type=tel],
.modal .field input[type=email], .modal .field input[type=url], .modal .field input[type=search],
.modal .field input[type=password], .modal .field input[type=date],
.modal .field input[type=datetime-local], .modal .field input[type=time],
.modal .field select, .modal .field textarea {
  min-width: 0; max-width: 100%; field-sizing: auto;
}
.modal .field > input[type=text], .modal .field > input[type=number], .modal .field > input[type=tel],
.modal .field > input[type=email], .modal .field > input[type=url], .modal .field > input[type=search],
.modal .field > input[type=password], .modal .field > input[type=date],
.modal .field > input[type=datetime-local], .modal .field > input[type=time],
.modal .field > select, .modal .field > textarea { width: 100%; }

/* 内嵌工具条 / 表格不越界；确实超宽的表格仍由 .modal-body 自己横向滚动 */
.modal .page-tools, .modal-body { min-width: 0; }

/* 长标题省略号，× 永远留在右上角，不会被标题挤出弹窗 */
.modal-head h3 { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 细滚动条：内容超高时只占 8px，不再压出一条粗灰条 */
.modal-body { scrollbar-width: thin; scrollbar-color: #c9cdd4 transparent; }
.modal-body::-webkit-scrollbar { width: 8px; height: 8px; }
.modal-body::-webkit-scrollbar-thumb { background: #c9cdd4; border-radius: 8px; }
.modal-body::-webkit-scrollbar-track { background: transparent; }
