/* 上上签 A7 · 手机版面（屏幕窄于 820px）：「人生」原来的页面全部改成手机宽度 */
@media (max-width: 820px) {
  :root {
    --today-content-width: calc(100vw - 20px);
    --today-panel-width: calc(100vw - 20px);
    --monthly-report-content-width: calc(100vw - 20px);
    --monthly-report-panel-width: calc(100vw - 20px);
    --management-panel-width: calc(100vw - 20px);
    --employee-flow-content-width: calc(100vw - 20px);
    --employee-flow-panel-width: calc(100vw - 20px);
    --layout-side-width: 100%;
    --layout-gap: 8px;
    --ui-table-font-size: 13px;
    --ui-table-head-height: 28px;
    --ui-table-row-height: 28px;
    --ui-cell-padding-x: 6px;
    --ui-cell-padding-y: 3px;
    --ui-page-title-size: 16px;
    --ui-module-title-size: 15px;
    --ui-button-font-size: 13px;
    --ui-note-font-size: 12px;
  }
  html.ssq-engine-view .workspace { padding: 6px 6px 40px !important; overflow-x: hidden; }
  /* 每页顶上的大标题和「今日经营净额」：上上签顶栏已经有了，收成一行小字 */
  html.ssq-engine-view .topbar { margin: 0 0 6px !important; gap: 6px !important; flex-wrap: nowrap !important; }
  html.ssq-engine-view #viewTitle { font-size: 15px !important; color: #4a5a74; }
  html.ssq-engine-view .date-card { display: none !important; }
  html.ssq-engine-view .screenshot-toggle { min-height: 28px; padding: 2px 10px; font-size: 12.5px; }
  /* 面板、卡片：手机宽度，留白缩小 */
  html.ssq-engine-view .view.active :is(section, .panel, [class*="-panel"], [class*="-card"], [class*="-shell"]) { max-width: 100%; }
  html.ssq-engine-view .view.active :is([class*="-panel"]) { padding: 8px !important; border-radius: 10px !important; }
  html.ssq-engine-view .view.active :is(h2) { font-size: 15px !important; }
  html.ssq-engine-view .view.active :is(h3) { font-size: 14px !important; }
  /* 宽表格：在自己的框里左右滑，第一列（序号）和姓名固定不动 */
  html.ssq-engine-view .view.active :is(.employee-ledger-wrap, .monthly-report-table-wrap, .dashboard-table-wrap, .employee-flow-year-card, .management-summary-card, [class*="table-wrap"]) {
    overflow-x: auto !important; -webkit-overflow-scrolling: touch; max-width: 100%;
  }
  html.ssq-engine-view .view.active table { font-size: 12.5px; }
  html.ssq-engine-view #employeeLedgerView .employee-ledger-table :is(th, td):nth-child(1) { position: sticky; left: 0; z-index: 2; min-width: 28px; width: 28px; }
  html.ssq-engine-view #employeeLedgerView .employee-ledger-table :is(th, td):nth-child(2) { position: sticky; left: 28px; z-index: 2; box-shadow: 2px 0 0 #dbe3f2; }
  html.ssq-engine-view #employeeLedgerView .employee-ledger-table td:nth-child(-n+2) { background: #fff; }
  /* 操作区（导入、新增等按钮）默认收起，点顶部「操作」才展开，表格先露出来 */
  html.ssq-engine-view:not(.ssq-side-open) :is(.ops-side, .employee-ledger-side) { display: none !important; }
  html.ssq-engine-view.ssq-side-open :is(.ops-side, .employee-ledger-side) { order: -1; }
  /* 各种按钮、输入框小一号 */
  html.ssq-engine-view .view.active :is(button, select, input) { font-size: 13.5px; }
  html.ssq-engine-view .view.active :is(input, select) { min-height: 32px; }
  /* 不必要的横向滚动条 */
  html.ssq-engine-view .view.active :is(.operation-panel, .employee-ledger-panel, .wallet-reconciliation-panel, .employee-flow-panel, .management-summary-panel, .monthly-report-panel) { overflow-x: hidden !important; }

  /* 核对：三个数两列排，钱包每排三个 */
  html.ssq-engine-view .wallet-summary-grid { grid-template-columns: 1fr 1fr !important; gap: 6px !important; }
  html.ssq-engine-view .wallet-summary-grid > :nth-child(3) { grid-column: 1 / -1; }
  html.ssq-engine-view .wallet-list { grid-template-columns: repeat(3, 1fr) !important; gap: 6px !important; }
  html.ssq-engine-view .wallet-list > * { min-width: 0; }
  /* 月报工资：卡片两列，数字显示完整 */
  html.ssq-engine-view :is(.monthly-report-metric-grid, .monthly-report-salary-list) { grid-template-columns: repeat(2, 1fr) !important; gap: 6px !important; }
  html.ssq-engine-view :is(.monthly-report-metric-grid, .monthly-report-salary-list, .wallet-summary-grid) * { white-space: normal !important; text-overflow: clip !important; overflow-wrap: anywhere; }
  html.ssq-engine-view :has(> .monthly-report-year-simple-row) { overflow-x: auto !important; }
  html.ssq-engine-view .monthly-report-year-simple-row { min-width: 560px; }
  html.ssq-engine-view .monthly-report-expense-calc { flex-wrap: wrap; }
}
/* A8：「人生」员工结算单弹窗在手机上占满屏、字小一号 */
@media (max-width: 820px) {
  #monthlyDetailModal .monthly-detail-dialog { width: 100vw !important; max-width: 100vw !important; max-height: 100dvh !important; height: 100dvh; border-radius: 0 !important; margin: 0 !important; overflow: auto; font-size: 13px; }
  #monthlyDetailModal { padding: 0 !important; z-index: 1500; }
  #monthlyDetailModal :is(.employee-settlement-overview-grid, [class*="-grid"]) { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  #monthlyDetailModal input, #monthlyDetailModal select { font-size: 16px; }
}
