/* Shared layout constraints. Containers must shrink before their scrolling content. */
:is(.page, .admin-page, .reports-page) { width: min(1520px, calc(100% - 48px)); margin: 24px auto 40px; grid-template-columns: minmax(0, 1fr); }
:is(main, section, header, footer, .card, .dashboard-grid, .dashboard-detail-grid, .filter-grid, .metric-cards, .param-grid, .form-grid, .table-wrap, .dashboard-table-wrap, .recent-table-wrap, .excel-wrap) { min-width: 0; }
:is(.table-wrap, .dashboard-table-wrap, .recent-table-wrap, .excel-wrap) { max-width: 100%; overscroll-behavior-inline: contain; }
:is(p, .hint, .user-info, .report-user, .admin-user, .reconcile-user) { overflow-wrap: anywhere; }
.app-shell-header { position: relative; padding-right: 78px; }
.app-shell-header .theme-toggle { position: absolute; top: 18px; right: 18px; left: auto; z-index: 2; box-shadow: none; }
.theme-toggle:hover { transform: none; background: var(--bg-muted); }
.theme-toggle:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }
.theme-toggle svg { flex-shrink: 0; }
.mobile-nav-toggle { display: none; }
.btn svg { flex-shrink: 0; }
.bulk-check { min-height: 44px; white-space: normal; }
.bulk-check input[type="checkbox"] { width: 18px; height: 18px; padding: 0; flex: 0 0 18px; }
.brand-icon { background: var(--action-bg); box-shadow: none; }
.metric-card { background: var(--glass-bg); box-shadow: none; transition: none; }
.metric-card:hover { transform: none; box-shadow: none; }
.metric-card .value { color: var(--text); font-variant-numeric: tabular-nums; }
:is(.config-row .card, .config-row .form-grid, .config-row .sf-config-grid, .config-row .form-grid > div, .config-row .sf-config-inline > div) { background: var(--glass-bg); border-color: var(--glass-border); box-shadow: none; }
.config-row :is(.hint, label:not(.check-row)) { color: var(--text-muted); }
.config-row .btn.primary { box-shadow: none; }
.reconcile-header { padding: 20px 78px 20px 20px; background: var(--glass-bg); border: 1px solid var(--glass-border); border-radius: var(--radius-card); }
.filter-card { background: var(--reconcile-panel); border-color: var(--reconcile-panel-border); }
.progress-bar { background: var(--action-bg); }
.progress-card[data-status="running"] .progress-bar::after,
.progress-card[data-status="queued"] .progress-bar::after { animation: none; display: none; }
/* No whole-page compositing, animated cell colours, or scroll-linked effects. */
*, *::before, *::after { transition-property: opacity, transform !important; }
:is(.page, .admin-page, .reports-page, .auth-page, .metric-card, th, td) { animation: none; transition: none; }
.submit-mode-dialog, .anomaly-modal-card { animation: dialog-enter 160ms ease-out; }
@keyframes dialog-enter { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

@media (max-width: 1100px) {
  :is(.page, .admin-page, .reports-page) { width: calc(100% - 32px); margin: 16px auto 28px; gap: 16px; }
  .filter-grid, .metric-cards, .report-summary-panel { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-grid, .dashboard-detail-grid { grid-template-columns: minmax(0, 1fr); }
  .header-brand { min-width: 0; }
  .header-brand > div:last-child { min-width: 0; }
}

@media (max-width: 600px) {
  html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
  body { font-size: 14px; }
  :is(.page, .admin-page, .reports-page) { width: auto; margin: 12px max(12px, env(safe-area-inset-left)) calc(24px + env(safe-area-inset-bottom)); gap: 14px; }
  .reconcile-page { padding: 12px max(12px, env(safe-area-inset-left)) calc(24px + env(safe-area-inset-bottom)); }
  :is(.page-header, .admin-header, .reports-header, .reconcile-header) { display: block; padding: 16px; border-radius: 12px; }
  :is(.app-shell-header > div:first-child, .header-brand) { padding-right: 44px; }
  .header-top { display: block; padding-right: 0 !important; }
  .header-brand { gap: 10px; align-items: flex-start; }
  .brand-icon { width: 36px; height: 36px; border-radius: 8px; }
  .brand-icon svg { width: 21px; height: 21px; }
  :is(.page-header, .admin-header, .reports-header, .reconcile-header, .auth-side) h1 { font-size: 20px; line-height: 1.4; letter-spacing: 0; }
  :is(.page-header, .admin-header, .reports-header, .reconcile-header) p { font-size: 12px; line-height: 1.65; margin-top: 6px; }
  .app-shell-header .theme-toggle { width: 40px; height: 40px; top: 12px; right: 12px; }
  .mobile-nav-toggle { display: inline-flex; min-height: 40px; margin-top: 12px; padding: 7px 12px; font-size: 13px; }
  .app-shell-header .page-navigation { display: none; }
  .app-shell-header .page-navigation.is-open { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
  .page-navigation :is(.user-info, .admin-user, .report-user, .reconcile-user) { grid-column: 1 / -1; border: 0; padding: 0 0 4px; box-shadow: none; background: none; }
  .page-navigation .btn { width: 100%; min-width: 0; padding: 9px 8px; font-size: 13px; }
  :is(.card, .reports-page .card, .admin-page .card) { padding: 16px; border-radius: 12px; }
  :is(.card h2, .reports-page .card h2, .admin-page .card h2) { font-size: 16px; }
  :is(.form-grid, .sf-config-inline, .config-row, .param-grid, .wechat-config-columns) { grid-template-columns: minmax(0, 1fr); }
  .form-grid .wide { grid-column: 1 / -1; }
  .filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .filter-grid > *, .param-group, .report-search-row, .recent-search-row > * { min-width: 0; }
  .keyword-box { grid-column: 1 / -1; }
  .metric-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .metric-card { padding: 12px; border-radius: 10px; }
  .metric-card .value { font-size: 24px; }
  .report-summary-panel { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .date-comparison-panel { grid-template-columns: minmax(0, 1fr); }
  :is(input:not([type="checkbox"]):not([type="radio"]), select, textarea) { font-size: 16px !important; min-height: 44px; max-width: 100%; min-width: 0; }
  :is(button, .btn, .recent-op-btn) { touch-action: manipulation; }
  .btn { min-height: 44px; white-space: normal; line-height: 1.4; }
  input[type="checkbox"], input[type="radio"] { flex-shrink: 0; }
  :is(.check-row, .register-row-select, .register-select-all-toggle) { min-height: 44px; }
  :is(.filter-actions, .row-actions, .mapping-import-row, .actions, .result-tools, .preview-controls, .pagination, .intercept-actions, .submit-action-group) { flex-wrap: wrap; gap: 8px; }
  :is(.filter-actions, .pagination, .intercept-actions, .submit-action-group) > .btn { flex: 1 1 110px; width: auto; }
  .search-row { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 12px; gap: 10px; }
  .search-row > label, .search-row > input { grid-column: 1 / -1; }
  .cookie-status { font-size: 12px; overflow-wrap: anywhere; }
  .recent-block { border: 0; box-shadow: none; padding: 0; border-top: 1px solid var(--line); padding-top: 16px; border-radius: 0; }
  .recent-card-item { padding: 12px; box-shadow: none; }
  .recent-card-summary, .recent-card-edit-grid { grid-template-columns: minmax(0, 1fr); }
  .recent-card-summary > div, .recent-card-details dd { min-width: 0; overflow-wrap: anywhere; }
  :is(.report-batch-row, .recent-batch-row, .report-mark-row, .recent-search-row, .report-search-row, .bulk-fill-row, .intercept-filter-row) { grid-template-columns: minmax(0, 1fr); }
  :is(.recent-search-row, .report-search-row, .bulk-fill-row, .intercept-filter-row) :is(input, select) { width: 100%; }
  .wechat-config-section { padding: 12px; }
  .wechat-save-bar { align-items: stretch; }
  .wechat-save-bar .btn { width: 100%; }
  .auth-shell { width: auto; margin: 16px 16px calc(24px + env(safe-area-inset-bottom)); grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .auth-side { padding: 18px 62px 18px 18px; box-shadow: none; }
  .auth-side > p { margin-top: 5px; font-size: 13px; }
  .auth-side ul, .auth-side-actions { display: none; }
  .auth-main { padding: 20px 18px; gap: 14px; }
  .auth-main h2 { font-size: 20px; }
  .auth-form { gap: 10px; }
  .captcha-row { grid-template-columns: minmax(0, 1fr) auto; }
  .captcha-row .btn { width: auto; }
  .auth-form input { min-height: 46px; }
  .auth-switch a { display: inline-flex; align-items: center; min-height: 44px; }
  .anomaly-modal { padding: 12px; }
  .anomaly-modal-card { width: 100%; max-height: calc(100dvh - 24px); }
  .anomaly-modal-head, .anomaly-modal-body, .anomaly-modal-footer { padding: 14px; min-width: 0; }
  .anomaly-modal-head > div { min-width: 0; }
  .anomaly-modal-head h2 { font-size: 18px; }
  .anomaly-modal-footer .btn { flex: 1 1 130px; }
  .submit-mode-modal { padding: 12px; }
  .submit-mode-dialog { width: min(100%, 520px); max-height: calc(100dvh - 24px); overflow: auto; padding: 18px; }
  dialog.duplicate-order-dialog { max-width: calc(100% - 24px); }
  .submit-mode-actions { flex-wrap: wrap; }
  .submit-mode-actions .btn { flex: 1 1 100px; }
  .app-toast-stack { top: auto; bottom: max(16px, env(safe-area-inset-bottom)); left: 12px; right: 12px; align-items: stretch; }
  .app-toast { width: 100%; max-width: 100%; }

  /* Same table controls, mobile card layout. No second rendering tree or copied inputs. */
  .mobile-record-table { display: block; width: 100% !important; min-width: 0 !important; table-layout: auto; }
  .mobile-record-table colgroup, .mobile-record-table thead th { display: none; }
  .mobile-record-table thead, .mobile-record-table thead tr { display: block; }
  .mobile-record-table thead th[data-mobile-select-head] { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; }
  .mobile-record-table th[data-mobile-select-head]::after { content: "全选本页"; font-size: 13px; }
  .mobile-record-table tbody { display: block; }
  .mobile-record-table tbody tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 10px; padding: 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--glass-bg); }
  .mobile-record-table tbody td { display: block; width: auto !important; min-width: 0 !important; max-width: none; padding: 8px; border: 0; text-align: left; white-space: normal; overflow-wrap: anywhere; background: transparent; }
  .mobile-record-table tbody td::before { content: attr(data-label); display: block; margin-bottom: 5px; color: var(--text-muted); font-size: 12px; font-weight: 500; }
  .mobile-record-table tbody td:nth-child(n) { text-align: left; }
  .mobile-record-table tbody td[data-mobile-empty] { grid-column: 1 / -1; }
  .mobile-record-table tbody td[data-mobile-empty]::before { display: none; }
  .mobile-record-table tbody td:has(.btn, .recent-op-btn) { grid-column: 1 / -1; }
  .mobile-record-table tbody td:has(input[type="checkbox"]) { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; min-height: 44px; }
  .mobile-record-table .submit-select-cell, .mobile-record-table .report-select-col { position: static; }
  .mobile-record-table input, .mobile-record-table select { width: 100%; }
  .mobile-record-table input[type="checkbox"] { width: 20px; height: 20px; margin: 0; }
  .excel-table tbody tr { grid-template-columns: minmax(0, 1fr); }
  .excel-table .registered-order-row td { background-image: none; }
  .excel-table .registered-order-row { border-color: var(--success); }
  .excel-table .changed-cell { background: var(--changed-bg); border-radius: 6px; }
  .excel-wrap { max-height: 75dvh; }
  .table-wrap:has(.mobile-record-table), .intercept-table-wrap { max-height: 75dvh; }
  .anomaly-modal-body .dashboard-table-wrap { max-height: none; border: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .submit-mode-dialog, .anomaly-modal-card { animation: none; }
}
