/* 移动端样式（仅在 body.m-body 下生效，桌面端完全不受影响）
 * ---------------------------------------------------------------------
 * 设计约束：
 *   1. 不改任何业务逻辑与字段，只调布局；功能对齐由 tests/mobile_parity_check.py 校验。
 *   2. 触控目标 ≥44px，输入框字号 ≥16px（iOS 下小于 16px 会自动放大页面）。
 *   3. 顶栏/底栏固定，内容区留出等量内边距 + 安全区（刘海屏/手势条）。
 */

/* ---------- 外壳 ---------- */
.m-body { padding-top: 48px; padding-bottom: calc(58px + env(safe-area-inset-bottom)); }
.m-body .wrap { margin: 10px auto; padding: 0 10px; max-width: 100%; }

.mtop{
  position: fixed; top: 0; left: 0; right: 0; z-index: 70;
  height: 48px; display: flex; align-items: center; gap: 8px;
  padding: 0 10px calc(0px) 10px;
  padding-top: env(safe-area-inset-top);
  background: var(--blue); color: #fff;
  box-shadow: 0 1px 6px rgba(16,24,40,.18);
}
.mtop-btn{
  width: 40px; height: 40px; flex: 0 0 auto; border: none; background: transparent;
  color: #fff; font-size: 20px; line-height: 1; border-radius: 8px; cursor: pointer;
}
.mtop-btn:active{ background: rgba(255,255,255,.18); }
.mtop-title{ flex: 1 1 auto; min-width: 0; font-size: 15.5px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mtop-user{ flex: 0 0 auto; font-size: 12px; color: #cfe0f0; max-width: 96px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* 抽屉 */
.m-mask{ position: fixed; inset: 0; background: rgba(20,30,45,.45); z-index: 88;
  opacity: 0; pointer-events: none; transition: opacity .18s ease; }
.m-mask.open{ opacity: 1; pointer-events: auto; }
.m-drawer{
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 89;
  width: 78%; max-width: 300px; background: #fff;
  transform: translateX(-100%); transition: transform .2s ease;
  box-shadow: 4px 0 24px rgba(16,24,40,.18);
  display: flex; flex-direction: column; overflow-y: auto;
  padding-bottom: env(safe-area-inset-bottom);
}
.m-drawer.open{ transform: translateX(0); }
.m-drawer-hd{ background: var(--blue); color: #fff; padding: 16px 16px 14px; }
.m-drawer-hd b{ display: block; font-size: 15px; margin-bottom: 4px; }
.m-drawer-hd small{ color: #cfe0f0; font-size: 12px; }
.m-drawer nav{ display: flex; flex-direction: column; padding: 6px 0; }
.m-drawer nav a{
  padding: 13px 18px; font-size: 15px; color: #24303c; border-bottom: 1px solid #f0f3f7;
}
.m-drawer nav a.on{ background: #eaf1f8; color: var(--blue); font-weight: 600; }
.m-drawer nav a:active{ background: #f2f6fa; }
.m-lock{ overflow: hidden; }

/* 底部 tab */
.mtab{
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 70;
  display: flex; background: #fff; border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -1px 8px rgba(16,24,40,.06);
}
.mtab a{
  flex: 1 1 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; min-height: 54px; font-size: 11.5px; color: #7a8794; text-decoration: none;
}
.mtab a i{ font-style: normal; font-size: 17px; line-height: 1; }
.mtab a.on{ color: var(--blue); font-weight: 600; }
.mtab a:active{ background: #f2f6fa; }

/* ---------- 通用表单 ---------- */
.m-body input, .m-body select, .m-body textarea{
  font-size: 16px !important;          /* 小于 16px 时 iOS 会自动放大页面 */
  min-height: 42px;
  width: 100%;
}
.m-body .filters{ display: block; }
.m-body .filters > div{ margin-bottom: 10px; }
.m-body .filters input, .m-body .filters select{ width: 100% !important; }
.m-body .filters .combo{ display: block; }
.m-body .filters .combo .caret{ right: 10px; }
.m-body .filters .btn, .m-body .filters a.btn{ display: block; width: 100%; text-align: center;
  margin-top: 8px; padding: 11px 16px; font-size: 15px; }
.m-body .btn{ min-height: 44px; display: inline-flex; align-items: center;
  justify-content: center; padding: 10px 16px; font-size: 15px; }
.m-body .btn.sm{ min-height: 34px; font-size: 13px; padding: 6px 12px; }

/* 成排按钮：查询/重置 一排，录入/导出 一排（比 4 个通栏按钮省一半高度） */
.m-body .filters .m-btnrow{ display: flex; gap: 8px; margin-top: 8px; }
.m-body .filters .m-btnrow .btn{ display: inline-flex; flex: 1 1 0; width: auto; margin-top: 0; }

/* AI 悬浮球：抬到口底栏之上，避免与底部 tab 重叠 */
.m-body #ai-fab{ bottom: calc(68px + env(safe-area-inset-bottom)); right: 14px;
  width: 48px; height: 48px; font-size: 12px; }
.m-body #ai-panel{ left: 8px; right: 8px; width: auto;
  bottom: calc(124px + env(safe-area-inset-bottom)); height: 58vh; }

/* ---------- 卡片与表格 ---------- */
.m-body .card{ padding: 14px 12px; border-radius: 10px; }
.m-body .card h3{ font-size: 15px; margin-bottom: 10px; }
/* 宽表格：让卡片自己横向滚动，避免整页被撑开导致左右晃 */
.m-body .card{ overflow-x: auto; -webkit-overflow-scrolling: touch; }
.m-body table{ font-size: 13px; }
.m-body th, .m-body td{ padding: 7px 8px; }
.m-body .grid.g4{ grid-template-columns: 1fr 1fr; gap: 10px; }
.m-body .grid.g2{ grid-template-columns: 1fr; gap: 10px; }
.m-body .kpi .val{ font-size: 19px; }
.m-body .right{ float: none; }

/* ---------- 交易列表卡片（m/tx_table_partial.html 使用） ---------- */
.m-list{ display: flex; flex-direction: column; gap: 8px; }
.m-row{
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: #fff;
}
.m-row-hd{ display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px; }
.m-row-hd .p{ flex: 1 1 auto; min-width: 0; font-size: 15px; font-weight: 600; color: #15233a;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m-row-hd .amt{ flex: 0 0 auto; font-size: 15px; font-weight: 700; color: var(--green); }
.m-row-sub{ font-size: 12.5px; color: #6b7a8b; line-height: 1.7; display: flex; flex-wrap: wrap; gap: 0 10px; }
.m-row-sub b{ color: #41536b; font-weight: 600; }
.m-row-ft{ margin-top: 8px; display: flex; align-items: center; gap: 8px; }
.m-row-ft .m-date{ font-size: 12px; color: #8a97a6; }
.m-row-ft .m-ops{ margin-left: auto; display: flex; gap: 6px; }
.m-tag{ display: inline-block; padding: 1px 7px; border-radius: 20px; font-size: 11.5px;
  background: #eef3f8; color: var(--blue); }
.m-sum{ font-size: 12.5px; color: #51606f; line-height: 1.8; margin-bottom: 10px; }

/* ---------- 录入弹窗：手机上全屏 ---------- */
.m-body #tx-add-modal{ padding: 0 !important; }
.m-body #tx-add-modal > div{
  max-width: 100% !important; border-radius: 0 !important;
  min-height: 100vh; box-shadow: none !important;
}
.m-body #tx-add-modal > div > div:first-child{ border-radius: 0 !important; padding: 12px 14px; }
.m-body .m-grid2{ grid-template-columns: 1fr !important; gap: 10px !important; }
.m-body .m-span2{ grid-column: span 1 !important; }
.m-body #tx-entry-body, .m-body #tx-review-body{ padding: 12px 12px 90px !important; }
/* 录入/审阅的主按钮贴底，拇指直接够到 */
.m-body #tx-entry-body > div:last-child,
.m-body #tx-review-body > div:last-child{
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 85;
  margin: 0 !important; padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: #fff; border-top: 1px solid var(--line); gap: 8px !important;
}
.m-body #tx-entry-body > div:last-child .btn,
.m-body #tx-review-body > div:last-child .btn{ flex: 1 1 0; }
/* 审阅表格在手机上改为横向滚动，不压缩列宽 */
.m-body #rev-table{ min-width: 720px; }

/* ---------- 分页 ---------- */
.m-body .pager{ flex-wrap: wrap; }
.m-body .pager a, .m-body .pager span{ padding: 8px 14px; font-size: 14px; }

/* ---------- 触屏不要 hover 残留 ---------- */
@media (hover: none){
  .m-body tr:hover td{ background: inherit; }
  .m-body .btn:hover{ background: var(--blue); }
  .m-body .btn.green:hover{ background: var(--green); }
  .m-body .sup-chip:hover{ background: #f7fafe; border-color: #d4e2f3; }
}

/* ---------- 底部弹层选择器（static/picker.js） ----------
 * 替代 iOS 上不可靠的 datalist：点字段弹出可从底部滚动的选项列表，
 * 带搜索框与「手动输入」出口。只在 body.m-body 下生效。 */
.m-body #tx-add-modal input.has-picker{
  padding-right: 34px !important;
  background-image: linear-gradient(45deg, transparent 50%, #7a8794 50%),
                    linear-gradient(135deg, #7a8794 50%, transparent 50%);
  background-position: calc(100% - 19px) 52%, calc(100% - 13px) 52%;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  cursor: pointer;
}
.mp-mask{
  position: fixed; inset: 0; z-index: 200; display: none;
  background: rgba(20,30,45,.45);
  align-items: flex-end; justify-content: center;
}
.mp-mask.open{ display: flex; }
.mp-sheet{
  width: 100%; max-height: 76vh; background: #fff;
  border-radius: 14px 14px 0 0; display: flex; flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -8px 28px rgba(16,24,40,.2);
  animation: mp-up .18s ease;
}
@keyframes mp-up{ from{ transform: translateY(14px); opacity:.7 } to{ transform: none; opacity:1 } }
.mp-hd{ display: flex; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.mp-hd b{ flex: 1 1 auto; font-size: 15px; color: #1f3a5f; }
.mp-x{ border: none; background: none; font-size: 24px; line-height: 1; color: #8a97a6; padding: 0 6px; }
.mp-search{ padding: 10px 12px; border-bottom: 1px solid #f0f3f7; }
.mp-search input{
  width: 100%; border: 1px solid var(--line); border-radius: 8px;
  padding: 9px 11px; font-size: 16px; background: #f8fafc;
}
.mp-list{ flex: 1 1 auto; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 4px 0; }
.mp-list button{
  display: block; width: 100%; text-align: left; border: none; background: #fff;
  padding: 14px 16px; font-size: 16px; color: #24303c; border-bottom: 1px solid #f4f6f9;
}
.mp-list button:active{ background: #eef4fb; }
.mp-list button.on{ color: var(--blue); font-weight: 600; background: #f2f7fc; }
.mp-list button.on::after{ content: "当前"; float: right; font-size: 12px; color: #8a97a6; font-weight: 400; }
.mp-empty{ padding: 22px 16px; color: #8a97a6; font-size: 13.5px; line-height: 1.7; }
.mp-ft{ display: flex; gap: 10px; padding: 10px 12px; border-top: 1px solid var(--line); }
.mp-ft button{
  flex: 1 1 0; min-height: 44px; border-radius: 8px; font-size: 15px;
  border: 1px solid var(--line); background: #fff; color: #41536b;
}
.mp-ft .mp-manual{ border-color: var(--blue2); color: var(--blue2); }
