export function formatBytes(bytes) {
if (!Number.isFinite(bytes) || bytes < 0) return '–'
const units = ['B', 'KB', 'MB', 'GB', 'TB']
let value = bytes
let unit = 0
while (value >= 1024 && unit < units.length - 1) {
value /= 1024
unit += 1
}
const digits = unit === 0 || value >= 10 ? 0 : 1
return `${value.toFixed(digits)} ${units[unit]}`
}
export function formatCount(n) {
return Number.isFinite(n) ? n.toLocaleString() : '–'
}