/* ==========================================================
   报销管理系统 · 全局样式
   浅色主题，超宽屏优先（内容区不设窄上限）
   ========================================================== */

:root {
  --bg: #f5f7fa;
  --card: #ffffff;
  --ink: #1a2433;
  --ink-2: #4a5768;
  --ink-3: #7c8899;
  --ink-4: #a8b3c2;
  --line: #e2e8f0;
  --line-2: #eef2f7;
  --pri: #2563eb;
  --pri-dark: #1d4ed8;
  --pri-soft: #eff4ff;
  --ok: #0f9d58;
  --ok-soft: #e9f7ef;
  --warn: #c77700;
  --warn-soft: #fff6e5;
  --danger: #d93025;
  --danger-soft: #fdecea;
  --purple: #7c3aed;
  --radius: 10px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow: 0 4px 16px rgba(16, 24, 40, 0.08);
  --shadow-lg: 0 12px 40px rgba(16, 24, 40, 0.16);
  --sidebar-w: 212px;
  --content-max: 2400px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--pri); text-decoration: none; }

/* ---------------- 布局 ---------------- */

.app { display: flex; min-height: 100vh; }

.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: #0f1b2d;
  color: #cdd7e5;
  display: flex;
  flex-direction: column;
  z-index: 60;
}

.brand {
  padding: 20px 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.brand .name {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  letter-spacing: .02em;
  display: flex;
  align-items: center;
  gap: 8px;
}
.brand .mark {
  width: 26px; height: 26px;
  border-radius: 7px;
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff;
  flex: 0 0 auto;
}
.brand .sub { font-size: 11px; color: #6b7d95; margin-top: 3px; }

.nav { flex: 1; padding: 12px 10px; overflow-y: auto; }
.nav-group { margin-bottom: 6px; }
.nav-title {
  font-size: 10.5px;
  color: #5b6b82;
  letter-spacing: .1em;
  padding: 10px 10px 5px;
  text-transform: uppercase;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: 7px;
  color: #b6c3d4;
  font-size: 13.5px;
  cursor: pointer;
  user-select: none;
  transition: background .12s, color .12s;
  position: relative;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: var(--pri); color: #fff; }
.nav-item .ico { width: 16px; text-align: center; font-size: 14px; opacity: .9; }
.nav-item .badge {
  margin-left: auto;
  background: #d93025;
  color: #fff;
  font-size: 10.5px;
  min-width: 17px;
  height: 17px;
  padding: 0 5px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
}

.side-foot {
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,.07);
}
.user-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 8px;
  border-radius: 8px;
}
.user-chip .avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6, #7c3aed);
  color: #fff; font-size: 12px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  flex: 0 0 auto;
}
.user-chip .info { flex: 1; min-width: 0; }
.user-chip .nm { font-size: 13px; color: #e6edf6; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip .role { font-size: 11px; color: #6b7d95; }
.side-foot .logout {
  margin-top: 6px;
  width: 100%;
  background: rgba(255,255,255,.05);
  border: none;
  color: #93a3b8;
  font-size: 12.5px;
  padding: 7px;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
}
.side-foot .logout:hover { background: rgba(217,48,37,.18); color: #ffb3ad; }

.main {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  padding: 12px 26px;
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 58px;
}
.topbar h1 {
  font-size: 17px;
  font-weight: 650;
  margin: 0;
  letter-spacing: .01em;
  white-space: nowrap;
}
.topbar .crumb { font-size: 12.5px; color: var(--ink-3); }
.topbar .spacer { flex: 1; }

.content {
  padding: 20px 26px 48px;
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  flex: 1;
}

/* ---------------- 卡片 ---------------- */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: 16px; }
.card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line-2);
}
.card-head h2 {
  font-size: 14.5px;
  font-weight: 650;
  margin: 0;
  white-space: nowrap;
}
/* 右侧说明文字优先省略，别把左边标题挤到换行 */
.card-head > .muted { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-head .spacer { flex: 1; }
.card-body { padding: 18px; }
.card-body.tight { padding: 0; }

/* ---------------- 按钮 ---------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink-2);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: all .12s;
  user-select: none;
}
.btn:hover { border-color: #c9d4e3; background: #fafbfd; color: var(--ink); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
/* 详情里的「编辑」置灰但保留，点一下会说明为什么不能改（比直接消失好找原因） */
.btn.is-disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn.is-disabled:hover { border-color: var(--line); background: #fff; }

.btn.primary {
  background: var(--pri);
  border-color: var(--pri);
  color: #fff;
  font-weight: 550;
}
.btn.primary:hover { background: var(--pri-dark); border-color: var(--pri-dark); color: #fff; }

.btn.danger { color: var(--danger); border-color: #f3c9c4; background: #fff; }
.btn.danger:hover { background: var(--danger-soft); }

.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: #f1f5f9; border-color: transparent; }

.btn.sm { height: 28px; padding: 0 10px; font-size: 12.5px; border-radius: 6px; }
.btn.lg { height: 40px; padding: 0 20px; font-size: 14px; }
.btn.block { width: 100%; }

.btn-group { display: inline-flex; gap: 8px; }

/* ---------------- 表单 ---------------- */

.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 12.5px;
  color: var(--ink-2);
  margin-bottom: 6px;
  font-weight: 550;
}
.field label .req { color: var(--danger); margin-left: 2px; }

.input, .select, .textarea {
  width: 100%;
  height: 36px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  font-size: 13.5px;
  font-family: inherit;
  outline: none;
  transition: border-color .12s, box-shadow .12s;
}
.textarea { height: auto; min-height: 76px; padding: 9px 11px; resize: vertical; line-height: 1.6; }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--pri);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
.input::placeholder, .textarea::placeholder { color: var(--ink-4); }
.input:disabled, .select:disabled { background: #f8fafc; color: var(--ink-3); cursor: not-allowed; }

.input.money {
  font-size: 20px;
  font-weight: 600;
  height: 48px;
  font-variant-numeric: tabular-nums;
  letter-spacing: .01em;
}

.field-hint { font-size: 12px; color: var(--ink-3); margin-top: 5px; }
.field-error { font-size: 12px; color: var(--danger); margin-top: 5px; }

/* 提示行里的行内文字按钮（例如「切回上次用的日期」）。
   用 button 而不是 a[href]：点 href="#" 会改 hash，把 hash 路由带走 */
.hint-link {
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: var(--pri);
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 2px;
  cursor: pointer;
}
.hint-link:hover { text-decoration-style: solid; }
.hint-link:focus-visible { outline: 2px solid var(--pri); outline-offset: 2px; border-radius: 3px; }

.form-grid { display: grid; gap: 0 18px; }
.cols-2 { grid-template-columns: 1fr 1fr; }
.cols-3 { grid-template-columns: repeat(3, 1fr); }
.cols-4 { grid-template-columns: repeat(4, 1fr); }
.span-2 { grid-column: span 2; }

/* 费用日期行：日期输入 + 「今天」快捷按钮。
   按钮写 height:auto，靠父级 align-items:stretch 跟随输入框高度，
   桌面 36px / 手机 42px 都能齐平，不用写两套媒体查询 */
.date-row { display: flex; align-items: stretch; gap: 8px; }
.date-row > .input { flex: 1; min-width: 0; }
.date-row > .btn { flex: none; height: auto; padding: 0 14px; }

/* ---------------- 筛选条 ---------------- */

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line-2);
  background: #fcfdff;
}
.filters .f { display: flex; flex-direction: column; gap: 4px; }
.filters .f > span { font-size: 11.5px; color: var(--ink-3); }
.filters .input, .filters .select { height: 32px; font-size: 13px; }
.filters .f.w-sm .input, .filters .f.w-sm .select { width: 130px; }
.filters .f.w-md .input, .filters .f.w-md .select { width: 180px; }
.filters .f.w-lg .input, .filters .f.w-lg .select { width: 260px; }
.filters .f.grow { flex: 1; min-width: 180px; }
/* 下拉下方的小提示（如「区间较长，建议按月」），无内容时不占位 */
.filters .f-hint { font-size: 11px; color: var(--warn, #b45309); line-height: 1; min-height: 0; }
.filters .f-hint:empty { display: none; }
.filters .actions { display: flex; gap: 8px; margin-left: auto; }

.quick-ranges { display: flex; gap: 4px; }
.quick-ranges button {
  height: 32px;
  padding: 0 9px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 6px;
  font-size: 12.5px;
  color: var(--ink-2);
  cursor: pointer;
  font-family: inherit;
}
.quick-ranges button:hover { border-color: var(--pri); color: var(--pri); }
.quick-ranges button.on { background: var(--pri-soft); border-color: #c7d9ff; color: var(--pri); font-weight: 550; }
/* 「我的草稿」是待办入口，用橙色和普通时间快捷区分开 */
.quick-ranges button.draft-shortcut { color: #b45309; border-color: #f0d9ae; background: #fffdf7; }
.quick-ranges button.draft-shortcut:hover { border-color: #e0b866; color: #92400e; }
.quick-ranges button.draft-shortcut.on { background: #fff4e0; border-color: #e0b866; color: #92400e; font-weight: 600; }

/* 工作台「待提交草稿」卡片：能点开就做成可点击的样子 */
.stat.is-clickable { cursor: pointer; transition: box-shadow .14s, border-color .14s, transform .1s; }
.stat.is-clickable:hover { box-shadow: 0 3px 12px rgba(15, 27, 45, .1); border-color: #e0b866; }
.stat.is-clickable:active { transform: translateY(1px); }
.stat.is-clickable .d { color: var(--pri); }
.stat.is-clickable:focus-visible { outline: 2px solid var(--pri); outline-offset: 2px; }

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

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

table.tb {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table.tb th {
  text-align: left;
  padding: 10px 12px;
  background: #f8fafc;
  color: var(--ink-2);
  font-weight: 600;
  font-size: 12.5px;
  white-space: nowrap;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 1;
}
table.tb td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--line-2);
  vertical-align: middle;
}
table.tb tbody tr:hover { background: #fafcff; }
table.tb tbody tr.selected { background: var(--pri-soft); }
table.tb .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.tb .center { text-align: center; }
table.tb .money { font-weight: 600; color: var(--ink); }
table.tb .muted { color: var(--ink-3); }
table.tb .nowrap { white-space: nowrap; }
table.tb .clip {
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
table.tb tr.empty-row td {
  text-align: center;
  color: var(--ink-3);
  padding: 48px 12px;
}

/* 表格最后一列（操作列）右对齐，按钮不换行 */
table.tb.actions td:last-child {
  text-align: right;
  white-space: nowrap;
}
table.tb.actions th:last-child { text-align: center; }

/* 默认不要压得太淡：大屏上几乎看不见，容易被当成"没有操作入口" */
.row-actions { display: flex; gap: 2px; justify-content: flex-end; opacity: .62; transition: opacity .12s; }
table.tb tbody tr:hover .row-actions { opacity: 1; }.row-actions button {
  border: none;
  background: transparent;
  color: var(--ink-3);
  font-size: 12.5px;
  padding: 3px 5px;
  border-radius: 5px;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
}
.row-actions button:hover { background: #eef2f7; color: var(--pri); }
.row-actions button.go { color: var(--pri); font-weight: 550; }
.row-actions button.go:hover { background: var(--pri-soft); }
.row-actions button.del:hover { background: var(--danger-soft); color: var(--danger); }

input[type="checkbox"] {
  width: 15px; height: 15px;
  accent-color: var(--pri);
  cursor: pointer;
  margin: 0;
}

/* ---------------- 缩略图 ---------------- */

.thumb {
  width: 38px; height: 38px;
  /* 表格列被压缩时，图片会被一并挤窄，加 min/max 锁死尺寸 */
  min-width: 38px; max-width: 38px;
  min-height: 38px; max-height: 38px;
  border-radius: 6px;
  object-fit: cover;
  border: 1px solid var(--line);
  background: #f1f5f9;
  cursor: pointer;
  display: block;
}
/* 待审批：整行可点开详情，用手型光标 + 悬停提示体现 */
table.tb tbody tr.ap-row { cursor: pointer; }
table.tb tbody tr.ap-row:hover { background: #f2f7ff; }
table.tb tbody tr.ap-row:focus-visible { outline: 2px solid var(--pri); outline-offset: -2px; }

/* 凭证格：缩略图 + 张数，点开是跨记录相册 */
.att-cell {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  border-radius: 6px;
  padding: 2px 4px;
  transition: background .12s;
}
.att-cell:hover { background: #eaf1ff; }
.att-cell .att-num {
  font-size: 11.5px;
  color: var(--ink-3);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.att-cell:hover .att-num { color: var(--pri); }

.thumb-stack { display: flex; align-items: center; gap: 4px; }
.thumb-more {
  font-size: 11px;
  color: var(--ink-3);
  background: #f1f5f9;
  border-radius: 5px;
  padding: 1px 5px;
}
.thumb-icon {
  width: 38px; height: 38px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #f8fafc;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; color: #b91c1c;
  cursor: pointer;
}

/* ---------------- 标签 ---------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  line-height: 1.7;
  padding: 0 8px;
  border-radius: 999px;
  border: 1px solid;
  white-space: nowrap;
  font-weight: 500;
}
.badge.draft { background: #f1f5f9; color: #64748b; border-color: #e2e8f0; }
.badge.submitted { background: var(--pri-soft); color: var(--pri); border-color: #cfe0ff; }
.badge.approved { background: var(--ok-soft); color: var(--ok); border-color: #c6e9d4; }
.badge.paid { background: #eef7f0; color: #166534; border-color: #cfe8d8; }
.badge.rejected { background: var(--danger-soft); color: var(--danger); border-color: #f7cfca; }

.dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  display: inline-block;
  flex: 0 0 auto;
}

.tag-cat {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12.5px;
  color: var(--ink-2);
  white-space: nowrap;
}

/* ---------------- 统计卡 ---------------- */

.stat-grid {
  display: grid;
  /* 6 张卡等分一行：宽度够就排一行，不够时媒体查询折成 3 列 / 2 列，避免横向滚动 */
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
/* 1180px 以下放不下 6 列金额，退成 3 列两行 */
@media (max-width: 1180px) {
  .stat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
}
.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 14px 13px;
  box-shadow: var(--shadow-sm);
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.stat .k { font-size: 12px; color: var(--ink-3); display: flex; align-items: center; gap: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat .v {
  font-size: 23px;
  font-weight: 700;
  margin-top: 5px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.01em;
}
.stat .v .unit { font-size: 14px; font-weight: 500; color: var(--ink-3); margin-left: 3px; }
.stat .d { font-size: 12px; color: var(--ink-3); margin-top: 3px; }
.stat .d .up { color: var(--danger); }
.stat .d .down { color: var(--ok); }
/* 币种卡：左侧竖色条区分人民币/港币，不折算、各算各的 */
.stat.cur-hkd { box-shadow: inset 3px 0 0 0 #d98b00; }
.stat.cur-cny { box-shadow: inset 3px 0 0 0 #2f6fd0; }
.stat .cur-sym {
  font-size: 10.5px;
  letter-spacing: .04em;
  color: var(--ink-4);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 0 4px;
}
.stat .cur-sym.hkd { color: #a75c00; border-color: #f3dcb6; background: #fffaf0; }
.stat .cur-sym.cny { color: #1f4f96; border-color: #d6e3f6; background: #f5f9ff; }
/* 「N 月」这类弱信息靠右，让标题主体不被挤断 */
.stat .k-m { margin-left: auto; color: var(--ink-4); }
/* 汇总卡底部「另有草稿未计入」：虚线小字，不抢主数字 */
.stat .stat-note {
  margin-top: auto;
  padding-top: 4px;
  border-top: 1px dashed var(--line);
  font-size: 11.5px;
  color: var(--ink-4);
  line-height: 1.5;
}
.stat .stat-note .dot-draft {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #c4c9d4;
  margin-right: 4px;
  vertical-align: 1px;
}
/* 明细区「其中草稿 …」小胶囊 */
.draft-chip {
  display: inline-block;
  margin-left: 4px;
  padding: 0 6px;
  border-radius: 4px;
  background: #f3f4f6;
  color: #6b7280;
  font-size: 11.5px;
  line-height: 18px;
}
/* 月历格子：含草稿时主金额后跟一个小加号，提示还有未提交的 */
.mini-cell .mc-draft {
  font-size: 9px;
  color: #9aa2af;
  margin-left: 1px;
}
/* 卡片里的副标题尽量压成一行，右端省略，不撑高卡片 */
.stat .d.nowrap-1 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 1500px) {
  .stat .k-m { display: none; }
}

/* ---------------- 图表 ---------------- */

.chart-box { position: relative; width: 100%; }
.chart-box.h-sm { height: 210px; }
.chart-box.h-md { height: 280px; }
.chart-box.h-lg { height: 340px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-2 > .card + .card, .grid-3 > .card + .card { margin-top: 0; }

/* ---------------- 分页 ---------------- */

.pager {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-top: 1px solid var(--line-2);
  font-size: 12.5px;
  color: var(--ink-3);
}
.pager .spacer { flex: 1; }
.pager button {
  min-width: 30px; height: 30px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12.5px;
  color: var(--ink-2);
  font-family: inherit;
}
.pager button:hover:not(:disabled) { border-color: var(--pri); color: var(--pri); }
.pager button.on { background: var(--pri); border-color: var(--pri); color: #fff; }
.pager button:disabled { opacity: .4; cursor: not-allowed; }

/* ---------------- 弹窗 ---------------- */

.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(15, 27, 45, .48);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 24px;
  animation: fadeIn .12s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { from { opacity: 0; transform: translateY(8px) scale(.99); } to { opacity: 1; transform: none; } }

.modal {
  background: #fff;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 520px;
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  animation: popIn .15s ease;
}
.modal.w-md { max-width: 680px; }
.modal.w-lg { max-width: 860px; }
.modal.w-xl { max-width: 1100px; }
.modal-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--line-2);
  display: flex;
  align-items: center;
  gap: 10px;
}
.modal-head h3 { margin: 0; font-size: 15px; font-weight: 650; }
.modal-head .x {
  margin-left: auto;
  border: none;
  background: transparent;
  font-size: 20px;
  line-height: 1;
  color: var(--ink-4);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 5px;
}
.modal-head .x:hover { background: #f1f5f9; color: var(--ink); }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-body.tight { padding: 0; }
.modal-foot {
  padding: 14px 20px;
  border-top: 1px solid var(--line-2);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  align-items: center;
}
.modal-foot .left { margin-right: auto; }

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

.toasts {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 400;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: #1a2433;
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: var(--shadow);
  animation: slideIn .18s ease;
  max-width: 420px;
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
@keyframes slideIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }
.toast.ok { background: #0f7a45; }
.toast.err { background: #b3261e; }
.toast.warn { background: #96600a; }

/* ---------------- 附件区 ---------------- */

.upload-zone {
  border: 1.5px dashed #cbd5e1;
  border-radius: var(--radius);
  background: #fcfdff;
  padding: 22px;
  text-align: center;
  color: var(--ink-3);
  font-size: 13px;
  cursor: pointer;
  transition: all .15s;
}
.upload-zone:hover, .upload-zone.drag {
  border-color: var(--pri);
  background: var(--pri-soft);
  color: var(--pri);
}
.upload-zone .big { font-size: 22px; margin-bottom: 6px; opacity: .65; }
.upload-zone .hint { font-size: 12px; color: var(--ink-4); margin-top: 4px; }

.attach-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(122px, 1fr));
  gap: 10px;
  margin-top: 12px;
}
.attach-item {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #f8fafc;
  aspect-ratio: 4 / 3;
  cursor: pointer;
}
.attach-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.attach-item .pdf {
  width: 100%; height: 100%;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  color: #b91c1c; font-size: 11px; font-weight: 600; gap: 4px;
}
.attach-item .bar {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  background: linear-gradient(transparent, rgba(15,27,45,.78));
  color: #fff;
  font-size: 10.5px;
  padding: 14px 6px 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.attach-item .bar .tag {
  background: rgba(255,255,255,.22);
  border-radius: 3px;
  padding: 0 4px;
  font-size: 9.5px;
}
.attach-item .ops {
  position: absolute;
  top: 4px; right: 4px;
  display: flex;
  gap: 3px;
  opacity: 0;
  transition: opacity .12s;
}
.attach-item:hover .ops { opacity: 1; }
/* 右上角「⤢」：提示这张点得开，默认藏着，指到卡片上才露出来（手机端常显） */
.attach-item .zoom-tip {
  position: absolute;
  top: 4px; right: 4px;
  width: 20px; height: 20px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 5px;
  background: rgba(15,27,45,.6);
  color: #fff;
  font-size: 11px;
  opacity: 0;
  transition: opacity .12s;
}
.attach-item:hover .zoom-tip { opacity: 1; }
.attach-item .ops button {
  width: 22px; height: 22px;
  border: none;
  border-radius: 5px;
  background: rgba(15,27,45,.68);
  color: #fff;
  font-size: 11px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  padding: 0;
}
.attach-item .ops button:hover { background: var(--pri); }
.attach-item .ops button.del:hover { background: var(--danger); }
.attach-item.uploading { opacity: .55; }
.attach-item .primary-mark {
  position: absolute;
  top: 4px; left: 4px;
  background: var(--pri);
  color: #fff;
  font-size: 9.5px;
  padding: 1px 5px;
  border-radius: 4px;
}

/* ---------------- 凭证分区（发票 / 其他） ---------------- */

.attach-section + .attach-section { margin-top: 14px; }
.attach-sec-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.attach-sec-head .spacer { flex: 1; }
.sec-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.sec-dot.invoice { background: #ea580c; }
.sec-dot.receipt { background: #94a3b8; }
.sec-title { font-size: 13.5px; font-weight: 650; color: var(--ink); }
.sec-count { font-size: 12px; color: var(--ink-3); }

/* 拖拽到某个分区时的提示 */
.attach-section.drag {
  background: #f2f7ff;
  border-radius: 10px;
  box-shadow: 0 0 0 1px var(--pri) inset;
}

.attach-empty {
  grid-column: 1 / -1;
  border: 1px dashed var(--line);
  border-radius: 10px;
  padding: 16px 14px;
  text-align: center;
  font-size: 12.5px;
  color: var(--ink-3);
  cursor: pointer;
  background: #fbfcfe;
}
.attach-empty:hover { border-color: var(--pri); color: var(--pri); background: var(--pri-soft); }

/* 卡片左下角的「发票」角标，位置在底部文件名条之上 */
.attach-item .invoice-mark {
  position: absolute;
  left: 4px;
  bottom: 24px;
  background: #ea580c;
  color: #fff;
  font-size: 9px;
  line-height: 14px;
  padding: 0 4px;
  border-radius: 3px;
}
.attach-item.is-invoice { border-color: #fdba74; }

.attach-hint-line {
  margin-top: 12px;
  font-size: 11.5px;
  color: var(--ink-3);
  line-height: 1.6;
}

/* 手机端：相册 / 拍照 / 文件 三个按钮排成一行，都是拇指够得着的大方块 */
.attach-ops {
  display: flex;
  gap: 8px;
  margin: 2px 0 4px;
}
.attach-ops .btn.sm {
  flex: 1;
  height: 44px;
  font-size: 14.5px;
  font-weight: 600;
  border-radius: 11px;
  background: #f3f7fc;
  color: var(--ink-2);
  border: 1px solid var(--line);
}
.attach-ops .btn:active { background: #e7eff9; }

/* 网格末尾的「再加一张」占位块 */
.attach-add {
  aspect-ratio: 1 / 1;
  border: 1px dashed var(--line);
  border-radius: 10px;
  background: #fafcff;
  color: var(--ink-3);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 12px;
  cursor: pointer;
  padding: 0;
}
.attach-add .plus { font-size: 26px; line-height: 1; color: var(--pri); font-weight: 300; }
.attach-add:active { background: #eef5ff; }

/* ---------------- 裁剪器 ---------------- */

.crop-stage {
  position: relative;
  background: #0f1b2d;
  border-radius: 8px;
  /* 随视口高度伸缩：普通屏约 460px，2K/4K 超宽屏可到 620px，避免大片空白 */
  height: clamp(320px, 52vh, 620px);
  overflow: hidden;
}
.crop-stage > img {
  display: block;
  max-width: 100%;
}
/* Cropper 会把图片替换成绝对定位容器，父级必须是定位上下文 */
.crop-stage .cropper-container {
  border-radius: 8px;
  overflow: hidden;
}
/* Cropper 默认给内部图片加 backface-visibility:hidden，会强制独立合成层。
   在没有 GPU 加速的环境（远程桌面、虚拟机、软件渲染）下这层经常不被光栅化，
   表现为裁剪区一片纯色、图片和裁剪框都看不见。改回 visible 可彻底规避。 */
.crop-stage .cropper-container img {
  backface-visibility: visible !important;
  -webkit-backface-visibility: visible !important;
}
.crop-tools { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }

/* ---------------- 灯箱 ---------------- */

.lightbox {
  position: fixed;
  inset: 0;
  /* 不透明：相册是独立一层，底下的详情弹窗不该透出来 */
  background: #080e18;
  z-index: 500;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  /* 顶部留给关闭 / 保存，底部留给缩略图条 */
  padding: 54px 56px 14px;
}
.lb-stage {
  flex: 1;
  min-height: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.lightbox .lb-stage img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 4px;
  transition: transform .22s ease;
  /* 手势自己处理，不让浏览器抢去做滚动 */
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  opacity: 0;
}
.lightbox .lb-stage img.lb-loaded { opacity: 1; transition: opacity .16s ease, transform .22s ease; }
.lightbox .lb-stage img.dragging { transition: none; }
.lightbox .nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px; height: 44px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,.12);
  color: #fff;
  font-size: 20px;
  cursor: pointer;
}
.lightbox .nav:hover { background: rgba(255,255,255,.24); }
.lightbox .prev { left: 24px; }
.lightbox .next { right: 24px; }
.lightbox .close,
.lightbox .lb-btn {
  position: absolute;
  top: 20px; right: 24px;
  width: 38px; height: 38px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,.12);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
}
/* 「保存」做成胶囊，文字放得下 */
.lightbox .lb-btn {
  right: 72px;
  width: auto;
  padding: 0 15px;
  font-size: 13px;
  border-radius: 19px;
  line-height: 38px;
}
.lightbox .close:hover,
.lightbox .lb-btn:hover { background: rgba(255,255,255,.24); }
/* 「删除」在左上角，和右上角的保存 / 关闭分开 */
.lightbox .lb-btn.del {
  right: auto;
  left: 24px;
  background: rgba(220, 38, 38, .6);
}
.lightbox .lb-btn.del:hover { background: rgba(220, 38, 38, .85); }
.lightbox .caption {
  color: #cbd5e1;
  font-size: 12.5px;
  text-align: center;
  padding: 10px 0 2px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 图片下方的业务信息条：让人知道这张图是哪笔费用、什么状态 */
.lb-info {
  width: min(760px, 100%);
  margin: 6px auto 0;
  padding: 9px 14px;
  border-radius: 10px;
  background: rgba(255, 255, 255, .09);
  border: 1px solid rgba(255, 255, 255, .12);
  color: #e2e8f0;
  font-size: 13px;
  line-height: 1.5;
  text-align: left;
}
.lb-info.hidden { display: none; }
.lb-i-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 8px;
}
.lb-i-amt { color: #fff; font-weight: 700; font-variant-numeric: tabular-nums; }
.lb-i-sep { color: #64748b; font-style: normal; }
.lb-i-title {
  flex: 1 1 160px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #cbd5e1;
}
.lb-i-count {
  margin-top: 3px;
  font-size: 11.5px;
  color: #94a3b8;
}
/* 缩略图条里换记录时的细分隔 */
.lb-thumb-sep {
  flex: none;
  width: 1px;
  height: 34px;
  margin: 0 2px;
  background: rgba(255, 255, 255, .28);
  align-self: center;
}
/* 底部缩略图条：手机上代替左右按钮，拇指直接点 */
.lb-strip {
  display: flex;
  gap: 8px;
  justify-content: flex-start;
  max-width: 100%;
  overflow-x: auto;
  padding: 4px 0 2px;
  scrollbar-width: none;
}
.lb-strip::-webkit-scrollbar { display: none; }
.lb-thumb {
  flex: none;
  width: 54px; height: 54px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 7px;
  overflow: hidden;
  background: rgba(255,255,255,.08);
  cursor: pointer;
  opacity: .55;
  transition: opacity .15s, border-color .15s;
}
.lb-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.lb-thumb:hover { opacity: .85; }
.lb-thumb.on { border-color: #fff; opacity: 1; }
.lb-tip {
  color: #7d8ca3;
  font-size: 11.5px;
  padding-top: 4px;
}

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

.empty {
  text-align: center;
  padding: 56px 20px;
  color: var(--ink-3);
}
.empty .ico { font-size: 30px; opacity: .35; margin-bottom: 10px; }
.empty .t { font-size: 14px; color: var(--ink-2); margin-bottom: 5px; }
.empty .d { font-size: 12.5px; }

/* ---------------- 其他 ---------------- */

.mono { font-family: "Cascadia Code", Consolas, monospace; font-size: 12px; }
.text-muted { color: var(--ink-3); }
.text-danger { color: var(--danger); }
.text-warn { color: var(--warn, #b45309); }

/* 统计报表里的下钻链接：点一下跳到费用记录页看对应清单 */
a.drill-link {
  color: inherit;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 2px;
  cursor: pointer;
}
a.drill-link:hover { text-decoration-style: solid; }
a.drill-link:focus-visible { outline: 2px solid var(--pri); outline-offset: 2px; border-radius: 3px; }
.mt-0 { margin-top: 0; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-0 { margin-bottom: 0; }
.flex { display: flex; align-items: center; gap: 8px; }
.flex-wrap { flex-wrap: wrap; }
.right { margin-left: auto; }
.hidden { display: none !important; }

.section-title {
  font-size: 13px;
  font-weight: 650;
  color: var(--ink-2);
  margin: 22px 0 10px;
  padding-left: 9px;
  border-left: 3px solid var(--pri);
}
.section-title:first-child { margin-top: 0; }

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px;
  color: var(--ink-3);
  font-size: 13px;
}
.spinner {
  width: 16px; height: 16px;
  border: 2px solid var(--line);
  border-top-color: var(--pri);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin-right: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.kv { display: flex; gap: 10px; font-size: 13px; padding: 5px 0; }
.kv .k { color: var(--ink-3); min-width: 72px; }
.kv .v { color: var(--ink); }

.switch {
  position: relative;
  display: inline-block;
  width: 40px; height: 22px;
  flex: 0 0 auto;
}
.switch input { opacity: 0; width: 0; height: 0; }
.switch span {
  position: absolute; inset: 0;
  background: #cbd5e1;
  border-radius: 22px;
  cursor: pointer;
  transition: .18s;
}
.switch span::before {
  content: "";
  position: absolute;
  width: 16px; height: 16px;
  left: 3px; top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: .18s;
}
.switch input:checked + span { background: var(--pri); }
.switch input:checked + span::before { transform: translateX(18px); }

/* ---------------- 响应式 ---------------- */

@media (max-width: 1100px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .cols-4 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 860px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform .2s;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: none; }
  .main { margin-left: 0; }
  .content { padding: 14px 14px 40px; }
  .topbar { padding: 10px 14px; }
  .cols-2, .cols-3, .cols-4 { grid-template-columns: 1fr; }
  /* ⚠️ span-2 在单列网格里会「凭空造出一列隐式网格」：
     本该上下排的字段变成左右并排，窄屏上右侧直接被切掉。
     单列时把 span-2 降回 span 1 */
  .form-grid .span-2 { grid-column: span 1; }
  .mobile-menu { display: inline-flex !important; }
  .filters .actions { margin-left: 0; width: 100%; }
  .filters .actions .btn { flex: 1; }
}

.mobile-menu {
  display: none;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 6px;
  width: 32px; height: 32px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 15px;
  color: var(--ink-2);
}

/* 数字输入框去掉上下调节箭头：额度、金额这类字段用不上，留着反而占位、易误点 */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

/* 打印 */
@media print {
  .sidebar, .topbar, .filters, .pager, .row-actions { display: none !important; }
  .main { margin-left: 0; }
  body { background: #fff; }
  .card { box-shadow: none; border-color: #ddd; }
}

/* ---------------- 录入页布局 ---------------- */

.form-layout {
  display: grid;
  grid-template-columns: minmax(0, 1080px) 320px;
  gap: 16px;
  align-items: start;
}
.form-layout .guide-card { position: sticky; top: 74px; }

.guide-list {
  margin: 0;
  padding-left: 17px;
  font-size: 12.5px;
  line-height: 1.85;
  color: var(--ink-2);
}
.guide-list li { margin: 8px 0; }
.guide-list li::marker { color: var(--ink-4); }

.note-line {
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  border: 1px solid;
}
.note-line.danger { background: var(--danger-soft); color: #9b2c22; border-color: #f7cfca; }
.note-line.info { background: var(--pri-soft); color: #1e40af; border-color: #cfe0ff; }

.muted { color: var(--ink-3); font-size: 12.5px; }

.nav-item .badge-dot {
  margin-left: auto;
  background: #d93025;
  color: #fff;
  font-size: 10.5px;
  min-width: 17px;
  height: 17px;
  padding: 0 5px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
}

@media (max-width: 1400px) {
  .form-layout { grid-template-columns: minmax(0, 1fr) 300px; }
}
@media (max-width: 1100px) {
  .form-layout { grid-template-columns: 1fr; }
  .form-layout .guide-card { position: static; }
}

/* ---------------- 列表补充 ---------------- */

.bulk-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  background: var(--pri-soft);
  border-bottom: 1px solid #cfe0ff;
  font-size: 13px;
  color: #1e40af;
  position: sticky;
  top: 58px;
  z-index: 20;
}
.bulk-bar .spacer { flex: 1; }

.list-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 18px;
  font-size: 12.5px;
  border-top: 1px solid var(--line-2);
}
.list-foot .spacer { flex: 1; }

.thumb-pill {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border-radius: 999px;
  background: #f1f5f9;
  font-size: 11.5px;
  color: var(--ink-2);
  cursor: pointer;
  transition: all .12s;
}
.thumb-pill:hover { background: var(--pri-soft); color: var(--pri); }

/* 发票数量小标：跟在「N 张」后面 */
/* 凭证列里「N 张」与「票N」保持一行，不换行撑高行高 */
table.tb td:has(.thumb-pill) { white-space: nowrap; }
table.tb td:has(.att-cell) { white-space: nowrap; }

/* 缩略图单元格整体不换行：缩略图 + 张数 + 发票角码挤在一行 */
.att-cell { white-space: nowrap; }
.att-cell .inv-pill { margin-left: 0; }

.inv-pill {
  display: inline-block;
  margin-left: 4px;
  padding: 0 5px;
  border-radius: 999px;
  background: #fff3e8;
  border: 1px solid #fed7aa;
  color: #c2410c;
  font-size: 10.5px;
  line-height: 16px;
  white-space: nowrap;
}

.detail-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line-2);
}
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 22px;
  margin: 12px 0 4px;
}
@media (max-width: 640px) {
  .detail-grid { grid-template-columns: 1fr; }
}

/* ---------------- 矩阵表 ---------------- */

table.tb.matrix td.muted-cell { color: var(--ink-4); }
table.tb.matrix tr.matrix-total td {
  background: #f8fafc;
  font-weight: 650;
  border-top: 2px solid var(--line);
}
table.tb.matrix tbody tr:last-child td { border-bottom: none; }

/* ---------------- 统计页：按币种分区 ---------------- */

.cur-block { margin-top: 20px; }
.cur-block:first-child { margin-top: 12px; }
.cur-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.cur-banner::before {
  content: '';
  width: 4px;
  height: 17px;
  border-radius: 2px;
  background: var(--cur-color, var(--pri));
}
.cur-name { font-size: 15px; font-weight: 700; color: var(--ink); }
.cur-banner .cur-chip {
  margin-left: auto;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--cur-color, var(--pri));
  background: #fff;
  border: 1px solid #e2e8f0;
}
.cur-name b { font-weight: 700; color: var(--cur-color, var(--pri)); }
.cur-meta { font-size: 12.5px; color: var(--ink-3); }

/* 统计报表顶部的费用总览：人民币与港币各一个总额 */
.total-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}
.total-item {
  position: relative;
  padding: 13px 16px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fcfdff;
  overflow: hidden;
}
.total-item::before {
  content: '';
  position: absolute; left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--ti-color, var(--pri));
}
.total-item[data-cur="CNY"] { --ti-color: #2563eb; }
.total-item[data-cur="HKD"] { --ti-color: #ea580c; }

.ti-cur {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--ink-3);
}
.ti-cur i { width: 8px; height: 8px; border-radius: 2px; background: var(--ti-color); }
.ti-sym { margin-left: auto; font-weight: 700; color: var(--ti-color); }
.ti-amt {
  margin-top: 5px;
  font-size: 24px;
  font-weight: 700;
  line-height: 1.15;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.ti-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
  font-size: 12px;
  color: var(--ink-3);
}
.total-item[data-zero="1"] { opacity: .5; }

.total-note {
  margin-top: 10px;
  font-size: 11.5px;
  color: var(--ink-3);
}

@media (max-width: 640px) {
  .total-grid { grid-template-columns: 1fr; gap: 10px; }
  .ti-amt { font-size: 21px; }
}

/* 类型占比明细：环形图下方自绘图例，名称 / 金额 / 占比三列对齐 */
.cat-legend {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 2px 10px;
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  max-height: 96px;
  overflow-y: auto;
}
.cat-lg {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  padding: 4px 6px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  font-size: 12px;
  color: var(--ink-2);
  text-align: left;
  cursor: pointer;
}
.cat-lg:hover { background: #f2f6fc; }
.cat-lg i { flex: none; width: 8px; height: 8px; border-radius: 2px; }
.cat-lg .n { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-lg .a { flex: none; font-variant-numeric: tabular-nums; color: var(--ink); font-weight: 600; }
.cat-lg .p { flex: none; width: 44px; text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-3); }

@media (max-width: 640px) {
  .cat-legend { grid-template-columns: 1fr; max-height: 128px; }
}

/* ---------------- 导出卡片 ---------------- */

.export-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}
.export-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color .15s, box-shadow .15s;
}
.export-card:hover { border-color: #c7d9ff; box-shadow: var(--shadow); }
.export-card .t { font-size: 15px; font-weight: 650; }
.export-card .d { font-size: 12.5px; color: var(--ink-3); line-height: 1.8; }
/* 三张卡片的说明行数不一样，按钮统一贴底，视觉上才对得齐 */
.export-card > .btn { margin-top: auto; }
.export-card .fmt {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px; height: 34px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
}
.fmt.xlsx { background: #15803d; }
.fmt.csv { background: #475569; }
.fmt.zip { background: #b45309; }

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--ink-2);
  padding: 5px 0;
  cursor: pointer;
}

/* ---------------- 设置项 ---------------- */

.setting-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line-2);
}
.setting-row:last-of-type { border-bottom: none; }
.setting-row .sr-t { font-size: 13.5px; font-weight: 600; color: var(--ink); }
.setting-row .sr-d { font-size: 12.5px; color: var(--ink-3); line-height: 1.7; margin-top: 3px; }

/* ---------------- 出勤月历 ---------------- */

.cal-card { padding: 0; overflow: hidden; }

.cal-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line-2);
  background: linear-gradient(180deg, #fbfdff, #fff);
}
.cal-nav { display: flex; align-items: center; gap: 6px; }
.cal-nav .btn.sm { min-width: 34px; padding: 4px 9px; }
.cal-title {
  margin-left: 6px;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: .01em;
  color: var(--ink);
  min-width: 108px;
}
.cal-person { display: flex; align-items: center; gap: 7px; font-size: 12.5px; }
.cal-legend {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 12px;
  color: var(--ink-3);
  flex-wrap: wrap;
}
.cal-legend span { display: inline-flex; align-items: center; gap: 5px; }
.cal-legend .lg {
  width: 11px; height: 11px;
  border-radius: 3px;
  display: inline-block;
  border: 1px solid transparent;
}
.lg.wk { background: #eef1f6; border-color: #dde3ec; }
.lg.hol { background: #fff1f0; border-color: #fbd5d0; }
.lg.adj { background: #fff7e6; border-color: #f8d9a0; }
.lg.rec { background: #eaf1ff; border-color: #c7d9ff; }

/* 汇总条 */
.cal-stat {
  display: flex;
  align-items: center;
  gap: 26px;
  flex-wrap: wrap;
  padding: 11px 18px;
  border-bottom: 1px solid var(--line-2);
  background: #fff;
}
.cal-stat-item { display: flex; align-items: baseline; gap: 6px; }
.cal-stat-item b { font-size: 18px; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.cal-stat-item span { font-size: 12px; color: var(--ink-3); }
.cal-stat-item.warn b { color: var(--warn); }
/* 口径说明的小问号，悬浮看完整规则 */
.cal-stat-item .q {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 12px;
  height: 12px;
  margin-left: 3px;
  border: 1px solid currentColor;
  border-radius: 50%;
  font-size: 9px;
  font-style: normal;
  line-height: 1;
  opacity: .55;
  cursor: help;
  vertical-align: 1px;
}
.cal-sums { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-left: auto; }
.cal-sum {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 4px 11px;
  border-radius: 999px;
  background: var(--pri-soft);
  border: 1px solid #d5e3ff;
  font-size: 13px;
  font-weight: 650;
  color: var(--pri-dark);
  font-variant-numeric: tabular-nums;
}
.cal-sum i { font-style: normal; font-size: 11.5px; font-weight: 500; color: var(--ink-3); }
.cal-sum em { font-style: normal; font-size: 11.5px; font-weight: 500; color: var(--ink-3); }
.cal-sum.settle { background: #fff7e6; border-color: #f8d9a0; color: #b45309; }

/* 星期表头 */
.cal-head {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  background: #f8fafc;
  border-bottom: 1px solid var(--line);
}
.cal-head div {
  padding: 8px 0;
  text-align: center;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
}
.cal-head div.we { color: var(--danger); }

/* 日期格子 */
/* 注意：必须 minmax(0,1fr)。写成 repeat(7,1fr) 时，"1fr" 的最小值是 auto，
   单元格里的不换行文字会把对应列撑宽，7 列就宽窄不一了。 */
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  grid-auto-rows: minmax(88px, auto);
  background: var(--line-2);
  gap: 1px;
}
.cal-cell {
  position: relative;
  background: #fff;
  padding: 6px 8px 7px;
  min-width: 0;
  overflow: hidden;
  cursor: pointer;
  transition: background .12s, box-shadow .12s;
  display: flex;
  flex-direction: column;
  gap: 3px;
  user-select: none;
}
.cal-cell:hover { background: #f6f9ff; }
.cal-cell.out { background: #fcfdfe; cursor: default; }
.cal-cell.out .cal-d { color: var(--ink-4); }
.cal-cell.is-weekend { background: #f8f9fb; }
.cal-cell.is-holiday { background: #fff8f7; }
.cal-cell.is-adjust { background: #fffaf0; }
.cal-cell.is-weekend:hover,
.cal-cell.is-holiday:hover,
.cal-cell.is-adjust:hover { background: #f2f7ff; }

.cal-top { display: flex; align-items: center; gap: 5px; min-height: 18px; }
.cal-d {
  font-size: 13.5px;
  font-weight: 650;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.cal-cell.is-today .cal-d {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--pri);
  color: #fff;
  font-weight: 600;
  margin: -2px 0 -2px -4px;
  padding: 0 4px;
}
/* 已登记的日期右上角有这个按钮：单独改 / 删那一天 */
.cal-more {
  margin-left: auto;
  width: 20px; height: 20px;
  flex: none;
  border: none;
  border-radius: 5px;
  background: #eef2f7;
  color: var(--ink-2);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  letter-spacing: 1px;
}
.cal-more:hover { background: var(--pri); color: #fff; }
.cal-cell.has-rec .cal-more { background: rgba(37, 99, 235, .1); color: var(--pri); }
.cal-cell.has-rec .cal-more:hover { background: var(--pri); color: #fff; }
/* 勾选标记也在右上角，有「⋯」时给它让位 */
.cal-top:has(.cal-more) .cal-check { right: 30px; }

.cal-tag {
  font-size: 10.5px;
  line-height: 15px;
  padding: 0 5px;
  border-radius: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: calc(100% - 26px);
}
.cal-tag.hol { background: #fff1f0; color: #c0392b; border: 1px solid #fbd5d0; }
.cal-tag.adj { background: #fff7e6; color: #b45309; border: 1px solid #f8d9a0; }
.cal-tag.wk { background: #eef1f6; color: #64748b; border: 1px solid #dde3ec; }

.cal-check {
  position: absolute;
  top: 5px; right: 7px;
  width: 17px; height: 17px;
  border-radius: 50%;
  background: var(--pri);
  color: #fff;
  font-size: 11px;
  line-height: 17px;
  text-align: center;
  font-weight: 700;
}

.cal-loc {
  font-size: 12px;
  color: var(--ink-2);
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding-right: 2px;
}
.cal-amt {
  font-size: 12px;
  font-weight: 650;
  color: var(--pri-dark);
  font-variant-numeric: tabular-nums;
}
/* 费用月历：当天笔数的小角标 */
.cal-cnt {
  margin-left: auto;
  flex-shrink: 0;
  font-size: 10.5px;
  line-height: 15px;
  padding: 0 5px;
  border-radius: 8px;
  background: #eaf1ff;
  border: 1px solid #c7d9ff;
  color: #3559b8;
  font-weight: 600;
  white-space: nowrap;
}
/* 有笔数时节日名要让位，否则「国庆节中秋节」和「3 笔」会挤成一团 */
.cal-top:has(.cal-cnt) .cal-tag { max-width: calc(100% - 62px); }
/* 港币行用琥珀色区分，一眼看出是哪一种币 */
.cal-amt.hkd { color: #b45309; }
/* 费用月历：有费用的日子用绿色条标记，和出勤的蓝色区分开 */
.cal-cell.has-exp { box-shadow: inset 3px 0 0 0 #2fae77; }
.lg.exp { background: #e7f8f0; border-color: #b6e6cd; }

/* 超提醒线计数：用警示色，和其它统计项区分开 */
.cal-stat-item.warn b { color: var(--danger); }
.cal-stat-item.warn span { color: #b42318; }
/* 单日最高做成一个汇总胶囊，和币种合计并排，不再和统计数字抢一行 */
.cal-sum.peak { background: #f4f7ff; border-color: #dde6fa; color: var(--ink); }
.cal-sum.peak i { color: #5570a8; }

/* 金额超提醒线 */
.lg.alt { background: #fff1f0; border-color: #f5b5ae; }
.cal-amt.over { color: var(--danger); font-weight: 750; }
.cal-cell.is-alert { background: #fffbfb; }
.cal-cell.is-alert:hover { background: #fff5f4; }
.cal-cell.is-alert.has-exp { box-shadow: inset 3px 0 0 0 var(--danger); }
.cal-cell.is-alert .cal-d { color: #b42318; }

/* 空白日期上的「＋」：平时隐藏，鼠标移上去才出现，不干扰看数 */
.cal-add {
  position: absolute;
  right: 5px;
  bottom: 4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink-3);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity .12s, background .12s, color .12s;
  padding: 0;
  z-index: 2;
}
.cal-cell:hover .cal-add { opacity: 1; }
.cal-add:hover { background: var(--pri); border-color: var(--pri); color: #fff; }

.cal-settle { font-size: 11px; color: #b45309; font-variant-numeric: tabular-nums; }
.cal-empty { font-size: 12px; color: var(--ink-4); }
/* 出勤备注：格子空间有限，单行截断，全文靠 title 悬浮显示 */
.cal-note {
  font-size: 11px;
  color: var(--ink-3);
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 1px 3px;
  border-radius: 3px;
  background: #f4f6fa;
  align-self: flex-start;
  max-width: 100%;
}
/* 工作日已过去却没登记：淡红标出。周末与法定节日不要求登记，不算漏登记 */
.cal-cell.miss { background: #fffbfb; }
.cal-cell.miss:hover { background: #fff5f4; }
.cal-cell.miss .cal-empty { color: #b42318; }
.cal-cell.miss::after {
  content: '待登记';
  position: absolute;
  right: 3px;
  bottom: 2px;
  font-size: 10px;
  line-height: 1;
  color: #b42318;
  opacity: .85;
}
.cal-cell.has-rec { box-shadow: inset 3px 0 0 0 #7aa7ff; }
.cal-cell.sel {
  background: #e8f0ff !important;
  box-shadow: inset 0 0 0 2px var(--pri);
}
.cal-cell.sel .cal-d { color: var(--pri-dark); }

/* 底部工具条 */
.cal-tools {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 18px;
  border-top: 1px solid var(--line-2);
  background: #fafcff;
  position: sticky;
  bottom: 0;
  z-index: 5;
}
.cal-tool-group { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.cal-tool-group .lbl { font-size: 12.5px; color: var(--ink-3); margin-right: 2px; }
.cal-sel-info { font-size: 13px; color: var(--ink-2); }
.cal-sel-info b { color: var(--pri); font-size: 16px; margin: 0 2px; }
.cal-tip { margin-top: 10px; font-size: 12px; color: var(--ink-3); }

/* 批量登记弹窗里的已选日期 */
.batch-sum { font-size: 13.5px; color: var(--ink-2); margin-bottom: 8px; }
.batch-sum b { color: var(--pri); font-size: 16px; }
.batch-sum .warn-text { color: var(--warn); }
.chip-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 132px;
  overflow: auto;
  padding: 9px 10px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 14px;
}
.chip {
  display: inline-flex;
  align-items: baseline;
  gap: 3px;
  padding: 2px 8px;
  border-radius: 6px;
  background: #fff;
  border: 1px solid var(--line);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.chip em { font-style: normal; font-size: 10.5px; color: var(--ink-3); font-weight: 400; }
.chip.has { background: #fff7e6; border-color: #f8d9a0; color: #b45309; }
.chip.off { opacity: .35; text-decoration: line-through; }
.check-line {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink-2);
  padding: 6px 0;
  cursor: pointer;
}
.check-line input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }
.check-line span em { font-style: normal; color: var(--muted); font-size: 12px; }
/* 应收发票：勾选后整行变成提醒色，保存前一眼能看到 */
.check-line.need-inv { gap: 6px; }
.check-line.need-inv > em { font-style: normal; color: var(--ink-4); font-size: 12px; }
.check-line.need-inv:has(input:checked) {
  color: #a75c00;
}
.check-line.need-inv:has(input:checked) > em { color: #b07a2a; }

/* 「不计补贴」整块：勾选后底色变浅，提示本次登记不计金额 */
.subsidy-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #fafbfd;
  transition: background 0.15s, border-color 0.15s;
}
.subsidy-box.on { background: #fff7e6; border-color: #f5d9a8; }
.subsidy-box .check-line { padding: 8px 0; }
.subsidy-box .check-line b { color: var(--ink); }
.subsidy-box .check-line em { font-style: normal; color: var(--muted); font-size: 12px; }
.subsidy-box .field-hint { padding-bottom: 8px; margin-top: -2px; }
.cal-amt.free { color: #b45309; font-weight: 600; }
.badge.free { background: #fff7e6; color: #b45309; border: 1px solid #f5d9a8; }
.settle-sub { font-size: 11px; color: #b45309; font-weight: 500; margin-top: 1px; }
.day-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 0 5px;
  border-radius: 4px;
  font-size: 10.5px;
  line-height: 16px;
  vertical-align: 1px;
}
.day-tag.hol { background: #fff1f0; color: #c0392b; border: 1px solid #fbd5d0; }
.day-tag.adj { background: #fff7e6; color: #b45309; border: 1px solid #f8d9a0; }
.day-tag.wk { background: #eef1f6; color: #64748b; border: 1px solid #dde3ec; }

/* 节假日配置页 */
.hol-month-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  background: #fff;
}
.hol-month-card .hm-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.hol-month-card .hm-head b { font-size: 13.5px; }





/* ==========================================================
   手机端适配
   目标：与电脑端功能完全一致，交互按触屏重做
   - 侧栏改抽屉 + 遮罩
   - 底部标签栏承载常用入口
   - 宽表在窄屏上变成卡片，不再横向拖动
   - 弹窗全屏铺开、按钮加大到手指能点
   ========================================================== */

html { -webkit-text-size-adjust: 100%; }

/* 抽屉遮罩：只在手机断点生效 */
.scrim {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 27, 45, .45);
  z-index: 55;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s;
}
.scrim.show { opacity: 1; pointer-events: auto; }

/* 底部标签栏 */
.tabbar {
  display: none;
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 90;
  background: rgba(255, 255, 255, .97);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -2px 12px rgba(16, 24, 40, .05);
  transition: opacity .18s;
}
.tabbar .tab {
  flex: 1;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  height: 58px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--ink-3);
  font-family: inherit;
  font-size: 10.5px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.tabbar .tab .ti { display: flex; align-items: center; justify-content: center; height: 22px; }
.tabbar .tab .ti .ico { width: 21px; height: 21px; }
.tabbar .tab.on { color: var(--pri); font-weight: 600; }
.tabbar .tab.cta .ti {
  width: 46px; height: 46px;
  margin-top: -18px;
  border-radius: 15px;
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: #fff;
  box-shadow: 0 6px 14px rgba(37, 99, 235, .32);
}
.tabbar .tab.cta .ti .ico { width: 23px; height: 23px; stroke-width: 2.2; }
.tabbar .tab.cta .tl { margin-top: 1px; color: var(--pri); font-weight: 600; }
.tabbar .tb-badge {
  position: absolute;
  top: 6px;
  left: 50%;
  margin-left: 6px;
  min-width: 16px; height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: #d93025;
  color: #fff;
  font-size: 10px;
  line-height: 16px;
  font-weight: 600;
}

/* ---------------- 平板 / 手机：结构层 ---------------- */

@media (max-width: 860px) {
  body.drawer-open { overflow: hidden; }

  .scrim { display: block; }

  .sidebar {
    width: min(80vw, 306px);
    padding-top: env(safe-area-inset-top);
    transform: translateX(-100%);
    transition: transform .22s ease;
    box-shadow: 0 0 40px rgba(0, 0, 0, .35);
    /* 高于底部标签栏(z-index:90)，否则抽屉底部的「退出登录」会被标签栏盖住 */
    z-index: 100;
  }
  .sidebar.open { transform: none; }
  .nav-item { padding: 11px 12px; font-size: 14.5px; }
  /* 底部留白：16px + 安全区，保证「退出登录」不贴屏幕边缘 */
  .side-foot { padding-bottom: calc(16px + env(safe-area-inset-bottom)); }

  /* 抽屉打开时淡出底部标签栏，避免二者叠在一起 */
  body.drawer-open .tabbar { opacity: 0; pointer-events: none; }

  /* 顶栏：贴顶吸顶，标题与操作按钮同行自适应 */
  .topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    padding: 6px 12px;
    gap: 8px;
    flex-wrap: nowrap;
    min-height: 48px;
  }
  .topbar h1 { font-size: 16.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .topbar .crumb { display: none; }
  .topbar .btn { height: 32px; padding: 0 11px; font-size: 13px; }
  .mobile-menu { width: 36px; height: 36px; font-size: 16px; }

  .content { padding: 10px 10px calc(80px + env(safe-area-inset-bottom)); }

  .tabbar { display: flex; }

  /* 统计卡两列，避免一屏只能看两张 */
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat { padding: 10px 11px; }
  .stat .v { font-size: 19px; }
  .stat .k { font-size: 12px; }
  .stat .d { font-size: 11.5px; }

  .card-body { padding: 12px; }
  .card-head { padding: 10px 12px; }
  .card-head h2 { font-size: 15px; }

  .chart-box.h-lg { height: 240px; }
  .chart-box.h-md { height: 220px; }

  .bulk-bar { top: 48px; flex-wrap: wrap; padding: 8px 12px; }
  .bulk-bar .spacer { display: none; }

  .list-foot { flex-wrap: wrap; padding: 8px 10px; }
  .pager { padding: 8px 10px; flex-wrap: wrap; gap: 6px; }
  .pager button { min-width: 34px; height: 34px; }
}

/* 手机：整体行距再压一档，一屏信息量更大 */
@media (max-width: 860px) {
  .card + .card { margin-top: 10px; }
  .form-grid { gap: 10px 12px; }
  .field { margin-bottom: 12px; }
  .field label { margin-bottom: 4px; }
  .field-hint, .field-error { margin-top: 3px; }
  .kv { padding: 3px 0; line-height: 1.45; }
  .check-row { padding: 3px 0; }
  .setting-row { padding: 10px 0; }
  .export-card { padding: 14px; gap: 8px; }
  .export-card .d { line-height: 1.5; }
  .detail-head { padding-bottom: 10px; }
  .detail-grid { margin: 8px 0 2px; gap: 0 16px; }
  .empty { padding: 32px 16px; }
  table.tb th { padding: 8px 10px; }
  table.tb td { padding: 7px 10px; }
}

/* ---------------- 手机：控件与列表 ---------------- */

@media (max-width: 720px) {

  /* 输入框 16px，避免 iOS 聚焦时自动放大页面 */
  .input, .select, .textarea { font-size: 16px; height: 42px; }
  .textarea { height: auto; }
  .btn { height: 38px; font-size: 14px; }
  .btn.sm { height: 32px; font-size: 13px; }

  /* 筛选条改两列网格 */
  .filters {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 10px;
  }
  .filters .f { width: auto !important; min-width: 0; }
  .filters .f:first-child,
  .filters .f.grow { grid-column: 1 / -1; }
  .filters .f:has(.quick-ranges) { grid-column: 1 / -1; }
  .filters .input, .filters .select { width: 100% !important; height: 40px; }
  .filters .f .flex { gap: 6px; }
  .filters .f .flex .input { min-width: 0; flex: 1; }
  .filters .actions { grid-column: 1 / -1; margin-left: 0; }
  .filters .actions .btn { flex: 1; height: 42px; }
  .quick-ranges { flex-wrap: wrap; }
  .quick-ranges button { flex: 1; min-width: 56px; height: 34px; }

  /* ---------- 表格转卡片 ---------- */
  .table-wrap { overflow: visible; }

  table.tb.cards { display: block; font-size: 13px; border-collapse: separate; }
  table.tb.cards thead { display: none; }
  table.tb.cards tbody { display: block; }
  table.tb.cards tr {
    display: block;
    position: relative;
    margin: 6px 0;
    padding: 8px 11px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
  }
  table.tb.cards:not(.no-check) tr { padding-left: 40px; }
  table.tb.cards tbody tr:hover { background: #fff; }
  table.tb.cards tbody tr.selected { background: var(--pri-soft); }
  table.tb.cards td {
    display: block;
    border: 0;
    padding: 0;
    line-height: 1.38;
    vertical-align: top;
  }
  table.tb.cards td::before {
    content: attr(data-label);
    display: inline-block;
    width: 52px;
    flex: none;
    color: var(--ink-3);
    font-size: 12px;
  }
  table.tb.cards td[data-label=""]::before { display: none; }

  /* 勾选列浮到卡片左上 */
  table.tb.cards td.c-check {
    position: absolute;
    left: 11px;
    top: 9px;
    width: auto;
  }
  table.tb.cards td.c-check::before { display: none; }
  table.tb.cards input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--pri); }

  /* 日期：置顶小字 */
  table.tb.cards td[data-label="费用日期"],
  table.tb.cards td[data-label="时间"] {
    font-size: 12px;
    color: var(--ink-3);
    padding-right: 74px;
  }
  table.tb.cards td[data-label="费用日期"]::before,
  table.tb.cards td[data-label="时间"]::before { display: none; }

  /* 状态：右上角徽标 */
  table.tb.cards td[data-label="状态"] {
    position: absolute;
    right: 11px;
    top: 7px;
  }
  table.tb.cards td[data-label="状态"]::before { display: none; }

  /* 事由：卡片主标题 */
  table.tb.cards td[data-label="事由"],
  table.tb.cards td[data-label="项目名称"],
  table.tb.cards td[data-label="登录名"] {
    font-size: 15px;
    font-weight: 600;
    color: var(--ink);
    margin: 0 0 2px;
    line-height: 1.3;
  }
  table.tb.cards td[data-label="事由"]::before,
  table.tb.cards td[data-label="项目名称"]::before,
  table.tb.cards td[data-label="登录名"]::before { display: none; }

  /* 项目 / 类型 / 凭证：自带语义，去掉标签后并成一行灰字 */
  table.tb.cards td[data-label="项目"],
  table.tb.cards td[data-label="类型"],
  table.tb.cards td[data-label="费用类型"],
  table.tb.cards td[data-label="凭证"] {
    display: inline-block;
    margin: 0 8px 0 0;
    font-size: 12.5px;
    color: var(--ink-3);
  }
  table.tb.cards td[data-label="项目"]::before,
  table.tb.cards td[data-label="类型"]::before,
  table.tb.cards td[data-label="费用类型"]::before,
  table.tb.cards td[data-label="凭证"]::before { display: none; }

  /* 卡片里数字列统一左对齐，否则「费用数 1」会挤成一坨 */
  table.tb.cards td.num { text-align: left; }

  /* 金额：卡片主数字 */
  table.tb.cards td[data-label="金额"],
  table.tb.cards td[data-label="累计金额"] {
    font-size: 16.5px;
    font-weight: 700;
    margin-top: 0;
  }
  table.tb.cards td[data-label="金额"]::before,
  table.tb.cards td[data-label="累计金额"]::before { display: none; }

  /* 操作：卡片底部一条按钮，手指好点 */
  table.tb.cards td[data-label="操作"] {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: flex-end;
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px dashed var(--line);
  }
  table.tb.cards td[data-label="操作"]::before { display: none; }
  table.tb.cards .row-actions { opacity: 1; gap: 6px; }
  table.tb.cards .row-actions button {
    min-height: 32px;
    padding: 0 13px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    font-size: 13px;
  }
  table.tb.cards .btn.sm { height: 32px; padding: 0 13px; font-size: 13px; }
  table.tb.cards .thumb { width: 40px; height: 40px; }

  /* 矩阵表保留表格形态，但首列吸左，横向滑动时不丢维度 */
  .matrix-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table.tb.matrix th:first-child,
  table.tb.matrix td:first-child {
    position: sticky;
    left: 0;
    z-index: 2;
    background: #fff;
    box-shadow: 6px 0 8px -8px rgba(16, 24, 40, .3);
  }
  table.tb.matrix thead th:first-child { background: #f8fafc; }

  /* ---------- 弹窗：大弹窗全屏 ---------- */
  .modal-mask { padding: 12px; }
  .modal.w-md, .modal.w-lg, .modal.w-xl {
    max-width: none;
    width: 100%;
    /* 负 margin 抵消遮罩内边距，高度要一并补齐，否则底部会露出 24px 的页面 */
    height: calc(100% + 24px);
    max-height: calc(100% + 24px);
    border-radius: 0;
    margin: -12px;
  }
  .modal-head { padding: calc(10px + env(safe-area-inset-top)) 12px 10px; }
  .modal-head .x { font-size: 26px; padding: 0 8px; }
  .modal-body { padding: 12px; }
  .modal-foot {
    padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
    flex-wrap: wrap;
    gap: 8px;
  }
  .modal-foot .btn { flex: 1 1 calc(50% - 8px); height: 44px; font-size: 15px; }
  .modal-foot .btn.ghost { flex: 0 0 auto; }
  .modal-foot > div[style*="flex:1"] { display: none; }

  .detail-head { flex-wrap: wrap; }
  /* 手机上凭证就是相册：固定两列大图，点开能滑动、放大、保存 */
  .attach-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .attach-item { aspect-ratio: 1 / 1; }
  .attach-item .bar { font-size: 11px; padding: 16px 6px 5px; }
  /* 右上角放大标记：手机没有 hover，常显提示这张能点开看原图 */
  .attach-item .zoom-tip { opacity: 1; }

  /* 触屏没有 hover：操作按钮常显，否则手机上根本删不掉附件 */
  .attach-item .ops { opacity: 1; }
  .attach-item .ops button { width: 24px; height: 24px; }
  /* 有放大标记时，操作按钮让到左边，避免叠在一起 */
  .attach-item:has(.zoom-tip) .ops { right: 28px; }

  /* ---------- 手机端相册查看器 ---------- */
  .lightbox { padding: calc(52px + env(safe-area-inset-top)) 8px calc(8px + env(safe-area-inset-bottom)); }
  /* 有底部缩略图条 + 滑动手势，左右箭头在窄屏上纯属占地方 */
  .lightbox .nav { display: none; }
  .lightbox .lb-stage img { max-height: 100%; }
  .lightbox .caption { font-size: 12px; padding: 8px 0 2px; }
  .lb-info { padding: 7px 11px; font-size: 12px; margin-top: 4px; }
  .lb-i-title { flex-basis: 100%; }
  .lb-i-count { font-size: 11px; margin-top: 2px; }
  .lightbox .close { top: calc(8px + env(safe-area-inset-top)); right: 10px; }
  .lightbox .lb-btn {
    top: calc(8px + env(safe-area-inset-top));
    right: 56px;
    height: 38px;
    line-height: 38px;
    padding: 0 14px;
  }
  .lightbox .lb-btn.del { left: 10px; right: auto; }
  .lb-thumb { width: 48px; height: 48px; }
  /* 缩略图下方状态与文件名挤在一行，标签不许折行，文件名自行省略 */
  .attach-item .bar { gap: 3px; padding: 12px 5px 4px; }
  .attach-item .bar .tag { white-space: nowrap; flex: none; }
  .attach-item .bar > span:last-child { min-width: 0; }

  /* ---------- 记一笔：操作按钮固定在底部 ---------- */
  body.form-page .tabbar { display: none; }
  /* backdrop-filter 会让顶栏成为 fixed 子元素的包含块，底部按钮会跑到屏幕顶部去 */
  body.form-page .topbar { backdrop-filter: none; -webkit-backdrop-filter: none; background: #fff; }
  body.form-page .topbar #topActions {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 95;
    display: flex;
    gap: 8px;
    margin: 0;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
    background: #fff;
    border-top: 1px solid var(--line);
    box-shadow: 0 -4px 16px rgba(16, 24, 40, .08);
  }
  body.form-page .topbar #topActions .btn { flex: 1; height: 46px; font-size: 15px; }
  body.form-page .topbar #topActions .btn.primary { flex: 1.3; }
  body.form-page .content { padding-bottom: calc(86px + env(safe-area-inset-bottom)); }

  /* 裁剪：容器按屏幕高度收缩，工具条可换行 */
  .crop-stage { height: min(58vh, 460px) !important; }
  /* 全屏弹窗里让裁剪区吃掉剩余高度，否则下方留一大片空白 */
  .modal:has(.crop-stage) .modal-body { display: flex; flex-direction: column; }
  .modal:has(.crop-stage) .crop-stage { flex: 1 1 auto; height: auto !important; min-height: 240px; }
  .modal:has(.crop-stage) .crop-tools { flex: none; margin-top: 10px; }
  .crop-tools { flex-wrap: wrap; gap: 6px; }
  .crop-tools .btn { flex: 1 1 auto; min-width: 60px; }

  /* 空状态、提示语 */
  .empty { padding: 30px 16px; }
  .toasts { left: 12px; right: 12px; top: auto; bottom: calc(74px + env(safe-area-inset-bottom)); }
  .toast { width: 100%; }
}

/* 超窄屏（iPhone SE 之类）再压一档 */
@media (max-width: 380px) {
  .stat-grid { grid-template-columns: 1fr; }
  .filters { grid-template-columns: 1fr; }
  .tabbar .tab { font-size: 10px; }
}

/* 费用记录：手机端筛选区收起按钮（桌面端不需要，直接隐藏） */
.filter-fold { display: none; }

/* ---------------- 工作台：本月支出分布 ---------------- */

.dash-row {
  display: grid;
  grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}
.dash-row > .card { margin-top: 0; }

.mini-card { padding: 0; overflow: hidden; }

/* 表头与格子共用同一套 7 列，保证对齐 */
.mini-head,
.mini-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}
.mini-head {
  padding: 0 12px;
  border-bottom: 1px solid var(--line-2);
  background: #fafcff;
}
.mini-head div {
  text-align: center;
  padding: 6px 0;
  font-size: 11.5px;
  color: var(--ink-3);
  font-weight: 600;
}
.mini-head div.we { color: var(--danger); }

/* 行高按固定值给，空格与有数据的格子同高，整块才像一张日历 */
.mini-grid {
  gap: 3px;
  padding: 8px 12px 4px;
  grid-auto-rows: 38px;
}
/* 空格必须占位，否则网格会塌陷；用 .mini-grid 前缀提高优先级，
   否则会被后面的 .mini-cell 基础背景色盖掉 */
.mini-grid .mini-cell.empty { background: transparent; }
.mini-cell {
  position: relative;
  border-radius: 6px;
  background: #f6f8fb;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  font-variant-numeric: tabular-nums;
  min-width: 0;
  overflow: hidden;
}
.mini-cell.empty { background: transparent; }
.mini-cell .mc-d { font-size: 11.5px; color: var(--ink-3); line-height: 1; }
.mini-cell.has { cursor: pointer; transition: transform .1s, box-shadow .1s; }
.mini-cell.has:hover { transform: translateY(-1px); box-shadow: 0 2px 8px rgba(37, 99, 235, .18); }
.mini-cell.has .mc-d { color: #1f4f96; font-weight: 600; }
.mini-cell .mc-a { font-size: 9.5px; line-height: 1; color: #2b5aa8; font-weight: 600; }

/* 四档深浅：越深花得越多 */
.mini-cell[data-lv="0"].has { background: #eef4fe; }
.mini-cell[data-lv="1"].has { background: #d5e5fd; }
.mini-cell[data-lv="2"].has { background: #a9c9f9; }
.mini-cell[data-lv="2"].has .mc-a, .mini-cell[data-lv="2"].has .mc-d { color: #123a72; }
.mini-cell[data-lv="3"].has { background: #5d93ee; }
.mini-cell[data-lv="3"].has .mc-a { color: #fff; }
.mini-cell[data-lv="3"].has .mc-d { color: #eaf2ff; }

.mini-cell.today { outline: 2px solid var(--pri); outline-offset: -2px; }
/* 选中某天：右侧列表同步过滤，格子用深色描边回显 */
.mini-cell.picked {
  outline: 2px solid var(--pri);
  outline-offset: -2px;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .16);
}
.mini-cell.picked .mc-d { font-weight: 700; }

/* 卡片头部的月份切换 */
.month-nav {
  display: flex;
  align-items: center;
  gap: 5px;
}
.month-nav .month-pick {
  width: 128px;
  height: 28px;
  padding: 0 6px;
  font-size: 13px;
}
.month-nav .btn.sm { padding: 0 8px; min-height: 28px; }

/* 右侧列表顶部的小计行 */
.recent-sub {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  font-size: 12.5px;
  color: var(--ink-3);
  border-bottom: 1px solid var(--line);
  background: #fbfcfe;
}
.recent-sub .spacer { flex: 1; }
.recent-sub .money { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }

/* 凭证角标：发票 / 其他 / 无 */
.att-tag {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 11.5px;
  line-height: 1.5;
  white-space: nowrap;
}
.att-tag.invoice { background: #eef4fe; color: #1f4f96; }
.att-tag.other { background: #f3f4f6; color: #64748b; }
.att-tag.none { background: #fdf2f2; color: #b42318; }
/* 待收发票：橙色提醒，区别于普通发票蓝 */
.att-tag.pending { background: #fff5e6; color: #a75c00; margin-left: 6px; }
/* 月历格子里的待收发票小圆点 */
.cal-flag {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #f59e0b;
}

.mini-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px 11px;
  font-size: 12px;
  color: var(--ink-3);
  flex-wrap: wrap;
}
.mini-foot .spacer { flex: 1; }
.mini-foot b { color: var(--ink); font-variant-numeric: tabular-nums; }
.mini-scale { display: inline-flex; gap: 3px; }
.mini-scale i {
  width: 12px; height: 12px;
  border-radius: 3px;
  display: inline-block;
}
.mini-scale i[data-lv="0"] { background: #eef4fe; }
.mini-scale i[data-lv="1"] { background: #d5e5fd; }
.mini-scale i[data-lv="2"] { background: #a9c9f9; }
.mini-scale i[data-lv="3"] { background: #5d93ee; }

@media (max-width: 1100px) {
  .dash-row { grid-template-columns: 1fr; }
  .mini-card { margin-bottom: 14px; }
}

/* 导出中心：实时预览条 */.export-preview {
  padding: 11px 14px;
  border-radius: 9px;
  background: #f7faff;
  border: 1px solid #e3ecfa;
  font-size: 13.5px;
  color: var(--ink-2);
}
.export-preview .cal-sums { margin-left: 0; }
.export-preview-line {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.export-preview-line b { color: var(--ink); font-variant-numeric: tabular-nums; }
.export-preview-line .spacer { flex: 1; }

/* ---------------- 月历 · 触屏适配 ---------------- */

@media (max-width: 720px) {
  /* 筛选区可收起：收起来后月历直接顶到上面 */
  .filter-fold { display: block; margin: -2px 0 8px; }
  .filter-fold .btn { width: 100%; }
  .card.folded .filters { display: none; }
  .card.folded { padding: 0; background: transparent; border: none; box-shadow: none; }

  .cal-bar { padding: 10px 12px; gap: 8px; }
  .cal-title { font-size: 15px; min-width: 80px; margin-left: 2px; }
  .cal-legend { display: none; }
  .cal-person { margin-left: auto; }
  .cal-stat {
    padding: 8px 12px;
    gap: 14px 18px;
  }
  .cal-stat-item b { font-size: 16px; }
  .cal-stat-item span { font-size: 11px; }
  .cal-sums { margin-left: 0; width: 100%; gap: 6px; }
  .cal-sum { font-size: 12px; padding: 2px 9px; }

  .cal-head div { padding: 6px 0; font-size: 11.5px; }
  /* 格子在手机上压缩高度，一屏能看到整月 */
  .cal-grid { grid-auto-rows: minmax(58px, auto); }
  .cal-cell { padding: 3px 4px 4px; gap: 1px; }
  .cal-d { font-size: 12.5px; }
  .cal-cell.is-today .cal-d { min-width: 20px; height: 20px; font-size: 12px; }
  .cal-tag {
    font-size: 9px;
    line-height: 13px;
    padding: 0 3px;
    border-radius: 3px;
    max-width: calc(100% - 6px);
    /* 手机上不显示节日名，只保留左侧色条，靠颜色区分 */
    display: none;
  }
  .cal-cell.is-holiday .cal-top::after {
    content: '';
    width: 5px; height: 5px;
    border-radius: 50%;
    background: #e05a4a;
    margin-left: auto;
  }
  .cal-cell.is-adjust .cal-top::after {
    content: '';
    width: 5px; height: 5px;
    border-radius: 50%;
    background: #e9a029;
    margin-left: auto;
  }
  /* 手机上格子只有 50px 左右，地点名放不下就只留金额（地点在 title 里） */
  .cal-loc { display: none; }
  .cal-amt { font-size: 10.5px; }
  .cal-note {
    font-size: 9.5px;
    line-height: 1.3;
    padding: 0 2px;
    max-width: 100%;
  }
  .cal-settle { font-size: 9.5px; }
  .cal-settle { display: none; }
  .cal-empty { display: none; }
  /* 手机格子太小，漏登记只留淡红底色，不写「待登记」 */
  .cal-cell.miss::after { display: none; }
  .cal-check { width: 14px; height: 14px; line-height: 14px; font-size: 9px; top: 3px; right: 4px; }
  /* 手机上「⋯」是主要的改/删入口，放大到拇指能点 */
  .cal-more { width: 24px; height: 24px; font-size: 15px; border-radius: 6px; }
  .cal-top:has(.cal-more) .cal-check { right: 28px; }
  /* 有「⋯」时右侧的节日/调休小圆点让位，避免两个圆标记挤在一起 */
  .cal-top:has(.cal-more)::after { display: none; }
  /* 费用月历：手机格子只有 50px，金额都要折行，「N 笔」放不下就收进悬浮/明细里，
     只保留左侧绿色竖条表示这天有费用（点进去看笔数） */
  .cal-cnt { display: none; }
  .cal-cell.has-exp .cal-note { display: none; }
  .cal-cell.has-exp .cal-amt { margin-right: 0; }
  .cal-top:has(.cal-cnt) .cal-tag { display: none; }
  /* 触屏没有 hover，「＋」常驻显示，尺寸放大到好点 */
  .cal-add {
    opacity: 1;
    width: 22px;
    height: 22px;
    right: 3px;
    bottom: 3px;
    font-size: 14px;
    background: #f4f7ff;
    border-color: #d5e2ff;
    color: #5570a8;
  }
  /* 手机上「单日最高」的金额会折行，独占一行更清爽 */
  .cal-stat-item.wide { flex-basis: 100%; align-items: baseline; flex-wrap: wrap; gap: 4px 6px; }
  .cal-stat-item.wide b { font-size: 15px; }
  .cal-stat-item.wide span { font-size: 11.5px; }
  .cal-top:has(.cal-cnt) .cal-tag { max-width: calc(100% - 36px); }
  /* 汇总胶囊在手机上一行放不下就往左贴满，不再靠右撑 */
  .cal-sum.peak { flex-basis: 100%; justify-content: center; }

  .cal-tools {
    padding: 9px 12px;
    gap: 8px;
    /* 内容区底部已有 80px 留白（避开底部标签栏），这里不再重复贴在标签栏上 */
    bottom: 0;
  }
  .cal-tool-group { width: 100%; gap: 6px; }
  .cal-tool-group .lbl { display: none; }
  .cal-tool-group .btn { flex: 1 1 auto; padding: 5px 8px; font-size: 12px; }
  .cal-sel-info { font-size: 12.5px; }
  .cal-tools > .btn.primary { flex: 1; height: 42px; font-size: 15px; }
  .cal-tip { font-size: 11.5px; padding: 0 2px; }

  /* 批量弹窗里的日期标签加大，手指好点 */
  .chip { padding: 4px 9px; font-size: 13px; }
  .chip-wrap { max-height: 108px; }
  .check-line { font-size: 13.5px; padding: 8px 0; }
  .day-tag { font-size: 10px; }
}

