/* ---------------------------------------------------------------------------
   费用台账 /finance/expenses/daily —— 2026-09-22 信息架构重排。
   区块顺序：新增费用（表单卡片）→ 近期费用（列表）→ 费用趋势 → 筛选（默认折叠）。

   纪律：
     · 只覆盖本页的 .fx-* 新类；console.css 里原有的 .finance-entry-* / .finance-ledger-* /
       .finance-voucher-* 一行未动（本表在 console.css 之后加载，需要时按类覆盖）。
     · 无 url(https?:) 外部引用（style-src 'self'）；无内联 style（CSP）。
     · 手机宽度（<= 720px）表格转成单列卡片，页面不出现横向滚动。
   --------------------------------------------------------------------------- */

.fx-page { display: grid; gap: var(--space-4); }

.fx-card {
  overflow: hidden; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-card); box-shadow: var(--shadow);
}

.fx-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-4);
  padding: var(--space-4) 18px; border-bottom: 1px solid var(--line); background: var(--surface);
}
.fx-head-copy { display: grid; gap: 3px; min-width: 0; }
.fx-head-copy strong { color: var(--text); font-size: var(--fs-section); line-height: var(--lh-section); }
.fx-head-copy span { color: var(--text-3); font-size: var(--fs-helper); }

/* ---- 诚实说明：未接入 / 无权限 / 登录失效 / 读取失败 ---- */
.fx-notice {
  display: grid; gap: 3px; margin: 0; padding: var(--space-3) 18px;
  border-bottom: 1px solid var(--line); font-size: var(--fs-helper);
}
.fx-notice strong { font-size: var(--fs-nav); }
.fx-notice--muted { background: var(--surface-2); color: var(--text-2); }
.fx-notice--muted strong { color: var(--text); }
.fx-notice--warn { background: var(--warn-soft); color: var(--warn); }
.fx-notice--warn strong { color: var(--warn); }

/* ---- 1. 新增费用 ---- */
.fx-entry-form { display: grid; gap: var(--space-3); padding: var(--space-4) 18px; }
.fx-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-3); }
.fx-field { display: grid; align-content: start; gap: 5px; min-width: 0; }
.fx-field--span2 { grid-column: span 2; }
.fx-field--span3 { grid-column: 1 / -1; }
.fx-field[hidden] { display: none; }
.fx-field-label { display: flex; align-items: baseline; gap: 6px; color: var(--text-2); font-size: var(--fs-label); font-weight: var(--fw-medium); }
.fx-req { color: var(--alert); font-size: var(--fs-label); font-weight: var(--fw-regular); }
.fx-field-hint { color: var(--text-3); font-size: var(--fs-helper); line-height: 1.5; }
.fx-field input, .fx-field select, .fx-field textarea {
  width: 100%; min-width: 0; min-height: var(--control-h); padding: 8px 10px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font: inherit; font-size: var(--fs-body);
}
.fx-field textarea { min-height: 62px; resize: vertical; line-height: var(--lh-body); }
.fx-field input::placeholder, .fx-field textarea::placeholder { color: var(--text-3); }
.fx-field input:focus, .fx-field select:focus, .fx-field textarea:focus {
  outline: 2px solid var(--accent-soft); border-color: var(--accent);
}
.fx-field :focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.fx-field input:disabled, .fx-field select:disabled, .fx-field textarea:disabled {
  background: var(--surface-2); color: var(--text-3); cursor: not-allowed;
}
.fx-field--invalid input, .fx-field--invalid select, .fx-field--invalid textarea { border-color: var(--alert); }
.fx-field--invalid .fx-field-label { color: var(--alert); }
.fx-error {
  margin: 0; padding: 9px 12px; border: 1px solid #f3cfcc; border-radius: var(--radius-sm);
  background: var(--alert-soft); color: var(--alert); font-size: var(--fs-nav);
}
.fx-error[hidden] { display: none; }
.fx-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); }
.fx-submit { min-width: 150px; min-height: var(--control-h); }
.fx-state { margin-inline-start: auto; }
.fx-foot {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--space-2) var(--space-4);
  padding: 10px 18px; border-top: 1px solid var(--line); background: var(--surface-2);
  color: var(--text-3); font-size: var(--fs-helper);
}

/* ---- 2. 近期费用 ---- */
.fx-read-state { margin: 0; padding: 10px 18px; border-bottom: 1px solid var(--line); background: var(--surface-2); font-size: var(--fs-helper); }
.fx-empty { display: grid; gap: 5px; padding: var(--space-8) 18px; text-align: center; }
.fx-empty[hidden] { display: none; }
.fx-empty strong { color: var(--text-2); font-size: var(--fs-card); font-weight: var(--fw-medium); }
.fx-empty span { color: var(--text-3); font-size: var(--fs-helper); }
.fx-table-wrap { max-height: min(60vh, 680px); overflow: auto; }
.fx-table-wrap[hidden] { display: none; }
/* min-width 按列宽之和取整：--content-max 1180 的正文列里刚好放得下 11 列，不出现卡片内横向滚动；
   更窄的桌面宽度下 .fx-table-wrap 才兜底滚动，窄屏则整体换成单列卡片（见下方 720px 断点）。 */
.fx-table { width: 100%; min-width: 1120px; margin: 0; border-collapse: collapse; table-layout: fixed; font-size: var(--fs-nav); }
.fx-table th, .fx-table td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.fx-table thead th {
  position: sticky; top: 0; z-index: 2; background: var(--surface-2); color: var(--text-2);
  font-weight: var(--fw-medium); white-space: nowrap; box-shadow: inset 0 -1px var(--line);
}
.fx-table thead th:first-child { width: 48px; }
.fx-table thead th:nth-child(2) { width: 106px; }
.fx-table thead th:nth-child(3) { width: 104px; }
.fx-table thead th:nth-child(4) { width: 92px; }
.fx-table thead th:nth-child(10) { width: 150px; }
.fx-table thead th:nth-child(11) { width: 100px; }
.fx-table td:nth-child(2), .fx-table td:nth-child(3), .fx-table td:nth-child(4) { white-space: nowrap; }
.fx-table td:nth-child(3) { font-variant-numeric: tabular-nums; }
.fx-table td:nth-child(6) { overflow-wrap: anywhere; }
.fx-row td { background: var(--surface); }
.fx-row:hover td { background: var(--surface-2); }
.fx-row--new td { background: var(--accent-soft); }
.fx-row--new td:first-child { box-shadow: inset 3px 0 var(--accent); }
@media (prefers-reduced-motion: no-preference) {
  .fx-row--new td { animation: fx-row-flash 2.2s ease-out 1; }
}
@keyframes fx-row-flash {
  0% { background: #dcebff; }
  100% { background: var(--accent-soft); }
}
.fx-voucher-cell .btn { display: block; width: 100%; }
/* 「详情」展开行（2026-09-25 审计 D 类：原来那个「查看详情」链接指回同一张列表）。
   一整行一个单元格，内容是凭证版本链。hidden 由 JS 控制，这里只管外观；
   .fx-row:hover 的背景不该把展开行也点亮，所以它自己声明一次背景。 */
.fx-detail-row td { background: var(--surface-2); border-top: 0; }
.fx-detail { padding: var(--space-2) 0; }
.fx-detail p { margin: 0; color: var(--text-3); font-size: var(--fs-helper); }
.fx-detail .kv { grid-template-columns: 132px 1fr; font-size: var(--fs-helper); }
.fx-detail .kv dd { overflow-wrap: anywhere; }
.fx-pager {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  padding: var(--space-3) 18px; border-top: 1px solid var(--line); background: var(--surface);
  color: var(--text-3); font-size: var(--fs-helper);
}
.fx-pager-actions { display: flex; gap: var(--space-2); }
/* 支付凭证面板沿用 console.css 的 .finance-voucher-* 外观，但它的 5 列固定网格至少要 764px，
   在「近期费用」卡里 768–1080px 之间会被卡片的 overflow:hidden 剪掉按钮；只在本卡内改成 flex 换行，
   其它地方的 .finance-voucher-* 规则一行未动。 */
.fx-list .finance-voucher-controls { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.fx-list .finance-voucher-controls select { flex: 1 1 190px; min-width: 0; }
.fx-list .finance-voucher-controls input[type="file"] { flex: 1 1 240px; min-width: 0; }
.fx-list .finance-voucher-controls .btn { flex: 0 0 auto; }

/* ---- 3. 费用趋势 ---- */
.fx-trend-table { width: 100%; margin: 0; border-collapse: collapse; font-size: var(--fs-nav); }
.fx-trend-table[hidden] { display: none; }
.fx-trend-table th, .fx-trend-table td { padding: 9px 18px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.fx-trend-table th { background: var(--surface-2); color: var(--text-2); font-weight: var(--fw-medium); }
.fx-trend-table th:nth-child(2), .fx-trend-table td:nth-child(2) { width: 88px; font-variant-numeric: tabular-nums; }
.fx-trend-table td:nth-child(3) { font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.fx-trend-table tbody tr:last-child th, .fx-trend-table tbody tr:last-child td { border-bottom: none; }
.fx-trend-empty { margin: 0; padding: var(--space-5) 18px; color: var(--text-3); font-size: var(--fs-helper); }
.fx-trend-empty[hidden] { display: none; }
.fx-trend-empty[data-state="ERROR"], .fx-trend-empty[data-state="NO_ANCHOR"] { color: var(--warn); background: var(--warn-soft); }
.fx-trend-basis { margin: 0; padding: 9px 18px; border-top: 1px solid var(--line); background: var(--surface-2); color: var(--text-3); font-size: var(--fs-helper); }
.fx-trend-basis[hidden] { display: none; }

/* ---- 4. 筛选（默认折叠） ---- */
.fx-filters { background: var(--surface); }
.fx-filter-bar { display: flex; align-items: center; gap: var(--space-2); padding: 10px 18px; }
.fx-filter-toggle {
  display: flex; align-items: baseline; flex: 1; gap: var(--space-2); min-width: 0; padding: 6px 8px;
  border: 1px solid transparent; border-radius: var(--radius-sm); background: transparent;
  color: var(--text-2); font: inherit; font-size: var(--fs-nav); text-align: left; cursor: pointer;
}
.fx-filter-toggle:hover { background: var(--surface-2); border-color: var(--line); }
.fx-filter-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.fx-filter-toggle-label { flex: none; color: var(--text); font-weight: var(--fw-medium); }
.fx-filter-summary { flex: 1; overflow: hidden; color: var(--text-3); font-size: var(--fs-helper); text-overflow: ellipsis; white-space: nowrap; }
.fx-filters[data-filtered="true"] .fx-filter-summary { color: var(--accent); font-weight: var(--fw-medium); }
.fx-filter-caret { flex: none; color: var(--text-3); font-size: var(--fs-helper); }
.fx-filter-clear[hidden] { display: none; }
.fx-filter-body { display: grid; gap: var(--space-3); padding: var(--space-3) 18px var(--space-4); border-top: 1px solid var(--line); background: var(--surface-2); }
.fx-filter-body[hidden] { display: none; }
.fx-filter-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-3); }
.fx-filter { display: grid; align-content: end; gap: 5px; min-width: 0; }
.fx-filter > span { color: var(--text-3); font-size: var(--fs-label); font-weight: var(--fw-medium); }
.fx-filter input, .fx-filter select {
  width: 100%; min-width: 0; min-height: 36px; padding: 6px 9px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font: inherit; font-size: var(--fs-body);
}
.fx-filter :focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.fx-filter-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }

/* ---- 窄屏：单列 + 表格转卡片，页面不出现横向滚动 ---- */
@media (max-width: 1100px) {
  .fx-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fx-field--span2, .fx-field--span3 { grid-column: 1 / -1; }
  .fx-filter-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .fx-head { align-items: flex-start; flex-direction: column; gap: var(--space-2); padding: var(--space-3) var(--space-4); }
  .fx-notice, .fx-read-state, .fx-pager, .fx-trend-basis, .fx-trend-empty, .fx-foot, .fx-filter-bar, .fx-filter-body { padding-inline: var(--space-4); }
  .fx-entry-form { padding: var(--space-3) var(--space-4); }
  .fx-grid, .fx-filter-grid { grid-template-columns: minmax(0, 1fr); }
  .fx-field { grid-column: 1 / -1; }
  .fx-actions { flex-direction: column; align-items: stretch; }
  .fx-actions .btn { width: 100%; min-height: 44px; }
  .fx-state { margin-inline-start: 0; text-align: center; }
  .fx-foot { flex-direction: column; gap: 3px; }
  .fx-pager { align-items: stretch; flex-direction: column; }
  .fx-pager-actions .btn { flex: 1; min-height: 44px; }
  .fx-filter-actions .btn { flex: 1; min-height: 44px; }
  .fx-list .finance-voucher-controls > * { flex: 1 1 100%; }
  .fx-list .finance-voucher-controls .btn { min-height: 44px; }

  /* 表格 → 单列卡片：每格自带中文行内标签（data-label），不靠表头对齐。 */
  .fx-table-wrap { max-height: none; overflow: visible; }
  .fx-table { min-width: 0; display: block; table-layout: auto; }
  .fx-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .fx-table tbody { display: block; }
  .fx-table tbody tr { display: block; padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--line); }
  .fx-table tbody td { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-3); padding: 3px 0; border: none; text-align: right; }
  .fx-table tbody td::before { content: attr(data-label); flex: none; color: var(--text-3); font-size: var(--fs-label); text-align: left; }
  .fx-table tbody td[data-label="序号"] { display: none; }
  .fx-table tbody td[data-label="费用用途"] { display: grid; gap: 2px; text-align: left; }
  .fx-table tbody td[data-label="支付凭证"], .fx-table tbody td[data-label="操作"] { display: grid; gap: var(--space-2); padding-top: var(--space-2); text-align: left; }
  .fx-row--new td, .fx-row:hover td { background: transparent; }
  .fx-row--new { background: var(--accent-soft); border-radius: var(--radius-sm); }
  .fx-row--new td:first-child { box-shadow: none; }

  .fx-trend-table { display: block; }
  .fx-trend-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .fx-trend-table tbody { display: block; }
  .fx-trend-table tbody tr { display: grid; gap: 2px; padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--line); }
  .fx-trend-table tbody td { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-3); padding: 0; border: none; }
  .fx-trend-table tbody td::before { content: attr(data-label); flex: none; color: var(--text-3); font-size: var(--fs-label); }
}
