/* =========================================================================
   手机 / 平板 适配（2026-10-18）
   -------------------------------------------------------------------------
   断点：
     ≥1024px       桌面 —— 本文件全部规则都不生效（原样不动）
     768 ~ 1023    平板 —— 侧栏收成 72px 图标栏；点左上按钮滑出完整抽屉
     < 768         手机 —— 侧栏变抽屉 + 底部 5 个主入口；弹窗变底部抽屉
   原则：
     · 只写「窄屏覆盖」，不改桌面既有观感；
     · 触摸优先：点击区域 ≥40px、去掉依赖 hover 的交互、输入框 16px（防 iOS 自动缩放）；
     · 一屏信息先保「看得清、点得到」，次要信息降级而不是堆叠。
   ========================================================================= */

/* ---------------- 小屏抽屉的遮罩 ---------------- */
.sidebar-scrim {
  position: fixed; inset: 0; z-index: 65;
  background: rgba(0, 0, 0, .5);
  opacity: 0; pointer-events: none; transition: opacity .2s ease;
}
body.drawer-open .sidebar-scrim { opacity: 1; pointer-events: auto; }

/* ---------------- 手机底部导航（默认不显示） ---------------- */
.mobile-tabs { display: none; }

/* 看板筛选摘要条（含导出图标）只在手机上出现 */
.bd-fsum { display: none; }

/* =========================================================================
   一、平板（768 ~ 1023）：侧栏收成图标栏
   ========================================================================= */
@media (min-width: 768px) and (max-width: 1023px) {
  /* ⚠️ style.css 里有一条 `@media (max-width:860px){ .sidebar{display:none} }`（老版窄屏处理），
     平板 768~860 也会命中 —— 必须显式恢复，否则整条图标栏消失。 */
  .sidebar { display: flex; width: 74px; padding: calc(18px + var(--safe-top)) 10px 14px; }
  .brand { padding: 0 0 14px; justify-content: center; }
  .brand-text, .nav-label, .nav-badge, .nav-caret, .nav-sub, .sidebar-foot { display: none !important; }
  .nav-group {
    height: 1px; padding: 0; margin: 12px 8px;
    font-size: 0; color: transparent; background: var(--line-soft); overflow: hidden;
  }
  .nav-item, .nav-fold-head { justify-content: center; padding: 12px 0; }
  .nav-item .nav-ic { margin: 0; }

  /* 点左上按钮 → 覆盖式完整导航（宽度和桌面一致，读完即走） */
  body.drawer-open .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 70;
    width: 258px; padding: calc(20px + var(--safe-top)) 12px 16px;
    border-right: 1px solid var(--line);
    box-shadow: 20px 0 60px rgba(0, 0, 0, .45);
    overflow-y: auto;
  }
  body.drawer-open .brand { padding: 0 10px 20px; justify-content: flex-start; }
  body.drawer-open .brand-text,
  body.drawer-open .nav-badge,
  body.drawer-open .nav-caret,
  body.drawer-open .sidefoot,
  body.drawer-open .sidebar-foot { display: revert !important; }
  body.drawer-open .nav-label { display: inline !important; }
  body.drawer-open .nav-sub { display: flex !important; flex-direction: column; }
  body.drawer-open .nav-group {
    height: auto; padding: 18px 12px 7px; margin: 0;
    font-size: 11px; color: var(--text3); background: none; overflow: visible;
  }
  body.drawer-open .nav-item,
  body.drawer-open .nav-fold-head { justify-content: flex-start; padding: 9px 12px; }

  /* 内容区：左右留白收紧一档，其余交给页面自己的响应式 */
  .main { padding: var(--safe-top) 20px 0; }
  .topbar { height: 68px; }
  .topbar h1 { font-size: 19px; }
  .page { padding-top: 16px; }

  /* 卡片按 3 列，正好一行放下 */
  .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
  .ccx-hint { display: none; }
  .ccx-head { gap: 8px; }

  /* 弹窗留出左右余量，不要贴边 */
  .modal { width: min(600px, calc(100vw - 64px)) !important; }
  .modal.pt-wide { width: min(720px, calc(100vw - 48px)) !important; }
}

/* =========================================================================
   二、手机（< 768）：抽屉导航 + 底部主入口
   ========================================================================= */
@media (max-width: 767px) {
  /* ---- 外壳：浏览器地址栏收放时不要跳动 ---- */
  .app, .main { height: 100vh; height: 100dvh; }
  html, body { overflow-x: hidden; }
  .main { padding: var(--safe-top) 14px 0; }

  /* ---- 侧栏 = 左滑抽屉 ---- */
  .sidebar {
    display: flex;                                 /* 同上：覆盖 style.css 的老规则 */
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 70;
    width: min(284px, 84vw); height: 100dvh; overflow-y: auto;
    padding: calc(18px + var(--safe-top)) 12px calc(16px + env(safe-area-inset-bottom));
    background: var(--bg); border-right: 1px solid var(--line);
    transform: translateX(-102%);
    transition: transform .26s cubic-bezier(.32, .72, 0, 1);
    box-shadow: 24px 0 70px rgba(0, 0, 0, .5);
  }
  body.drawer-open .sidebar { transform: none; }
  body.drawer-open { overflow: hidden; }
  .nav-item { padding: 11px 12px; min-height: 44px; }

  /* ---- 顶栏：菜单 + 标题 + 主题 / 刷新 / 账号 ----
     ⚠️ 头像（#btn-account）是手机端进账号面板、退出登录的唯一入口，不能隐藏。 */
  .topbar { height: 58px; gap: 8px; }
  .topbar .eyebrow { display: none; }
  .topbar h1,
  .topbar.hero-mode #page-title { font-size: 17px; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .topbar.hero-mode #page-eyebrow { display: none; }
  .tb-date, .tb-sep { display: none; }
  .topbar-left { gap: 8px; min-width: 0; }
  .icon-btn { width: 36px; height: 36px; border-radius: 10px; }
  .avatar { width: 36px; height: 36px; border-radius: 10px; display: inline-flex; }
  .top-actions { gap: 6px; }
  .title-sub { display: block; margin: 2px 0 0; font-size: 11px; }

  /* ---- 页面：底部给导航条留位 ---- */
  .page { padding-top: 12px; }
  .page.active { padding-bottom: calc(80px + env(safe-area-inset-bottom)); }

  /* ---- 底部导航 ---- */
  .mobile-tabs {
    display: grid; grid-template-columns: repeat(5, 1fr);
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    background: var(--card);
    background: color-mix(in srgb, var(--card) 92%, transparent);
    -webkit-backdrop-filter: blur(16px) saturate(1.3);
    backdrop-filter: blur(16px) saturate(1.3);
    border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .mtab {
    position: relative; height: 56px; border: 0; background: none;
    color: var(--text3); font-size: 10.5px; letter-spacing: .2px;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    transition: color .15s;
    -webkit-tap-highlight-color: transparent;
  }
  .mtab svg { width: 21px; height: 21px; }
  .mtab.active { color: var(--blue); }
  .mtab.active::before {
    content: ''; position: absolute; top: 0; left: 50%; width: 22px; height: 2px;
    margin-left: -11px; border-radius: 0 0 2px 2px; background: var(--blue);
  }
  .mtab:active { background: color-mix(in srgb, var(--text2) 10%, transparent); }
  .mtab-dot {
    position: absolute; top: 7px; left: 50%; margin-left: 6px;
    width: 5px; height: 5px; border-radius: 50%; background: var(--red); display: none;
  }
  .mtab-dot.on { display: block; }

  /* ---- 卡片 / 列表 ---- */
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
  .kpi { padding: 12px; gap: 10px; border-radius: 12px; }
  .kpi-ic { width: 32px; height: 32px; border-radius: 8px; }
  .kpi-value { font-size: 21px; }
  .kpi-note { font-size: 11px; }
  .panel { border-radius: 12px; }
  .panel-head { padding: 13px 14px 10px; }
  .panel-head h3 { font-size: 14px; }

  /* ---- 触摸目标：按钮统一到 38px 高，图标按钮 40px ---- */
  .btn { padding: 8px 12px; min-height: 36px; }
  .icon-btn, .pay-colset-btn { min-height: 36px; }

  /* ---- 输入框 16px：iOS 聚焦时不会自动放大页面 ---- */
  input, select, textarea { font-size: 16px; }
  .pay-search input, .pt-search input { font-size: 16px; }

  /* ---- 弹窗 = 底部抽屉（拇指够得着，长表单也能滚） ---- */
  .modal-backdrop { align-items: flex-end; padding: 0; }
  .modal,
  .modal.pt-wide, .modal.pt-mid, .modal.pt-small {
    width: 100% !important; max-width: 100%;
    max-height: 90vh; max-height: 90dvh;
    border-radius: 18px 18px 0 0; border-bottom: 0;
    animation: sheetIn .26s cubic-bezier(.32, .72, 0, 1);
  }
  @keyframes sheetIn { from { opacity: .6; transform: translateY(24px); } to { opacity: 1; transform: none; } }
  .modal-head { position: sticky; top: 0; z-index: 2; background: var(--card); padding: 20px 16px 8px; }
  .modal-head::before {
    content: ''; position: absolute; top: 8px; left: 50%; width: 38px; height: 4px;
    margin-left: -19px; border-radius: 2px; background: var(--line);
  }
  .modal-head h3 { font-size: 15.5px; }
  .modal-body { padding: 10px 16px calc(20px + env(safe-area-inset-bottom)); }
  .modal-body .form-actions { position: sticky; bottom: 0; background: var(--card); padding: 10px 0 2px; }
  .field-row { grid-template-columns: 1fr; gap: 0; }
  .detail-row { align-items: flex-start; }
  .detail-row .dk { width: 78px; }

  /* ---- Toast：贴底，不挤占顶栏 ---- */
  .toast-wrap {
    position: fixed; left: 12px; right: 12px;
    bottom: calc(70px + env(safe-area-inset-bottom));
    max-width: none; flex-direction: column; align-items: stretch; z-index: 80;
  }
  .toast { width: 100%; justify-content: flex-start; padding: 11px 14px; font-size: 13px; }

  /* ---- 备份提醒 ---- */
  .backup-tip { border-radius: 12px; margin: 10px 0 0; }

  /* ---- 合同卡条 & 筛选行 ---- */
  .ccx-block { margin-bottom: 12px; }
  .ccx-head { row-gap: 8px; }
  .ccx-title { font-size: 14px; }
  .ccx-tools { flex: 1 1 100%; gap: 6px; flex-wrap: nowrap; }
  /* 手机工具条：只留图标（文字在 title / aria-label 里），挤成等宽方形按钮 */
  .ccx-tools .btn { flex: 1 1 0; justify-content: center; padding: 0 8px; gap: 0; }
  .pay-search { order: 6; flex: 1 1 100%; width: 100%; height: 38px; border-radius: 12px; }
  .ccx { width: 212px; min-height: 116px; }
  .ccx-sbar { display: none; }                 /* 手机上直接手指滑，不需要自绘条 */
  .pay-tabsrow { gap: 8px; }
  .pay-filters { gap: 6px; justify-content: flex-start; }
  .pay-fdiv { flex: 0 0 auto; }

  /* ---- 付款表格：横向滑动查看，表头与首列保持可见 ---- */
  /* 只改排列方式，滚动容器仍交给 .page.active（原来写成 overflow:visible 会让长列表无法滚动） */
  #page-payments.active { display: block; overflow-y: auto; padding-bottom: calc(80px + env(safe-area-inset-bottom)); }
  #page-payments .pay-tablewrap { max-height: 62vh; max-height: 62dvh; min-height: 0; -webkit-overflow-scrolling: touch; }
  .pay-table { font-size: 12.5px; }
  .pay-table thead th { padding: 9px 10px; font-size: 12px; }
  .pay-table tbody td { padding: 8px 10px; }
  .pay-bulkbar { padding: 8px 10px; gap: 6px; }

  /* ---- 合同看板 ---- */
  .bd-head { flex-direction: column; align-items: flex-start; gap: 10px; }
  .bd-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .bd-kpi { padding: 11px 12px; }
  .bd-kpi-val { font-size: 20px; }
  .bd-panel { padding: 12px 12px 10px; border-radius: 12px; }
  .bd-filters { gap: 6px; }

  /* ---- 个人待办：整页跟着页面滚，别锁死高度 ---- */
  .pt-module { height: auto; min-height: 0; }
  .pt-work { flex-direction: column; }
  .pt-listcol { overflow: visible; padding-right: 0; }
  .pt-right { width: 100% !important; max-width: none; margin-top: 10px; }
  .pt-hw { flex-direction: column; }
  .pt-lcols { flex-direction: column; }

  /* ---- 系统设置 ---- */
  .set-card { padding: 14px; border-radius: 12px; }
  .set-head h3 { font-size: 14px; }

  /* ---- 驾驶舱：内容按块堆叠，不要强行撑满一屏 ---- */
  #page-cockpit.active { display: block; }
  #page-cockpit .content-grid { display: block; min-height: 0; }
  #page-cockpit .content-grid > .panel .todo-scroll { max-height: none; }
  /* 列表上方的分段切换（全部/系统/个人）会挤成竖排 —— 锁单行并可横向滑 */
  .tabs { flex: none; max-width: 100%; overflow-x: auto; }
  .tabs button { white-space: nowrap; padding: 5px 9px; }

  /* ---- 个人待办：顶部工具条放不下 → 分两行（胶囊 + 操作 / 搜索整行） ---- */
  .pt-topbar { height: auto; flex-wrap: wrap; gap: 8px; padding: 2px 0 4px; }
  .pt-pills { flex: 1 1 auto; min-width: 0; overflow-x: auto; scrollbar-width: none; }
  .pt-pills::-webkit-scrollbar { display: none; }
  .pt-pill { flex: none; height: 32px; }
  .pt-search { flex: 1 1 100%; width: 100%; order: 5; height: 38px; border-radius: 12px; }
  .pt-actions { flex: none; }
  /* 问候条：日期/时间胶囊移到下一行，标题不再被挤成竖排 */
  .pt-hg { height: auto; padding: 12px 13px; align-items: flex-start; gap: 10px; border-radius: 12px; }
  .pt-hg-row { flex-wrap: wrap; gap: 6px 10px; }
  .pt-hg-hello { font-size: 18px; white-space: nowrap; }
  .pt-hg-pills { margin-left: 0; width: 100%; gap: 6px; flex-wrap: wrap; }
  .pt-hg-pill { height: 26px; padding: 0 9px; font-size: 12px; }
  .pt-hg-sub { margin-top: 6px; white-space: normal; line-height: 1.5; }
  .pt-hm { gap: 8px; }
  .pt-lcols, .pt-hw { gap: 8px; }

  /* ---- 合同看板：筛选条重排成「胶囊 + 6×2 月份格 + 整行下拉」 ---- */
  .bd-filters { padding: 10px; gap: 8px; border-radius: 12px; flex-direction: column; align-items: stretch; }
  .bd-fsum { display: flex; align-items: center; gap: 8px; }
  .bd-fsum-t {
    flex: 1; min-width: 0; font-size: 12px; color: var(--text2);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .bd-fsum-btn {
    flex: none; height: 30px; padding: 0 10px; border-radius: 8px;
    border: 1px solid var(--line); background: var(--card2); color: var(--text2);
    font-size: 12px; display: inline-flex; align-items: center; gap: 4px;
  }
  .bd-fsum-btn svg { transition: transform .2s; }
  .bd-filters:not(.collapsed) .bd-fsum-btn svg { transform: rotate(180deg); }
  .bd-filters.collapsed { padding: 9px 10px; }
  .bd-filters.collapsed .bd-frow { display: none; }
  /* 展开后底部已经有「导出图片」了，摘要条里那个图标就不再重复出现 */
  .bd-filters:not(.collapsed) .bd-fsum .bd-export-btn { display: none; }
  .bd-frow { gap: 8px; }
  .bd-flabel-gap { margin-left: 0; }
  .bd-chips { flex-wrap: wrap; gap: 5px; }
  .bd-quick { flex: 1 1 100%; }
  .bd-qbtn { flex: 1 1 0; height: 30px; }
  .bd-mgrid { flex: 1 1 100%; display: grid; grid-template-columns: repeat(6, 1fr); gap: 5px; }
  .bd-mchip { width: auto; height: 30px; }
  .bd-f { flex: 1 1 100%; }
  .bd-f select, .bd-f input[type="date"] { flex: 1; width: 100%; min-width: 0; height: 34px; }
  .bd-f-date { flex-wrap: wrap; }
  .bd-reset { margin-left: 0; flex: 1 1 100%; height: 34px; }
  .bd-svg-h { max-height: none; }

  /* ---- 合同支付：手机上不要再冻结右侧三列（否则可视区被吃掉一半） ---- */
  .pay-table .pay-frz { position: static; box-shadow: none; }
  .pay-table.has-frz .pay-frz { position: static; }
  .ccx-tools { flex-wrap: wrap; }
  .pay-filters { justify-content: flex-start; }

  /* ---- 系统设置：单列（.set-wrap 是 flex，必须显式换列，否则卡片并排） ---- */
  .set-wrap { flex-direction: column; gap: 0; }
  .set-wrap > .set-card, .set-wrap > .set-col { width: 100%; }
  #page-settings .page-head { display: none; }   /* 顶栏已经有标题，别重复 */

  /* ---- 付款计划：手机卡片列表（替代只能露出两列的表格） ---- */
  .pm-bar { display: flex; align-items: center; gap: 8px; margin: 2px 0 8px; }
  .pm-count { font-size: 12px; color: var(--text3); white-space: nowrap; flex: none; }
  .pm-sort { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text2); white-space: nowrap; flex: none; }
  .pm-sort select {
    height: 34px; padding: 0 8px; font-size: 13px; max-width: 150px;
    background: var(--card2); border: 1px solid var(--line); border-radius: 9px; color: var(--text);
    -webkit-appearance: none; appearance: none;
  }
  .pm-dir {
    width: 34px; height: 34px; flex: none; border-radius: 9px;
    border: 1px solid var(--line); background: var(--card2); color: var(--text2); font-size: 14px;
  }
  .pm-dir:disabled { opacity: .4; }
  .pay-mlist { display: flex; flex-direction: column; gap: 8px; }

  /* ---- 设置页：吸顶分节标题 ---- */
  .set-sec-h {
    position: sticky; top: 0; z-index: 6;
    margin: 2px 0 8px; padding: 10px 4px 8px;
    font-size: 12.5px; font-weight: 700; color: var(--text2); letter-spacing: .4px;
    background: color-mix(in srgb, var(--bg, #14161a) 94%, transparent);
    -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
  }

  /* ---- 合同看板：手机筛选抽屉 ---- */
  body.bd-sheet-open { overflow: hidden; }
  .bd-sheet-mask { display: none; }
  .bd-filters.open .bd-sheet-mask {
    display: block; position: fixed; inset: 0; z-index: 88;
    background: rgba(0, 0, 0, .45);
  }
  .bd-sheet {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 89;
    max-height: 80vh; overflow: auto; -webkit-overflow-scrolling: touch;
    background: var(--card); border-radius: 18px 18px 0 0;
    border-top: 1px solid var(--line);
    padding: 0 14px calc(18px + env(safe-area-inset-bottom));
    box-shadow: 0 -14px 40px rgba(0, 0, 0, .45);
    transform: translateY(105%); transition: transform .24s ease;
  }
  .bd-filters.open .bd-sheet { transform: none; }
  .bd-sheet-h {
    position: sticky; top: 0; z-index: 1;
    display: flex; align-items: center; justify-content: space-between;
    padding: 13px 0 10px; margin-bottom: 4px;
    background: var(--card); border-bottom: 1px solid var(--line);
    font-size: 15px;
  }
  .bd-sheet-done {
    height: 32px; padding: 0 14px; border-radius: 9px; border: 0;
    background: var(--blue); color: #fff; font-size: 13px; font-weight: 600;
  }
  .bd-sheet .bd-frow { display: block; padding: 10px 0; border-top: 1px solid var(--line); }
  .bd-sheet .bd-frow:first-of-type { border-top: 0; }
  .bd-sheet .bd-fgrid, .bd-sheet .bd-f { width: 100%; }
  .bd-sheet .bd-f select, .bd-sheet .bd-f input[type="date"] { width: 100%; flex: 1; }
  .bd-sheet .bd-mgrid { flex-basis: 100%; }
  .pm-item {
    display: flex; gap: 10px; align-items: flex-start;
    padding: 11px 12px; background: var(--card);
    border: 1px solid var(--line); border-radius: 12px;
    transition: border-color .15s, background .15s;
    -webkit-tap-highlight-color: transparent;
  }
  .pm-item:active { background: var(--hover); }
  .pm-item.chk { border-color: var(--blue); background: color-mix(in srgb, var(--blue) 9%, var(--card)); }
  .pm-chk { flex: none; padding-top: 2px; }
  .pm-chk input { width: 18px; height: 18px; }
  .pm-body { flex: 1; min-width: 0; }
  .pm-r1 { display: flex; align-items: baseline; gap: 8px; }
  .pm-no {
    font-size: 11.5px; color: var(--text3); letter-spacing: .2px;
    font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .pm-amt { margin-left: auto; flex: none; font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; }
  .pm-amt.money-due { color: var(--red); }
  .pm-name {
    margin-top: 4px; font-size: 13px; color: var(--text); line-height: 1.45;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  }
  .pm-r2 { margin-top: 7px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 11.5px; color: var(--text3); }
  .pm-r2 .pay-badge { margin-left: auto; }
  .pm-sep { color: var(--line); }
  .pm-go { flex: none; align-self: center; color: var(--text3); display: inline-flex; }

  /* ---- 一卡一合同：合同头 + 节点列表 ---- */
  .pm-card {
    background: var(--card); border: 1px solid var(--line); border-radius: 13px; overflow: hidden;
  }
  .pm-card.allchk { border-color: var(--blue); }
  .pm-card-h {
    display: flex; align-items: flex-start; gap: 9px; padding: 10px 11px 9px;
    background: linear-gradient(180deg, color-mix(in srgb, var(--card2) 70%, transparent), transparent);
    -webkit-tap-highlight-color: transparent;
  }
  .pm-card-h:active { background: var(--hover); }
  .pm-card-t { flex: 1; min-width: 0; }
  .pm-card-no {
    font-size: 11px; color: var(--text3); letter-spacing: .2px;
    font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .pm-card-name {
    margin-top: 3px; font-size: 13px; font-weight: 600; color: var(--text); line-height: 1.4;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  }
  .pm-card-meta { margin-top: 5px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px; font-size: 11px; color: var(--text3); }
  .pm-card-meta .pm-over { color: var(--red); }
  .pm-card-r { flex: none; text-align: right; min-width: 98px; }
  .pm-card-amt { font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; }
  .pm-card-paid { margin-top: 2px; font-size: 10.5px; color: var(--text3); }
  .pm-card-bar { margin-top: 5px; height: 3px; border-radius: 2px; background: var(--line); overflow: hidden; }
  .pm-card-bar > i { display: block; height: 100%; background: var(--green); border-radius: 2px; }
  .pm-caret {
    flex: none; align-self: center; color: var(--text3); display: inline-flex;
    transition: transform .18s;
  }
  .pm-card.collapsed .pm-caret { transform: rotate(-90deg); }
  .pm-card.collapsed .pm-nodes { display: none; }
  /* 卡片里的节点行：去掉外框，用分隔线排队 */
  .pm-nodes { border-top: 1px solid var(--line); }
  .pm-card .pm-item {
    border: 0; border-radius: 0; background: transparent;
    padding: 8px 11px; gap: 8px; align-items: center;
  }
  .pm-card .pm-item + .pm-item { border-top: 1px dashed var(--line); }
  .pm-card .pm-item .pm-amt { font-size: 14px; }
  .pm-card .pm-item .pm-name { margin-top: 2px; font-size: 12.5px; -webkit-line-clamp: 1; }
  .pm-card .pm-item .pm-r2 { margin-top: 4px; }
  .pm-card .pm-item .pm-go { display: none; }
  .pm-card .pm-item .pm-no { display: none; }
  /* 节点行改成「名称 + 金额」同一行，下面一行放日期/比例/状态 */
  .pm-card .pm-item .pm-body { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 8px; }
  .pm-card .pm-item .pm-name { grid-column: 1; grid-row: 1; margin-top: 0; align-self: center; }
  .pm-card .pm-item .pm-r1 { grid-column: 2; grid-row: 1; }
  .pm-card .pm-item .pm-r2 { grid-column: 1 / -1; grid-row: 2; }
}

/* =========================================================================
   三、手机横屏 / 很矮的窗口：再收紧一档
   ========================================================================= */
@media (max-width: 900px) and (max-height: 520px) {
  .topbar { height: 50px; }
  .page { padding-top: 8px; }
  .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .kpi { padding: 9px 10px; }
  .kpi-value { font-size: 18px; }
  .mobile-tabs .mtab { height: 48px; }
  .mtab svg { width: 19px; height: 19px; }
  .page.active { padding-bottom: calc(66px + env(safe-area-inset-bottom)); }
}

/* =========================================================================
   四、其它零碎修正
   ========================================================================= */
/* 设置页的文件夹结构图：长行在手机里会顶出卡片，允许在任意位置折行 */
.set-struct { overflow-wrap: anywhere; word-break: break-word; }

/* 手机/平板：备份提醒的「立即导出」按钮不要被挤成两行 */
@media (max-width: 767px) {
  .backup-tip .bt-go { white-space: nowrap; }
  .backup-tip { flex-wrap: wrap; row-gap: 6px; }
}

/* 手机：待办行右侧的「到期/等级/日期」（桌面靠 hover 才显示）在触屏上既不显示又白占宽度，
   直接隐藏，把宽度让给标题；标题与说明各放宽到 2 行。 */
@media (max-width: 767px) {
  .todo-row { padding: 10px 8px; gap: 9px; }
  .todo-row .todo-side { display: none; }
  /* 标签与标题用「行内流」排：标题接在标签后面自然折行，不会因为宽度不够把标签单独挤成一行 */
  .todo-line1 { display: block; }
  .todo-line1 .chip { display: inline-block; vertical-align: 1px; margin-right: 6px; }
  .todo-title { display: inline; white-space: normal; }
  /* 系统待办的标题是合同全名，换行会把行高顶到 100px+ —— 手机上单行省略，
     完整合同号 + 节点名在第二行，说明文字让位给「详情」。 */
  .sw-wrap[data-kind="system"] .todo-line1 { display: flex; align-items: center; gap: 6px; }
  .sw-wrap[data-kind="system"] .todo-title {
    display: block; flex: 1 1 auto; min-width: 0;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .sw-wrap[data-kind="system"] .todo-desc { display: none; }
  .sw-wrap[data-kind="system"] .todo-sub { margin-top: 2px; font-size: 11.5px; }
  .todo-line2 { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
}

/* ============================================================================
   手机端弹窗：全屏面板 + 单列表单 + 粘底按钮（2026-10-18）
   原问题：沿用桌面「两列表单 + 88px 标签列」，390px 宽下每列只剩 ~70px，
   日期/时间控件被截成 "9:"、"可"；弹窗上下留空、正文挤在中间。
   ============================================================================ */
@media (max-width: 767px) {
  #modal { padding: 0; align-items: stretch; }

  #modal-box {
    width: 100%; max-width: 100%;
    height: 100dvh; max-height: 100dvh;
    border-radius: 0; border: 0;
    display: flex; flex-direction: column;
    overflow: hidden;
    animation: none;
  }

  /* 头部：固定在顶上，说明最多两行 */
  #modal-box > .pt-dialog-head,
  #modal-box > .modal-head {
    flex: none; align-items: center;
    padding: 14px 16px 10px;
    border-bottom: 1px solid var(--line);
    background: var(--card);
  }
  #modal-box > .modal-head h3 { font-size: 16px; }
  #modal-box > .pt-dialog-head .tt { font-size: 16px; }
  #modal-box > .pt-dialog-head .st {
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden; white-space: normal; font-size: 11.5px; line-height: 1.5; margin-top: 3px;
  }
  #modal-box > .pt-dialog-head .badge { width: 30px; height: 30px; }
  #modal-box .modal-x { width: 36px; height: 36px; flex: none; }

  /* 正文：中间滚动，不再限高 */
  #modal-box > .pt-dialog-body,
  #modal-box > .modal-body {
    flex: 1 1 auto; min-height: 0;
    max-height: none; overflow-y: auto;
    padding: 14px 16px 20px;
    -webkit-overflow-scrolling: touch;
  }

  /* 底部按钮：直接子元素天然固定；.form-actions 在正文里则粘底 */
  #modal-box > .pt-dialog-foot {
    flex: none; margin: 0; gap: 10px; flex-wrap: nowrap;
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line); background: var(--card);
  }
  #modal-box .modal-body > .form-actions {
    position: sticky; bottom: -20px; margin: 14px -16px -20px;
    gap: 10px; flex-wrap: nowrap;
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line); background: var(--card);
  }
  #modal-box .pt-dialog-foot .pt-dbtn,
  #modal-box .modal-body > .form-actions .btn {
    flex: 1 1 0; min-width: 0;
    height: 44px; justify-content: center; font-size: 15px;
  }

  /* 表单：单列、标签在上、控件 16px（iOS 不自动放大） */
  #modal-box .pt-form { grid-template-columns: 1fr; gap: 14px; }
  #modal-box .pt-fld { grid-template-columns: 1fr; gap: 6px; }
  #modal-box .pt-fld > label {
    text-align: left; padding-top: 0;
    font-size: 12.5px; color: var(--p-muted);
  }
  #modal-box .pt-fld input,
  #modal-box .pt-fld select,
  #modal-box .pt-fld textarea {
    font-size: 16px; padding: 10px 12px; border-radius: 9px;
  }
  #modal-box .pt-fld .pt-inline { gap: 8px; }
  #modal-box .pt-fld .pt-inline input { min-width: 0; }
  #modal-box .pt-fld .tip { font-size: 11.5px; }
  #modal-box .pt-quick { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
  #modal-box .pt-quickrow { gap: 6px; }
  #modal-box .pt-bool { padding-top: 0; }
  #modal-box .pt-group:not(:first-child) { margin-top: 16px; padding-top: 14px; }
  #modal-box .field-row { grid-template-columns: 1fr; gap: 10px; }
  #modal-box .field { margin-bottom: 14px; }
  #modal-box .field input, #modal-box .field select, #modal-box .field textarea { font-size: 16px; }

  /* 附件：按钮给足高度 */
  #modal-box .pt-attach-add, #modal-box .pt-attach .btn { min-height: 42px; }
  #modal-box .pt-attach-item { max-width: 100%; }
}

/* 修正：pt-dialog 是 #modal-box 里的包裹层，上面的选择器要落在 .pt-dialog 上 */
@media (max-width: 767px) {
  #modal-box > .pt-dialog { display: flex; flex-direction: column; height: 100%; min-height: 0; }
  #modal-box .pt-dialog-head {
    flex: none; align-items: center;
    padding: 14px 16px 10px;
    border-bottom: 1px solid var(--line); background: var(--card);
  }
  #modal-box .pt-dialog-head .tt { font-size: 16px; }
  #modal-box .pt-dialog-head .st {
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden; white-space: normal; font-size: 11.5px; line-height: 1.5; margin-top: 3px;
  }
  #modal-box .pt-dialog-head .badge { width: 30px; height: 30px; }
  #modal-box .pt-dialog-body {
    flex: 1 1 auto; min-height: 0; max-height: none;
    overflow-y: auto; padding: 14px 16px 18px;
    -webkit-overflow-scrolling: touch;
  }
  #modal-box .pt-dialog-foot {
    flex: none; margin: 0; gap: 10px; flex-wrap: nowrap;
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line); background: var(--card);
  }
  #modal-box .pt-dialog-foot .pt-dbtn { flex: 1 1 0; height: 44px; font-size: 15px; }
}

/* 手机：日期/时间一行放不下时，让输入框独占一行，今天/日历按钮掉到下一行 */
@media (max-width: 767px) {
  #modal-box .pt-fld .pt-inline { flex-wrap: wrap; }
  #modal-box .pt-fld .pt-inline > input { flex: 1 1 100%; }
  #modal-box .pt-fld .pt-inline > .btn,
  #modal-box .pt-fld .pt-inline > button { flex: 0 0 auto; min-height: 40px; }
  #modal-box .pt-quick { min-width: 62px; }
}

/* 手机：任何弹窗的底部操作区（`.form-actions` 可能是 .modal-body 的兄弟节点） */
@media (max-width: 767px) {
  #modal-box > .form-actions,
  #modal-box .modal-body > .form-actions {
    position: sticky; bottom: 0; z-index: 3;
    display: flex; flex-wrap: nowrap; justify-content: stretch;
    gap: 8px; margin: 0; padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line); background: var(--card);
  }
  #modal-box > .form-actions .btn,
  #modal-box .modal-body > .form-actions .btn {
    flex: 1 1 0; min-width: 0; height: 44px;
    padding: 0 8px; font-size: 14px; letter-spacing: 0;
    justify-content: center; white-space: nowrap; overflow: hidden;
  }
  /* 底部操作区在 body 内部时，抵消 body 的左右内边距 */
  #modal-box .modal-body > .form-actions { margin: 14px -16px -20px; }
}

/* 兜底：某些弹窗把 .form-actions 放在 form 里面（不一定是 .modal-body 的直接子元素），
   这里用后代选择器统一底部操作区的排布，避免按钮还是桌面的右对齐小尺寸。 */
@media (max-width: 767px) {
  #modal-box .form-actions {
    display: flex; flex-wrap: nowrap; justify-content: stretch;
    gap: 8px; margin: 0;
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line); background: var(--card);
    position: sticky; bottom: 0; z-index: 3;
  }
  #modal-box .form-actions .btn {
    flex: 1 1 0; min-width: 0; height: 44px;
    padding: 0 8px; font-size: 14px; justify-content: center;
    white-space: nowrap; overflow: hidden;
  }
}

/* 手机：列设置每行改成「卡片」，一行放下序号/显示名，第二行放类型与两个勾选 */
@media (max-width: 767px) {
  #modal-box .pay-colhead { display: none; }
  #modal-box .pay-collist { display: grid; gap: 10px; }
  #modal-box .pay-colrow {
    display: grid;
    grid-template-columns: 46px minmax(0, 1fr) auto auto auto;
    grid-template-areas:
      "no label label label del"
      "no type  ck1   ck2   del";
    align-items: center; gap: 8px 6px;
    padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
    background: var(--p-field, rgba(255,255,255,.02));
  }
  #modal-box .pcr-no { grid-area: no; display: flex; align-items: center; gap: 2px; font-size: 12px; }
  #modal-box .pcr-mv { width: 20px; height: 24px; }
  #modal-box .pcr-label { grid-area: label; width: 100%; min-width: 0; font-size: 15px; padding: 8px 10px; }
  #modal-box .pcr-t { grid-area: type; font-size: 11.5px; padding: 2px 6px; }
  #modal-box .pay-colrow .pay-cb:nth-of-type(1) { grid-area: ck1; }
  #modal-box .pay-colrow .pay-cb:nth-of-type(2) { grid-area: ck2; }
  #modal-box .pay-colrow .pcr-na { grid-area: ck1 / ck1 / ck1 / ck2; font-size: 11.5px; }
  #modal-box .pcr-del { grid-area: del; align-self: center; }
  #modal-box .pay-cb { font-size: 12px; gap: 4px; }

  #modal-box .pay-coladd { display: flex; flex-wrap: wrap; gap: 8px; }
  #modal-box .pay-coladd input { flex: 1 1 100%; font-size: 15px; }
  #modal-box .pay-coladd select { flex: 0 0 92px; font-size: 14px; }
  #modal-box .pay-coladd .btn { flex: 1 1 0; height: 40px; }
}

/* 列设置：改用 flex 换行（grid-area 在旧样式上会被行高撑变形） */
@media (max-width: 767px) {
  #modal-box .pay-collist { display: flex; flex-direction: column; gap: 10px; max-height: none; overflow: visible; }
  #modal-box .pay-colrow {
    display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px;
    padding: 10px 12px; border-radius: 10px;
  }
  #modal-box .pay-colrow .pcr-no { flex: 0 0 auto; font-size: 12px; }
  #modal-box .pay-colrow .pcr-mv { width: 22px; height: 26px; }
  #modal-box .pay-colrow .pcr-label {
    flex: 1 1 150px; min-width: 0; height: 38px; box-sizing: border-box;
    font-size: 15px; padding: 0 10px;
    border: 1px solid var(--line); border-radius: 8px; background: var(--field, rgba(255,255,255,.03));
  }
  #modal-box .pay-colrow .pcr-t { flex: 0 0 auto; font-size: 11.5px; }
  #modal-box .pay-colrow .pay-cb { flex: 0 0 auto; font-size: 12.5px; }
  #modal-box .pay-colrow .pcr-na { flex: 0 0 auto; grid-column: auto; font-size: 11.5px; }
  #modal-box .pay-colrow .pcr-del { flex: 0 0 auto; margin-left: auto; }
  #modal-box .pay-collist { max-height: none; }
}

/* 列设置：名称输入独占第一行，第二行放类型 + 两个勾选 + 删除 */
@media (max-width: 767px) {
  #modal-box .pay-colrow .pcr-label { flex: 1 1 100%; }
  #modal-box .pay-colrow .pcr-t { margin-right: 2px; }
  #modal-box .pay-colrow .pcr-del { margin-left: auto; }
}

/* 列设置：顶部两段说明在手机上收成两行，别占掉半屏 */
@media (max-width: 767px) {
  #modal-box .pay-colset > .pt-msg {
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden; margin-bottom: 8px; font-size: 11.5px; line-height: 1.6;
  }
}

/* 日期/时间行：手机上隐藏冗余的「今天」小按钮（下面的快捷片已有今天），
   输入框与日历/时钟图标保持同一行，不再各占一行 */
@media (max-width: 767px) {
  #modal-box .pt-fld .pt-inline { flex-wrap: nowrap; }
  #modal-box .pt-fld .pt-inline > input { flex: 1 1 auto; min-width: 0; }
  #modal-box .pt-fld .pt-inline > button[data-today] { display: none; }
  #modal-box .pt-fld .pt-inline > button { flex: 0 0 auto; min-height: 40px; }
}

/* 附件按钮铺满一行，拇指好点 */
@media (max-width: 767px) {
  #modal-box .pt-attach-add { width: 100%; justify-content: center; }
}
