/*
 * 手机端适配 (docs/后台UI优化与移动端适配设计方案.md)
 *
 * - 设计变量在 theme.css; 这里只有手机端覆盖规则, 必须排在 theme.css / shell.css / 内联样式之后
 * - @media (max-width: 768px): 统一覆盖 Element Plus 的弹窗、表单、工具栏、分页等,
 *   53 个页面不逐页改也能在手机上用; 断点与 store.js 的 MOBILE_QUERY 一致
 * - .m-* : 手机卡片视图 (重点页面 v-if="store.isMobile" 时使用)
 */
/* ---------- 通用: 金额 / 数字 ---------- */
.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.amt { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.amt-in { color: var(--c-success); }
.amt-out { color: var(--c-danger); }

/* ---------- 手机卡片视图 (重点页) ---------- */
.m-list { display: flex; flex-direction: column; gap: var(--sp-2); }
.m-card { background: var(--c-card); border-radius: var(--r-2); padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--c-line); }
.m-card-top { display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-2); }
.m-card-amount { font-size: 20px; font-weight: 700; color: var(--c-text); font-variant-numeric: tabular-nums; }
.m-card-amount small { font-size: 13px; font-weight: 600; margin-right: 1px; }
.m-card-title { font-size: 15px; font-weight: 600; color: var(--c-text); min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m-card-line { font-size: 13px; color: var(--c-text-2); margin-top: 6px; display: flex; gap: 6px; min-width: 0; }
.m-card-line .k { color: var(--c-text-3); flex: none; }
.m-card-line .v { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.m-card-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: var(--sp-2);
  margin-top: var(--sp-3); padding-top: var(--sp-3); border-top: 1px dashed var(--c-line); }
.m-card-actions .el-button + .el-button { margin-left: 0; }
.m-empty { padding: 32px 0; }

/* ==================================================================== */
/*                         手机 (≤ 768px)                                */
/* ==================================================================== */
@media (max-width: 768px) {
  :root { --header-h: 48px; }

  /* --- 顶栏: ☰ + 页面名 + 头像 (品牌 / 副标题 / 顶栏按钮收到抽屉里) --- */
  .topbar { gap: var(--sp-3); padding: 0 var(--sp-3); }
  .brand { height: auto; }
  .brand-logo { width: 32px; height: 32px; }
  .brand-name, .brand-sub, .topbar-btn { display: none; }
  .menu-btn { display: grid; place-items: center; width: 36px; height: 36px; border: 0; background: transparent;
    color: var(--c-text); font-size: 20px; border-radius: var(--r-1); cursor: pointer; }
  .page-title { display: block; flex: 1; text-align: center; font-size: 16px; font-weight: 600; color: var(--c-text);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .user-menu-text { display: none; }
  .topbar-actions { gap: 0; }

  /* --- 框架: 侧边栏变抽屉, 内容区收紧 --- */
  .layout { padding-left: 0; }
  .main-content { padding: var(--sp-4) var(--sp-3) calc(var(--sp-4) + env(safe-area-inset-bottom)); }
  .sidebar { position: fixed; top: 0; bottom: 0; left: 0; width: 80%; max-width: 300px; z-index: 2001;
    box-sizing: border-box; padding: 12px;
    transform: translateX(-100%); transition: transform .22s ease; box-shadow: 0 0 24px rgba(15, 23, 42, .18); }
  .sidebar.open { transform: none; }
  .sidebar-mask { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 2000; }
  .page-card { padding: var(--sp-3); border-radius: var(--r-2); }
  .page-card:not(.kb-help) > h3:first-child { display: none; } /* 顶栏已显示页面名, 不再重复 */
  .el-dialog.manual-dialog { height: 92vh; margin-top: 4vh; margin-bottom: 4vh; }
  .kb-help { gap: 0; }
  .kb-help-toc-pane { width: 120px; padding: 12px 8px; }
  .kb-help-pane { padding: 12px 14px 28px; }

  /* --- 工作台 --- */
  .wb-head { flex-wrap: wrap; min-height: 0; margin-bottom: var(--sp-4); }
  .wb-title { font-size: 20px; }
  .wb-role { height: 24px; margin-left: var(--sp-2); padding: 0 10px; font-size: 13px; }
  .wb-corp { flex-basis: 100%; margin: var(--sp-2) 0 0; font-size: 14px; }
  .wb-pill { height: 32px; padding: 0 10px; font-size: 12px; }
  .wb-grid { grid-template-columns: 1fr 1fr; gap: var(--sp-3); }
  .wb-card { min-height: 0; padding: 14px; }
  .wb-card-value { font-size: 20px; line-height: 28px; word-break: break-all; }
  .wb-card .wb-pill { padding: 0 8px; height: 28px; }

  /* --- 工具栏: 自动折行, 输入控件占满 --- */
  .toolbar { flex-wrap: wrap; gap: var(--sp-2); }
  .toolbar > .el-input, .toolbar > .el-select, .toolbar > .el-date-editor { width: 100% !important; }
  .toolbar > .el-button + .el-button { margin-left: 0; }

  /* --- 弹窗: 宽度 94vw, 内容可滚, 底部按钮可见 --- */
  .el-dialog { width: 94vw !important; max-width: 94vw; margin: 3vh auto !important; }
  .el-dialog:not(.is-fullscreen) .el-dialog__body { max-height: 70vh; overflow-y: auto; }
  .el-dialog.is-fullscreen { width: 100vw !important; max-width: 100vw; margin: 0 !important;
    display: flex; flex-direction: column; }
  .el-dialog.is-fullscreen .el-dialog__body { flex: 1; overflow-y: auto; }
  .el-dialog__footer { padding-bottom: calc(var(--sp-3) + env(safe-area-inset-bottom)); }
  .el-message-box { width: 90vw !important; max-width: 90vw; }
  .el-drawer { width: 90vw !important; }

  /* --- 表单: 标签在上, 输入占满 --- */
  .el-form-item { flex-direction: column; align-items: stretch; margin-bottom: var(--sp-3); }
  .el-form-item__label { width: auto !important; justify-content: flex-start !important;
    line-height: 20px; padding-bottom: 6px; height: auto; }
  .el-form-item__content { margin-left: 0 !important; }
  .el-form-item__content > .el-input, .el-form-item__content > .el-select,
  .el-form-item__content > .el-input-number, .el-form-item__content > .el-date-editor { width: 100% !important; }
  .el-form--inline .el-form-item { display: flex; margin-right: 0; width: 100%; }

  /* --- 输入框 16px: 避免 iOS 聚焦自动放大 --- */
  .el-input__inner, .el-textarea__inner, .el-select__selected-item, .el-input-number .el-input__inner { font-size: 16px; }

  /* --- 分页: 只留翻页 --- */
  .el-pagination { justify-content: center !important; flex-wrap: wrap; }
  .el-pagination__total, .el-pagination__sizes, .el-pagination__jump { display: none !important; }

  /* --- 表格: 横向可滚 (非卡片化页面的兜底) --- */
  .el-table { font-size: 13px; }
  .el-table .cell { padding: 0 6px; }

  /* --- 描述列表: 单列 --- */
  .el-descriptions__table { table-layout: auto; }
  .el-descriptions__label { white-space: nowrap; }
}
