/* 手机与窄屏平板；只改布局，不覆盖 .hidden 或角色权限。 */
@media (max-width: 900px) {
  html, body { min-width: 0; }
  #appView { flex-direction: column; height: 100vh; height: 100dvh; overflow: hidden; }
  .sidebar { position: relative; width: 100%; flex: none; }
  .side-brand { min-height: 52px; padding: 9px 104px 9px 14px; }
  .side-brand-name { font-size: 14px; }
  .side-user { position: absolute; top: 9px; right: 10px; padding: 0; border: 0; }
  .side-user-name, .side-user-role { display: none; }
  .side-user .btn { padding: 9px; font-size: 12px; }
  .edition-badge { margin: 0 10px 4px; }
  .nav { display: flex; flex: none; gap: 5px; padding: 6px 8px; overflow-x: auto; white-space: nowrap; border-top: 1px solid rgba(255,255,255,.08); }
  .nav-item { width: auto; flex: 0 0 auto; margin: 0; padding: 10px; font-size: 12px; gap: 4px; }
  .nav-ico { width: auto; }
  .main { min-height: 0; }
  .topbar { height: auto; min-height: 52px; padding: 8px 12px; gap: 8px; flex-wrap: wrap; }
  .topbar-title { font-size: 15px; }
  .topbar-right { min-width: 0; margin-left: auto; gap: 6px; flex-wrap: wrap; font-size: 11px; }
  .topbar-period { font-size: 12px; }
  .topbar-period select { max-width: 170px; padding: 7px 4px; }
  .topbar-org, .topbar-time, .edition-top { display: none; }
  .content { min-height: 0; padding: 12px 10px calc(28px + env(safe-area-inset-bottom)); }
  .page-head { display: block; margin-bottom: 12px; }
  .page-head h1 { font-size: 20px; }
  .page-head .sub { line-height: 1.6; }
  .page-head .actions { margin-top: 10px; flex-wrap: wrap; }
  .card { min-width: 0; padding: 14px; margin-bottom: 12px; overflow-wrap: anywhere; }
  .card-title, .card-title .lt { gap: 8px; flex-wrap: wrap; }
  .card-title .lt::before { flex: none; }
  .grid-2, .grid-3, .grid-4, .form-2col, .ms-3col { grid-template-columns: minmax(0, 1fr); }
  .grid > *, .form-2col > *, .ms-3col > * { min-width: 0; }
  .form-row { min-width: 0; margin-bottom: 11px; }
  .form-row input, .form-row select, .form-row textarea { max-width: 100%; }
  /* 16px 防止 iOS 聚焦后自动放大；复选框保持原生尺寸。 */
  input:not([type="checkbox"]):not([type="radio"]), select, textarea { font-size: 16px; }
  .flex, .flex-between, .task-actions, .modal-foot, .tut-foot, .ms-tools { flex-wrap: wrap; }
  .tbl-wrap, .table-wrap, .mobile-table-scroll { max-width: 100%; min-width: 0; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { min-width: 620px; font-size: 12px; }
  th, td { padding: 8px 7px; }
  /* 每日数量必须首屏可见，不能跟普通报表一起强制 620px 宽。 */
  #dailyMatrixWrap { max-height: min(50dvh, 360px); }
  #dailyMatrixWrap table { min-width: 0; width: 100%; table-layout: fixed; }
  #dailyMatrixWrap th, #dailyMatrixWrap td { overflow-wrap: anywhere; white-space: normal; }
  #dailyMatrixWrap tr:first-child th:nth-child(2) { width: 50px !important; }
  #dailyMatrixWrap tr:first-child th:nth-child(3) { width: 110px !important; }
  #dailyMatrixWrap input { min-width: 0; min-height: 40px; font-size: 16px; }
  .plan-matrix input { min-width: 80px; min-height: 36px; }
  .ms-list { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
  .ms-item { min-height: 36px; }
  .ms-item span { white-space: normal; }
  .org-members { grid-template-columns: minmax(0, 1fr); }
  .org-node-head, .org-person { flex-wrap: wrap; }
  .rank-item { gap: 8px; padding: 10px; flex-wrap: wrap; }
  .rank-bar-wrap { width: 70px; }
  .bars { overflow-x: auto; gap: 10px; }
  .bar-col { min-width: 54px; }
  .task-actions .btn { line-height: 1.3; }
  .modal-mask { padding: 8px; align-items: flex-end; }
  .modal, #modalRoot .modal { width: 100%; max-height: 92vh; max-height: 92dvh; border-radius: 12px 12px 0 0; }
  .modal-head, .modal-body { padding-left: 15px; padding-right: 15px; }
  .modal-head { gap: 8px; }
  .modal-head h3 { min-width: 0; overflow-wrap: anywhere; }
  .modal-foot { padding: 11px 15px calc(11px + env(safe-area-inset-bottom)); }
  .modal-foot .btn { flex: 1; line-height: 1.3; }
  .tut-title { font-size: 17px; }
  .tut-body { font-size: 13px; }
  #toastRoot { top: auto; bottom: calc(14px + env(safe-area-inset-bottom)); left: 10px; right: 10px; pointer-events: none; }
  .toast { max-width: none; }
  .login-wrap { min-height: 100vh; min-height: 100dvh; padding: 20px 0; }
  .login-card { width: min(400px, calc(100vw - 28px)); padding: 26px 22px 22px; }
  .login-brand { gap: 10px; margin-bottom: 20px; }
  .brand-name { font-size: 15px; }
  .brand-sub { font-size: 10.5px; }
  .login-sec { width: calc(100vw - 36px); line-height: 1.5; }
  .upload-zone { padding: 24px 12px; }
  #siteAssistant { right: 14px; bottom: calc(18px + env(safe-area-inset-bottom)); }
  .assistant-panel { max-width: calc(100vw - 28px); max-height: 70dvh; }
}
@media (max-width: 380px) {
  .nav-item { padding-left: 8px; padding-right: 8px; }
  .topbar-title { font-size: 14px; }
  .topbar-period select { max-width: 145px; }
}
