/* Shared responsive fixes for all management pages. */
.modal-header { flex-wrap: wrap; gap: 12px; }
.modal-header h2, .detail-item { min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 768px) {
    body { line-height: 1.5; }
    .container { padding: 12px; }
    .header { flex-direction: column; align-items: stretch; gap: 16px; padding: 16px; margin-bottom: 12px; }
    .header h1 { font-size: 22px; }
    .nav { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
    .nav a { display: flex; align-items: center; justify-content: center; padding: 8px 2px; font-size: 14px; text-align: center; }
    .content { padding: 12px; }
    button, .btn, .nav a { min-height: 44px; }
    button, .btn { min-width: 44px; }
    a.btn { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
    input, select, textarea, .table-input, .detail-item input,
    .detail-item select, .detail-item textarea, .branch-select select {
        min-width: 0; max-width: 100%; min-height: 44px; font-size: 16px;
    }
    .toolbar { flex-wrap: wrap; gap: 12px; }
    .toolbar > *, .search-bar { width: 100%; min-width: 0; }
    .search-bar { gap: 8px; }
    .search-bar input { flex: 1; width: 0; min-width: 0; padding: 10px 12px; }
    .search-bar button { padding: 10px 16px; flex-shrink: 0; }
    .stats-bar { flex-wrap: wrap; gap: 8px; padding: 10px 12px; margin-bottom: 0; }
    .bulk-sync-bar, .import-bar { align-items: stretch; }
    .bulk-sync-bar > strong, .import-bar > strong { width: 100%; }
    .bulk-sync-bar select, .import-bar input[type="file"] { width: 100%; min-width: 0; max-width: 100%; }
    .bulk-sync-status, .import-status, #sync-status { overflow-wrap: anywhere; line-height: 1.6; }
    .bulk-sync-results { min-width: 0; }
    .pagination { flex-wrap: wrap; gap: 8px; }
    .pagination button { padding: 8px 12px; }
    .actions { flex-wrap: wrap; gap: 8px; }

    .mobile-cards { overflow: visible; }
    .mobile-cards table, .mobile-cards tbody { display: block; }
    /* Keep column headers available to assistive technology. */
    .mobile-cards thead { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); }
    .mobile-cards tr { display: block; border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; margin-bottom: 12px; }
    .mobile-cards td { display: grid; grid-template-columns: 96px minmax(0, 1fr); align-items: center; gap: 8px; padding: 8px 0; white-space: normal; overflow-wrap: anywhere; }
    .mobile-cards td::before { content: attr(data-label); color: var(--muted); font-size: 13px; }
    .bulk-branches { min-width: 0; }
    .bulk-branches label { overflow-wrap: anywhere; }
    input[type="checkbox"] { min-height: auto; flex-shrink: 0; }
    .mobile-cards thead:has(input[type="checkbox"]) { position: static; display: block; width: auto; height: auto; overflow: visible; clip-path: none; }
    .mobile-cards thead:has(input[type="checkbox"]) tr { padding: 0; border: 0; }
    .mobile-cards thead:has(input[type="checkbox"]) th { display: none; }
    .mobile-cards thead:has(input[type="checkbox"]) th:first-child { display: block; padding: 4px 12px; border-radius: 6px; }
    .mobile-cards thead .product-selection { gap: 8px; }
    .mobile-cards thead .product-selection::after { content: "全选当前页商品"; font-size: 14px; }
    .mobile-cards td:last-child { border-bottom: 0; }
    .mobile-cards td > * { min-width: 0; }
    .mobile-cards .table-input { padding: 8px; }
    .mobile-cards .table-input:read-only { padding-left: 0; }

    /* Compact product summaries; full specifications remain in the detail modal. */
    #product-table tr { display: grid; grid-template-columns: 56px minmax(0, 1fr); gap: 4px 10px; padding: 10px; margin-bottom: 8px; }
    #product-table td { display: none; padding: 0; border: 0; min-width: 0; }
    #product-table td[data-label="图片"] { display: block; grid-column: 1; grid-row: 1 / 4; }
    #product-table .image-thumb { width: 56px; height: 56px; }
    #product-table td[data-label="图片"] .btn { padding: 6px; width: 56px; }
    #product-table td[data-label="商品名称"] { display: -webkit-box; grid-column: 2; grid-row: 1; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; font-weight: 600; line-height: 22px; }
    #product-table td[data-label="采购价(含税)"],
    #product-table td[data-label="建议售价"] { display: flex; grid-column: 2; gap: 6px; flex-wrap: wrap; font-size: 14px; }
    #product-table td[data-label="采购价(含税)"] { grid-row: 2; }
    #product-table td[data-label="建议售价"] { grid-row: 3; color: var(--primary); }
    #product-table td[data-label="选择商品"] { display: block; grid-column: 1; grid-row: 4; }
    #product-table td[data-label="操作"] { display: block; grid-column: 2; grid-row: 4; }
    #product-table td[data-label="图片"]::before,
    #product-table td[data-label="商品名称"]::before,
    #product-table td[data-label="选择商品"]::before,
    #product-table td[data-label="操作"]::before { content: none; }

    body:has(.modal.active) { overflow: hidden; }
    .modal { padding: 8px; height: 100dvh; overscroll-behavior: contain; }
    .modal-content { padding: 16px; min-width: 0; margin: 0 auto; }
    .modal-header { flex-direction: column; align-items: stretch; gap: 12px; }
    .modal-header h2 { overflow-wrap: anywhere; }
    .modal-header-actions { justify-content: flex-start; }
    .modal-sync-actions { width: 100%; min-width: 0; flex-wrap: wrap; padding: 0 0 12px; border-right: 0; border-bottom: 1px solid var(--line); }
    .modal-sync-actions select { min-width: 0; width: 100%; }
    .detail-grid { grid-template-columns: minmax(0, 1fr); gap: 12px; }
    .detail-item.full-width { grid-column: auto; }
    .detail-item { min-width: 0; padding: 12px; overflow-wrap: anywhere; }
    .image-section img { max-width: 100%; height: auto; margin: 0 auto; }
    .image-upload-area { padding: 16px 8px; margin-bottom: 20px; }
    .image-upload-area button { margin-top: 8px; }
    .sync-section { padding: 12px; }
    .branch-select { flex-wrap: wrap; }

    .welcome { padding: 24px 4px; }
    .welcome h2 { font-size: 24px; }
    .welcome p { font-size: 16px; margin-bottom: 24px; }
    .stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 24px; }
    .stat-card { min-width: 0; padding: 20px 8px; }
    .stat-card h3 { font-size: 36px; overflow-wrap: anywhere; }
    .stat-card p { margin-bottom: 0; font-size: 14px; }
    .login-container { padding: 32px 20px; margin: auto; }
    body:has(.login-container) { min-height: 100dvh; padding: 16px; }
    .footer { font-size: 13px; padding: 16px 0; }
}
